iaik.security.cipher
Class PBEKeyBMP

java.lang.Object
  |
  +--iaik.security.cipher.PBEKeyBMP

public class PBEKeyBMP
extends java.lang.Object
implements SecretKey

A secret key for PBE (Password Based Encryption).

PKCS#12 breaks with the recommendation of PKCS#5 suggesting passwords to consist of printable ASCII characters. PKCS #12 creates passwords from BMPStrings with a NULL terminator by encoding every character of the original BMPString in 2 bytes in big-endian format (most-significant byte first).

This class returns the password as a byte array of the default ASCII encoding. But in contrast to PBEKey here the password is created from a BMPstring with a NULL terminator.

E.g.: User-password "Beavis" would lead to the following string of 14 bytes:

0x00 0x42 0x00 0x65 0x00 0x61 0x00 0x76 0x00 0x69 0x00 0x73 0x00 0x00

You can also use the "PKCS#12" SecretKeyFactory for converting a password to a PBEKeyBMP.

See Also:
SecretKey, SecretKey, PBEKey, PbeWithSHAAnd3_KeyTripleDES_CBC, PbeWithSHAAnd40BitRC2_CBC, Serialized Form

Fields inherited from interface java.security.Key
serialVersionUID
 
Constructor Summary
PBEKeyBMP(char[] password)
          Creates a new PBEKeyBMP from a char array.
PBEKeyBMP(PBEKeySpec keySpec)
          Creates a new PBEKey from a PBEKeySpec.
PBEKeyBMP(java.lang.String password)
          Creates a new PBEKeyBMP from a String.
 
Method Summary
 java.lang.String getAlgorithm()
          Returns the algorithm name.
 byte[] getEncoded()
          Returns the password as byte array.
static byte[] getEncoded(char[] password)
          Converts the ASCII passwort to a 2 bytes big-endian format BMPString.
 java.lang.String getFormat()
          Returns the format name.
 char[] getKey()
          Returns the password as char array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PBEKeyBMP

public PBEKeyBMP(java.lang.String password)
Creates a new PBEKeyBMP from a String.
Parameters:
password - the password as a string

PBEKeyBMP

public PBEKeyBMP(char[] password)
Creates a new PBEKeyBMP from a char array.
Parameters:
password - the password as a char array

PBEKeyBMP

public PBEKeyBMP(PBEKeySpec keySpec)
Creates a new PBEKey from a PBEKeySpec.
Parameters:
keySpec - the password as KeySpec
Method Detail

getEncoded

public final byte[] getEncoded()
Returns the password as byte array.
Returns:
the password as byte array

getEncoded

public static final byte[] getEncoded(char[] password)
Converts the ASCII passwort to a 2 bytes big-endian format BMPString.
Returns:
the password as byte array

getKey

public char[] getKey()
Returns the password as char array.
Returns:
the password as char array

getAlgorithm

public java.lang.String getAlgorithm()
Returns the algorithm name.
Returns:
"PBE"

getFormat

public java.lang.String getFormat()
Returns the format name.
Returns:
"RAW_BMP"