11#include <botan/assert.h>
12#include <botan/ec_group.h>
13#include <botan/hash.h>
14#include <botan/mem_ops.h>
16#include <botan/internal/ffi_mp.h>
17#include <botan/internal/ffi_pkey.h>
18#include <botan/internal/ffi_rng.h>
19#include <botan/internal/ffi_util.h>
21#if defined(BOTAN_HAS_DL_GROUP)
22 #include <botan/dl_group.h>
25#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
26 #include <botan/ecc_key.h>
29#if defined(BOTAN_HAS_RSA)
30 #include <botan/rsa.h>
33#if defined(BOTAN_HAS_ELGAMAL)
34 #include <botan/elgamal.h>
37#if defined(BOTAN_HAS_DSA)
38 #include <botan/dsa.h>
41#if defined(BOTAN_HAS_ECDSA)
42 #include <botan/ecdsa.h>
45#if defined(BOTAN_HAS_SM2)
46 #include <botan/sm2.h>
49#if defined(BOTAN_HAS_ECDH)
50 #include <botan/ecdh.h>
53#if defined(BOTAN_HAS_X25519)
54 #include <botan/x25519.h>
57#if defined(BOTAN_HAS_X448)
58 #include <botan/x448.h>
61#if defined(BOTAN_HAS_ED25519)
62 #include <botan/ed25519.h>
65#if defined(BOTAN_HAS_ED448)
66 #include <botan/ed448.h>
69#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
73#if defined(BOTAN_HAS_KYBER) || defined(BOTAN_HAS_KYBER_90S)
74 #include <botan/kyber.h>
77#if defined(BOTAN_HAS_ML_KEM)
78 #include <botan/ml_kem.h>
81#if defined(BOTAN_HAS_FRODOKEM)
82 #include <botan/frodokem.h>
85#if defined(BOTAN_HAS_ML_DSA)
86 #include <botan/ml_dsa.h>
89#if defined(BOTAN_HAS_SLH_DSA_WITH_SHA2) || defined(BOTAN_HAS_SLH_DSA_WITH_SHAKE)
90 #include <botan/slh_dsa.h>
93#if defined(BOTAN_HAS_CLASSICMCELIECE)
94 #include <botan/cmce.h>
99#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
103template <
class ECPrivateKey_t>
104int privkey_load_ec(std::unique_ptr<ECPrivateKey_t>& key,
const Botan::BigInt& scalar,
const char* curve_name) {
105 if(curve_name ==
nullptr) {
114 key.reset(
new ECPrivateKey_t(null_rng, grp, scalar));
118template <
class ECPublicKey_t>
119int pubkey_load_ec(std::unique_ptr<ECPublicKey_t>& key,
122 const char* curve_name) {
123 if(curve_name ==
nullptr) {
134 key.reset(
new ECPublicKey_t(group, pt.value()));
141template <
class ECPublicKey_t>
142int pubkey_load_ec_sec1(std::unique_ptr<ECPublicKey_t>& key,
143 std::span<const uint8_t> sec1,
144 std::string_view curve_name) {
152 key.reset(
new ECPublicKey_t(group, pt.value()));
162#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
165 if(field ==
"public_x") {
167 }
else if(field ==
"public_y") {
181#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
184 if(field ==
"public_x") {
186 }
else if(field ==
"public_y") {
206 if(field_name_cstr ==
nullptr) {
210 const std::string field_name(field_name_cstr);
216 if(field_name_cstr ==
nullptr) {
220 const std::string field_name(field_name_cstr);
228 if(n_bits < 1024 || n_bits > 16 * 1024) {
232 const std::string n_str = std::to_string(n_bits);
238#if defined(BOTAN_HAS_RSA)
255#if defined(BOTAN_HAS_RSA)
256 if(key ==
nullptr || bits ==
nullptr) {
263 auto rsa = std::make_unique<Botan::RSA_PrivateKey>(alg_id, std::span{bits, len});
273#if defined(BOTAN_HAS_RSA)
279 auto rsa = std::make_unique<Botan::RSA_PublicKey>(
safe_get(n),
safe_get(e));
289#if defined(BOTAN_HAS_RSA)
290 if(key ==
nullptr || bits ==
nullptr) {
297 auto rsa = std::make_unique<Botan::RSA_PublicKey>(alg_id, std::span{bits, len});
335#if defined(BOTAN_HAS_RSA)
360#if defined(BOTAN_HAS_DSA)
362 if((rng_obj ==
nullptr) || (key ==
nullptr)) {
366 if((pbits % 64 != 0) || (qbits % 8 != 0) || (pbits < 1024) || (pbits > 3072) || (qbits < 160) || (qbits > 256)) {
373 auto dsa = std::make_unique<Botan::DSA_PrivateKey>(rng, group);
383#if defined(BOTAN_HAS_DSA)
391 auto dsa = std::make_unique<Botan::DSA_PrivateKey>(group,
safe_get(x));
401#if defined(BOTAN_HAS_DSA)
409 auto dsa = std::make_unique<Botan::DSA_PublicKey>(group,
safe_get(y));
445#if defined(BOTAN_HAS_ECC_KEY)
450 if(ec_key ==
nullptr) {
467 const char* curve_name) {
468#if defined(BOTAN_HAS_ECDSA)
469 if(key ==
nullptr || curve_name ==
nullptr) {
475 std::unique_ptr<Botan::ECDSA_PublicKey> p_key;
477 const int rc = pubkey_load_ec(p_key,
safe_get(public_x),
safe_get(public_y), curve_name);
491#if defined(BOTAN_HAS_ECDSA)
492 if(key ==
nullptr || sec1 ==
nullptr || curve_name ==
nullptr) {
498 std::unique_ptr<Botan::ECDSA_PublicKey> p_key;
500 const int rc = pubkey_load_ec_sec1(p_key, {sec1, sec1_len}, curve_name);
514#if defined(BOTAN_HAS_ECDSA)
515 if(key ==
nullptr || curve_name ==
nullptr) {
521 std::unique_ptr<Botan::ECDSA_PrivateKey> p_key;
522 const int rc = privkey_load_ec(p_key,
safe_get(scalar), curve_name);
536#if defined(BOTAN_HAS_ELGAMAL)
537 if(key ==
nullptr || rng_obj ==
nullptr) {
542 if(pbits < 1024 || qbits < 160) {
552 auto elg = std::make_unique<Botan::ElGamal_PrivateKey>(rng, group);
562#if defined(BOTAN_HAS_ELGAMAL)
569 auto elg = std::make_unique<Botan::ElGamal_PublicKey>(group,
safe_get(y));
579#if defined(BOTAN_HAS_ELGAMAL)
586 auto elg = std::make_unique<Botan::ElGamal_PrivateKey>(group,
safe_get(x));
602#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
609 auto dh = std::make_unique<Botan::DH_PrivateKey>(group,
safe_get(x));
619#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
626 auto dh = std::make_unique<Botan::DH_PublicKey>(group,
safe_get(y));
638 if(key_obj ==
nullptr || param_str ==
nullptr) {
643 const std::string params(param_str);
645 if(params ==
"X25519" || params ==
"x25519" || params ==
"curve25519") {
649 if(params ==
"X448" || params ==
"x448") {
659 const char* curve_name) {
660#if defined(BOTAN_HAS_ECDH)
661 if(key ==
nullptr || curve_name ==
nullptr) {
666 std::unique_ptr<Botan::ECDH_PublicKey> p_key;
667 const int rc = pubkey_load_ec(p_key,
safe_get(public_x),
safe_get(public_y), curve_name);
681#if defined(BOTAN_HAS_ECDH)
682 if(key ==
nullptr || sec1 ==
nullptr || curve_name ==
nullptr) {
688 std::unique_ptr<Botan::ECDH_PublicKey> p_key;
690 const int rc = pubkey_load_ec_sec1(p_key, {sec1, sec1_len}, curve_name);
704#if defined(BOTAN_HAS_ECDH)
705 if(key ==
nullptr || curve_name ==
nullptr) {
710 std::unique_ptr<Botan::ECDH_PrivateKey> p_key;
711 const int rc = privkey_load_ec(p_key,
safe_get(scalar), curve_name);
726 uint8_t out[],
size_t* out_len,
const char* ident,
const char* hash_algo,
const botan_pubkey_t key) {
727 if(out ==
nullptr || out_len ==
nullptr || ident ==
nullptr || hash_algo ==
nullptr || key ==
nullptr) {
731#if defined(BOTAN_HAS_SM2)
736 if(ec_key ==
nullptr) {
744 const std::string ident_str(ident);
761 const char* curve_name) {
762#if defined(BOTAN_HAS_SM2)
763 if(key ==
nullptr || curve_name ==
nullptr) {
769 std::unique_ptr<Botan::SM2_PublicKey> p_key;
770 if(pubkey_load_ec(p_key,
safe_get(public_x),
safe_get(public_y), curve_name) == 0) {
783#if defined(BOTAN_HAS_SM2)
784 if(key ==
nullptr || sec1 ==
nullptr || curve_name ==
nullptr) {
790 std::unique_ptr<Botan::SM2_PublicKey> p_key;
792 const int rc = pubkey_load_ec_sec1(p_key, {sec1, sec1_len}, curve_name);
806#if defined(BOTAN_HAS_SM2)
807 if(key ==
nullptr || curve_name ==
nullptr) {
813 std::unique_ptr<Botan::SM2_PrivateKey> p_key;
814 const int rc = privkey_load_ec(p_key,
safe_get(scalar), curve_name);
830 const char* curve_name) {
841#if defined(BOTAN_HAS_ED25519)
858#if defined(BOTAN_HAS_ED25519)
864 const std::vector<uint8_t> pubkey_vec(pubkey, pubkey + 32);
865 auto ed25519 = std::make_unique<Botan::Ed25519_PublicKey>(pubkey_vec);
875#if defined(BOTAN_HAS_ED25519)
878 const auto ed_key = ed->raw_private_key_bits();
879 if(ed_key.size() != 64) {
895#if defined(BOTAN_HAS_ED25519)
898 const std::vector<uint8_t>& ed_key = ed->get_public_key();
899 if(ed_key.size() != 32) {
917#if defined(BOTAN_HAS_ED448)
923 auto ed448 = std::make_unique<Botan::Ed448_PrivateKey>(std::span(privkey, 57));
933#if defined(BOTAN_HAS_ED448)
939 auto ed448 = std::make_unique<Botan::Ed448_PublicKey>(std::span(pubkey, 57));
949#if defined(BOTAN_HAS_ED448)
952 const auto ed_key = ed->raw_private_key_bits();
966#if defined(BOTAN_HAS_ED448)
969 const auto ed_key = ed->public_key_bits();
985#if defined(BOTAN_HAS_X25519)
991 auto x25519 = std::make_unique<Botan::X25519_PrivateKey>(std::span{privkey, 32});
1001#if defined(BOTAN_HAS_X25519)
1002 if(key ==
nullptr) {
1007 auto x25519 = std::make_unique<Botan::X25519_PublicKey>(std::span{pubkey, 32});
1017#if defined(BOTAN_HAS_X25519)
1020 const auto x25519_key = x25519->raw_private_key_bits();
1021 if(x25519_key.size() != 32) {
1037#if defined(BOTAN_HAS_X25519)
1040 Botan::copy_mem(std::span{output, 32}, x25519->raw_public_key_bits());
1055#if defined(BOTAN_HAS_X448)
1056 if(key ==
nullptr) {
1061 auto x448 = std::make_unique<Botan::X448_PrivateKey>(std::span{privkey, 56});
1071#if defined(BOTAN_HAS_X448)
1072 if(key ==
nullptr) {
1077 auto x448 = std::make_unique<Botan::X448_PublicKey>(std::span{pubkey, 56});
1087#if defined(BOTAN_HAS_X448)
1090 const auto x448_key = x448->raw_private_key_bits();
1104#if defined(BOTAN_HAS_X448)
1124#if defined(BOTAN_HAS_KYBER)
1125 if(key ==
nullptr) {
1130 const auto mode = [](
size_t len) -> std::optional<Botan::KyberMode> {
1133 }
else if(len == 2400) {
1135 }
else if(len == 3168) {
1142 if(mode.has_value()) {
1144 auto kyber = std::make_unique<Botan::Kyber_PrivateKey>(std::span{privkey, key_len}, *mode);
1157#if defined(BOTAN_HAS_KYBER)
1158 if(key ==
nullptr) {
1163 const auto mode = [](
size_t len) -> std::optional<Botan::KyberMode> {
1166 }
else if(len == 1184) {
1168 }
else if(len == 1568) {
1175 if(mode.has_value()) {
1176 auto kyber = std::make_unique<Botan::Kyber_PublicKey>(std::span{pubkey, key_len}, *mode);
1188#if defined(BOTAN_HAS_KYBER)
1203#if defined(BOTAN_HAS_KYBER)
1222#if defined(BOTAN_HAS_ML_KEM)
1223 if(key ==
nullptr || privkey ==
nullptr || mlkem_mode ==
nullptr) {
1231 if(!mode.is_ml_kem()) {
1235 auto mlkem_key = std::make_unique<Botan::ML_KEM_PrivateKey>(std::span{privkey, key_len}, mode);
1245#if defined(BOTAN_HAS_ML_KEM)
1246 if(key ==
nullptr || pubkey ==
nullptr || mlkem_mode ==
nullptr) {
1254 if(!mode.is_ml_kem()) {
1258 auto mlkem_key = std::make_unique<Botan::ML_KEM_PublicKey>(std::span{pubkey, key_len}, mode.mode());
1272#if defined(BOTAN_HAS_ML_DSA)
1273 if(key ==
nullptr || privkey ==
nullptr || mldsa_mode ==
nullptr) {
1281 if(!mode.is_ml_dsa()) {
1285 auto mldsa_key = std::make_unique<Botan::ML_DSA_PrivateKey>(std::span{privkey, key_len}, mode);
1295#if defined(BOTAN_HAS_ML_DSA)
1296 if(key ==
nullptr || pubkey ==
nullptr || mldsa_mode ==
nullptr) {
1304 if(!mode.is_ml_dsa()) {
1308 auto mldsa_key = std::make_unique<Botan::ML_DSA_PublicKey>(std::span{pubkey, key_len}, mode);
1322#if defined(BOTAN_HAS_SLH_DSA_WITH_SHA2) || defined(BOTAN_HAS_SLH_DSA_WITH_SHAKE)
1323 if(key ==
nullptr || privkey ==
nullptr || slhdsa_mode ==
nullptr) {
1330 auto mode = Botan::SLH_DSA_Parameters::create(slhdsa_mode);
1331 if(!mode.is_slh_dsa()) {
1335 auto slhdsa_key = std::make_unique<Botan::SLH_DSA_PrivateKey>(std::span{privkey, key_len}, mode);
1345#if defined(BOTAN_HAS_SLH_DSA_WITH_SHA2) || defined(BOTAN_HAS_SLH_DSA_WITH_SHAKE)
1346 if(key ==
nullptr || pubkey ==
nullptr || slhdsa_mode ==
nullptr) {
1353 auto mode = Botan::SLH_DSA_Parameters::create(slhdsa_mode);
1354 if(!mode.is_slh_dsa()) {
1358 auto mldsa_key = std::make_unique<Botan::SLH_DSA_PublicKey>(std::span{pubkey, key_len}, mode);
1372#if defined(BOTAN_HAS_FRODOKEM)
1373 if(key ==
nullptr || privkey ==
nullptr || frodo_mode ==
nullptr) {
1381 auto frodo_key = std::make_unique<Botan::FrodoKEM_PrivateKey>(std::span{privkey, key_len}, mode);
1391#if defined(BOTAN_HAS_FRODOKEM)
1392 if(key ==
nullptr || pubkey ==
nullptr || frodo_mode ==
nullptr) {
1400 auto frodo_key = std::make_unique<Botan::FrodoKEM_PublicKey>(std::span{pubkey, key_len}, mode);
1414 const uint8_t privkey[],
1416 const char* cmce_mode) {
1417#if defined(BOTAN_HAS_CLASSICMCELIECE)
1418 if(key ==
nullptr || privkey ==
nullptr || cmce_mode ==
nullptr) {
1426 auto cmce_key = std::make_unique<Botan::Classic_McEliece_PrivateKey>(std::span{privkey, key_len}, mode);
1436 const uint8_t pubkey[],
1438 const char* cmce_mode) {
1439#if defined(BOTAN_HAS_CLASSICMCELIECE)
1440 if(key ==
nullptr || pubkey ==
nullptr || cmce_mode ==
nullptr) {
1448 auto cmce_key = std::make_unique<Botan::Classic_McEliece_PublicKey>(std::span{pubkey, key_len}, mode);
1458#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
1461 auto pt = ecc->_public_ec_point().serialize_uncompressed();
1476 const std::string mce_params = std::to_string(n) +
"," + std::to_string(t);
1488 BOTAN_UNUSED(mce_key_obj, aead, ct, ct_len, ad, ad_len, out, out_len);
1501 BOTAN_UNUSED(mce_key_obj, rng_obj, aead, pt, pt_len, ad, ad_len, out, out_len);
virtual std::string algo_name() const =0
virtual const BigInt & get_int_field(std::string_view field) const
static BigInt from_bytes(std::span< const uint8_t > bytes)
static Classic_McEliece_Parameter_Set from_string(std::string_view param_name)
Get the parameter set for a given parameter set name.
static std::optional< EC_AffinePoint > from_bigint_xy(const EC_Group &group, const BigInt &x, const BigInt &y)
static std::optional< EC_AffinePoint > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)
static EC_Group from_name(std::string_view name)
bool used_explicit_encoding() const
static bool supports_named_group(std::string_view name)
const EC_Group & domain() const
const EC_AffinePoint & _public_ec_point() const
static Ed25519_PrivateKey from_seed(std::span< const uint8_t > seed)
A private key for Ed448/Ed448ph according to RFC 8032.
A public key for Ed448/Ed448ph according to RFC 8032.
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
A private key for the X448 key agreement scheme according to RFC 7748.
A public key for the X448 key agreement scheme according to RFC 7748.
struct botan_pubkey_struct * botan_pubkey_t
struct botan_privkey_struct * botan_privkey_t
int(* botan_view_bin_fn)(botan_view_ctx view_ctx, const uint8_t *data, size_t len)
int botan_privkey_create(botan_privkey_t *key, const char *algo_name, const char *algo_params, botan_rng_t rng)
#define BOTAN_PRIVKEY_EXPORT_FLAG_PEM
struct botan_mp_struct * botan_mp_t
struct botan_rng_struct * botan_rng_t
#define BOTAN_PRIVKEY_EXPORT_FLAG_DER
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_ERROR_UNKNOWN_ERROR
@ BOTAN_FFI_ERROR_BAD_FLAG
@ BOTAN_FFI_ERROR_NULL_POINTER
@ BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE
@ BOTAN_FFI_ERROR_BAD_PARAMETER
int botan_privkey_create_elgamal(botan_privkey_t *key, botan_rng_t rng_obj, size_t pbits, size_t qbits)
int botan_pubkey_rsa_get_n(botan_mp_t n, botan_pubkey_t key)
int botan_privkey_load_x448(botan_privkey_t *key, const uint8_t privkey[56])
int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char *field_name_cstr)
int botan_pubkey_load_ml_dsa(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *mldsa_mode)
int botan_privkey_load_ecdh(botan_privkey_t *key, const botan_mp_t scalar, const char *curve_name)
int botan_privkey_view_kyber_raw_key(botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_pubkey_load_dh(botan_pubkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t y)
int botan_pubkey_ed25519_get_pubkey(botan_pubkey_t key, uint8_t output[32])
int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key, uint8_t out[], size_t *out_len, uint32_t flags)
int botan_privkey_load_rsa_pkcs1(botan_privkey_t *key, const uint8_t bits[], size_t len)
int botan_pubkey_load_sm2(botan_pubkey_t *key, const botan_mp_t public_x, const botan_mp_t public_y, const char *curve_name)
int botan_pubkey_load_slh_dsa(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *slhdsa_mode)
int botan_pubkey_sm2_compute_za(uint8_t out[], size_t *out_len, const char *ident, const char *hash_algo, const botan_pubkey_t key)
int botan_pubkey_load_classic_mceliece(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *cmce_mode)
int botan_privkey_load_classic_mceliece(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *cmce_mode)
int botan_privkey_load_x25519(botan_privkey_t *key, const uint8_t privkey[32])
int botan_pubkey_dsa_get_p(botan_mp_t p, botan_pubkey_t key)
int botan_pubkey_load_ecdh_sec1(botan_pubkey_t *key, const uint8_t sec1[], size_t sec1_len, const char *curve_name)
int botan_privkey_rsa_get_q(botan_mp_t q, botan_privkey_t key)
int botan_pubkey_ecc_key_used_explicit_encoding(botan_pubkey_t key)
int botan_pubkey_load_frodokem(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *frodo_mode)
int botan_privkey_ed25519_get_privkey(botan_privkey_t key, uint8_t output[64])
int botan_pubkey_load_rsa_pkcs1(botan_pubkey_t *key, const uint8_t bits[], size_t len)
int botan_privkey_load_sm2_enc(botan_privkey_t *key, const botan_mp_t scalar, const char *curve_name)
int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char *field_name_cstr)
int botan_pubkey_x448_get_pubkey(botan_pubkey_t key, uint8_t output[56])
int botan_privkey_load_rsa(botan_privkey_t *key, botan_mp_t rsa_p, botan_mp_t rsa_q, botan_mp_t rsa_e)
int botan_pubkey_dsa_get_y(botan_mp_t y, botan_pubkey_t key)
int botan_pubkey_load_ml_kem(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len, const char *mlkem_mode)
int botan_privkey_load_ed448(botan_privkey_t *key, const uint8_t privkey[57])
int botan_pubkey_view_ec_public_point(const botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_privkey_load_dh(botan_privkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t x)
int botan_privkey_load_sm2(botan_privkey_t *key, const botan_mp_t scalar, const char *curve_name)
int botan_pubkey_load_ed25519(botan_pubkey_t *key, const uint8_t pubkey[32])
int botan_privkey_load_ecdsa(botan_privkey_t *key, const botan_mp_t scalar, const char *curve_name)
int botan_mceies_encrypt(botan_pubkey_t mce_key_obj, botan_rng_t rng_obj, const char *aead, const uint8_t pt[], size_t pt_len, const uint8_t ad[], size_t ad_len, uint8_t out[], size_t *out_len)
int botan_pubkey_load_sm2_sec1(botan_pubkey_t *key, const uint8_t sec1[], size_t sec1_len, const char *curve_name)
int botan_pubkey_x25519_get_pubkey(botan_pubkey_t key, uint8_t output[32])
int botan_pubkey_load_elgamal(botan_pubkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t y)
int botan_privkey_load_slh_dsa(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *slhdsa_mode)
int botan_privkey_create_dsa(botan_privkey_t *key, botan_rng_t rng_obj, size_t pbits, size_t qbits)
int botan_privkey_rsa_get_p(botan_mp_t p, botan_privkey_t key)
int botan_privkey_create_mceliece(botan_privkey_t *key_obj, botan_rng_t rng_obj, size_t n, size_t t)
int botan_pubkey_load_ed448(botan_pubkey_t *key, const uint8_t pubkey[57])
int botan_privkey_load_ml_kem(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *mlkem_mode)
int botan_privkey_create_ecdh(botan_privkey_t *key_obj, botan_rng_t rng_obj, const char *param_str)
int botan_privkey_rsa_get_d(botan_mp_t d, botan_privkey_t key)
int botan_pubkey_load_sm2_enc(botan_pubkey_t *key, const botan_mp_t public_x, const botan_mp_t public_y, const char *curve_name)
int botan_mceies_decrypt(botan_privkey_t mce_key_obj, const char *aead, const uint8_t ct[], size_t ct_len, const uint8_t ad[], size_t ad_len, uint8_t out[], size_t *out_len)
int botan_pubkey_load_x25519(botan_pubkey_t *key, const uint8_t pubkey[32])
int botan_privkey_load_elgamal(botan_privkey_t *key, botan_mp_t p, botan_mp_t g, botan_mp_t x)
int botan_privkey_create_rsa(botan_privkey_t *key_obj, botan_rng_t rng_obj, size_t n_bits)
int botan_pubkey_load_dsa(botan_pubkey_t *key, botan_mp_t p, botan_mp_t q, botan_mp_t g, botan_mp_t y)
int botan_pubkey_load_kyber(botan_pubkey_t *key, const uint8_t pubkey[], size_t key_len)
int botan_pubkey_ed448_get_pubkey(botan_pubkey_t key, uint8_t output[57])
int botan_privkey_create_dh(botan_privkey_t *key_obj, botan_rng_t rng_obj, const char *param_str)
int botan_privkey_load_dsa(botan_privkey_t *key, botan_mp_t p, botan_mp_t q, botan_mp_t g, botan_mp_t x)
int botan_privkey_rsa_get_n(botan_mp_t n, botan_privkey_t key)
int botan_privkey_load_kyber(botan_privkey_t *key, const uint8_t privkey[], size_t key_len)
int botan_pubkey_rsa_get_e(botan_mp_t e, botan_pubkey_t key)
int botan_pubkey_load_ecdsa_sec1(botan_pubkey_t *key, const uint8_t sec1[], size_t sec1_len, const char *curve_name)
int botan_pubkey_dsa_get_g(botan_mp_t g, botan_pubkey_t key)
int botan_pubkey_dsa_get_q(botan_mp_t q, botan_pubkey_t key)
int botan_privkey_load_frodokem(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *frodo_mode)
int botan_pubkey_load_ecdsa(botan_pubkey_t *key, const botan_mp_t public_x, const botan_mp_t public_y, const char *curve_name)
int botan_pubkey_load_ecdh(botan_pubkey_t *key, const botan_mp_t public_x, const botan_mp_t public_y, const char *curve_name)
int botan_privkey_load_ml_dsa(botan_privkey_t *key, const uint8_t privkey[], size_t key_len, const char *mldsa_mode)
int botan_privkey_x448_get_privkey(botan_privkey_t key, uint8_t output[56])
int botan_privkey_load_ed25519(botan_privkey_t *key, const uint8_t privkey[32])
int botan_privkey_rsa_get_e(botan_mp_t e, botan_privkey_t key)
int botan_privkey_x25519_get_privkey(botan_privkey_t key, uint8_t output[32])
int botan_privkey_ed448_get_privkey(botan_privkey_t key, uint8_t output[57])
int botan_privkey_dsa_get_x(botan_mp_t x, botan_privkey_t key)
int botan_pubkey_load_rsa(botan_pubkey_t *key, botan_mp_t n, botan_mp_t e)
int botan_privkey_create_ecdsa(botan_privkey_t *key_obj, botan_rng_t rng_obj, const char *param_str)
int botan_pubkey_view_kyber_raw_key(botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_pubkey_load_x448(botan_pubkey_t *key, const uint8_t pubkey[56])
#define BOTAN_FFI_VISIT(obj, lambda)
std::string encode(const uint8_t der[], size_t length, std::string_view label, size_t width)
int invoke_view_callback(botan_view_bin_fn view, botan_view_ctx ctx, std::span< const uint8_t > buf)
T & safe_get(botan_struct< T, M > *p)
BOTAN_FFI_ERROR ffi_new_object(T *obj, Args &&... args)
int ffi_guard_thunk(const char *func_name, T thunk)
int write_vec_output(uint8_t out[], size_t *out_len, std::span< const uint8_t > buf)
int write_str_output(char out[], size_t *out_len, const std::string &str)
DilithiumMode ML_DSA_Mode
constexpr void copy_mem(T *out, const T *in, size_t n)
std::vector< uint8_t > sm2_compute_za(HashFunction &hash, std::string_view user_id, const EC_Group &group, const EC_AffinePoint &pubkey)