Class AEADUtils

java.lang.Object
org.bouncycastle.bcpg.AEADUtils
All Implemented Interfaces:
AEADAlgorithmTags

public class AEADUtils extends Object implements AEADAlgorithmTags
  • Method Details

    • getIVLength

      public static int getIVLength(int aeadAlgorithmTag)
      Return the length of the IV used by the given AEAD algorithm in octets.
      Parameters:
      aeadAlgorithmTag - AEAD algorithm identifier
      Returns:
      length of the IV
    • getAuthTagLength

      public static int getAuthTagLength(int aeadAlgorithmTag)
      Return the length of the authentication tag used by the given AEAD algorithm in octets.
      Parameters:
      aeadAlgorithmTag - AEAD algorithm identifier
      Returns:
      length of the auth tag
    • splitMessageKeyAndIv

      public static byte[][] splitMessageKeyAndIv(byte[] messageKeyAndIv, int cipherAlgo, int aeadAlgo)
      Split a given byte array containing
      m
      bytes of key and
      n-8
      bytes of IV into two separate byte arrays.
      m
      is the key length of the cipher algorithm, while
      n
      is the IV length of the AEAD algorithm. Note, that the IV is filled with
      n-8
      bytes only, the remainder is left as 0s. Return an array of both arrays with the key and index 0 and the IV at index 1.
      Parameters:
      messageKeyAndIv -
      m+n-8
      bytes of concatenated message key and IV
      cipherAlgo - symmetric cipher algorithm
      aeadAlgo - AEAD algorithm
      Returns:
      array of arrays containing message key and IV