Documentation
¶
Overview ¶
Package kem implements key encapsulation mechanisms (KEMs) for the Signal protocol. Kyber1024 (round-3, type byte 0x08) is the active KEM; the ML-KEM-1024 type byte (0x0A) is recognized for forward compatibility but is not yet enabled.
It is a pure-Go port of rust/protocol/src/kem.rs over github.com/cloudflare/circl. Serialization is wire-compatible with upstream libsignal: a key or ciphertext is one KeyType byte followed by the raw bytes circl produces (verified against upstream fixtures in TestUpstreamKeyFixtures).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadKEMCiphertextLengthError ¶
BadKEMCiphertextLengthError is returned when a serialized ciphertext has the wrong length for its key type.
func (BadKEMCiphertextLengthError) Error ¶
func (e BadKEMCiphertextLengthError) Error() string
type BadKEMKeyLengthError ¶
BadKEMKeyLengthError is returned when a serialized key has the wrong length for its key type.
func (BadKEMKeyLengthError) Error ¶
func (e BadKEMKeyLengthError) Error() string
type BadKEMKeyTypeError ¶
type BadKEMKeyTypeError struct {
Type byte
}
BadKEMKeyTypeError is returned for an unrecognized KEM key-type byte.
func (BadKEMKeyTypeError) Error ¶
func (e BadKEMKeyTypeError) Error() string
type ErrNoKeyTypeIdentifier ¶
type ErrNoKeyTypeIdentifier struct{}
ErrNoKeyTypeIdentifier is returned when deserializing from empty input that carries no KeyType byte.
func (ErrNoKeyTypeIdentifier) Error ¶
func (ErrNoKeyTypeIdentifier) Error() string
type KeyPair ¶
KeyPair is a KEM public/secret key pair.
func GenerateKeyPair ¶
GenerateKeyPair generates a new key pair for the given KEM type, drawing seed entropy from rng. rng must be a cryptographically secure source.
func KeyPairFromPublicAndSecret ¶
KeyPairFromPublicAndSecret deserializes a key pair from the wire forms of a public and secret key, requiring matching key types.
type KeyType ¶
type KeyType uint8
KeyType identifies a supported KEM protocol by its one-byte wire tag.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a KEM public key, able to encapsulate a shared secret.
func DeserializePublicKey ¶
DeserializePublicKey parses the wire form of a public key, validating the KeyType byte and the body length for that type.
func (PublicKey) Encapsulate ¶
Encapsulate produces a fresh shared secret and a serialized ciphertext for the recipient holding the matching secret key. Randomness is drawn from the underlying KEM's cryptographically secure source.
func (PublicKey) Equal ¶
Equal reports whether two public keys are equal, comparing the key body in constant time once the key types match.
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey is a KEM secret key, able to decapsulate a shared secret.
func DeserializeSecretKey ¶
DeserializeSecretKey parses the wire form of a secret key, validating the KeyType byte and the body length for that type.
func (SecretKey) Decapsulate ¶
Decapsulate recovers the shared secret from a serialized ciphertext. The ciphertext's key type must match this secret key's type.
func (SecretKey) Format ¶
Format implements fmt.Formatter for the secret key, redacting under every verb.
type UnsupportedKEMKeyTypeError ¶
type UnsupportedKEMKeyTypeError struct {
Type byte
}
UnsupportedKEMKeyTypeError is returned for a key type that is recognized on the wire but not currently enabled (ML-KEM-1024).
func (UnsupportedKEMKeyTypeError) Error ¶
func (e UnsupportedKEMKeyTypeError) Error() string
type WrongKEMKeyTypeError ¶
WrongKEMKeyTypeError is returned when a ciphertext's key type does not match the secret key used to decapsulate it.
func (WrongKEMKeyTypeError) Error ¶
func (e WrongKEMKeyTypeError) Error() string