diff options
Diffstat (limited to 'src/lib/ffi')
-rw-r--r-- | src/lib/ffi/ffi.cpp | 8 | ||||
-rw-r--r-- | src/lib/ffi/ffi_block.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_cert.cpp | 10 | ||||
-rw-r--r-- | src/lib/ffi/ffi_cipher.cpp | 6 | ||||
-rw-r--r-- | src/lib/ffi/ffi_fpe.cpp | 6 | ||||
-rw-r--r-- | src/lib/ffi/ffi_hash.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_hotp.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_kdf.cpp | 10 | ||||
-rw-r--r-- | src/lib/ffi/ffi_keywrap.cpp | 4 | ||||
-rw-r--r-- | src/lib/ffi/ffi_mac.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_mp.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_pk_op.cpp | 10 | ||||
-rw-r--r-- | src/lib/ffi/ffi_pkey.cpp | 10 | ||||
-rw-r--r-- | src/lib/ffi/ffi_pkey_algs.cpp | 48 | ||||
-rw-r--r-- | src/lib/ffi/ffi_rng.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_totp.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_util.h | 4 |
17 files changed, 65 insertions, 65 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index 65c8dbcb4..74291199b 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -188,7 +188,7 @@ int botan_scrub_mem(void* mem, size_t bytes) int botan_hex_encode(const uint8_t* in, size_t len, char* out, uint32_t flags) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const bool uppercase = (flags & BOTAN_FFI_HEX_LOWER_CASE) == 0; Botan::hex_encode(out, in, len, uppercase); return BOTAN_FFI_SUCCESS; @@ -197,7 +197,7 @@ int botan_hex_encode(const uint8_t* in, size_t len, char* out, uint32_t flags) int botan_hex_decode(const char* hex_str, size_t in_len, uint8_t* out, size_t* out_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const std::vector<uint8_t> bin = Botan::hex_decode(hex_str, in_len); return Botan_FFI::write_vec_output(out, out_len, bin); }); @@ -205,7 +205,7 @@ int botan_hex_decode(const char* hex_str, size_t in_len, uint8_t* out, size_t* o int botan_base64_encode(const uint8_t* in, size_t len, char* out, size_t* out_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const std::string base64 = Botan::base64_encode(in, len); return Botan_FFI::write_str_output(out, out_len, base64); }); @@ -214,7 +214,7 @@ int botan_base64_encode(const uint8_t* in, size_t len, char* out, size_t* out_le int botan_base64_decode(const char* base64_str, size_t in_len, uint8_t* out, size_t* out_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(*out_len < Botan::base64_decode_max_output(in_len)) { *out_len = Botan::base64_decode_max_output(in_len); diff --git a/src/lib/ffi/ffi_block.cpp b/src/lib/ffi/ffi_block.cpp index bf5cd1b94..71de6943b 100644 --- a/src/lib/ffi/ffi_block.cpp +++ b/src/lib/ffi/ffi_block.cpp @@ -16,7 +16,7 @@ BOTAN_FFI_DECLARE_STRUCT(botan_block_cipher_struct, Botan::BlockCipher, 0x64C297 int botan_block_cipher_init(botan_block_cipher_t* bc, const char* bc_name) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(bc == nullptr || bc_name == nullptr || *bc_name == 0) return BOTAN_FFI_ERROR_NULL_POINTER; diff --git a/src/lib/ffi/ffi_cert.cpp b/src/lib/ffi/ffi_cert.cpp index 09f778bdc..dd7f37ecb 100644 --- a/src/lib/ffi/ffi_cert.cpp +++ b/src/lib/ffi/ffi_cert.cpp @@ -31,7 +31,7 @@ int botan_x509_cert_load_file(botan_x509_cert_t* cert_obj, const char* cert_path #if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::X509_Certificate> c(new Botan::X509_Certificate(cert_path)); *cert_obj = new botan_x509_cert_struct(c.release()); return BOTAN_FFI_SUCCESS; @@ -49,7 +49,7 @@ int botan_x509_cert_dup(botan_x509_cert_t* cert_obj, botan_x509_cert_t cert) #if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::X509_Certificate> c(new Botan::X509_Certificate(safe_get(cert))); *cert_obj = new botan_x509_cert_struct(c.release()); return BOTAN_FFI_SUCCESS; @@ -67,7 +67,7 @@ int botan_x509_cert_load(botan_x509_cert_t* cert_obj, const uint8_t cert_bits[], return BOTAN_FFI_ERROR_NULL_POINTER; #if defined(BOTAN_HAS_X509_CERTIFICATES) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::DataSource_Memory bits(cert_bits, cert_bits_len); std::unique_ptr<Botan::X509_Certificate> c(new Botan::X509_Certificate(bits)); *cert_obj = new botan_x509_cert_struct(c.release()); @@ -87,7 +87,7 @@ int botan_x509_cert_get_public_key(botan_x509_cert_t cert, botan_pubkey_t* key) *key = nullptr; #if defined(BOTAN_HAS_X509_CERTIFICATES) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::Public_Key> publicKey = safe_get(cert).load_subject_public_key(); *key = new botan_pubkey_struct(publicKey.release()); return BOTAN_FFI_SUCCESS; @@ -280,7 +280,7 @@ int botan_x509_cert_verify(int* result_code, required_strength = 110; #if defined(BOTAN_HAS_X509_CERTIFICATES) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const std::string hostname((hostname_cstr == nullptr) ? "" : hostname_cstr); const Botan::Usage_Type usage = Botan::Usage_Type::UNSPECIFIED; const auto validation_time = reference_time == 0 ? diff --git a/src/lib/ffi/ffi_cipher.cpp b/src/lib/ffi/ffi_cipher.cpp index 7b672d407..dc340ea61 100644 --- a/src/lib/ffi/ffi_cipher.cpp +++ b/src/lib/ffi/ffi_cipher.cpp @@ -20,7 +20,7 @@ struct botan_cipher_struct final : public botan_struct<Botan::Cipher_Mode, 0xB4A int botan_cipher_init(botan_cipher_t* cipher, const char* cipher_name, uint32_t flags) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const bool encrypt_p = ((flags & BOTAN_CIPHER_INIT_FLAG_MASK_DIRECTION) == BOTAN_CIPHER_INIT_FLAG_ENCRYPT); const Botan::Cipher_Dir dir = encrypt_p ? Botan::ENCRYPTION : Botan::DECRYPTION; std::unique_ptr<Botan::Cipher_Mode> mode(Botan::Cipher_Mode::create(cipher_name, dir)); @@ -88,7 +88,7 @@ int botan_cipher_set_key(botan_cipher_t cipher, int botan_cipher_start(botan_cipher_t cipher_obj, const uint8_t* nonce, size_t nonce_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::Cipher_Mode& cipher = safe_get(cipher_obj); cipher.start(nonce, nonce_len); cipher_obj->m_buf.reserve(cipher.update_granularity()); @@ -105,7 +105,7 @@ int botan_cipher_update(botan_cipher_t cipher_obj, size_t orig_input_size, size_t* input_consumed) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { size_t input_size = orig_input_size; size_t output_size = orig_output_size; diff --git a/src/lib/ffi/ffi_fpe.cpp b/src/lib/ffi/ffi_fpe.cpp index 34e47d47f..01706ea20 100644 --- a/src/lib/ffi/ffi_fpe.cpp +++ b/src/lib/ffi/ffi_fpe.cpp @@ -29,7 +29,7 @@ int botan_fpe_fe1_init(botan_fpe_t* fpe, botan_mp_t n, { #if defined(BOTAN_HAS_FPE_FE1) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() { + return ffi_guard_thunk(__func__, [=]() { if(fpe == nullptr || key == nullptr) return BOTAN_FFI_ERROR_NULL_POINTER; @@ -67,7 +67,7 @@ int botan_fpe_destroy(botan_fpe_t fpe) int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len) { #if defined(BOTAN_HAS_FPE_FE1) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() { + return ffi_guard_thunk(__func__, [=]() { Botan::BigInt r = safe_get(fpe).encrypt(safe_get(x), tweak, tweak_len); safe_get(x) = r; return BOTAN_FFI_SUCCESS; @@ -80,7 +80,7 @@ int botan_fpe_encrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size int botan_fpe_decrypt(botan_fpe_t fpe, botan_mp_t x, const uint8_t tweak[], size_t tweak_len) { #if defined(BOTAN_HAS_FPE_FE1) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() { + return ffi_guard_thunk(__func__, [=]() { Botan::BigInt r = safe_get(fpe).decrypt(safe_get(x), tweak, tweak_len); safe_get(x) = r; return BOTAN_FFI_SUCCESS; diff --git a/src/lib/ffi/ffi_hash.cpp b/src/lib/ffi/ffi_hash.cpp index b8ad4a85a..12eb92301 100644 --- a/src/lib/ffi/ffi_hash.cpp +++ b/src/lib/ffi/ffi_hash.cpp @@ -16,7 +16,7 @@ BOTAN_FFI_DECLARE_STRUCT(botan_hash_struct, Botan::HashFunction, 0x1F0A4F84); int botan_hash_init(botan_hash_t* hash, const char* hash_name, uint32_t flags) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(hash == nullptr || hash_name == nullptr || *hash_name == 0) return BOTAN_FFI_ERROR_NULL_POINTER; if(flags != 0) diff --git a/src/lib/ffi/ffi_hotp.cpp b/src/lib/ffi/ffi_hotp.cpp index 8c4cc3bfb..e1c4c40e8 100644 --- a/src/lib/ffi/ffi_hotp.cpp +++ b/src/lib/ffi/ffi_hotp.cpp @@ -32,7 +32,7 @@ int botan_hotp_init(botan_hotp_t* hotp, *hotp = nullptr; #if defined(BOTAN_HAS_HOTP) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *hotp = new botan_hotp_struct( new Botan::HOTP(key, key_len, hash_algo, digits)); diff --git a/src/lib/ffi/ffi_kdf.cpp b/src/lib/ffi/ffi_kdf.cpp index c55515a42..d38dd594b 100644 --- a/src/lib/ffi/ffi_kdf.cpp +++ b/src/lib/ffi/ffi_kdf.cpp @@ -67,7 +67,7 @@ int botan_pwdhash( if(password_len == 0) password_len = std::strlen(password); - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { auto pwdhash_fam = Botan::PasswordHashFamily::create(algo); if(!pwdhash_fam) @@ -102,7 +102,7 @@ int botan_pwdhash_timed( if(password_len == 0) password_len = std::strlen(password); - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { auto pwdhash_fam = Botan::PasswordHashFamily::create(algo); @@ -132,7 +132,7 @@ int botan_kdf(const char* kdf_algo, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::KDF> kdf(Botan::get_kdf(kdf_algo)); kdf->kdf(out, out_len, secret, secret_len, salt, salt_len, label, label_len); return BOTAN_FFI_SUCCESS; @@ -156,7 +156,7 @@ int botan_bcrypt_generate(uint8_t* out, size_t* out_len, uint32_t flags) { #if defined(BOTAN_HAS_BCRYPT) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(out == nullptr || out_len == nullptr || pass == nullptr) return BOTAN_FFI_ERROR_NULL_POINTER; @@ -178,7 +178,7 @@ int botan_bcrypt_generate(uint8_t* out, size_t* out_len, int botan_bcrypt_is_valid(const char* pass, const char* hash) { #if defined(BOTAN_HAS_BCRYPT) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { return Botan::check_bcrypt(pass, hash) ? BOTAN_FFI_SUCCESS : BOTAN_FFI_INVALID_VERIFIER; }); #else diff --git a/src/lib/ffi/ffi_keywrap.cpp b/src/lib/ffi/ffi_keywrap.cpp index 546137df0..f74904cb7 100644 --- a/src/lib/ffi/ffi_keywrap.cpp +++ b/src/lib/ffi/ffi_keywrap.cpp @@ -20,7 +20,7 @@ int botan_key_wrap3394(const uint8_t key[], size_t key_len, uint8_t wrapped_key[], size_t* wrapped_key_len) { #if defined(BOTAN_HAS_RFC3394_KEYWRAP) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const Botan::SymmetricKey kek_sym(kek, kek_len); const Botan::secure_vector<uint8_t> key_pt(key, key + key_len); const Botan::secure_vector<uint8_t> key_ct = Botan::rfc3394_keywrap(key_pt, kek_sym); @@ -36,7 +36,7 @@ int botan_key_unwrap3394(const uint8_t wrapped_key[], size_t wrapped_key_len, uint8_t key[], size_t* key_len) { #if defined(BOTAN_HAS_RFC3394_KEYWRAP) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const Botan::SymmetricKey kek_sym(kek, kek_len); const Botan::secure_vector<uint8_t> key_ct(wrapped_key, wrapped_key + wrapped_key_len); const Botan::secure_vector<uint8_t> key_pt = Botan::rfc3394_keyunwrap(key_ct, kek_sym); diff --git a/src/lib/ffi/ffi_mac.cpp b/src/lib/ffi/ffi_mac.cpp index b1b021720..3b6cc3bef 100644 --- a/src/lib/ffi/ffi_mac.cpp +++ b/src/lib/ffi/ffi_mac.cpp @@ -16,7 +16,7 @@ BOTAN_FFI_DECLARE_STRUCT(botan_mac_struct, Botan::MessageAuthenticationCode, 0xA int botan_mac_init(botan_mac_t* mac, const char* mac_name, uint32_t flags) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(!mac || !mac_name || flags != 0) return BOTAN_FFI_ERROR_NULL_POINTER; diff --git a/src/lib/ffi/ffi_mp.cpp b/src/lib/ffi/ffi_mp.cpp index 38a83e91b..d9b41cb52 100644 --- a/src/lib/ffi/ffi_mp.cpp +++ b/src/lib/ffi/ffi_mp.cpp @@ -19,7 +19,7 @@ using namespace Botan_FFI; int botan_mp_init(botan_mp_t* mp_out) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(mp_out == nullptr) return BOTAN_FFI_ERROR_NULL_POINTER; diff --git a/src/lib/ffi/ffi_pk_op.cpp b/src/lib/ffi/ffi_pk_op.cpp index e6035fa7d..10fd379b4 100644 --- a/src/lib/ffi/ffi_pk_op.cpp +++ b/src/lib/ffi/ffi_pk_op.cpp @@ -31,7 +31,7 @@ int botan_pk_op_encrypt_create(botan_pk_op_encrypt_t* op, if(flags != 0) return BOTAN_FFI_ERROR_BAD_FLAG; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *op = nullptr; std::unique_ptr<Botan::PK_Encryptor> pk(new Botan::PK_Encryptor_EME(safe_get(key_obj), Botan::system_rng(), padding)); @@ -76,7 +76,7 @@ int botan_pk_op_decrypt_create(botan_pk_op_decrypt_t* op, if(flags != 0) return BOTAN_FFI_ERROR_BAD_FLAG; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *op = nullptr; std::unique_ptr<Botan::PK_Decryptor> pk(new Botan::PK_Decryptor_EME(safe_get(key_obj), Botan::system_rng(), padding)); @@ -120,7 +120,7 @@ int botan_pk_op_sign_create(botan_pk_op_sign_t* op, if(flags != 0) return BOTAN_FFI_ERROR_BAD_FLAG; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *op = nullptr; std::unique_ptr<Botan::PK_Signer> pk(new Botan::PK_Signer(safe_get(key_obj), Botan::system_rng(), hash)); @@ -165,7 +165,7 @@ int botan_pk_op_verify_create(botan_pk_op_verify_t* op, if(flags != 0) return BOTAN_FFI_ERROR_BAD_FLAG; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *op = nullptr; std::unique_ptr<Botan::PK_Verifier> pk(new Botan::PK_Verifier(safe_get(key_obj), hash)); *op = new botan_pk_op_verify_struct(pk.release()); @@ -206,7 +206,7 @@ int botan_pk_op_key_agreement_create(botan_pk_op_ka_t* op, if(flags != 0) return BOTAN_FFI_ERROR_BAD_FLAG; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *op = nullptr; std::unique_ptr<Botan::PK_Key_Agreement> pk(new Botan::PK_Key_Agreement(safe_get(key_obj), Botan::system_rng(), kdf)); *op = new botan_pk_op_ka_struct(pk.release()); diff --git a/src/lib/ffi/ffi_pkey.cpp b/src/lib/ffi/ffi_pkey.cpp index 584252f2b..24bc96758 100644 --- a/src/lib/ffi/ffi_pkey.cpp +++ b/src/lib/ffi/ffi_pkey.cpp @@ -28,7 +28,7 @@ int botan_privkey_create(botan_privkey_t* key_obj, const char* algo_params, botan_rng_t rng_obj) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(key_obj == nullptr) return BOTAN_FFI_ERROR_NULL_POINTER; @@ -62,7 +62,7 @@ int botan_privkey_load(botan_privkey_t* key, botan_rng_t rng_obj, *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::DataSource_Memory src(bits, len); std::unique_ptr<Botan::Private_Key> pkcs8; @@ -95,7 +95,7 @@ int botan_pubkey_load(botan_pubkey_t* key, { *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::DataSource_Memory src(bits, bits_len); std::unique_ptr<Botan::Public_Key> pubkey(Botan::X509::load_key(src)); @@ -114,7 +114,7 @@ int botan_pubkey_destroy(botan_pubkey_t key) int botan_privkey_export_pubkey(botan_pubkey_t* pubout, botan_privkey_t key_obj) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::Public_Key> pubkey(Botan::X509::load_key(Botan::X509::BER_encode(safe_get(key_obj)))); @@ -265,7 +265,7 @@ int botan_pubkey_fingerprint(botan_pubkey_t key, const char* hash_fn, int botan_pkcs_hash_id(const char* hash_name, uint8_t pkcs_id[], size_t* pkcs_id_len) { #if defined(BOTAN_HAS_HASH_ID) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const std::vector<uint8_t> hash_id = Botan::pkcs_hash_id(hash_name); return write_output(pkcs_id, pkcs_id_len, hash_id.data(), hash_id.size()); }); diff --git a/src/lib/ffi/ffi_pkey_algs.cpp b/src/lib/ffi/ffi_pkey_algs.cpp index e98cb542b..66e04a668 100644 --- a/src/lib/ffi/ffi_pkey_algs.cpp +++ b/src/lib/ffi/ffi_pkey_algs.cpp @@ -271,7 +271,7 @@ int botan_privkey_load_rsa(botan_privkey_t* key, #if defined(BOTAN_HAS_RSA) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *key = new botan_privkey_struct(new Botan::RSA_PrivateKey(safe_get(rsa_p), safe_get(rsa_q), safe_get(rsa_e))); @@ -291,7 +291,7 @@ int botan_privkey_load_rsa_pkcs1(botan_privkey_t* key, *key = nullptr; Botan::secure_vector<uint8_t> src(bits, bits + len); - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::AlgorithmIdentifier alg_id("RSA", Botan::AlgorithmIdentifier::USE_NULL_PARAM); *key = new botan_privkey_struct(new Botan::RSA_PrivateKey(alg_id, src)); return BOTAN_FFI_SUCCESS; @@ -307,7 +307,7 @@ int botan_pubkey_load_rsa(botan_pubkey_t* key, { #if defined(BOTAN_HAS_RSA) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *key = new botan_pubkey_struct(new Botan::RSA_PublicKey(safe_get(n), safe_get(e))); return BOTAN_FFI_SUCCESS; }); @@ -393,7 +393,7 @@ int botan_privkey_create_dsa(botan_privkey_t* key, botan_rng_t rng_obj, size_t p return BOTAN_FFI_ERROR_BAD_PARAMETER; } - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::RandomNumberGenerator& rng = safe_get(rng_obj); Botan::DL_Group group(rng, Botan::DL_Group::Prime_Subgroup, pbits, qbits); *key = new botan_privkey_struct(new Botan::DSA_PrivateKey(rng, group)); @@ -411,7 +411,7 @@ int botan_privkey_load_dsa(botan_privkey_t* key, #if defined(BOTAN_HAS_DSA) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::Null_RNG null_rng; Botan::DL_Group group(safe_get(p), safe_get(q), safe_get(g)); *key = new botan_privkey_struct(new Botan::DSA_PrivateKey(null_rng, group, safe_get(x))); @@ -429,7 +429,7 @@ int botan_pubkey_load_dsa(botan_pubkey_t* key, #if defined(BOTAN_HAS_DSA) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::DL_Group group(safe_get(p), safe_get(q), safe_get(g)); *key = new botan_pubkey_struct(new Botan::DSA_PublicKey(group, safe_get(y))); return BOTAN_FFI_SUCCESS; @@ -478,7 +478,7 @@ int botan_pubkey_load_ecdsa(botan_pubkey_t* key, const char* curve_name) { #if defined(BOTAN_HAS_ECDSA) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::ECDSA_PublicKey> p_key; int rc = pubkey_load_ec(p_key, safe_get(public_x), safe_get(public_y), curve_name); @@ -498,7 +498,7 @@ int botan_privkey_load_ecdsa(botan_privkey_t* key, const char* curve_name) { #if defined(BOTAN_HAS_ECDSA) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::ECDSA_PrivateKey> p_key; int rc = privkey_load_ec(p_key, safe_get(scalar), curve_name); if(rc == BOTAN_FFI_SUCCESS) @@ -530,7 +530,7 @@ int botan_privkey_create_elgamal(botan_privkey_t* key, ? Botan::DL_Group::Strong : Botan::DL_Group::Prime_Subgroup; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::RandomNumberGenerator& rng = safe_get(rng_obj); Botan::DL_Group group(rng, prime_type, pbits, qbits); *key = new botan_privkey_struct(new Botan::ElGamal_PrivateKey(rng, group)); @@ -547,7 +547,7 @@ int botan_pubkey_load_elgamal(botan_pubkey_t* key, { #if defined(BOTAN_HAS_ELGAMAL) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::DL_Group group(safe_get(p), safe_get(g)); *key = new botan_pubkey_struct(new Botan::ElGamal_PublicKey(group, safe_get(y))); return BOTAN_FFI_SUCCESS; @@ -563,7 +563,7 @@ int botan_privkey_load_elgamal(botan_privkey_t* key, { #if defined(BOTAN_HAS_ELGAMAL) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::Null_RNG null_rng; Botan::DL_Group group(safe_get(p), safe_get(g)); *key = new botan_privkey_struct(new Botan::ElGamal_PrivateKey(null_rng, group, safe_get(x))); @@ -587,7 +587,7 @@ int botan_privkey_load_dh(botan_privkey_t* key, { #if defined(BOTAN_HAS_DIFFIE_HELLMAN) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::Null_RNG null_rng; Botan::DL_Group group(safe_get(p), safe_get(g)); *key = new botan_privkey_struct(new Botan::DH_PrivateKey(null_rng, group, safe_get(x))); @@ -604,7 +604,7 @@ int botan_pubkey_load_dh(botan_pubkey_t* key, { #if defined(BOTAN_HAS_DIFFIE_HELLMAN) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::DL_Group group(safe_get(p), safe_get(g)); *key = new botan_pubkey_struct(new Botan::DH_PublicKey(group, safe_get(y))); return BOTAN_FFI_SUCCESS; @@ -636,7 +636,7 @@ int botan_pubkey_load_ecdh(botan_pubkey_t* key, const char* curve_name) { #if defined(BOTAN_HAS_ECDH) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::ECDH_PublicKey> p_key; int rc = pubkey_load_ec(p_key, safe_get(public_x), safe_get(public_y), curve_name); @@ -655,7 +655,7 @@ int botan_privkey_load_ecdh(botan_privkey_t* key, const char* curve_name) { #if defined(BOTAN_HAS_ECDH) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::ECDH_PrivateKey> p_key; int rc = privkey_load_ec(p_key, safe_get(scalar), curve_name); if(rc == BOTAN_FFI_SUCCESS) @@ -682,7 +682,7 @@ int botan_pubkey_sm2_compute_za(uint8_t out[], return BOTAN_FFI_ERROR_NULL_POINTER; #if defined(BOTAN_HAS_SM2) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const Botan::Public_Key& pub_key = safe_get(key); const Botan::EC_PublicKey* ec_key = dynamic_cast<const Botan::EC_PublicKey*>(&pub_key); @@ -712,7 +712,7 @@ int botan_pubkey_load_sm2(botan_pubkey_t* key, const char* curve_name) { #if defined(BOTAN_HAS_SM2) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::SM2_PublicKey> p_key; if(!pubkey_load_ec(p_key, safe_get(public_x), safe_get(public_y), curve_name)) { @@ -732,7 +732,7 @@ int botan_privkey_load_sm2(botan_privkey_t* key, const char* curve_name) { #if defined(BOTAN_HAS_SM2) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { std::unique_ptr<Botan::SM2_PrivateKey> p_key; int rc = privkey_load_ec(p_key, safe_get(scalar), curve_name); @@ -768,7 +768,7 @@ int botan_privkey_load_ed25519(botan_privkey_t* key, { #if defined(BOTAN_HAS_ED25519) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const Botan::secure_vector<uint8_t> privkey_vec(privkey, privkey + 32); *key = new botan_privkey_struct(new Botan::Ed25519_PrivateKey(privkey_vec)); return BOTAN_FFI_SUCCESS; @@ -784,7 +784,7 @@ int botan_pubkey_load_ed25519(botan_pubkey_t* key, { #if defined(BOTAN_HAS_ED25519) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const std::vector<uint8_t> pubkey_vec(pubkey, pubkey + 32); *key = new botan_pubkey_struct(new Botan::Ed25519_PublicKey(pubkey_vec)); return BOTAN_FFI_SUCCESS; @@ -850,7 +850,7 @@ int botan_privkey_load_x25519(botan_privkey_t* key, { #if defined(BOTAN_HAS_X25519) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const Botan::secure_vector<uint8_t> privkey_vec(privkey, privkey + 32); *key = new botan_privkey_struct(new Botan::X25519_PrivateKey(privkey_vec)); return BOTAN_FFI_SUCCESS; @@ -866,7 +866,7 @@ int botan_pubkey_load_x25519(botan_pubkey_t* key, { #if defined(BOTAN_HAS_X25519) *key = nullptr; - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { const std::vector<uint8_t> pubkey_vec(pubkey, pubkey + 32); *key = new botan_pubkey_struct(new Botan::X25519_PublicKey(pubkey_vec)); return BOTAN_FFI_SUCCESS; @@ -937,7 +937,7 @@ int botan_mceies_decrypt(botan_privkey_t mce_key_obj, const uint8_t ad[], size_t ad_len, uint8_t out[], size_t* out_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::Private_Key& key = safe_get(mce_key_obj); #if defined(BOTAN_HAS_MCELIECE) && defined(BOTAN_HAS_MCEIES) @@ -960,7 +960,7 @@ int botan_mceies_encrypt(botan_pubkey_t mce_key_obj, const uint8_t ad[], size_t ad_len, uint8_t out[], size_t* out_len) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { Botan::Public_Key& key = safe_get(mce_key_obj); Botan::RandomNumberGenerator& rng = safe_get(rng_obj); diff --git a/src/lib/ffi/ffi_rng.cpp b/src/lib/ffi/ffi_rng.cpp index e193d4123..e312bad80 100644 --- a/src/lib/ffi/ffi_rng.cpp +++ b/src/lib/ffi/ffi_rng.cpp @@ -20,7 +20,7 @@ using namespace Botan_FFI; int botan_rng_init(botan_rng_t* rng_out, const char* rng_type) { - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { if(rng_out == nullptr) return BOTAN_FFI_ERROR_NULL_POINTER; diff --git a/src/lib/ffi/ffi_totp.cpp b/src/lib/ffi/ffi_totp.cpp index 7cd575042..66e07a92a 100644 --- a/src/lib/ffi/ffi_totp.cpp +++ b/src/lib/ffi/ffi_totp.cpp @@ -33,7 +33,7 @@ int botan_totp_init(botan_totp_t* totp, *totp = nullptr; #if defined(BOTAN_HAS_TOTP) - return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { + return ffi_guard_thunk(__func__, [=]() -> int { *totp = new botan_totp_struct( new Botan::TOTP(key, key_len, hash_algo, digits, time_step)); diff --git a/src/lib/ffi/ffi_util.h b/src/lib/ffi/ffi_util.h index f72af0a63..d68baf699 100644 --- a/src/lib/ffi/ffi_util.h +++ b/src/lib/ffi/ffi_util.h @@ -84,7 +84,7 @@ int apply_fn(botan_struct<T, M>* o, const char* func_name, F func) } #define BOTAN_FFI_DO(T, obj, param, block) \ - apply_fn(obj, BOTAN_CURRENT_FUNCTION, \ + apply_fn(obj, __func__, \ [=](T& param) -> int { do { block } while(0); return BOTAN_FFI_SUCCESS; }) template<typename T, uint32_t M> @@ -111,7 +111,7 @@ int ffi_delete_object(botan_struct<T, M>* obj, const char* func_name) } } -#define BOTAN_FFI_CHECKED_DELETE(o) ffi_delete_object(o, BOTAN_CURRENT_FUNCTION) +#define BOTAN_FFI_CHECKED_DELETE(o) ffi_delete_object(o, __func__) inline int write_output(uint8_t out[], size_t* out_len, const uint8_t buf[], size_t buf_len) { |