| 1 | #cxx . . $ `<file>/mlspp/lib/hpke/src/group.h`/pragma once |
| 2 | |
| 3 | #include <hpke/hpke.h>cxx . . $ `<file>/mlspp/lib/hpke/include/hpke/hpke.h`/ |
| 4 | #include <hpke/signature.h>cxx . . $ `<file>/mlspp/lib/hpke/include/hpke/signature.h`/ |
| 5 | |
| 6 | #include "openssl_common.h"cxx . . $ `<file>/mlspp/lib/hpke/src/openssl_common.h`/ |
| 7 | #include <openssl/evp.h> |
| 8 | |
| 9 | namespace mlsppcxx . . $ mlspp/::hpkecxx . . $ mlspp/hpke/ { |
| 10 | |
| 11 | struct Groupcxx . . $ mlspp/hpke/Group# |
| 12 | { |
| 13 | enum struct IDcxx . . $ mlspp/hpke/Group#ID# : uint8_tcxx . . $ uint8_t# |
| 14 | { |
| 15 | P256cxx . . $ mlspp/hpke/Group#ID#P256., |
| 16 | P384cxx . . $ mlspp/hpke/Group#ID#P384., |
| 17 | P521cxx . . $ mlspp/hpke/Group#ID#P521., |
| 18 | X25519cxx . . $ mlspp/hpke/Group#ID#X25519., |
| 19 | X448cxx . . $ mlspp/hpke/Group#ID#X448., |
| 20 | Ed25519cxx . . $ mlspp/hpke/Group#ID#Ed25519., |
| 21 | Ed448cxx . . $ mlspp/hpke/Group#ID#Ed448., |
| 22 | }; |
| 23 | |
| 24 | struct PublicKeycxx . . $ mlspp/hpke/Group#PublicKey# |
| 25 | : public KEMcxx . . $ mlspp/hpke/KEM#::PublicKeycxx . . $ mlspp/hpke/KEM#PublicKey# |
| 26 | , public Signaturecxx . . $ mlspp/hpke/Signature#::PublicKeycxx . . $ mlspp/hpke/Signature#PublicKey# |
| 27 | { |
| 28 | virtual ~cxx . . $ mlspp/hpke/Group#PublicKey#`~PublicKey`(ced63f7c635d850d).PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#() = default; |
| 29 | }; |
| 30 | |
| 31 | struct PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey# |
| 32 | { |
| 33 | virtual ~cxx . . $ mlspp/hpke/Group#PrivateKey#`~PrivateKey`(ced63f7c635d850d).PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#() = default; |
| 34 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#> public_keycxx . . $ mlspp/hpke/Group#PrivateKey#public_key(be74f74a136692ce).() const = 0; |
| 35 | }; |
| 36 | |
| 37 | template<Groupcxx . . $ mlspp/hpke/Group#::IDcxx . . $ mlspp/hpke/Group#ID# id> |
| 38 | static const Groupcxx . . $ mlspp/hpke/Group#& getcxx . . $ mlspp/hpke/Group#get(f05f80c0d9382943).(); |
| 39 | |
| 40 | virtual ~cxx . . $ mlspp/hpke/Group#`~Group`(ced63f7c635d850d).Groupcxx . . $ mlspp/hpke/Group#() = default; |
| 41 | |
| 42 | const IDcxx . . $ mlspp/hpke/Group#ID# idcxx . . $ mlspp/hpke/Group#id.; |
| 43 | const size_t dh_sizecxx . . $ mlspp/hpke/Group#dh_size.; |
| 44 | const size_t pk_sizecxx . . $ mlspp/hpke/Group#pk_size.; |
| 45 | const size_t sk_sizecxx . . $ mlspp/hpke/Group#sk_size.; |
| 46 | const stdcxx . . $ std/::stringcxx . . $ std/string# jwk_key_typecxx . . $ mlspp/hpke/Group#jwk_key_type.; |
| 47 | const stdcxx . . $ std/::stringcxx . . $ std/string# jwk_curve_namecxx . . $ mlspp/hpke/Group#jwk_curve_name.; |
| 48 | |
| 49 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#> generate_key_paircxx . . $ mlspp/hpke/Group#generate_key_pair(1c1051ed47dfeb34).() const = 0; |
| 50 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#> derive_key_paircxx . . $ mlspp/hpke/Group#derive_key_pair(7c8b5279bfce12cf).( |
| 51 | const bytescxx . . $ mlspp/bytes_ns/bytes#& suite_id, |
| 52 | const bytescxx . . $ mlspp/bytes_ns/bytes#& ikm) const = 0; |
| 53 | |
| 54 | virtual bytescxx . . $ mlspp/bytes_ns/bytes# serializecxx . . $ mlspp/hpke/Group#serialize(709e30fcbf6c1f24).(const PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#& pk) const = 0; |
| 55 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#> deserializecxx . . $ mlspp/hpke/Group#deserialize(6b5fed5c6c0b0d85).(const bytescxx . . $ mlspp/bytes_ns/bytes#& enc) const = 0; |
| 56 | |
| 57 | virtual bytescxx . . $ mlspp/bytes_ns/bytes# serialize_privatecxx . . $ mlspp/hpke/Group#serialize_private(3111aac385788878).(const PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#& sk) const = 0; |
| 58 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#> deserialize_privatecxx . . $ mlspp/hpke/Group#deserialize_private(9261b7df97b3e19f).( |
| 59 | const bytescxx . . $ mlspp/bytes_ns/bytes#& skm) const = 0; |
| 60 | |
| 61 | virtual bytescxx . . $ mlspp/bytes_ns/bytes# dhcxx . . $ mlspp/hpke/Group#dh(5515d6704683bf5b).(const PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#& sk, const PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#& pk) const = 0; |
| 62 | |
| 63 | virtual bytescxx . . $ mlspp/bytes_ns/bytes# signcxx . . $ mlspp/hpke/Group#sign(5f3ce07bf36d85db).(const bytescxx . . $ mlspp/bytes_ns/bytes#& data, const PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#& sk) const = 0; |
| 64 | virtual bool verifycxx . . $ mlspp/hpke/Group#verify(aac7f32cb6307656).(const bytescxx . . $ mlspp/bytes_ns/bytes#& data, |
| 65 | const bytescxx . . $ mlspp/bytes_ns/bytes#& sig, |
| 66 | const PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#& pk) const = 0; |
| 67 | |
| 68 | virtual stdcxx . . $ std/::tuplecxx . . $ std/tuple#<bytescxx . . $ mlspp/bytes_ns/bytes#, bytescxx . . $ mlspp/bytes_ns/bytes#> coordinatescxx . . $ mlspp/hpke/Group#coordinates(4ed3c5dd9bcc18fa).(const PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#& pk) const = 0; |
| 69 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#> public_key_from_coordinatescxx . . $ mlspp/hpke/Group#public_key_from_coordinates(5d18259fe6fe47b6).( |
| 70 | const bytescxx . . $ mlspp/bytes_ns/bytes#& x, |
| 71 | const bytescxx . . $ mlspp/bytes_ns/bytes#& y) const = 0; |
| 72 | |
| 73 | protected: |
| 74 | const KDFcxx . . $ mlspp/hpke/KDF#& kdfcxx . . $ mlspp/hpke/Group#kdf.; |
| 75 | |
| 76 | friend struct DHKEMcxx . . $ mlspp/hpke/DHKEM#; |
| 77 | |
| 78 | Groupcxx . . $ mlspp/hpke/Group#Group(3802f28964769a07).(IDcxx . . $ mlspp/hpke/Group#ID# group_id_in, const KDFcxx . . $ mlspp/hpke/KDF#& kdf_in); |
| 79 | }; |
| 80 | |
| 81 | struct EVPGroupcxx . . $ mlspp/hpke/EVPGroup# : public Groupcxx . . $ mlspp/hpke/Group# |
| 82 | { |
| 83 | EVPGroupcxx . . $ mlspp/hpke/EVPGroup#EVPGroup(3802f28964769a07).(Groupcxx . . $ mlspp/hpke/Group#::IDcxx . . $ mlspp/hpke/Group#ID# group_id, const KDFcxx . . $ mlspp/hpke/KDF#& kdf); |
| 84 | |
| 85 | struct PublicKeycxx . . $ mlspp/hpke/EVPGroup#PublicKey# : public Groupcxx . . $ mlspp/hpke/Group#::PublicKeycxx . . $ mlspp/hpke/Group#PublicKey# |
| 86 | { |
| 87 | explicit PublicKeycxx . . $ mlspp/hpke/EVPGroup#PublicKey#PublicKey(a36cc1e96a19ea9b).(EVP_PKEY* pkey_in); |
| 88 | ~cxx . . $ mlspp/hpke/EVPGroup#PublicKey#`~PublicKey`(ced63f7c635d850d).PublicKeycxx . . $ mlspp/hpke/EVPGroup#PublicKey#() override = default; |
| 89 | |
| 90 | // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) |
| 91 | typed_unique_ptrcxx . . $ mlspp/hpke/typed_unique_ptr#<EVP_PKEY> pkeycxx . . $ mlspp/hpke/EVPGroup#PublicKey#pkey.; |
| 92 | }; |
| 93 | |
| 94 | struct PrivateKeycxx . . $ mlspp/hpke/EVPGroup#PrivateKey# : public Groupcxx . . $ mlspp/hpke/Group#::PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey# |
| 95 | { |
| 96 | explicit PrivateKeycxx . . $ mlspp/hpke/EVPGroup#PrivateKey#PrivateKey(a36cc1e96a19ea9b).(EVP_PKEY* pkey_in); |
| 97 | ~cxx . . $ mlspp/hpke/EVPGroup#PrivateKey#`~PrivateKey`(ced63f7c635d850d).PrivateKeycxx . . $ mlspp/hpke/EVPGroup#PrivateKey#() override = default; |
| 98 | |
| 99 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Groupcxx . . $ mlspp/hpke/Group#::PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#> public_keycxx . . $ mlspp/hpke/EVPGroup#PrivateKey#public_key(be74f74a136692ce).() const override; |
| 100 | |
| 101 | // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) |
| 102 | typed_unique_ptrcxx . . $ mlspp/hpke/typed_unique_ptr#<EVP_PKEY> pkeycxx . . $ mlspp/hpke/EVPGroup#PrivateKey#pkey.; |
| 103 | }; |
| 104 | |
| 105 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Groupcxx . . $ mlspp/hpke/Group#::PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#> generate_key_paircxx . . $ mlspp/hpke/EVPGroup#generate_key_pair(1c1051ed47dfeb34).() const override; |
| 106 | |
| 107 | bytescxx . . $ mlspp/bytes_ns/bytes# dhcxx . . $ mlspp/hpke/EVPGroup#dh(5515d6704683bf5b).(const Groupcxx . . $ mlspp/hpke/Group#::PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#& sk, |
| 108 | const Groupcxx . . $ mlspp/hpke/Group#::PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#& pk) const override; |
| 109 | |
| 110 | bytescxx . . $ mlspp/bytes_ns/bytes# signcxx . . $ mlspp/hpke/EVPGroup#sign(5f3ce07bf36d85db).(const bytescxx . . $ mlspp/bytes_ns/bytes#& data, const Groupcxx . . $ mlspp/hpke/Group#::PrivateKeycxx . . $ mlspp/hpke/Group#PrivateKey#& sk) const override; |
| 111 | bool verifycxx . . $ mlspp/hpke/EVPGroup#verify(aac7f32cb6307656).(const bytescxx . . $ mlspp/bytes_ns/bytes#& data, |
| 112 | const bytescxx . . $ mlspp/bytes_ns/bytes#& sig, |
| 113 | const Groupcxx . . $ mlspp/hpke/Group#::PublicKeycxx . . $ mlspp/hpke/Group#PublicKey#& pk) const override; |
| 114 | }; |
| 115 | |
| 116 | } // namespace mlspp::hpke |