Class PKCS12Key

java.lang.Object
org.bouncycastle.jcajce.PKCS12Key
All Implemented Interfaces:
Serializable, Key, SecretKey, Destroyable, PBKDFKey
Direct Known Subclasses:
PKCS12KeyWithParameters

public class PKCS12Key extends Object implements PBKDFKey
A password based key for use with PKCS#12.
See Also:
  • Constructor Details

    • PKCS12Key

      public PKCS12Key(char[] password)
      Basic constructor for a password based key - secret key generation parameters will be passed separately..
      Parameters:
      password - password to use.
    • PKCS12Key

      public PKCS12Key(char[] password, boolean useWrongZeroLengthConversion)
      Unfortunately there seems to be some confusion about how to handle zero length passwords.
      Parameters:
      password - password to use.
      useWrongZeroLengthConversion - use the incorrect encoding approach (add pad bytes)
  • Method Details

    • getPassword

      public char[] getPassword()
      Return a reference to the char[] array holding the password.
      Returns:
      a reference to the password array.
    • getAlgorithm

      public String getAlgorithm()
      Return the password based key derivation function this key is for,
      Specified by:
      getAlgorithm in interface Key
      Returns:
      the string "PKCS12"
    • getFormat

      public String getFormat()
      Return the format encoding.
      Specified by:
      getFormat in interface Key
      Returns:
      the string "PKCS12", representing the char[] to byte[] conversion.
    • getEncoded

      public byte[] getEncoded()
      Return the password converted to bytes.
      Specified by:
      getEncoded in interface Key
      Returns:
      the password converted to a byte array.