Class BcPKCS12PBEOutputEncryptorBuilder

java.lang.Object
org.bouncycastle.pkcs.bc.BcPKCS12PBEOutputEncryptorBuilder

public class BcPKCS12PBEOutputEncryptorBuilder extends Object
Lightweight builder for an OutputEncryptor that applies one of the PKCS#12 password-based encryption schemes from RFC 7292 Appendix C. Defaults to SHA-1 as the KDF digest with an iteration count of 1024.
  • Constructor Details

    • BcPKCS12PBEOutputEncryptorBuilder

      public BcPKCS12PBEOutputEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier algorithm, org.bouncycastle.crypto.BlockCipher engine)
      Build an encryptor for the given PKCS#12 PBE algorithm using SHA-1 as the KDF digest.
      Parameters:
      algorithm - the PKCS#12 PBE algorithm identifier.
      engine - the underlying block cipher to wrap with PKCS#7 padding.
    • BcPKCS12PBEOutputEncryptorBuilder

      public BcPKCS12PBEOutputEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier algorithm, org.bouncycastle.crypto.BlockCipher engine, org.bouncycastle.crypto.ExtendedDigest pbeDigest)
      Build an encryptor for the given PKCS#12 PBE algorithm and an explicit KDF digest.
      Parameters:
      algorithm - the PKCS#12 PBE algorithm identifier.
      engine - the underlying block cipher to wrap with PKCS#7 padding.
      pbeDigest - the digest to use inside the PKCS#12 KDF.
  • Method Details

    • setIterationCount

      public BcPKCS12PBEOutputEncryptorBuilder setIterationCount(int iterationCount)
      Override the iteration count used by the PKCS#12 KDF. Defaults to 1024.
      Parameters:
      iterationCount - the iteration count.
      Returns:
      this builder.
    • build

      public OutputEncryptor build(char[] password)
      Bind the builder to a password and return a configured OutputEncryptor.
      Parameters:
      password - the password used to derive the encryption key.
      Returns:
      an output encryptor parameterised with a freshly generated salt and the configured iteration count.