Top Fields Constructors Methods
org.bouncycastle.crypto.hpke

public Class HPKE

extends Object
Class Inheritance
Imports
org.bouncycastle.crypto.AsymmetricCipherKeyPair, .InvalidCipherTextException, org.bouncycastle.crypto.params.AsymmetricKeyParameter, org.bouncycastle.util.Arrays, .Pack, .Strings

Field Summary

Modifier and TypeField and Description
public static final short
public static final short
public static final short
public static final short
private final short
private final byte[]
private final byte[]
private final DHKEM
private final HKDF
public static final short
public static final short
public static final short
private final short
public static final short
public static final short
public static final short
public static final short
public static final short
private final short
private final byte
public static final byte
public static final byte
public static final byte
public static final byte
pack-priv short

Constructor Summary

AccessConstructor and Description
public
HPKE(byte mode, short kemId, short kdfId, short aeadId)

Hybrid Public Key Encryption as described in RFC9180.

Method Summary

Modifier and TypeMethod and Description
public AsymmetricCipherKeyPair
deriveKeyPair(byte[] ikm)

public AsymmetricCipherKeyPair
deserializePrivateKey(byte[] skEncoded, byte[] pkEncoded)

public AsymmetricKeyParameter
deserializePublicKey(byte[] pkEncoded)

public AsymmetricCipherKeyPair
private HPKEContext
keySchedule(byte mode, byte[] sharedSecret, byte[] info, byte[] psk, byte[] pskid)

public byte[]
open(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] aad, byte[] ct, byte[] psk, byte[] pskId, AsymmetricKeyParameter pkS)

public byte[]
receiveExport(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] exporterContext, int L, byte[] psk, byte[] pskId, AsymmetricKeyParameter pkS)

public byte[][]
seal(AsymmetricKeyParameter pkR, byte[] info, byte[] aad, byte[] pt, byte[] psk, byte[] pskId, AsymmetricCipherKeyPair skS)

public byte[][]
sendExport(AsymmetricKeyParameter pkR, byte[] info, byte[] exporterContext, int L, byte[] psk, byte[] pskId, AsymmetricCipherKeyPair skS)

public byte[]
public byte[]
public HPKEContext
setupAuthPSKR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] psk, byte[] psk_id, AsymmetricKeyParameter pkS)

public HPKEContextWithEncapsulation
setupAuthPSKS(AsymmetricKeyParameter pkR, byte[] info, byte[] psk, byte[] psk_id, AsymmetricCipherKeyPair skS)

public HPKEContext
setupAuthR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, AsymmetricKeyParameter pkS)

public HPKEContextWithEncapsulation
public HPKEContext
setupBaseR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info)

public HPKEContextWithEncapsulation
public HPKEContextWithEncapsulation
public HPKEContext
setupPSKR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] psk, byte[] psk_id)

public HPKEContextWithEncapsulation
SetupPSKS(AsymmetricKeyParameter pkR, byte[] info, byte[] psk, byte[] psk_id)

private void
VerifyPSKInputs(byte mode, byte[] psk, byte[] pskid)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aead_AES_GCM128back to summary
public static final short aead_AES_GCM128
aead_AES_GCM256back to summary
public static final short aead_AES_GCM256
aead_CHACHA20_POLY1305back to summary
public static final short aead_CHACHA20_POLY1305
aead_EXPORT_ONLYback to summary
public static final short aead_EXPORT_ONLY
aeadIdback to summary
private final short aeadId
default_pskback to summary
private final byte[] default_psk
default_psk_idback to summary
private final byte[] default_psk_id
dhkemback to summary
private final DHKEM dhkem
hkdfback to summary
private final HKDF hkdf
kdf_HKDF_SHA256back to summary
public static final short kdf_HKDF_SHA256
kdf_HKDF_SHA384back to summary
public static final short kdf_HKDF_SHA384
kdf_HKDF_SHA512back to summary
public static final short kdf_HKDF_SHA512
kdfIdback to summary
private final short kdfId
kem_P256_SHA256back to summary
public static final short kem_P256_SHA256
kem_P384_SHA348back to summary
public static final short kem_P384_SHA348
kem_P521_SHA512back to summary
public static final short kem_P521_SHA512
kem_X25519_SHA256back to summary
public static final short kem_X25519_SHA256
kem_X448_SHA512back to summary
public static final short kem_X448_SHA512
kemIdback to summary
private final short kemId
modeback to summary
private final byte mode
mode_authback to summary
public static final byte mode_auth
mode_auth_pskback to summary
public static final byte mode_auth_psk
mode_baseback to summary
public static final byte mode_base
mode_pskback to summary
public static final byte mode_psk
Nkback to summary
pack-priv short Nk

