Class PBKDF2Params

java.lang.Object
org.bouncycastle.asn1.ASN1Object
org.bouncycastle.asn1.pkcs.PBKDF2Params
All Implemented Interfaces:
ASN1Encodable, Encodable

public class PBKDF2Params extends ASN1Object
     PBKDF2-params ::= SEQUENCE {
               salt CHOICE {
                      specified OCTET STRING,
                      otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
               },
              iterationCount INTEGER (1..MAX),
              keyLength INTEGER (1..MAX) OPTIONAL,
              prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1 }
 
  • Constructor Details

    • PBKDF2Params

      public PBKDF2Params(byte[] salt, int iterationCount)
      Create a PBKDF2Params with the specified salt, iteration count, and algid-hmacWithSHA1 for the prf.
      Parameters:
      salt - input salt.
      iterationCount - input iteration count.
    • PBKDF2Params

      public PBKDF2Params(byte[] salt, int iterationCount, int keyLength)
      Create a PBKDF2Params with the specified salt, iteration count, keyLength, and algid-hmacWithSHA1 for the prf.
      Parameters:
      salt - input salt.
      iterationCount - input iteration count.
      keyLength - intended key length to be produced.
    • PBKDF2Params

      public PBKDF2Params(byte[] salt, int iterationCount, int keyLength, AlgorithmIdentifier prf)
      Create a PBKDF2Params with the specified salt, iteration count, keyLength, and a defined prf.
      Parameters:
      salt - input salt.
      iterationCount - input iteration count.
      keyLength - intended key length to be produced.
      prf - the pseudo-random function to use.
    • PBKDF2Params

      public PBKDF2Params(byte[] salt, int iterationCount, AlgorithmIdentifier prf)
      Create a PBKDF2Params with the specified salt, iteration count, and a defined prf.
      Parameters:
      salt - input salt.
      iterationCount - input iteration count.
      prf - the pseudo-random function to use.
  • Method Details

    • getInstance

      public static PBKDF2Params getInstance(Object obj)
      Create PBKDF2Params from the passed in object,
      Parameters:
      obj - either PBKDF2Params or an ASN1Sequence.
      Returns:
      a PBKDF2Params instance.
    • getSalt

      public byte[] getSalt()
      Return the salt to use.
      Returns:
      the input salt.
    • getIterationCount

      public BigInteger getIterationCount()
      Return the iteration count to use.
      Returns:
      the input iteration count.
    • getKeyLength

      public BigInteger getKeyLength()
      Return the intended length in octets of the derived key.
      Returns:
      length in octets for derived key, if specified.
    • isDefaultPrf

      public boolean isDefaultPrf()
      Return true if the PRF is the default (hmacWithSHA1)
      Returns:
      true if PRF is default, false otherwise.
    • getPrf

      public AlgorithmIdentifier getPrf()
      Return the algId of the underlying pseudo random function to use.
      Returns:
      the prf algorithm identifier.
    • toASN1Primitive

      public ASN1Primitive toASN1Primitive()
      Return an ASN.1 structure suitable for encoding.
      Specified by:
      toASN1Primitive in interface ASN1Encodable
      Specified by:
      toASN1Primitive in class ASN1Object
      Returns:
      the object as an ASN.1 encodable structure.