Setup
HPKE setup functions (RFC 9180 §5.1). Creates encryption contexts for each mode.
- class rfc9180.setup.HPKESetup(kem, kdf, aead)[source]
Bases:
objectHPKE Setup functions (RFC 9180 §5.1).
Handles the setup phase of HPKE operations, creating encryption contexts for different HPKE modes.
- Parameters:
- verify_psk_inputs(mode, psk, psk_id)[source]
Verify PSK inputs are consistent with the mode.
- Parameters:
- Raises:
ValueError – If PSK inputs are inconsistent with the mode.
- Return type:
- key_schedule(role, mode, shared_secret, info, psk, psk_id)[source]
Perform key schedule to derive encryption context.
- Parameters:
- Returns:
Encryption context for the specified role.
- Return type:
- Raises:
ValueError – If
roleis not"S"or"R", or if PSK inputs are inconsistent with the mode.
- setup_base_recipient(enc, skR, info)[source]
Setup Base mode for recipient.
- Parameters:
- Returns:
Recipient context.
- Return type:
- setup_psk_sender(pkR, info, psk, psk_id)[source]
Setup PSK mode for sender.
- Parameters:
pkR (Key Object) – Recipient’s public key.
info (bytes) – Application-supplied information.
psk (bytes) – Pre-shared key. RFC 9180 §9.5 requires at least 32 bytes of entropy. Entropy is not measurable from the byte string; only VerifyPSKInputs is enforced.
psk_id (bytes) – Pre-shared key identifier.
- Returns:
Tuple of (encapsulated key, sender context).
- Return type:
- Raises:
ValueError – If
pskandpsk_idare inconsistent with PSK mode.
- setup_psk_recipient(enc, skR, info, psk, psk_id)[source]
Setup PSK mode for recipient.
- Parameters:
enc (bytes) – Encapsulated public key.
skR (Key Object) – Recipient’s private key.
info (bytes) – Application-supplied information.
psk (bytes) – Pre-shared key. RFC 9180 §9.5 requires at least 32 bytes of entropy. Entropy is not measurable from the byte string; only VerifyPSKInputs is enforced.
psk_id (bytes) – Pre-shared key identifier.
- Returns:
Recipient context.
- Return type:
- Raises:
ValueError – If
pskandpsk_idare inconsistent with PSK mode.
- setup_auth_recipient(enc, skR, info, pkS)[source]
Setup Auth mode for recipient.
- Parameters:
- Returns:
Recipient context.
- Return type:
- setup_auth_psk_sender(pkR, info, psk, psk_id, skS)[source]
Setup AuthPSK mode for sender.
- Parameters:
pkR (Key Object) – Recipient’s public key.
info (bytes) – Application-supplied information.
psk (bytes) – Pre-shared key. RFC 9180 §9.5 requires at least 32 bytes of entropy. Entropy is not measurable from the byte string; only VerifyPSKInputs is enforced.
psk_id (bytes) – Pre-shared key identifier.
skS (Key Object) – Sender’s private key.
- Returns:
Tuple of (encapsulated key, sender context).
- Return type:
- Raises:
ValueError – If
pskandpsk_idare inconsistent with AuthPSK mode.
- setup_auth_psk_recipient(enc, skR, info, psk, psk_id, pkS)[source]
Setup AuthPSK mode for recipient.
- Parameters:
enc (bytes) – Encapsulated public key.
skR (Key Object) – Recipient’s private key.
info (bytes) – Application-supplied information.
psk (bytes) – Pre-shared key. RFC 9180 §9.5 requires at least 32 bytes of entropy. Entropy is not measurable from the byte string; only VerifyPSKInputs is enforced.
psk_id (bytes) – Pre-shared key identifier.
pkS (Key Object) – Sender’s public key.
- Returns:
Recipient context.
- Return type:
- Raises:
ValueError – If
pskandpsk_idare inconsistent with AuthPSK mode.