Class EncryptedNonce

java.lang.Object
org.cryptacular.generator.sp80038a.EncryptedNonce
All Implemented Interfaces:
Nonce

public class EncryptedNonce extends Object implements Nonce
Nonce generation strategy that produces a random value according to NIST SP-800-38a, appendix C, method 1 (encrypted nonce), suitable for use with any block cipher mode described in that standard except OFB.

Instances of this class are thread safe.

Author:
Middleware Services
  • Constructor Details

    • EncryptedNonce

      public EncryptedNonce(Spec<org.bouncycastle.crypto.BlockCipher> cipherSpec, SecretKey key)
      Creates a new instance.
      Parameters:
      cipherSpec - Block cipher specification.
      key - Symmetric key.
    • EncryptedNonce

      public EncryptedNonce(org.bouncycastle.crypto.BlockCipher cipher, SecretKey key)
      Creates a new instance.
      Parameters:
      cipher - Block cipher to use.
      key - Symmetric key.
  • Method Details

    • generate

      public byte[] generate() throws LimitException
      Description copied from interface: Nonce
      Generates a nonce value.
      Specified by:
      generate in interface Nonce
      Returns:
      Nonce bytes.
      Throws:
      LimitException - When a limit imposed by the nonce generation strategy, if any, is exceeded.
    • getLength

      public int getLength()
      Specified by:
      getLength in interface Nonce
      Returns:
      Length in bytes of generated nonce values.