Constructor Detail

HPKEback to summary
public HPKE(byte mode, short kemId, short kdfId, short aeadId)

Hybrid Public Key Encryption as described in RFC9180.

See Also
RFC9180 An implementation of the Hybrid Public Key Encryption.

Method Detail

deriveKeyPairback to summary
public AsymmetricCipherKeyPair deriveKeyPair(byte[] ikm)
deserializePrivateKeyback to summary
public AsymmetricCipherKeyPair deserializePrivateKey(byte[] skEncoded, byte[] pkEncoded)
deserializePublicKeyback to summary
public AsymmetricKeyParameter deserializePublicKey(byte[] pkEncoded)
generatePrivateKeyback to summary
public AsymmetricCipherKeyPair generatePrivateKey()
keyScheduleback to summary
private HPKEContext keySchedule(byte mode, byte[] sharedSecret, byte[] info, byte[] psk, byte[] pskid)
openback to summary
public byte[] open(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] aad, byte[] ct, byte[] psk, byte[] pskId, AsymmetricKeyParameter pkS) throws InvalidCipherTextException
receiveExportback to summary
public byte[] receiveExport(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] exporterContext, int L, byte[] psk, byte[] pskId, AsymmetricKeyParameter pkS)
sealback to summary
public byte[][] seal(AsymmetricKeyParameter pkR, byte[] info, byte[] aad, byte[] pt, byte[] psk, byte[] pskId, AsymmetricCipherKeyPair skS) throws InvalidCipherTextException
sendExportback to summary
public byte[][] sendExport(AsymmetricKeyParameter pkR, byte[] info, byte[] exporterContext, int L, byte[] psk, byte[] pskId, AsymmetricCipherKeyPair skS)
serializePrivateKeyback to summary
public byte[] serializePrivateKey(AsymmetricKeyParameter sk)
serializePublicKeyback to summary
public byte[] serializePublicKey(AsymmetricKeyParameter pk)
setupAuthPSKRback to summary
public HPKEContext setupAuthPSKR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] psk, byte[] psk_id, AsymmetricKeyParameter pkS)
setupAuthPSKSback to summary
public HPKEContextWithEncapsulation setupAuthPSKS(AsymmetricKeyParameter pkR, byte[] info, byte[] psk, byte[] psk_id, AsymmetricCipherKeyPair skS)
setupAuthRback to summary
public HPKEContext setupAuthR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, AsymmetricKeyParameter pkS)
setupAuthSback to summary
public HPKEContextWithEncapsulation setupAuthS(AsymmetricKeyParameter pkR, byte[] info, AsymmetricCipherKeyPair skS)
setupBaseRback to summary
public HPKEContext setupBaseR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info)
setupBaseSback to summary
public HPKEContextWithEncapsulation setupBaseS(AsymmetricKeyParameter pkR, byte[] info)
setupBaseSback to summary
public HPKEContextWithEncapsulation setupBaseS(AsymmetricKeyParameter pkR, byte[] info, AsymmetricCipherKeyPair kpE)
setupPSKRback to summary
public HPKEContext setupPSKR(byte[] enc, AsymmetricCipherKeyPair skR, byte[] info, byte[] psk, byte[] psk_id)
SetupPSKSback to summary
public HPKEContextWithEncapsulation SetupPSKS(AsymmetricKeyParameter pkR, byte[] info, byte[] psk, byte[] psk_id)
VerifyPSKInputsback to summary
private void VerifyPSKInputs(byte mode, byte[] psk, byte[] pskid)