51 #include <botan/build.h>
153 #define BOTAN_FFI_HEX_LOWER_CASE 1
184 uint8_t* out,
size_t* out_len);
231 botan_rng_t source_rng,
243 const uint8_t* entropy,
408 size_t* out_minimum_keylength,
409 size_t* out_maximum_keylength,
410 size_t* out_keylength_modulo);
424 #define BOTAN_CIPHER_INIT_FLAG_MASK_DIRECTION 1
425 #define BOTAN_CIPHER_INIT_FLAG_ENCRYPT 0
426 #define BOTAN_CIPHER_INIT_FLAG_DECRYPT 1
468 size_t* out_minimum_keylength,
469 size_t* out_maximum_keylength);
483 const uint8_t* key,
size_t key_len);
499 const uint8_t* ad,
size_t ad_len);
505 const uint8_t* nonce,
size_t nonce_len);
507 #define BOTAN_CIPHER_UPDATE_FLAG_FINAL (1U << 0)
516 size_t* output_written,
517 const uint8_t input_bytes[],
519 size_t* input_consumed);
550 uint8_t out[],
size_t out_len,
551 const
char* passphrase,
552 const uint8_t salt[],
size_t salt_len,
580 uint8_t out[],
size_t out_len,
581 const
char* passphrase,
582 const uint8_t salt[],
size_t salt_len,
583 size_t milliseconds_to_run,
584 size_t* out_iterations_used);
609 const
char* passphrase,
610 size_t passphrase_len,
611 const uint8_t salt[],
638 const
char* passphrase,
639 size_t passphrase_len,
640 const uint8_t salt[],
648 BOTAN_PUBLIC_API(2,8)
int
651 const
char* passphrase,
652 const uint8_t salt[],
size_t salt_len,
653 size_t N,
size_t r,
size_t p);
668 BOTAN_PUBLIC_API(2,0)
int botan_kdf(const
char* kdf_algo,
669 uint8_t out[],
size_t out_len,
670 const uint8_t secret[],
size_t secret_len,
671 const uint8_t salt[],
size_t salt_len,
672 const uint8_t label[],
size_t label_len);
683 const
char* cipher_name);
701 const uint8_t key[],
size_t len);
732 char* name,
size_t* name_len);
743 size_t* out_minimum_keylength,
744 size_t* out_maximum_keylength,
745 size_t* out_keylength_modulo);
766 BOTAN_PUBLIC_API(2,1)
int botan_mp_to_hex(const botan_mp_t mp,
char* out);
771 BOTAN_PUBLIC_API(2,1)
int botan_mp_to_str(const botan_mp_t mp, uint8_t base,
char* out,
size_t* out_len);
812 BOTAN_PUBLIC_API(2,1)
int botan_mp_to_bin(const botan_mp_t mp, uint8_t vec[]);
817 BOTAN_PUBLIC_API(2,1)
int botan_mp_from_bin(const botan_mp_t mp, const uint8_t vec[],
size_t vec_len);
845 BOTAN_PUBLIC_API(2,8)
int botan_mp_add_u32(botan_mp_t result, const botan_mp_t x, uint32_t y);
846 BOTAN_PUBLIC_API(2,8)
int botan_mp_sub_u32(botan_mp_t result, const botan_mp_t x, uint32_t y);
848 BOTAN_PUBLIC_API(2,1)
int botan_mp_add(botan_mp_t result, const botan_mp_t x, const botan_mp_t y);
849 BOTAN_PUBLIC_API(2,1)
int botan_mp_sub(botan_mp_t result, const botan_mp_t x, const botan_mp_t y);
850 BOTAN_PUBLIC_API(2,1)
int botan_mp_mul(botan_mp_t result, const botan_mp_t x, const botan_mp_t y);
852 BOTAN_PUBLIC_API(2,1)
int botan_mp_div(botan_mp_t quotient,
853 botan_mp_t remainder,
854 const botan_mp_t x, const botan_mp_t y);
856 BOTAN_PUBLIC_API(2,1)
int botan_mp_mod_mul(botan_mp_t result, const botan_mp_t x,
857 const botan_mp_t y, const botan_mp_t mod);
864 BOTAN_PUBLIC_API(2,1)
int botan_mp_equal(const botan_mp_t x, const botan_mp_t y);
871 BOTAN_PUBLIC_API(2,1)
int botan_mp_cmp(
int* result, const botan_mp_t x, const botan_mp_t y);
876 BOTAN_PUBLIC_API(2,1)
int botan_mp_swap(botan_mp_t x, botan_mp_t y);
879 BOTAN_PUBLIC_API(2,1)
int botan_mp_powmod(botan_mp_t out, const botan_mp_t base, const botan_mp_t exponent, const botan_mp_t modulus);
881 BOTAN_PUBLIC_API(2,1)
int botan_mp_lshift(botan_mp_t out, const botan_mp_t in,
size_t shift);
882 BOTAN_PUBLIC_API(2,1)
int botan_mp_rshift(botan_mp_t out, const botan_mp_t in,
size_t shift);
884 BOTAN_PUBLIC_API(2,1)
int botan_mp_mod_inverse(botan_mp_t out, const botan_mp_t in, const botan_mp_t modulus);
886 BOTAN_PUBLIC_API(2,1)
int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng,
size_t bits);
889 const botan_mp_t lower_bound, const botan_mp_t upper_bound);
891 BOTAN_PUBLIC_API(2,1)
int botan_mp_gcd(botan_mp_t out, const botan_mp_t x, const botan_mp_t y);
898 BOTAN_PUBLIC_API(2,1)
int botan_mp_is_prime(const botan_mp_t n, botan_rng_t rng,
size_t test_prob);
933 const
char* password,
962 const
char* algo_name,
963 const
char* algo_params,
966 #define BOTAN_CHECK_KEY_EXPENSIVE_TESTS 1
1000 botan_privkey_t* key,
1025 botan_privkey_t* key,
1037 const uint8_t bits[],
size_t len,
1038 const
char* password);
1045 #define BOTAN_PRIVKEY_EXPORT_FLAG_DER 0
1046 #define BOTAN_PRIVKEY_EXPORT_FLAG_PEM 1
1056 uint8_t out[],
size_t* out_len,
1064 BOTAN_DEPRECATED("Use botan_privkey_export_encrypted_pbkdf_{msec,iter}
")
1065 BOTAN_PUBLIC_API(2,0) int botan_privkey_export_encrypted(botan_privkey_t key,
1066 uint8_t out[], size_t* out_len,
1068 const char* passphrase,
1069 const char* encryption_algo,
1073 * Export a private key, running PBKDF for specified amount of time
1074 * @param key the private key to export
1076 BOTAN_PUBLIC_API(2,0) int botan_privkey_export_encrypted_pbkdf_msec(botan_privkey_t key,
1077 uint8_t out[], size_t* out_len,
1079 const char* passphrase,
1080 uint32_t pbkdf_msec_runtime,
1081 size_t* pbkdf_iterations_out,
1082 const char* cipher_algo,
1083 const char* pbkdf_algo,
1089 BOTAN_PUBLIC_API(2,0) int botan_privkey_export_encrypted_pbkdf_iter(botan_privkey_t key,
1090 uint8_t out[], size_t* out_len,
1092 const char* passphrase,
1093 size_t pbkdf_iterations,
1094 const char* cipher_algo,
1095 const char* pbkdf_algo,
1098 typedef struct botan_pubkey_struct* botan_pubkey_t;
1100 BOTAN_PUBLIC_API(2,0) int botan_pubkey_load(botan_pubkey_t* key, const uint8_t bits[], size_t len);
1102 BOTAN_PUBLIC_API(2,0) int botan_privkey_export_pubkey(botan_pubkey_t* out, botan_privkey_t in);
1104 BOTAN_PUBLIC_API(2,0) int botan_pubkey_export(botan_pubkey_t key, uint8_t out[], size_t* out_len, uint32_t flags);
1106 BOTAN_PUBLIC_API(2,0) int botan_pubkey_algo_name(botan_pubkey_t key, char out[], size_t* out_len);
1111 BOTAN_PUBLIC_API(2,0) int botan_pubkey_check_key(botan_pubkey_t key, botan_rng_t rng, uint32_t flags);
1113 BOTAN_PUBLIC_API(2,0) int botan_pubkey_estimated_strength(botan_pubkey_t key, size_t* estimate);
1115 BOTAN_PUBLIC_API(2,0) int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash,
1116 uint8_t out[], size_t* out_len);
1121 BOTAN_PUBLIC_API(2,0) int botan_pubkey_destroy(botan_pubkey_t key);
1124 * Get arbitrary named fields from public or privat keys
1126 BOTAN_PUBLIC_API(2,0) int botan_pubkey_get_field(botan_mp_t output,
1128 const char* field_name);
1130 BOTAN_PUBLIC_API(2,0) int botan_privkey_get_field(botan_mp_t output,
1131 botan_privkey_t key,
1132 const char* field_name);
1135 * Algorithm specific key operations: RSA
1137 BOTAN_PUBLIC_API(2,0) int botan_privkey_load_rsa(botan_privkey_t* key,
1142 BOTAN_PUBLIC_API(2,8) int botan_privkey_load_rsa_pkcs1(botan_privkey_t* key,
1143 const uint8_t bits[],
1147 int botan_privkey_rsa_get_p(botan_mp_t p, botan_privkey_t rsa_key);
1149 int botan_privkey_rsa_get_q(botan_mp_t q, botan_privkey_t rsa_key);
1151 int botan_privkey_rsa_get_d(botan_mp_t d, botan_privkey_t rsa_key);
1153 int botan_privkey_rsa_get_n(botan_mp_t n, botan_privkey_t rsa_key);
1155 int botan_privkey_rsa_get_e(botan_mp_t e, botan_privkey_t rsa_key);
1157 BOTAN_PUBLIC_API(2,8) int botan_privkey_rsa_get_privkey(botan_privkey_t rsa_key,
1158 uint8_t out[], size_t* out_len,
1161 BOTAN_PUBLIC_API(2,0) int botan_pubkey_load_rsa(botan_pubkey_t* key,
1166 int botan_pubkey_rsa_get_e(botan_mp_t e, botan_pubkey_t rsa_key);
1168 int botan_pubkey_rsa_get_n(botan_mp_t n, botan_pubkey_t rsa_key);
1171 * Algorithm specific key operations: DSA
1173 BOTAN_PUBLIC_API(2,0) int botan_privkey_load_dsa(botan_privkey_t* key,
1179 BOTAN_PUBLIC_API(2,0) int botan_pubkey_load_dsa(botan_pubkey_t* key,
1186 int botan_privkey_dsa_get_x(botan_mp_t n, botan_privkey_t key);
1189 int botan_pubkey_dsa_get_p(botan_mp_t p, botan_pubkey_t key);
1191 int botan_pubkey_dsa_get_q(botan_mp_t q, botan_pubkey_t key);
1193 int botan_pubkey_dsa_get_g(botan_mp_t d, botan_pubkey_t key);
1195 int botan_pubkey_dsa_get_y(botan_mp_t y, botan_pubkey_t key);
1198 * Loads Diffie Hellman private key
1200 * @param key variable populated with key material
1201 * @param p prime order of a Z_p group
1202 * @param g group generator
1203 * @param x private key
1205 * @pre key is NULL on input
1206 * @post function allocates memory and assigns to `key'
1208 * @return 0 on success, a negative value on failure
1210 BOTAN_PUBLIC_API(2,0) int botan_privkey_load_dh(botan_privkey_t* key,
1227 BOTAN_PUBLIC_API(2,0) int botan_pubkey_load_dh(botan_pubkey_t* key,
1233 * Algorithm specific key operations: ElGamal
1248 BOTAN_PUBLIC_API(2,0) int botan_pubkey_load_elgamal(botan_pubkey_t* key,
1266 BOTAN_PUBLIC_API(2,0) int botan_privkey_load_elgamal(botan_privkey_t* key,
1272 * Algorithm specific key operations: Ed25519
1275 BOTAN_PUBLIC_API(2,2) int botan_privkey_load_ed25519(botan_privkey_t* key,
1276 const uint8_t privkey[32]);
1278 BOTAN_PUBLIC_API(2,2) int botan_pubkey_load_ed25519(botan_pubkey_t* key,
1279 const uint8_t pubkey[32]);
1281 BOTAN_PUBLIC_API(2,2) int botan_privkey_ed25519_get_privkey(botan_privkey_t key,
1282 uint8_t output[64]);
1284 BOTAN_PUBLIC_API(2,2) int botan_pubkey_ed25519_get_pubkey(botan_pubkey_t key,
1285 uint8_t pubkey[32]);
1288 * Algorithm specific key operations: X25519
1291 BOTAN_PUBLIC_API(2,8) int botan_privkey_load_x25519(botan_privkey_t* key,
1292 const uint8_t privkey[32]);
1294 BOTAN_PUBLIC_API(2,8) int botan_pubkey_load_x25519(botan_pubkey_t* key,
1295 const uint8_t pubkey[32]);
1297 BOTAN_PUBLIC_API(2,8) int botan_privkey_x25519_get_privkey(botan_privkey_t key,
1298 uint8_t output[32]);
1300 BOTAN_PUBLIC_API(2,8) int botan_pubkey_x25519_get_pubkey(botan_pubkey_t key,
1301 uint8_t pubkey[32]);
1304 * Algorithm specific key operations: ECDSA and ECDH
1306 BOTAN_PUBLIC_API(2,2)
1307 int botan_privkey_load_ecdsa(botan_privkey_t* key,
1308 const botan_mp_t scalar,
1309 const char* curve_name);
1311 BOTAN_PUBLIC_API(2,2)
1312 int botan_pubkey_load_ecdsa(botan_pubkey_t* key,
1313 const botan_mp_t public_x,
1314 const botan_mp_t public_y,
1315 const char* curve_name);
1317 BOTAN_PUBLIC_API(2,2)
1318 int botan_pubkey_load_ecdh(botan_pubkey_t* key,
1319 const botan_mp_t public_x,
1320 const botan_mp_t public_y,
1321 const char* curve_name);
1323 BOTAN_PUBLIC_API(2,2)
1324 int botan_privkey_load_ecdh(botan_privkey_t* key,
1325 const botan_mp_t scalar,
1326 const char* curve_name);
1328 BOTAN_PUBLIC_API(2,2)
1329 int botan_pubkey_load_sm2(botan_pubkey_t* key,
1330 const botan_mp_t public_x,
1331 const botan_mp_t public_y,
1332 const char* curve_name);
1334 BOTAN_PUBLIC_API(2,2)
1335 int botan_privkey_load_sm2(botan_privkey_t* key,
1336 const botan_mp_t scalar,
1337 const char* curve_name);
1340 int botan_pubkey_load_sm2_enc(botan_pubkey_t* key,
1341 const botan_mp_t public_x,
1342 const botan_mp_t public_y,
1343 const char* curve_name);
1346 int botan_privkey_load_sm2_enc(botan_privkey_t* key,
1347 const botan_mp_t scalar,
1348 const char* curve_name);
1350 BOTAN_PUBLIC_API(2,3)
1351 int botan_pubkey_sm2_compute_za(uint8_t out[],
1354 const char* hash_algo,
1355 const botan_pubkey_t key);
1358 * Public Key Encryption
1360 typedef struct botan_pk_op_encrypt_struct* botan_pk_op_encrypt_t;
1362 BOTAN_PUBLIC_API(2,0) int botan_pk_op_encrypt_create(botan_pk_op_encrypt_t* op,
1364 const char* padding,
1370 BOTAN_PUBLIC_API(2,0) int botan_pk_op_encrypt_destroy(botan_pk_op_encrypt_t op);
1372 BOTAN_PUBLIC_API(2,8) int botan_pk_op_encrypt_output_length(botan_pk_op_encrypt_t op,
1376 BOTAN_PUBLIC_API(2,0) int botan_pk_op_encrypt(botan_pk_op_encrypt_t op,
1380 const uint8_t plaintext[],
1381 size_t plaintext_len);
1384 * Public Key Decryption
1386 typedef struct botan_pk_op_decrypt_struct* botan_pk_op_decrypt_t;
1388 BOTAN_PUBLIC_API(2,0) int botan_pk_op_decrypt_create(botan_pk_op_decrypt_t* op,
1389 botan_privkey_t key,
1390 const char* padding,
1396 BOTAN_PUBLIC_API(2,0) int botan_pk_op_decrypt_destroy(botan_pk_op_decrypt_t op);
1398 BOTAN_PUBLIC_API(2,8) int botan_pk_op_decrypt_output_length(botan_pk_op_decrypt_t op,
1402 BOTAN_PUBLIC_API(2,0) int botan_pk_op_decrypt(botan_pk_op_decrypt_t op,
1403 uint8_t out[], size_t* out_len,
1404 const uint8_t ciphertext[], size_t ciphertext_len);
1407 * Signature Generation
1409 typedef struct botan_pk_op_sign_struct* botan_pk_op_sign_t;
1411 BOTAN_PUBLIC_API(2,0)
1412 int botan_pk_op_sign_create(botan_pk_op_sign_t* op,
1413 botan_privkey_t key,
1414 const char* hash_and_padding,
1420 BOTAN_PUBLIC_API(2,0) int botan_pk_op_sign_destroy(botan_pk_op_sign_t op);
1422 BOTAN_PUBLIC_API(2,8) int botan_pk_op_sign_output_length(botan_pk_op_sign_t op, size_t* olen);
1424 BOTAN_PUBLIC_API(2,0) int botan_pk_op_sign_update(botan_pk_op_sign_t op, const uint8_t in[], size_t in_len);
1426 BOTAN_PUBLIC_API(2,0)
1427 int botan_pk_op_sign_finish(botan_pk_op_sign_t op, botan_rng_t rng,
1428 uint8_t sig[], size_t* sig_len);
1431 * Signature Verification
1433 typedef struct botan_pk_op_verify_struct* botan_pk_op_verify_t;
1435 BOTAN_PUBLIC_API(2,0)
1436 int botan_pk_op_verify_create(botan_pk_op_verify_t* op,
1438 const char* hash_and_padding,
1444 BOTAN_PUBLIC_API(2,0) int botan_pk_op_verify_destroy(botan_pk_op_verify_t op);
1446 BOTAN_PUBLIC_API(2,0) int botan_pk_op_verify_update(botan_pk_op_verify_t op, const uint8_t in[], size_t in_len);
1447 BOTAN_PUBLIC_API(2,0) int botan_pk_op_verify_finish(botan_pk_op_verify_t op, const uint8_t sig[], size_t sig_len);
1452 typedef struct botan_pk_op_ka_struct* botan_pk_op_ka_t;
1454 BOTAN_PUBLIC_API(2,0)
1455 int botan_pk_op_key_agreement_create(botan_pk_op_ka_t* op,
1456 botan_privkey_t key,
1463 BOTAN_PUBLIC_API(2,0) int botan_pk_op_key_agreement_destroy(botan_pk_op_ka_t op);
1465 BOTAN_PUBLIC_API(2,0) int botan_pk_op_key_agreement_export_public(botan_privkey_t key,
1466 uint8_t out[], size_t* out_len);
1468 BOTAN_PUBLIC_API(2,8) int botan_pk_op_key_agreement_size(botan_pk_op_ka_t op, size_t* out_len);
1470 BOTAN_PUBLIC_API(2,0)
1471 int botan_pk_op_key_agreement(botan_pk_op_ka_t op,
1472 uint8_t out[], size_t* out_len,
1473 const uint8_t other_key[], size_t other_key_len,
1474 const uint8_t salt[], size_t salt_len);
1476 BOTAN_PUBLIC_API(2,0) int botan_pkcs_hash_id(const char* hash_name, uint8_t pkcs_id[], size_t* pkcs_id_len);
1481 * @param mce_key must be a McEliece key
1482 * ct_len should be pt_len + n/8 + a few?
1484 BOTAN_PUBLIC_API(2,0) BOTAN_DEPRECATED("Poorly specified, avoid in
new code
")
1485 int botan_mceies_encrypt(botan_pubkey_t mce_key,
1488 const uint8_t pt[], size_t pt_len,
1489 const uint8_t ad[], size_t ad_len,
1490 uint8_t ct[], size_t* ct_len);
1492 BOTAN_PUBLIC_API(2,0) BOTAN_DEPRECATED("Poorly specified, avoid in
new code
")
1493 int botan_mceies_decrypt(botan_privkey_t mce_key,
1495 const uint8_t ct[], size_t ct_len,
1496 const uint8_t ad[], size_t ad_len,
1497 uint8_t pt[], size_t* pt_len);
1500 * X.509 certificates
1501 **************************/
1503 typedef struct botan_x509_cert_struct* botan_x509_cert_t;
1505 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_load(botan_x509_cert_t* cert_obj, const uint8_t cert[], size_t cert_len);
1506 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* filename);
1511 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_destroy(botan_x509_cert_t cert);
1513 BOTAN_PUBLIC_API(2,8) int botan_x509_cert_dup(botan_x509_cert_t* new_cert, botan_x509_cert_t cert);
1515 /* Prefer botan_x509_cert_not_before and botan_x509_cert_not_after */
1516 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t* out_len);
1517 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t* out_len);
1519 BOTAN_PUBLIC_API(2,8) int botan_x509_cert_not_before(botan_x509_cert_t cert, uint64_t* time_since_epoch);
1520 BOTAN_PUBLIC_API(2,8) int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t* time_since_epoch);
1522 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char* hash, uint8_t out[], size_t* out_len);
1524 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
1525 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
1526 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t* out_len);
1528 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert,
1529 uint8_t out[], size_t* out_len);
1531 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_get_public_key(botan_x509_cert_t cert, botan_pubkey_t* key);
1533 BOTAN_PUBLIC_API(2,0)
1534 int botan_x509_cert_get_issuer_dn(botan_x509_cert_t cert,
1535 const char* key, size_t index,
1536 uint8_t out[], size_t* out_len);
1538 BOTAN_PUBLIC_API(2,0)
1539 int botan_x509_cert_get_subject_dn(botan_x509_cert_t cert,
1540 const char* key, size_t index,
1541 uint8_t out[], size_t* out_len);
1543 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t* out_len);
1545 /* Must match values of Key_Constraints in key_constraints.h */
1546 enum botan_x509_cert_key_constraints {
1548 DIGITAL_SIGNATURE = 32768,
1549 NON_REPUDIATION = 16384,
1550 KEY_ENCIPHERMENT = 8192,
1551 DATA_ENCIPHERMENT = 4096,
1552 KEY_AGREEMENT = 2048,
1553 KEY_CERT_SIGN = 1024,
1555 ENCIPHER_ONLY = 256,
1559 BOTAN_PUBLIC_API(2,0) int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage);
1565 BOTAN_PUBLIC_API(2,5) int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char* hostname);
1575 BOTAN_PUBLIC_API(2,8) int botan_x509_cert_verify(
1576 int* validation_result,
1577 botan_x509_cert_t cert,
1578 const botan_x509_cert_t* intermediates,
1579 size_t intermediates_len,
1580 const botan_x509_cert_t* trusted,
1582 const char* trusted_path,
1583 size_t required_strength,
1584 const char* hostname,
1585 uint64_t reference_time);
1591 BOTAN_PUBLIC_API(2,8) const char* botan_x509_cert_validation_status(int code);
1595 **************************/
1597 typedef struct botan_x509_crl_struct* botan_x509_crl_t;
1599 BOTAN_PUBLIC_API(2,13) int botan_x509_crl_load_file(botan_x509_crl_t* crl_obj, const char* crl_path);
1600 BOTAN_PUBLIC_API(2,13) int botan_x509_crl_load(botan_x509_crl_t* crl_obj, const uint8_t crl_bits[], size_t crl_bits_len);
1602 BOTAN_PUBLIC_API(2,13) int botan_x509_crl_destroy(botan_x509_crl_t crl);
1608 BOTAN_PUBLIC_API(2,13) int botan_x509_is_revoked(botan_x509_crl_t crl, botan_x509_cert_t cert);
1614 BOTAN_PUBLIC_API(2,13) int botan_x509_cert_verify_with_crl(
1615 int* validation_result,
1616 botan_x509_cert_t cert,
1617 const botan_x509_cert_t* intermediates,
1618 size_t intermediates_len,
1619 const botan_x509_cert_t* trusted,
1621 const botan_x509_crl_t* crls,
1623 const char* trusted_path,
1624 size_t required_strength,
1625 const char* hostname,
1626 uint64_t reference_time);
1631 BOTAN_PUBLIC_API(2,2)
1632 int botan_key_wrap3394(const uint8_t key[], size_t key_len,
1633 const uint8_t kek[], size_t kek_len,
1634 uint8_t wrapped_key[], size_t *wrapped_key_len);
1636 BOTAN_PUBLIC_API(2,2)
1637 int botan_key_unwrap3394(const uint8_t wrapped_key[], size_t wrapped_key_len,
1638 const uint8_t kek[], size_t kek_len,
1639 uint8_t key[], size_t *key_len);
1645 typedef struct botan_hotp_struct* botan_hotp_t;
1650 BOTAN_PUBLIC_API(2,8)
1651 int botan_hotp_init(botan_hotp_t* hotp,
1652 const uint8_t key[], size_t key_len,
1653 const char* hash_algo,
1660 BOTAN_PUBLIC_API(2,8)
1661 int botan_hotp_destroy(botan_hotp_t hotp);
1666 BOTAN_PUBLIC_API(2,8)
1667 int botan_hotp_generate(botan_hotp_t hotp,
1668 uint32_t* hotp_code,
1669 uint64_t hotp_counter);
1674 BOTAN_PUBLIC_API(2,8)
1675 int botan_hotp_check(botan_hotp_t hotp,
1676 uint64_t* next_hotp_counter,
1678 uint64_t hotp_counter,
1679 size_t resync_range);
1686 typedef struct botan_totp_struct* botan_totp_t;
1691 BOTAN_PUBLIC_API(2,8)
1692 int botan_totp_init(botan_totp_t* totp,
1693 const uint8_t key[], size_t key_len,
1694 const char* hash_algo,
1702 BOTAN_PUBLIC_API(2,8)
1703 int botan_totp_destroy(botan_totp_t totp);
1711 BOTAN_PUBLIC_API(2,8)
1712 int botan_totp_generate(botan_totp_t totp,
1713 uint32_t* totp_code,
1714 uint64_t timestamp);
1724 BOTAN_PUBLIC_API(2,8)
1725 int botan_totp_check(botan_totp_t totp,
1728 size_t acceptable_clock_drift);
1735 typedef struct botan_fpe_struct* botan_fpe_t;
1737 #define BOTAN_FPE_FLAG_FE1_COMPAT_MODE 1
1739 BOTAN_PUBLIC_API(2,8)
1740 int botan_fpe_fe1_init(botan_fpe_t* fpe, botan_mp_t n,
1741 const uint8_t key[], size_t key_len,
1742 size_t rounds, uint32_t flags);
1747 BOTAN_PUBLIC_API(2,8)
1748 int botan_fpe_destroy(botan_fpe_t fpe);
1750 BOTAN_PUBLIC_API(2,8)
1751 int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
1753 BOTAN_PUBLIC_API(2,8)
1754 int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len);
int botan_mp_init(botan_mp_t *mp)
int botan_cipher_query_keylen(botan_cipher_t, size_t *out_minimum_keylength, size_t *out_maximum_keylength)
int botan_cipher_init(botan_cipher_t *cipher, const char *name, uint32_t flags)
int botan_mp_to_str(const botan_mp_t mp, uint8_t base, char *out, size_t *out_len)
int botan_privkey_export(botan_privkey_t key, uint8_t out[], size_t *out_len, uint32_t flags)
int botan_hash_clear(botan_hash_t hash)
int botan_cipher_update(botan_cipher_t cipher, uint32_t flags, uint8_t output[], size_t output_size, size_t *output_written, const uint8_t input_bytes[], size_t input_size, size_t *input_consumed)
int botan_block_cipher_init(botan_block_cipher_t *bc, const char *cipher_name)
int botan_constant_time_compare(const uint8_t *x, const uint8_t *y, size_t len)
uint32_t botan_version_datestamp(void)
int botan_privkey_create_rsa(botan_privkey_t *key, botan_rng_t rng, size_t n_bits)
int botan_mp_clear(botan_mp_t mp)
int botan_mp_sub_u32(botan_mp_t result, const botan_mp_t x, uint32_t y)
int botan_base64_decode(const char *base64_str, size_t in_len, uint8_t *out, size_t *out_len)
int botan_kdf(const char *kdf_algo, uint8_t out[], size_t out_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len)
int botan_cipher_name(botan_cipher_t cipher, char *name, size_t *name_len)
int botan_mp_flip_sign(botan_mp_t mp)
int botan_mp_to_uint32(const botan_mp_t mp, uint32_t *val)
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_mp_equal(const botan_mp_t x, const botan_mp_t y)
int botan_hash_block_size(botan_hash_t hash, size_t *block_size)
int botan_block_cipher_set_key(botan_block_cipher_t bc, const uint8_t key[], size_t len)
#define BOTAN_PUBLIC_API(maj, min)
int botan_privkey_create_elgamal(botan_privkey_t *key, botan_rng_t rng, size_t pbits, size_t qbits)
int botan_mp_is_negative(const botan_mp_t mp)
int botan_block_cipher_get_keyspec(botan_block_cipher_t cipher, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
int botan_mac_final(botan_mac_t mac, uint8_t out[])
int botan_mac_name(botan_mac_t mac, char *name, size_t *name_len)
int botan_mac_init(botan_mac_t *mac, const char *mac_name, uint32_t flags)
int botan_privkey_get_field(botan_mp_t output, botan_privkey_t key, const char *field_name)
int botan_mp_set_from_mp(botan_mp_t dest, const botan_mp_t source)
int botan_cipher_output_length(botan_cipher_t cipher, size_t in_len, size_t *out_len)
int botan_same_mem(const uint8_t *x, const uint8_t *y, size_t len)
int botan_mp_destroy(botan_mp_t mp)
int botan_hash_copy_state(botan_hash_t *dest, const botan_hash_t source)
int botan_rng_add_entropy(botan_rng_t rng, const uint8_t *entropy, size_t entropy_len)
int botan_mp_rand_bits(botan_mp_t rand_out, botan_rng_t rng, size_t bits)
int botan_mp_add_u32(botan_mp_t result, const botan_mp_t x, uint32_t y)
int botan_cipher_get_update_granularity(botan_cipher_t cipher, size_t *ug)
int botan_cipher_set_associated_data(botan_cipher_t cipher, const uint8_t *ad, size_t ad_len)
int botan_pwdhash(const char *algo, size_t param1, size_t param2, size_t param3, uint8_t out[], size_t out_len, const char *passphrase, size_t passphrase_len, const uint8_t salt[], size_t salt_len)
int botan_mp_to_bin(const botan_mp_t mp, uint8_t vec[])
int botan_block_cipher_destroy(botan_block_cipher_t bc)
int botan_privkey_create_mceliece(botan_privkey_t *key, botan_rng_t rng, size_t n, size_t t)
int botan_bcrypt_generate(uint8_t *out, size_t *out_len, const char *password, botan_rng_t rng, size_t work_factor, uint32_t flags)
int botan_mac_destroy(botan_mac_t mac)
int botan_hash_name(botan_hash_t hash, char *name, size_t *name_len)
int botan_mp_set_from_radix_str(botan_mp_t dest, const char *str, size_t radix)
struct botan_mac_struct * botan_mac_t
int botan_block_cipher_clear(botan_block_cipher_t bc)
int botan_mp_set_bit(botan_mp_t n, size_t bit)
int botan_mp_mod_mul(botan_mp_t result, const botan_mp_t x, const botan_mp_t y, const botan_mp_t mod)
int botan_mac_set_key(botan_mac_t mac, const uint8_t *key, size_t key_len)
int botan_rng_destroy(botan_rng_t rng)
int botan_base64_encode(const uint8_t *x, size_t len, char *out, size_t *out_len)
int botan_mp_is_positive(const botan_mp_t mp)
int botan_cipher_reset(botan_cipher_t cipher)
int botan_privkey_algo_name(botan_privkey_t key, char out[], size_t *out_len)
int botan_mac_output_length(botan_mac_t mac, size_t *output_length)
int botan_hash_update(botan_hash_t hash, const uint8_t *in, size_t in_len)
struct botan_mp_struct * botan_mp_t
int botan_mp_swap(botan_mp_t x, botan_mp_t y)
int botan_hash_final(botan_hash_t hash, uint8_t out[])
int botan_hash_output_length(botan_hash_t hash, size_t *output_length)
int botan_mp_rshift(botan_mp_t out, const botan_mp_t in, size_t shift)
int botan_pbkdf_timed(const char *pbkdf_algo, uint8_t out[], size_t out_len, const char *passphrase, const uint8_t salt[], size_t salt_len, size_t milliseconds_to_run, size_t *out_iterations_used)
int botan_mp_is_even(const botan_mp_t mp)
int botan_mp_get_bit(const botan_mp_t n, size_t bit)
int botan_hex_encode(const uint8_t *x, size_t len, char *out, uint32_t flags)
int botan_mp_to_hex(const botan_mp_t mp, char *out)
uint32_t botan_ffi_api_version(void)
struct botan_hash_struct * botan_hash_t
int botan_privkey_create_ecdh(botan_privkey_t *key, botan_rng_t rng, const char *params)
int botan_rng_init(botan_rng_t *rng, const char *rng_type)
int botan_mp_sub(botan_mp_t result, const botan_mp_t x, const botan_mp_t y)
int botan_cipher_destroy(botan_cipher_t cipher)
int botan_cipher_set_key(botan_cipher_t cipher, const uint8_t *key, size_t key_len)
int botan_hash_init(botan_hash_t *hash, const char *hash_name, uint32_t flags)
int botan_mac_update(botan_mac_t mac, const uint8_t *buf, size_t len)
int botan_hex_decode(const char *hex_str, size_t in_len, uint8_t *out, size_t *out_len)
int botan_hash_destroy(botan_hash_t hash)
int botan_pwdhash_timed(const char *algo, uint32_t msec, size_t *param1, size_t *param2, size_t *param3, uint8_t out[], size_t out_len, const char *passphrase, size_t passphrase_len, const uint8_t salt[], size_t salt_len)
int botan_scrypt(uint8_t out[], size_t out_len, const char *passphrase, const uint8_t salt[], size_t salt_len, size_t N, size_t r, size_t p)
int botan_block_cipher_decrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks)
int botan_cipher_valid_nonce_length(botan_cipher_t cipher, size_t nl)
int botan_cipher_get_keyspec(botan_cipher_t, size_t *min_keylen, size_t *max_keylen, size_t *mod_keylen)
int botan_mp_set_from_int(botan_mp_t mp, int initial_value)
struct botan_privkey_struct * botan_privkey_t
int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t *tag_size)
int botan_privkey_create(botan_privkey_t *key, const char *algo_name, const char *algo_params, botan_rng_t rng)
int botan_mp_rand_range(botan_mp_t rand_out, botan_rng_t rng, const botan_mp_t lower_bound, const botan_mp_t upper_bound)
int botan_mp_is_zero(const botan_mp_t mp)
int botan_privkey_create_dh(botan_privkey_t *key, botan_rng_t rng, const char *param)
int botan_mp_is_prime(const botan_mp_t n, botan_rng_t rng, size_t test_prob)
int botan_rng_reseed(botan_rng_t rng, size_t bits)
int botan_privkey_create_ecdsa(botan_privkey_t *key, botan_rng_t rng, const char *params)
int botan_mp_num_bytes(const botan_mp_t n, size_t *bytes)
struct botan_block_cipher_struct * botan_block_cipher_t
int botan_block_cipher_name(botan_block_cipher_t cipher, char *name, size_t *name_len)
int botan_cipher_start(botan_cipher_t cipher, const uint8_t *nonce, size_t nonce_len)
int botan_privkey_load(botan_privkey_t *key, botan_rng_t rng, const uint8_t bits[], size_t len, const char *password)
int botan_scrub_mem(void *mem, size_t bytes)
int botan_block_cipher_encrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks)
const char * botan_version_string(void)
int botan_mp_mul(botan_mp_t result, const botan_mp_t x, const botan_mp_t y)
uint32_t botan_version_patch(void)
int botan_block_cipher_block_size(botan_block_cipher_t bc)
int botan_pubkey_get_field(botan_mp_t output, botan_pubkey_t key, const char *field_name)
int botan_mac_get_keyspec(botan_mac_t mac, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
int botan_cipher_clear(botan_cipher_t hash)
int botan_mp_is_odd(const botan_mp_t mp)
int botan_mp_mod_inverse(botan_mp_t out, const botan_mp_t in, const botan_mp_t modulus)
int botan_mp_add(botan_mp_t result, const botan_mp_t x, const botan_mp_t y)
int botan_mp_lshift(botan_mp_t out, const botan_mp_t in, size_t shift)
int botan_privkey_check_key(botan_privkey_t key, botan_rng_t rng, uint32_t flags)
int botan_mp_cmp(int *result, const botan_mp_t x, const botan_mp_t y)
int botan_privkey_create_dsa(botan_privkey_t *key, botan_rng_t rng, size_t pbits, size_t qbits)
int botan_mp_div(botan_mp_t quotient, botan_mp_t remainder, const botan_mp_t x, const botan_mp_t y)
int botan_bcrypt_is_valid(const char *pass, const char *hash)
int botan_mac_clear(botan_mac_t mac)
int botan_rng_get(botan_rng_t rng, uint8_t *out, size_t out_len)
struct botan_cipher_struct * botan_cipher_t
int botan_mp_powmod(botan_mp_t out, const botan_mp_t base, const botan_mp_t exponent, const botan_mp_t modulus)
int botan_pbkdf(const char *pbkdf_algo, uint8_t out[], size_t out_len, const char *passphrase, const uint8_t salt[], size_t salt_len, size_t iterations)
int botan_mp_from_bin(const botan_mp_t mp, const uint8_t vec[], size_t vec_len)
const char * botan_error_description(int err)
int botan_ffi_supports_api(uint32_t api_version)
int botan_mp_clear_bit(botan_mp_t n, size_t bit)
int botan_mp_num_bits(const botan_mp_t n, size_t *bits)
int botan_rng_reseed_from_rng(botan_rng_t rng, botan_rng_t source_rng, size_t bits)
int botan_cipher_get_default_nonce_length(botan_cipher_t cipher, size_t *nl)
int botan_privkey_load_sm2(botan_privkey_t *key, const botan_mp_t scalar, const char *curve_name)
struct botan_rng_struct * botan_rng_t
uint32_t botan_version_major(void)
int botan_mp_set_from_str(botan_mp_t dest, const char *str)
uint32_t botan_version_minor(void)
int botan_privkey_destroy(botan_privkey_t key)
int botan_mp_gcd(botan_mp_t out, const botan_mp_t x, const botan_mp_t y)