diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ffi/ffi_kdf.cpp | 2 | ||||
-rw-r--r-- | src/lib/ffi/ffi_pkey_algs.cpp | 10 | ||||
-rw-r--r-- | src/lib/ffi/ffi_util.h | 7 |
3 files changed, 9 insertions, 10 deletions
diff --git a/src/lib/ffi/ffi_kdf.cpp b/src/lib/ffi/ffi_kdf.cpp index 479bf2140..c63406625 100644 --- a/src/lib/ffi/ffi_kdf.cpp +++ b/src/lib/ffi/ffi_kdf.cpp @@ -91,7 +91,7 @@ int botan_bcrypt_generate(uint8_t* out, size_t* out_len, return BOTAN_FFI_ERROR_BAD_FLAG; if(wf < 4 || wf > 18) - throw FFI_Error("Bad bcrypt work factor " + std::to_string(wf), BOTAN_FFI_ERROR_BAD_PARAMETER); + return BOTAN_FFI_ERROR_BAD_PARAMETER; Botan::RandomNumberGenerator& rng = safe_get(rng_obj); const std::string bcrypt = Botan::generate_bcrypt(pass, rng, static_cast<uint16_t>(wf)); diff --git a/src/lib/ffi/ffi_pkey_algs.cpp b/src/lib/ffi/ffi_pkey_algs.cpp index 622da7a14..7987639c8 100644 --- a/src/lib/ffi/ffi_pkey_algs.cpp +++ b/src/lib/ffi/ffi_pkey_algs.cpp @@ -117,7 +117,7 @@ Botan::BigInt pubkey_get_field(const Botan::Public_Key& key, else if(field == "e") return rsa->get_e(); else - throw Botan::Exception("Field not supported"); + return BOTAN_FFI_ERROR_BAD_PARAMETER; } #endif @@ -134,7 +134,7 @@ Botan::BigInt pubkey_get_field(const Botan::Public_Key& key, else if(field == "y") return dl->get_y(); else - throw Botan::Exception("Field not supported"); + return BOTAN_FFI_ERROR_BAD_PARAMETER; } #endif @@ -160,12 +160,12 @@ Botan::BigInt pubkey_get_field(const Botan::Public_Key& key, else if(field == "order") return ecc->domain().get_order(); else - throw Botan::Exception("Field not supported"); + return BOTAN_FFI_ERROR_BAD_PARAMETER; } #endif // Some other algorithm type not supported by this function - throw Botan::Exception("Unsupported algorithm type for botan_pubkey_get_field"); + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; } Botan::BigInt privkey_get_field(const Botan::Private_Key& key, @@ -216,7 +216,7 @@ Botan::BigInt privkey_get_field(const Botan::Private_Key& key, #endif // Some other algorithm type not supported by this function - throw Botan::Exception("Unsupported algorithm type for botan_privkey_get_field"); + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; } } diff --git a/src/lib/ffi/ffi_util.h b/src/lib/ffi/ffi_util.h index 2b9206f0b..684b25870 100644 --- a/src/lib/ffi/ffi_util.h +++ b/src/lib/ffi/ffi_util.h @@ -63,11 +63,10 @@ T& safe_get(botan_struct<T,M>* p) if(p->magic_ok() == false) throw FFI_Error("Bad magic in ffi object", BOTAN_FFI_ERROR_INVALID_OBJECT); - T* t = p->unsafe_get(); - if(t) + if(T* t = p->unsafe_get()) return *t; - else - throw FFI_Error("Invalid object pointer", BOTAN_FFI_ERROR_INVALID_OBJECT); + + throw FFI_Error("Invalid object pointer", BOTAN_FFI_ERROR_INVALID_OBJECT); } int ffi_guard_thunk(const char* func_name, std::function<int ()>); |