java.lang.Object
net.i2p.crypto.HKDF
HMAC-based Key Derivation Function (HKDF) implementation using HMAC-SHA256.
This class implements the HKDF algorithm as specified in RFC 5869 for deriving cryptographic keys from input key material. It provides secure key expansion functionality essential for I2P's cryptographic operations including session key generation and key derivation.
Features and capabilities:
- HMAC-SHA256 based derivation for cryptographic security
- Support for one or two output keys with optional info parameter
- Thread-safe operation with no internal state
- Fixed 32-byte output size for consistency across I2P
- Reusable instances for performance optimization
- See Also:
Constructor Summary
ConstructorsConstructorDescriptionHKDF(I2PAppContext context) Create an instance bound to an application context.Method Summary
Constructor Details
HKDF
Create an instance bound to an application context.- Parameters:
context- the app context
Method Details
calculate
public void calculate(byte[] key, byte[] data, byte[] out) One output, no info.- Parameters:
key- first 32 bytes used as the keydata- the input dataout- must be exactly 32 bytes
calculate
One output with info.- Parameters:
key- first 32 bytes used as the keydata- the input datainfo- non-null ASCII, "" if noneout- must be exactly 32 bytes
calculate
public void calculate(byte[] key, byte[] data, byte[] out, byte[] out2, int off2) Two outputs, no info.- Parameters:
key- first 32 bytes used as the keydata- the input data the output keys are derived fromout- 32 bytes will be copied to hereout2- 32 bytes will be copied to here, may be the same as outoff2- offset for copy to out2
calculate
Two outputs with info.- Parameters:
key- first 32 bytes used as the keydata- the input data the output keys are derived frominfo- non-null ASCII, "" if noneout- 32 bytes will be copied to hereout2- 32 bytes will be copied to here, may be the same as outoff2- offset for copy to out2