Class HpkeUtil
- java.lang.Object
-
- com.google.crypto.tink.hybrid.internal.HpkeUtil
-
public final class HpkeUtil extends java.lang.ObjectCollection of helper functions for HPKE.
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]AES_128_GCM_AEAD_IDstatic byte[]AES_256_GCM_AEAD_IDstatic byte[]AUTH_MODEstatic byte[]BASE_MODEstatic byte[]CHACHA20_POLY1305_AEAD_IDstatic byte[]EMPTY_SALTstatic byte[]HKDF_SHA256_KDF_IDstatic byte[]HKDF_SHA384_KDF_IDstatic byte[]HKDF_SHA512_KDF_IDstatic byte[]P256_HKDF_SHA256_KEM_IDstatic byte[]P384_HKDF_SHA384_KEM_IDstatic byte[]P521_HKDF_SHA512_KEM_IDstatic byte[]X25519_HKDF_SHA256_KEM_ID
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intencodingSizeInBytes(HpkeParameters.KemId kemId)Returns the encapsulated key length (in bytes) for the specifiedkemId.static intgetEncodedPrivateKeyLength(HpkeParameters.KemId kemId)Lengths from 'Nsk' column in https://www.rfc-editor.org/rfc/rfc9180.html#table-2.static intgetEncodedPublicKeyLength(HpkeParameters.KemId kemId)Lengths from 'Npk' column in https://www.rfc-editor.org/rfc/rfc9180.html#table-2.static byte[]intToByteArray(int capacity, int value)Transforms a passed value to an MSB first byte array with the size of the specified capacity.
-
-
-
Field Detail
-
BASE_MODE
public static final byte[] BASE_MODE
-
AUTH_MODE
public static final byte[] AUTH_MODE
-
X25519_HKDF_SHA256_KEM_ID
public static final byte[] X25519_HKDF_SHA256_KEM_ID
-
P256_HKDF_SHA256_KEM_ID
public static final byte[] P256_HKDF_SHA256_KEM_ID
-
P384_HKDF_SHA384_KEM_ID
public static final byte[] P384_HKDF_SHA384_KEM_ID
-
P521_HKDF_SHA512_KEM_ID
public static final byte[] P521_HKDF_SHA512_KEM_ID
-
HKDF_SHA256_KDF_ID
public static final byte[] HKDF_SHA256_KDF_ID
-
HKDF_SHA384_KDF_ID
public static final byte[] HKDF_SHA384_KDF_ID
-
HKDF_SHA512_KDF_ID
public static final byte[] HKDF_SHA512_KDF_ID
-
AES_128_GCM_AEAD_ID
public static final byte[] AES_128_GCM_AEAD_ID
-
AES_256_GCM_AEAD_ID
public static final byte[] AES_256_GCM_AEAD_ID
-
CHACHA20_POLY1305_AEAD_ID
public static final byte[] CHACHA20_POLY1305_AEAD_ID
-
EMPTY_SALT
public static final byte[] EMPTY_SALT
-
-
Method Detail
-
intToByteArray
public static byte[] intToByteArray(int capacity, int value)Transforms a passed value to an MSB first byte array with the size of the specified capacity. (i.e.,Bytes.intToByteArray(int, int)with MSB first instead of LSB first).The HPKE standard defines this function as I2OSP(n, w) where w = capacity and n = value.
https://www.rfc-editor.org/rfc/rfc9180.html#name-notation
- Parameters:
capacity- size of the resulting byte arrayvalue- that should be represented as a byte array
-
getEncodedPublicKeyLength
public static int getEncodedPublicKeyLength(HpkeParameters.KemId kemId) throws java.security.GeneralSecurityException
Lengths from 'Npk' column in https://www.rfc-editor.org/rfc/rfc9180.html#table-2.- Throws:
java.security.GeneralSecurityException
-
encodingSizeInBytes
public static int encodingSizeInBytes(HpkeParameters.KemId kemId)
Returns the encapsulated key length (in bytes) for the specifiedkemId. This value corresponds to the 'Nenc' column in the following table.https://www.rfc-editor.org/rfc/rfc9180.html#name-key-encapsulation-mechanism.
-
getEncodedPrivateKeyLength
public static int getEncodedPrivateKeyLength(HpkeParameters.KemId kemId) throws java.security.GeneralSecurityException
Lengths from 'Nsk' column in https://www.rfc-editor.org/rfc/rfc9180.html#table-2.- Throws:
java.security.GeneralSecurityException
-
-