ID for key encapsulation mechanism.
Modulehpke-0.2.1Haskell2010
Crypto.HPKE
Hybrid Public Key Encryption (RFC9180).
Contents
Synopsis
- newtype KEM_ID
- pattern DHKEM_P256_HKDF_SHA256
- pattern DHKEM_P384_HKDF_SHA384
- pattern DHKEM_P521_HKDF_SHA512
- pattern DHKEM_X25519_HKDF_SHA256
- pattern DHKEM_X448_HKDF_SHA512
- newtype KDF_ID
- pattern HKDF_SHA256
- pattern HKDF_SHA384
- pattern HKDF_SHA512
- newtype AEAD_ID
- pattern AES_128_GCM
- pattern AES_256_GCM
- pattern ChaCha20Poly1305
- value setupBaseS
- value setupBaseR
- value setupPSKS
- value setupPSKR
- value seal
- value open
- value exportS
- value exportR
- data ContextS
- data ContextR
- newtype EncodedSecretKey
- newtype EncodedPublicKey
- newtype SharedSecret
- type Info
- type PSK
- type PSK_ID
- type AAD
- type PlainText
- type CipherText
- type Key
- data HPKEError
- value nEnc
- value nTag
- Packagehpke-0.2.1
- Exports37
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceHPKE.hs
IDs
ID for key derivation function.
Constructors
ID for authenticated encryption with additional data
Constructors
Setup
For mode_base and mode_auth
setupBaseS :: KEM_ID-> KDF_ID-> AEAD_ID-> Maybe EncodedSecretKeyMy ephemeral secret key. Automatically generated if Nothing
-> Maybe EncodedSecretKeyMy secret key for authentication.
mode_baseis used if Nothing.base_authis used, otherwise.-> EncodedPublicKeyPeer's public key.
-> Info-> IO (EncodedPublicKey, ContextS)
Setting up base/auth mode for a sender. This throws HPKEError.
setupBaseR :: KEM_ID-> KDF_ID-> AEAD_ID-> EncodedSecretKeyMy secret key
-> Maybe EncodedSecretKeyMy secret key for authentication.
mode_baseis used if Nothing.base_authis used, otherwise.-> EncodedPublicKeyPeer's public key.
-> Info-> IO ContextR
Setting up base/auth mode for a receiver with its key pair. This throws HPKEError.
For mode_psk and mode_auth_psk
setupPSKS :: KEM_ID-> KDF_ID-> AEAD_ID-> Maybe EncodedSecretKeyMy ephemeral secret key. Automatically generated if Nothing
-> Maybe EncodedSecretKeyMy secret key for authentication.
mode_baseis used if Nothing.base_authis used, otherwise.-> EncodedPublicKeyPeer's public key.
-> Info-> PSK-> PSK_ID-> IO (EncodedPublicKey, ContextS)
Setting up psk/auth_psk mode for a sender. This throws HPKEError.
setupPSKR :: KEM_ID-> KDF_ID-> AEAD_ID-> EncodedSecretKeyMy secret key
-> Maybe EncodedSecretKeyMy secret key for authentication.
mode_baseis used if Nothing.base_authis used, otherwise.-> EncodedPublicKeyPeer's public key.
-> Info-> PSK-> PSK_ID-> IO ContextR
Setting up psk/auth_psk mode for a receiver with its key pair. This throws HPKEError.
Encryption and Decyption
Encryption. This throws HPKEError.
Decryption. This throws HPKEError.
Secret export
Exporting secret.
RFC 9180 section 5.3 allows a length of at most 255 * Nh, where Nh is
the output of the KDF's hash; a longer one is Left ExportError.
Exporting secret.
RFC 9180 section 5.3 allows a length of at most 255 * Nh, where Nh is
the output of the KDF's hash; a longer one is Left ExportError.
Types
Context for senders.
Context for receivers.
Encoded secret key.
Constructors
Instances4Eq, Show, IsString, DebugShow
Eq EncodedSecretKeyDefined in hpke-0.2.1 · Crypto.HPKE.TypesShow EncodedSecretKeyDefined in hpke-0.2.1 · Crypto.HPKE.TypesThe key material is not shown. Use debugShow to see it.
IsString EncodedSecretKeyDefined in hpke-0.2.1 · Crypto.HPKE.TypesDebugShow EncodedSecretKeyDefined in hpke-0.2.1 · Crypto.HPKE.Types
Encoded public key.
Constructors
Instances3Eq, Show, IsString
Eq EncodedPublicKeyDefined in hpke-0.2.1 · Crypto.HPKE.TypesShow EncodedPublicKeyDefined in hpke-0.2.1 · Crypto.HPKE.TypesIsString EncodedPublicKeyDefined in hpke-0.2.1 · Crypto.HPKE.Types
Information string.
Pre-shared key.
ID for pre-shared key.
Additional authenticated data for AEAD.
Plain text.
Cipher text (including a authentication tag)
Encryption key.
Error
Errors for HPKE
Constructors
ValidationError StringDeserializeError StringEncapError StringDecapError StringSealError StringOriginal
OpenError StringMessageLimitReachedError StringDeriveKeyPairError StringKeyScheduleError StringOriginal
ExportError StringOriginal. An export longer than the
255 * Nhthat RFC 9180 section 5.3 allows.Unsupported String
Misc
Length of "enc", aka sender's public key.
Length of AEAD tag.