Key Specifications

As well as supporting the relevant JCA/JCE defined KeySpec classes, SafeNet ProtectToolkit-J includes a number of custom provider-independent key classes for use with its KeyFactory classes. These classes all live in the au.com.safenet.crypto.spec package:

AsciiEncodedKeySpec

Used to encode RSA, DSA or Diffie-Hellman public and private keys as ASCII strings. These strings contain the key's integer components as hexadecimal strings separated by a full stop. For example, an RSA private key:

public_exponent.modulus.private_exponent.p.q 

A public key will contain only the first two elements and a private key will contain all five. The RSA KeyFactory can convert from this KeySpec into the provider-based key.

For DSA keys the format is:

y.p.q.g (private keys) x.p.q.g (public keys)

For Diffie-Hellman keys, the format is:

y.p.g (private keys) x.p.g (public keys)

CASTKeySpec

Used to encode keys for the CAST algorithm. This class takes a byte array, which it will use directly as the CAST key. The array must be less than or equal to 16 bytes, the maximum key size for a CAST key.

IDEAKeySpec

Used to encode keys for the IDEA algorithm. This class takes a byte array and uses the first 16 bytes of the array as the IDEA key.

RC2KeySpec

Used to encode keys for the RC2 algorithm. This class takes a byte array, which it will use directly as the RC2 key. The array must be less than or equal to 128 bytes, the maximum key size for a RC2 key.

RC4KeySpec

Used to encode keys for the RC4 algorithm. This class takes a byte array, which it will use directly as the RC4 key. The array must be less than or equal to 256 bytes, the maximum key size for a RC4 key.

AESKeySpec

Used to encode keys for the AES algorithm. This class takes a byte array, which it will use directly as the AES key. The array must be 16, 24 or 32 bytes.