Book Home Java Enterprise in a Nutshell Search this book

Chapter 28. The javax.crypto.spec Package

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

Figure 28-1. The javax.crypto.spec package

DESedeKeySpecJCE 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;
// Public Instance Methods
public byte[ ] getKey ();
}

Hierarchy: Object-->DESedeKeySpec(java.security.spec.KeySpec)

DESKeySpecJCE 1.2
javax.crypto.spec

This class is a transparent representation of a DES key. The key is eight bytes long.

public class DESKeySpec implements java.security.spec.KeySpec {
// Public Constructors
public DESKeySpec (byte[ ] key) throws java.security.InvalidKeyException;
public DESKeySpec (byte[ ] key, int offset) throws java.security.InvalidKeyException;
// Public Constants
public static final int DES_KEY_LEN ; =8
// Public Class Methods
public static boolean isParityAdjusted (byte[ ] key, int offset) throws java.security.InvalidKeyException;
public static boolean isWeak (byte[ ] key, int offset) throws java.security.InvalidKeyException;
// Public Instance Methods
public byte[ ] getKey ();
}

Hierarchy: Object-->DESKeySpec(java.security.spec.KeySpec)

DHGenParameterSpecJCE 1.2
javax.crypto.spec

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);
// Public Instance Methods
public int getExponentSize ();
public int getPrimeSize ();
}

Hierarchy: Object-->DHGenParameterSpec(java.security.spec.AlgorithmParameterSpec)

DHParameterSpecJCE 1.2
javax.crypto.spec

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);
// Public Instance Methods
public java.math.BigInteger getG ();
public int getL ();
public java.math.BigInteger getP ();
}

Hierarchy: Object-->DHParameterSpec(java.security.spec.AlgorithmParameterSpec)

Returned By: javax.crypto.interfaces.DHKey.getParams()

DHPrivateKeySpecJCE 1.2
javax.crypto.spec

This java.security.spec.KeySpec is a transparent representation of a Diffie-Hellman private key.

public class DHPrivateKeySpec implements java.security.spec.KeySpec {
// Public Constructors
public DHPrivateKeySpec (java.math.BigInteger x, java.math.BigInteger p, java.math.BigInteger g);
// Public Instance Methods
public java.math.BigInteger getG ();
public java.math.BigInteger getP ();
public java.math.BigInteger getX ();
}

Hierarchy: Object-->DHPrivateKeySpec(java.security.spec.KeySpec)

DHPublicKeySpecJCE 1.2
javax.crypto.spec

This java.security.spec.KeySpec is a transparent representation of a Diffie-Hellman public key.

public class DHPublicKeySpec implements java.security.spec.KeySpec {
// Public Constructors
public DHPublicKeySpec (java.math.BigInteger y, java.math.BigInteger p, java.math.BigInteger g);
// Public Instance Methods
public java.math.BigInteger getG ();
public java.math.BigInteger getP ();
public java.math.BigInteger getY ();
}

Hierarchy: Object-->DHPublicKeySpec(java.security.spec.KeySpec)

IvParameterSpecJCE 1.2
javax.crypto.spec

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);
// Public Instance Methods
public byte[ ] getIV ();
}

Hierarchy: Object-->IvParameterSpec(java.security.spec.AlgorithmParameterSpec)

PBEKeySpecJCE 1.2
javax.crypto.spec

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 {
// Public Constructors
public PBEKeySpec (char[ ] password);
// Public Instance Methods
public final char[ ] getPassword ();
}

Hierarchy: Object-->PBEKeySpec(java.security.spec.KeySpec)

PBEParameterSpecJCE 1.2
javax.crypto.spec

This class is a transparent representation of the parameters used with the password-based encryption algorithm defined by PKCS#5.

public class PBEParameterSpec implements java.security.spec.AlgorithmParameterSpec {
// Public Constructors
public PBEParameterSpec (byte[ ] salt, int iterationCount);
// Public Instance Methods
public int getIterationCount ();
public byte[ ] getSalt ();
}

Hierarchy: Object-->PBEParameterSpec(java.security.spec.AlgorithmParameterSpec)

RC2ParameterSpecJCE 1.2
javax.crypto.spec

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);
// Public Instance Methods
public int getEffectiveKeyBits ();
public byte[ ] getIV ();
}

Hierarchy: Object-->RC2ParameterSpec(java.security.spec.AlgorithmParameterSpec)

RC5ParameterSpecJCE 1.2
javax.crypto.spec

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);
// Public Instance Methods
public byte[ ] getIV ();
public int getRounds ();
public int getVersion ();
public int getWordSize ();
}

Hierarchy: Object-->RC5ParameterSpec(java.security.spec.AlgorithmParameterSpec)

SecretKeySpecJCE 1.2
javax.crypto.specserializable

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);
// Methods Implementing Key
public String getAlgorithm ();
public byte[ ] getEncoded ();
public String getFormat ();
// Public Methods Overriding Object
public boolean equals (Object obj);
public int hashCode ();
}

Hierarchy: Object-->SecretKeySpec(java.security.spec.KeySpec,javax.crypto.SecretKey(java.security.Key(Serializable)))



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.

This HTML Help has been published using the chm2web software.