|
Botan 3.14.1
Crypto and TLS for C&
|
#include <hpke.h>
Public Member Functions | |
| KEM_Id | kem () const |
| std::vector< uint8_t > | serialize () const |
| SerializePublicKey from RFC 9180 Section 7.1.1. | |
| const Botan::Public_Key & | underlying () const |
Static Public Member Functions | |
| static Public_Key | deserialize (KEM_Id kem, std::span< const uint8_t > bytes) |
| static Public_Key | from_key (KEM_Id kem, std::unique_ptr< Botan::Public_Key > key) |
Friends | |
| class | HPKE::Private_Key |
| class | HPKE::Recipient_Context |
| class | HPKE::Sender_Context |
| bool | operator== (const Public_Key &a, const Public_Key &b) |
An HPKE public key
This is a value type (cheap to copy) wrapping an asymmetric key that has been checked against a particular HPKE KEM: its algorithm (and, for the NIST curves, its group) matches the KEM, and a key deserialized from the wire is well formed, which for the NIST curves includes being a point on the curve. One check is deferred: RFC 9180 Section 7.1.4 specifies the rejection of low order X25519/X448 points in terms of the Diffie-Hellman output, so such a key can be constructed, but any context setup using it throws Invalid_Argument. Holding a Public_Key therefore does not by itself establish that an untrusted peer's key is acceptable.
It has no inheritance relationship with Botan::Public_Key or with HPKE::Private_Key.
|
static |
DeserializePublicKey from RFC 9180 Section 7.1.1
Accepts exactly the wire format the KEM defines (raw bytes for X25519/X448, an uncompressed SEC1 point for the NIST curves). Throws Decoding_Error if the length or encoding is wrong, or if a NIST curve point is not on the curve. Low order X25519/X448 points are not detected here; see the class description.
Definition at line 246 of file hpke.cpp.
References Botan::HPKE::KEM_Ops::create(), and kem().
|
static |
Adopt an existing key for use with HPKE
For the NIST curves both ECDH and ECDSA keys are accepted, the latter being how keys with the id-ecPublicKey OID (eg from an X.509 certificate) are loaded; an ECDSA key is converted, so underlying() always returns an ECDH key. Keys of other EC algorithms (SM2, ECGDSA, ...) are not accepted.
Throws Invalid_Argument unless the algorithm (and, for the NIST curves, the group) matches the KEM.
Definition at line 252 of file hpke.cpp.
References BOTAN_ARG_CHECK, Botan::HPKE::KEM_Ops::create(), and kem().
| KEM_Id Botan::HPKE::Public_Key::kem | ( | ) | const |
Definition at line 259 of file hpke.cpp.
Referenced by deserialize(), from_key(), and operator==.
| std::vector< uint8_t > Botan::HPKE::Public_Key::serialize | ( | ) | const |
SerializePublicKey from RFC 9180 Section 7.1.1.
Definition at line 263 of file hpke.cpp.
Referenced by operator==.
| const Botan::Public_Key & Botan::HPKE::Public_Key::underlying | ( | ) | const |
|
friend |
|
friend |
|
friend |
|
friend |
Definition at line 329 of file hpke.h.
References kem(), and serialize().