Cryptography And Java Cryptography And Java - Cs.umd.edu

11m ago
16 Views
1 Downloads
543.31 KB
17 Pages
Last View : Today
Last Download : 3m ago
Upload by : Helen France
Transcription

Cryptography and Java

Cryptography and Java Java provides cryptographic functionality using two APIs: JCA – Java Cryptography Architecture – security framework integrated with the core Java API JCE – Java Cryptography Extension – Extensions for strong encryption (exported after 2000 US export policy)

Basic Architecture Provider based architecture Application JCE JCA javax.crypto java.security provider A provider B . provider Z provider A provider B . provider Z

Design principles Algorithm independence – Algorithm extensibility – easy updation of engine classes with new algorithms Implementation independence – specification of engine classes use of cryptographic service providers Implementation interoperability – providers working with each other

Engine classes Cryptographic operations are classified into classes in JCA/JCE. This classes are called as engines. – – JCA engines JCE engines

JCA engines MessageDigest (produces hash value) Signature (produces digital signature) – KeyPairGenerator (produces pair of keys) KeyFactory (breaks down a key) KeyStore (manages and stores keys) SecureRandom (produces random numbers) – AlgorithmParameters (encoding and decoding) – AlgorithmParameterGenerator (generates parameters) CertificateFactory (public key cert, revocation) CertPathBuilder (establish relationship chains between certs) CertStore (stores certificates and revocation lists)

JCE engines Cipher (encryption/decryption) KeyGenerator (produces secret keys used by ciphers) SecretKeyFactory (operates on SecretKey objects) KeyAgreement (key agreement protocol) Mac (message authentication code functionality)

Location JCA engines are located in java.security package JCE engines are located in javax.crypto package

Getting started Example 1: Generate a DES/AES key and use cipher to encrypt a message. byte[] message "I am a superman, sshhh don't tell anyone".getBytes(); KeyGenerator keygenerator KeyGenerator.getInstance("DES"); SecretKey desKey keygenerator.generateKey(); Cipher desCipher Cipher.getInstance("DES/ECB/PKCS5Padding"); // Initialize the cipher for encryption desCipher.init(Cipher.ENCRYPT MODE, desKey); // Encrypt message and return byte[] encryptedMessage desCipher.doFinal(message);

Example 2: Generate random bytes using SecureRandom. import java.security.SecureRandom; public class Main { public static void main(String[] argv) throws Exception { SecureRandom secRandom SecureRandom.getInstance("SHA1PRNG"); secRandom.setSeed(711); byte[] bytes new byte[20]; secRandom.nextBytes(bytes); } }

Your Best Friend Look up API docs for the relevant packages – – java.security javax.crypto JCA reference guide – /CryptoSpec.html

Appendix

Algorithm extensibility example MessageDigest ultrafastlmplementation MessageDigest.getInstance("UltraFastHash");

Implementation independence Offers the developer a choice of how to handle the presence of providers MessageDigest Dev1Md5Implementation MessageDigest.getlnstance("MD5", "Provider1");

Implementation interoperability Providers are interoperable The developer might use provider A to generate a key pair, passing that key pair along to provider B's signature algorithm

Adding providers There are two ways Adding statically Adding dynamically Static addition: – – – Copy the JCE provider JAR file to java home/jre/lib/ext/ Stop the Application Server Edit the 'java home/jre/lib/security/java.security' properties file in any text editor. Add the JCE provider you’ve just downloaded to this file. security.provider.n provider class name

Adding providers Static addition (cont.) security.provider.2 org.bouncycastle.jce.provider.BouncyCastleProvider Dynamic addition // create a provider object Provider bountyProvider new (); // Add the bountycastle Provider to the current list of // providers available on the system. Security.addProvider (bountyProvider);

Cryptography and Java Java provides cryptographic functionality using two APIs: JCA - Java Cryptography Architecture - security framework integrated with the core Java API JCE - Java Cryptography Extension - Extensions for strong encryption (exported after 2000 US export policy)

Related Documents:

java.io Input and output java.lang Language support java.math Arbitrary-precision numbers java.net Networking java.nio "New" (memory-mapped) I/O java.rmi Remote method invocations java.security Security support java.sql Database support java.text Internationalized formatting of text and numbers java.time Dates, time, duration, time zones, etc.

Java Version Java FAQs 2. Java Version 2.1 Used Java Version This is how you find your Java version: Start the Control Panel Java General About. 2.2 Checking Java Version Check Java version on https://www.java.com/de/download/installed.jsp. 2.3 Switching on Java Console Start Control Panel Java Advanced. The following window appears:

Cryptography: Java Cryptography Architecture (JCA), Java Cryptography Extension (JCE) Secure network communications: Java Secure Socket Extension (JSSE), Java Generic Security Service (JGSS), Simple Authentication and Security Layer (SASL) Public key infrastructure: X.509 and Certificate Revoca-tion Lists (CRL) in java.security.cert, Java .

3. _ is a software that interprets Java bytecode. a. Java virtual machine b. Java compiler c. Java debugger d. Java API 4. Which of the following is true? a. Java uses only interpreter b. Java uses only compiler. c. Java uses both interpreter and compiler. d. None of the above. 5. A Java file with

Cryptography in Java The Java Cryptography Architecture (JCA) is a set of APIs to implement concepts of modern cryptography such as digital signatures, message digests, certificates, encryption, key generation and management, and secure random number generation, etc. Using JCA, developers c

Java IO to download a file. The Java IO provides APIs to read bytes from InputStream and writing them to a File on disk. While, Java NET package provides APIs to interact with a resource residing over internet with the help of URL. In order to use Java IO and Java NET we need to use java.io.* and java.net.* packages into our class. Using

–‘java’ command launches Java runtime with Java bytecode An interpreter executes a program by processing each Java bytecode A just-in-time compiler generates native instructions for a target machine from Java bytecode of a hotspot method 9 Easy and High Performance GPU Programming for Java Programmers Java program (.

Am I my Brother’s Keeper? Acts 15:19-35 Introduction: Since the beginning of time when the first man and woman rebelled against God, mankind has been separated from God. Every person since that time has been born into that rebellion and sin. Because of sin, people are separated from God and are unable to have a right relationship with Him or each other. Ill. of evil and suffering Inside of .