Class KTSGenerateKeySpec.Builder

java.lang.Object
org.bouncycastle.jcajce.spec.KTSGenerateKeySpec.Builder
Enclosing class:
KTSGenerateKeySpec

public static final class KTSGenerateKeySpec.Builder extends Object
Builder class for creating a KTSGenerateKeySpec.
  • Constructor Details

    • Builder

      public Builder(PublicKey publicKey, String algorithmName, int keySizeInBits)
      Basic builder.
      Parameters:
      publicKey - the public key to be used for encryption/encapsulation generation.
      algorithmName - the algorithm name for the secret key we wish to calculate.
      keySizeInBits - the size of the key we want to produce in bits.
    • Builder

      public Builder(PublicKey publicKey, String algorithmName, int keySizeInBits, byte[] otherInfo)
      Basic builder.
      Parameters:
      publicKey - the public key to be used for encryption/encapsulation generation.
      algorithmName - the algorithm name for the secret key we wish to calculate.
      keySizeInBits - the size of the key we want to produce in bits.
      otherInfo - the otherInfo/IV encoding to be applied to the KDF.
  • Method Details

    • withSecureRandom

      public KTSGenerateKeySpec.Builder withSecureRandom(SecureRandom random)
      Set the SecureRandom which will be used to generate the secret.
      Parameters:
      random - the source of randomness for the secret.
      Returns:
      the current Builder instance.
    • withMac

      public KTSGenerateKeySpec.Builder withMac(String macAlgorithmName, int macKeySizeInBits)
      Set the MAC algorithm name and its associated key size for the MAC key section of the secret.
      Parameters:
      macAlgorithmName - name of the MAC algorithm we will use.
      macKeySizeInBits - size of the MAC key (in bits)
      Returns:
      the current Builder instance.
    • withParameterSpec

      public KTSGenerateKeySpec.Builder withParameterSpec(AlgorithmParameterSpec parameterSpec)
      Set the algorithm parameter spec to be used with the public key.
      Parameters:
      parameterSpec - the algorithm parameter spec to be used in encryption.
      Returns:
      the current Builder instance.
    • withKdfAlgorithm

      Set the KDF algorithm and digest algorithm for key generation.
      Parameters:
      kdfBuilder - the KDF algorithm to apply.
      Returns:
      the current Builder instance.
    • withKdfAlgorithm

      public KTSGenerateKeySpec.Builder withKdfAlgorithm(AlgorithmIdentifier kdfAlgorithm)
      Set the KDF algorithm and digest algorithm for key generation.
      Parameters:
      kdfAlgorithm - the KDF algorithm to apply.
      Returns:
      the current Builder instance.
    • withKdfSalt

      public KTSGenerateKeySpec.Builder withKdfSalt(byte[] salt)
      Set the KDF salt for key generation (ignored for OAEP).
      Parameters:
      salt - the salt for initialising the KDF PRF.
      Returns:
      the current Builder instance.
    • build

      public KTSGenerateKeySpec build()
      Build the new key spec.
      Returns:
      a new key spec configured according to the builder state.