The javax.crypto.spec
package contains classes that define transparent
java.security.spec.KeySpec and
java.security.spec.AlgorithmParameterSpec
representations of secret keys, Diffie-Hellman public and private
keys, and parameters used by various cryptographic algorithms. The classes in this package are used in conjunction with
java.security.KeyFactory,
javax.crypto.SecretKeyFactory and
java.security.AlgorithmParameters for converting
opaque Key, and
AlgorithmParameters objects to and from transparent
representations. Figure 28-1 shows the class hierarchy of
this package. In order to make good use of this package, you
must be familiar with the specifications of the various cryptographic
algorithms it supports and the basic mathematics that underlie those
algorithms.
Figure 28-1. The javax.crypto.spec package
DESedeKeySpec
JCE 1.2
javax.crypto.spec
This class is a transparent representation of a DESede (triple-DES)
key. The key is 24 bytes long.
public class DESedeKeySpec implements java.security.spec.KeySpec {
//
Public Constructors
public DESedeKeySpec (byte[ ] key) throws java.security.InvalidKeyException;
public DESedeKeySpec (byte[ ] key, int offset) throws java.security.InvalidKeyException;
//
Public Constants
public static final int DES_EDE_KEY_LEN ;
=24
//
Public Class Methods
public static boolean isParityAdjusted (byte[ ] key, int offset) throws java.security.InvalidKeyException;
This class is a transparent representation of the values needed to
generate a set of Diffie-Hellman parameters (see
DHParameterSpec). An instance of this class can be
passed to the init() method of a
java.security.AlgorithmParameterGenerator that computes
Diffie-Hellman parameters.
public class DHGenParameterSpec implements java.security.spec.AlgorithmParameterSpec {
//
Public Constructors
public DHGenParameterSpec (int primeSize, int exponentSize);
This class is a transparent representation of the set of parameters
required by the Diffie-Hellman key-agreement algorithm. All parties
to the key agreement must share these parameters and use them to
generate a Diffie-Hellman public/private key pair.
public class DHParameterSpec implements java.security.spec.AlgorithmParameterSpec {
//
Public Constructors
public DHParameterSpec (java.math.BigInteger p, java.math.BigInteger g);
public DHParameterSpec (java.math.BigInteger p, java.math.BigInteger g, int l);
This java.security.spec.AlgorithmParameterSpec
is a transparent representation of an initialization vector
or IV. An IV is required for block ciphers used in feedback mode,
such as DES in CBC mode.
public class IvParameterSpec implements java.security.spec.AlgorithmParameterSpec {
//
Public Constructors
public IvParameterSpec (byte[ ] iv);
public IvParameterSpec (byte[ ] iv, int offset, int len);
This class is a transparent representation of a password used in
password-based encryption (PBE). The password is stored as a
char array rather than as a
String, so that the characters of the password can
be overwritten when they are no longer
needed (for increased security).
public class PBEKeySpec implements java.security.spec.KeySpec {
This class is a transparent representation of the parameters used by
the RC2 encryption algorithm. An object of this class
initializes a Cipher object that implements RC2. Note that the "SunJCE" provider supplied by Sun does not implement
RC2.
public class RC2ParameterSpec implements java.security.spec.AlgorithmParameterSpec {
//
Public Constructors
public RC2ParameterSpec (int effectiveKeyBits);
public RC2ParameterSpec (int effectiveKeyBits, byte[ ] iv);
public RC2ParameterSpec (int effectiveKeyBits, byte[ ] iv, int offset);
This class is a transparent representation of the parameters used by
the RC5 encryption algorithm. An object of this class
initializes a Cipher object that implements RC5. Note that the "SunJCE" provider supplied by Sun does not implement
RC5.
public class RC5ParameterSpec implements java.security.spec.AlgorithmParameterSpec {
//
Public Constructors
public RC5ParameterSpec (int version, int rounds, int wordSize);
public RC5ParameterSpec (int version, int rounds, int wordSize, byte[ ] iv);
public RC5ParameterSpec (int version, int rounds, int wordSize, byte[ ] iv, int offset);
This class is a transparent and algorithm-independent representation
of a secret key. This class is useful only for encryption algorithms
(such as DES and DESede) whose secret keys can be represented as
arbitrary byte arrays and do not require auxiliary
parameters. Note that SecretKeySpec implements the
javax.crypto.SecretKey interface directly, so no
algorithm-specific javax.crypto.SecretKeyFactory
object is required.
public class SecretKeySpec implements java.security.spec.KeySpecjavax.crypto.SecretKey {
//
Public Constructors
public SecretKeySpec (byte[ ] key, String algorithm);
public SecretKeySpec (byte[ ] key, int offset, int len, String algorithm);