diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ffi/ffi.h | 4 | ||||
-rw-r--r-- | src/lib/ffi/ffi_kdf.cpp | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h index ff7086488..fbc396d12 100644 --- a/src/lib/ffi/ffi.h +++ b/src/lib/ffi/ffi.h @@ -559,6 +559,8 @@ BOTAN_PUBLIC_API(2,0) int botan_pbkdf_timed(const char* pbkdf_algo, * @param out buffer to store the derived key, must be of out_len bytes * @param out_len the desired length of the key to produce * @param passphrase the password to derive the key from +* @param passphrase_len if > 0, specifies length of password. If len == 0, then +* strlen will be called on passphrase to compute the length. * @param salt a randomly chosen salt * @param salt_len length of salt in bytes * @return 0 on success, a negative value on failure @@ -585,6 +587,8 @@ int BOTAN_PUBLIC_API(2,8) botan_pwdhash( * @param out buffer to store the derived key, must be of out_len bytes * @param out_len the desired length of the key to produce * @param passphrase the password to derive the key from +* @param passphrase_len if > 0, specifies length of password. If len == 0, then +* strlen will be called on passphrase to compute the length. * @param salt a randomly chosen salt * @param salt_len length of salt in bytes * @return 0 on success, a negative value on failure diff --git a/src/lib/ffi/ffi_kdf.cpp b/src/lib/ffi/ffi_kdf.cpp index b72fe935e..639d25b1f 100644 --- a/src/lib/ffi/ffi_kdf.cpp +++ b/src/lib/ffi/ffi_kdf.cpp @@ -31,7 +31,7 @@ int botan_pbkdf(const char* algo, uint8_t out[], size_t out_len, 0, 0, out, out_len, - pass, std::strlen(pass), + pass, 0, salt, salt_len); } @@ -48,7 +48,7 @@ int botan_pbkdf_timed(const char* algo, nullptr, nullptr, out, out_len, - password, std::strlen(password), + password, 0, salt, salt_len); } @@ -64,6 +64,12 @@ int botan_pwdhash( const uint8_t salt[], size_t salt_len) { + if(algo == nullptr || password == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; + + if(password_len == 0) + password_len = std::strlen(password); + return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { auto pwdhash_fam = Botan::PasswordHashFamily::create(algo); @@ -93,6 +99,12 @@ int botan_pwdhash_timed( const uint8_t salt[], size_t salt_len) { + if(algo == nullptr || password == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; + + if(password_len == 0) + password_len = std::strlen(password); + return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() -> int { auto pwdhash_fam = Botan::PasswordHashFamily::create(algo); |