Exceptions

HPKE-specific exception hierarchy. All exceptions inherit from HPKEError.

exception rfc9180.exceptions.HPKEError[source]

Bases: Exception

Base exception for HPKE errors.

All HPKE-specific exceptions inherit from this class.

exception rfc9180.exceptions.ValidationError[source]

Bases: HPKEError

KEM input/output validation failure.

Raised when KEM operations fail validation checks, such as all-zero DH outputs.

exception rfc9180.exceptions.DeserializeError[source]

Bases: HPKEError

Key deserialization failure.

Raised when key deserialization fails due to invalid format or length.

exception rfc9180.exceptions.EncapError[source]

Bases: HPKEError

Encapsulation failure.

Raised when key encapsulation operations fail.

exception rfc9180.exceptions.DecapError[source]

Bases: HPKEError

Decapsulation failure.

Raised when key decapsulation operations fail.

exception rfc9180.exceptions.OpenError[source]

Bases: HPKEError

AEAD decryption failure.

Raised when AEAD decryption operations fail, typically due to authentication failure or invalid ciphertext.

exception rfc9180.exceptions.MessageLimitReachedError[source]

Bases: HPKEError

Sequence number overflow.

Raised when the sequence number exceeds the maximum allowed value for the AEAD algorithm.

exception rfc9180.exceptions.DeriveKeyPairError[source]

Bases: HPKEError

Key pair derivation failure.

Raised when key pair derivation fails, such as when rejection sampling exceeds the maximum number of iterations.

Exception Summary

  • ValidationError: KEM input/output validation (e.g. all-zero DH outputs)

  • DeserializeError: Invalid key format or length during deserialization

  • EncapError: Key encapsulation failure

  • DecapError: Key decapsulation failure (invalid enc, wrong key)

  • OpenError: AEAD decryption failure (tampered data, wrong key)

  • MessageLimitReachedError: Sequence number overflow (max messages exceeded)

  • DeriveKeyPairError: Key pair derivation failed (e.g. rejection sampling)