Botan 3.6.1
Crypto and TLS for C&
|
#include <botan/ffi.h>
#include <botan/data_src.h>
#include <botan/hash.h>
#include <botan/pk_algs.h>
#include <botan/pk_keys.h>
#include <botan/pkcs8.h>
#include <botan/x509_key.h>
#include <botan/internal/ffi_pkey.h>
#include <botan/internal/ffi_rng.h>
#include <botan/internal/ffi_util.h>
Go to the source code of this file.
Functions | |
int | botan_pkcs_hash_id (const char *hash_name, uint8_t pkcs_id[], size_t *pkcs_id_len) |
int | botan_privkey_algo_name (botan_privkey_t key, char out[], size_t *out_len) |
int | botan_privkey_check_key (botan_privkey_t key, botan_rng_t rng, uint32_t flags) |
int | botan_privkey_create (botan_privkey_t *key_obj, const char *algo_name, const char *algo_params, botan_rng_t rng_obj) |
int | botan_privkey_destroy (botan_privkey_t key) |
int | botan_privkey_export (botan_privkey_t key, uint8_t out[], size_t *out_len, uint32_t flags) |
int | botan_privkey_export_encrypted (botan_privkey_t key, uint8_t out[], size_t *out_len, botan_rng_t rng_obj, const char *pass, const char *, uint32_t flags) |
int | botan_privkey_export_encrypted_pbkdf_iter (botan_privkey_t key, uint8_t out[], size_t *out_len, botan_rng_t rng, const char *passphrase, size_t pbkdf_iter, const char *cipher, const char *pbkdf_algo, uint32_t flags) |
int | botan_privkey_export_encrypted_pbkdf_msec (botan_privkey_t key, uint8_t out[], size_t *out_len, botan_rng_t rng, const char *passphrase, uint32_t pbkdf_msec, size_t *pbkdf_iters_out, const char *cipher, const char *pbkdf_hash, uint32_t flags) |
int | botan_privkey_export_pubkey (botan_pubkey_t *pubout, botan_privkey_t key_obj) |
int | botan_privkey_load (botan_privkey_t *key, botan_rng_t rng_obj, const uint8_t bits[], size_t len, const char *password) |
int | botan_privkey_view_der (botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view) |
int | botan_privkey_view_encrypted_der (botan_privkey_t key, botan_rng_t rng_obj, const char *passphrase, const char *maybe_cipher, const char *maybe_pbkdf_algo, size_t maybe_pbkdf_iterations, botan_view_ctx ctx, botan_view_bin_fn view) |
int | botan_privkey_view_encrypted_der_timed (botan_privkey_t key, botan_rng_t rng_obj, const char *passphrase, const char *maybe_cipher, const char *maybe_pbkdf_algo, size_t pbkdf_runtime_msec, botan_view_ctx ctx, botan_view_bin_fn view) |
int | botan_privkey_view_encrypted_pem (botan_privkey_t key, botan_rng_t rng_obj, const char *passphrase, const char *maybe_cipher, const char *maybe_pbkdf_algo, size_t maybe_pbkdf_iterations, botan_view_ctx ctx, botan_view_str_fn view) |
int | botan_privkey_view_encrypted_pem_timed (botan_privkey_t key, botan_rng_t rng_obj, const char *passphrase, const char *maybe_cipher, const char *maybe_pbkdf_algo, size_t pbkdf_runtime_msec, botan_view_ctx ctx, botan_view_str_fn view) |
int | botan_privkey_view_pem (botan_privkey_t key, botan_view_ctx ctx, botan_view_str_fn view) |
int | botan_privkey_view_raw (botan_privkey_t key, botan_view_ctx ctx, botan_view_bin_fn view) |
int | botan_pubkey_algo_name (botan_pubkey_t key, char out[], size_t *out_len) |
int | botan_pubkey_check_key (botan_pubkey_t key, botan_rng_t rng, uint32_t flags) |
int | botan_pubkey_destroy (botan_pubkey_t key) |
int | botan_pubkey_estimated_strength (botan_pubkey_t key, size_t *estimate) |
int | botan_pubkey_export (botan_pubkey_t key, uint8_t out[], size_t *out_len, uint32_t flags) |
int | botan_pubkey_fingerprint (botan_pubkey_t key, const char *hash_fn, uint8_t out[], size_t *out_len) |
int | botan_pubkey_load (botan_pubkey_t *key, const uint8_t bits[], size_t bits_len) |
int | botan_pubkey_view_der (botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view) |
int | botan_pubkey_view_pem (botan_pubkey_t key, botan_view_ctx ctx, botan_view_str_fn view) |
int | botan_pubkey_view_raw (botan_pubkey_t key, botan_view_ctx ctx, botan_view_bin_fn view) |
int botan_pkcs_hash_id | ( | const char * | hash_name, |
uint8_t | pkcs_id[], | ||
size_t * | pkcs_id_len ) |
Signature Scheme Utility Functions
Definition at line 356 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_UNUSED, Botan_FFI::ffi_guard_thunk(), Botan::pkcs_hash_id(), and Botan_FFI::write_output().
int botan_privkey_algo_name | ( | botan_privkey_t | key, |
char | out[], | ||
size_t * | out_len ) |
Definition at line 111 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::write_str_output().
int botan_privkey_check_key | ( | botan_privkey_t | key, |
botan_rng_t | rng, | ||
uint32_t | flags ) |
Definition at line 127 of file ffi_pkey.cpp.
References BOTAN_CHECK_KEY_EXPENSIVE_TESTS, BOTAN_FFI_ERROR_INVALID_INPUT, BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_privkey_create | ( | botan_privkey_t * | key, |
const char * | algo_name, | ||
const char * | algo_params, | ||
botan_rng_t | rng ) |
Create a new private key
key | the new object will be placed here |
algo_name | something like "RSA" or "ECDSA" |
algo_params | is specific to the algorithm. For RSA, specifies the modulus bit length. For ECC is the name of the curve. |
rng | a random number generator |
Definition at line 27 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, Botan::create_private_key(), Botan_FFI::ffi_guard_thunk(), and Botan_FFI::safe_get().
Referenced by botan_privkey_create_dh(), botan_privkey_create_ecdh(), botan_privkey_create_ecdsa(), botan_privkey_create_mceliece(), and botan_privkey_create_rsa().
int botan_privkey_destroy | ( | botan_privkey_t | key | ) |
Definition at line 79 of file ffi_pkey.cpp.
References BOTAN_FFI_CHECKED_DELETE.
int botan_privkey_export | ( | botan_privkey_t | key, |
uint8_t | out[], | ||
size_t * | out_len, | ||
uint32_t | flags ) |
On input *out_len is number of bytes in out[] On output *out_len is number of bytes written (or required) If out is not big enough no output is written, *out_len is set and 1 is returned Returns 0 on success and sets If some other error occurs a negative integer is returned.
Definition at line 161 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_BAD_FLAG, BOTAN_PRIVKEY_EXPORT_FLAG_DER, BOTAN_PRIVKEY_EXPORT_FLAG_PEM, BOTAN_PRIVKEY_EXPORT_FLAG_RAW, botan_privkey_view_der(), botan_privkey_view_pem(), botan_privkey_view_raw(), Botan_FFI::copy_view_bin(), and Botan_FFI::copy_view_str().
int botan_privkey_export_encrypted | ( | botan_privkey_t | key, |
uint8_t | out[], | ||
size_t * | out_len, | ||
botan_rng_t | rng, | ||
const char * | passphrase, | ||
const char * | encryption_algo, | ||
uint32_t | flags ) |
Set encryption_algo to NULL or "" to have the library choose a default (recommended)
Definition at line 188 of file ffi_pkey.cpp.
References botan_privkey_export_encrypted_pbkdf_iter().
int botan_privkey_export_encrypted_pbkdf_iter | ( | botan_privkey_t | key, |
uint8_t | out[], | ||
size_t * | out_len, | ||
botan_rng_t | rng, | ||
const char * | passphrase, | ||
size_t | pbkdf_iterations, | ||
const char * | cipher_algo, | ||
const char * | pbkdf_algo, | ||
uint32_t | flags ) |
Export a private key using the specified number of iterations.
Definition at line 275 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_BAD_FLAG, BOTAN_PRIVKEY_EXPORT_FLAG_DER, BOTAN_PRIVKEY_EXPORT_FLAG_PEM, botan_privkey_view_encrypted_der(), botan_privkey_view_encrypted_pem(), Botan_FFI::copy_view_bin(), and Botan_FFI::copy_view_str().
Referenced by botan_privkey_export_encrypted().
int botan_privkey_export_encrypted_pbkdf_msec | ( | botan_privkey_t | key, |
uint8_t | out[], | ||
size_t * | out_len, | ||
botan_rng_t | rng, | ||
const char * | passphrase, | ||
uint32_t | pbkdf_msec, | ||
size_t * | pbkdf_iters_out, | ||
const char * | cipher, | ||
const char * | pbkdf_hash, | ||
uint32_t | flags ) |
Definition at line 198 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_BAD_FLAG, BOTAN_PRIVKEY_EXPORT_FLAG_DER, BOTAN_PRIVKEY_EXPORT_FLAG_PEM, botan_privkey_view_encrypted_der_timed(), botan_privkey_view_encrypted_pem_timed(), Botan_FFI::copy_view_bin(), and Botan_FFI::copy_view_str().
int botan_privkey_export_pubkey | ( | botan_pubkey_t * | pubout, |
botan_privkey_t | key_obj ) |
Definition at line 103 of file ffi_pkey.cpp.
References BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), and Botan_FFI::safe_get().
int botan_privkey_load | ( | botan_privkey_t * | key, |
botan_rng_t | rng, | ||
const uint8_t | bits[], | ||
size_t | len, | ||
const char * | password ) |
Input currently assumed to be PKCS #8 structure; Set password to NULL to indicate no encryption expected Starting in 2.8.0, the rng parameter is unused and may be set to null
Definition at line 54 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_UNKNOWN_ERROR, BOTAN_FFI_SUCCESS, BOTAN_UNUSED, Botan_FFI::ffi_guard_thunk(), and Botan::PKCS8::load_key().
int botan_privkey_view_der | ( | botan_privkey_t | key, |
botan_view_ctx | ctx, | ||
botan_view_bin_fn | view ) |
View the private key's DER encoding
Definition at line 173 of file ffi_pkey.cpp.
References Botan::PKCS8::BER_encode(), BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().
Referenced by botan_privkey_export().
int botan_privkey_view_encrypted_der | ( | botan_privkey_t | key, |
botan_rng_t | rng, | ||
const char * | passphrase, | ||
const char * | cipher_algo, | ||
const char * | pbkdf_algo, | ||
size_t | pbkdf_iterations, | ||
botan_view_ctx | ctx, | ||
botan_view_bin_fn | view ) |
View the encryption of a private key (binary DER encoding)
Set cipher_algo, pbkdf_algo to NULL to use defaults Set pbkdf_iterations to 0 to use defaults
Definition at line 295 of file ffi_pkey.cpp.
References Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().
Referenced by botan_privkey_export_encrypted_pbkdf_iter().
int botan_privkey_view_encrypted_der_timed | ( | botan_privkey_t | key, |
botan_rng_t | rng, | ||
const char * | passphrase, | ||
const char * | cipher_algo, | ||
const char * | pbkdf_algo, | ||
size_t | pbkdf_runtime_msec, | ||
botan_view_ctx | ctx, | ||
botan_view_bin_fn | view ) |
View the encryption of a private key (binary DER encoding)
Set cipher_algo, pbkdf_algo to NULL to use defaults
Definition at line 223 of file ffi_pkey.cpp.
References Botan::PKCS8::BER_encode_encrypted_pbkdf_msec(), BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, Botan_FFI::invoke_view_callback(), and Botan_FFI::safe_get().
Referenced by botan_privkey_export_encrypted_pbkdf_msec().
int botan_privkey_view_encrypted_pem | ( | botan_privkey_t | key, |
botan_rng_t | rng, | ||
const char * | passphrase, | ||
const char * | cipher_algo, | ||
const char * | pbkdf_algo, | ||
size_t | pbkdf_iterations, | ||
botan_view_ctx | ctx, | ||
botan_view_str_fn | view ) |
View the encryption of a private key (PEM encoding)
Set cipher_algo, pbkdf_algo to NULL to use defaults Set pbkdf_iterations to 0 to use defaults
Definition at line 320 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, Botan_FFI::invoke_view_callback(), Botan::PKCS8::PEM_encode_encrypted_pbkdf_iter(), and Botan_FFI::safe_get().
Referenced by botan_privkey_export_encrypted_pbkdf_iter().
int botan_privkey_view_encrypted_pem_timed | ( | botan_privkey_t | key, |
botan_rng_t | rng, | ||
const char * | passphrase, | ||
const char * | cipher_algo, | ||
const char * | pbkdf_algo, | ||
size_t | pbkdf_runtime_msec, | ||
botan_view_ctx | ctx, | ||
botan_view_str_fn | view ) |
View the encryption of a private key (PEM encoding)
Set cipher_algo, pbkdf_algo to NULL to use defaults
Definition at line 249 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_VISIT, Botan_FFI::invoke_view_callback(), Botan::PKCS8::PEM_encode_encrypted_pbkdf_msec(), and Botan_FFI::safe_get().
Referenced by botan_privkey_export_encrypted_pbkdf_msec().
int botan_privkey_view_pem | ( | botan_privkey_t | key, |
botan_view_ctx | ctx, | ||
botan_view_str_fn | view ) |
View the private key's PEM encoding
Definition at line 178 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::invoke_view_callback(), and Botan::PKCS8::PEM_encode().
Referenced by botan_privkey_export().
int botan_privkey_view_raw | ( | botan_privkey_t | key, |
botan_view_ctx | ctx, | ||
botan_view_bin_fn | view ) |
View the private key's raw encoding
Definition at line 183 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().
Referenced by botan_privkey_export().
int botan_pubkey_algo_name | ( | botan_pubkey_t | key, |
char | out[], | ||
size_t * | out_len ) |
Definition at line 115 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::write_str_output().
int botan_pubkey_check_key | ( | botan_pubkey_t | key, |
botan_rng_t | rng, | ||
uint32_t | flags ) |
Returns 0 if key is valid, negative if invalid key or some other error
Definition at line 119 of file ffi_pkey.cpp.
References BOTAN_CHECK_KEY_EXPENSIVE_TESTS, BOTAN_FFI_ERROR_INVALID_INPUT, BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_pubkey_destroy | ( | botan_pubkey_t | key | ) |
Definition at line 99 of file ffi_pkey.cpp.
References BOTAN_FFI_CHECKED_DELETE.
int botan_pubkey_estimated_strength | ( | botan_pubkey_t | key, |
size_t * | estimate ) |
int botan_pubkey_export | ( | botan_pubkey_t | key, |
uint8_t | out[], | ||
size_t * | out_len, | ||
uint32_t | flags ) |
Definition at line 134 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_BAD_FLAG, BOTAN_PRIVKEY_EXPORT_FLAG_DER, BOTAN_PRIVKEY_EXPORT_FLAG_PEM, BOTAN_PRIVKEY_EXPORT_FLAG_RAW, botan_pubkey_view_der(), botan_pubkey_view_pem(), botan_pubkey_view_raw(), Botan_FFI::copy_view_bin(), and Botan_FFI::copy_view_str().
int botan_pubkey_fingerprint | ( | botan_pubkey_t | key, |
const char * | hash_fn, | ||
uint8_t | out[], | ||
size_t * | out_len ) |
Definition at line 349 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, Botan::HashFunction::create_or_throw(), and Botan_FFI::write_vec_output().
int botan_pubkey_load | ( | botan_pubkey_t * | key, |
const uint8_t | bits[], | ||
size_t | bits_len ) |
Definition at line 83 of file ffi_pkey.cpp.
References BOTAN_FFI_ERROR_UNKNOWN_ERROR, BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), and Botan::X509::load_key().
int botan_pubkey_view_der | ( | botan_pubkey_t | key, |
botan_view_ctx | ctx, | ||
botan_view_bin_fn | view ) |
View the public key's DER encoding
Definition at line 146 of file ffi_pkey.cpp.
References Botan::X509::BER_encode(), BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().
Referenced by botan_pubkey_export().
int botan_pubkey_view_pem | ( | botan_pubkey_t | key, |
botan_view_ctx | ctx, | ||
botan_view_str_fn | view ) |
View the public key's PEM encoding
Definition at line 151 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, Botan_FFI::invoke_view_callback(), and Botan::X509::PEM_encode().
Referenced by botan_pubkey_export().
int botan_pubkey_view_raw | ( | botan_pubkey_t | key, |
botan_view_ctx | ctx, | ||
botan_view_bin_fn | view ) |
View the public key's raw encoding
Definition at line 156 of file ffi_pkey.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::invoke_view_callback().
Referenced by botan_pubkey_export().