Top Description Fields Constructors Methods
org.bouncycastle.openpgp.operator.bc

pack-priv Class RFC6637KDFCalculator

extends Object
Class Inheritance
Imports
java.io.IOException, .OutputStream, org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags, org.bouncycastle.crypto.generators.HKDFBytesGenerator, org.bouncycastle.crypto.params.HKDFParameters, org.bouncycastle.math.ec.ECPoint, org.bouncycastle.openpgp.PGPException, org.bouncycastle.openpgp.operator.PGPDigestCalculator, org.bouncycastle.util.Strings, org.bouncycastle.util.encoders.Hex

Calculator for the EC based KDF algorithm described in RFC 6637

Field Summary

Modifier and TypeField and Description
private static final byte[]
private final PGPDigestCalculator
private final int

Constructor Summary

AccessConstructor and Description
public
RFC6637KDFCalculator(PGPDigestCalculator digCalc, int keyAlgorithm)

Method Summary

Modifier and TypeMethod and Description
public byte[]
createKey(ECPoint s, byte[] userKeyingMaterial)

public byte[]
createKey(byte[] secret, byte[] userKeyingMaterial)

public static byte[]

Returns:

The derived key for encryption.
createKey
(int
The algorithm to use for key derivation, such as SHA256 or SHA512.
algorithm
,
int
The key algorithm identifier, representing AES-128 or AES-256.
keyAlgorithm
,
byte[]
The bytes to prepend before deriving the key, which should include: - 32/56 octets of the ephemeral X25519 or X448 public key - 32/56 octets of the recipient public key material - 32/56 octets of the shared secret
prepend
,
String
The info parameter used in the HKDF function. For X25519, use "OpenPGP X25519". For X448, use "OpenPGP X448".
info
)

Creates a session key for X25519 or X448 encryption based on the provided algorithm and key algorithm.

private static int
getKeyLen(int algID)

private static byte[]
KDF(PGPDigestCalculator digCalc, byte[] ZB, int keyLen, byte[] param)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ANONYMOUS_SENDERback to summary
private static final byte[] ANONYMOUS_SENDER
digCalcback to summary
private final PGPDigestCalculator digCalc
keyAlgorithmback to summary
private final int keyAlgorithm

Constructor Detail

RFC6637KDFCalculatorback to summary
public RFC6637KDFCalculator(PGPDigestCalculator digCalc, int keyAlgorithm)

Method Detail

createKeyback to summary
public byte[] createKey(ECPoint s, byte[] userKeyingMaterial) throws PGPException
createKeyback to summary
public byte[] createKey(byte[] secret, byte[] userKeyingMaterial) throws PGPException
createKeyback to summary
public static byte[] createKey(int algorithm, int keyAlgorithm, byte[] prepend, String info) throws PGPException

Creates a session key for X25519 or X448 encryption based on the provided algorithm and key algorithm.

The method follows the specifications outlined in the OpenPGP standards, specifically sections 5.1.6 and 5.1.7 of rfc9580.

Parameters
algorithm:int

The algorithm to use for key derivation, such as SHA256 or SHA512.

keyAlgorithm:int

The key algorithm identifier, representing AES-128 or AES-256.

prepend:byte[]

The bytes to prepend before deriving the key, which should include: - 32/56 octets of the ephemeral X25519 or X448 public key - 32/56 octets of the recipient public key material - 32/56 octets of the shared secret

info:String

The info parameter used in the HKDF function. For X25519, use "OpenPGP X25519". For X448, use "OpenPGP X448".

Returns:byte[]

The derived key for encryption.

Exceptions
PGPException:
If an error occurs during key derivation.
See Also
rfc9580 - OpenPGP
getKeyLenback to summary
private static int getKeyLen(int algID) throws PGPException
KDFback to summary
private static byte[] KDF(PGPDigestCalculator digCalc, byte[] ZB, int keyLen, byte[] param) throws IOException