diff options
Diffstat (limited to 'src/lib/ffi/ffi_hash.cpp')
-rw-r--r-- | src/lib/ffi/ffi_hash.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi_hash.cpp b/src/lib/ffi/ffi_hash.cpp index 601d97c52..b8ad4a85a 100644 --- a/src/lib/ffi/ffi_hash.cpp +++ b/src/lib/ffi/ffi_hash.cpp @@ -38,11 +38,15 @@ int botan_hash_destroy(botan_hash_t hash) int botan_hash_output_length(botan_hash_t hash, size_t* out) { + if(out == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.output_length(); }); } int botan_hash_block_size(botan_hash_t hash, size_t* out) { + if(out == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.hash_block_size(); }); } @@ -53,11 +57,19 @@ int botan_hash_clear(botan_hash_t hash) int botan_hash_update(botan_hash_t hash, const uint8_t* buf, size_t len) { + if(len == 0) + return 0; + + if(buf == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; + return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.update(buf, len); }); } int botan_hash_final(botan_hash_t hash, uint8_t out[]) { + if(out == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.final(out); }); } @@ -69,6 +81,9 @@ int botan_hash_copy_state(botan_hash_t* dest, const botan_hash_t source) int botan_hash_name(botan_hash_t hash, char* name, size_t* name_len) { + if(name_len == nullptr) + return BOTAN_FFI_ERROR_NULL_POINTER; + return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { return write_str_output(name, name_len, h.name()); }); } |