Package org.bouncycastle.bcpg
Class AEADUtils
java.lang.Object
org.bouncycastle.bcpg.AEADUtils
- All Implemented Interfaces:
AEADAlgorithmTags
-
Field Summary
Fields inherited from interface org.bouncycastle.bcpg.AEADAlgorithmTags
EAX, GCM, OCB
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getAuthTagLength
(int aeadAlgorithmTag) Return the length of the authentication tag used by the given AEAD algorithm in octets.static int
getIVLength
(int aeadAlgorithmTag) Return the length of the IV used by the given AEAD algorithm in octets.static byte[][]
splitMessageKeyAndIv
(byte[] messageKeyAndIv, int cipherAlgo, int aeadAlgo) Split a given byte array containing
-
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 containingm
bytes of key andn-8
bytes of IV into two separate byte arrays.m
is the key length of the cipher algorithm, whilen
is the IV length of the AEAD algorithm. Note, that the IV is filled withn-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 IVcipherAlgo
- symmetric cipher algorithmaeadAlgo
- AEAD algorithm- Returns:
- array of arrays containing message key and IV
-