diff options
author | Richard Huveneers <[email protected]> | 2020-06-13 11:13:44 +0200 |
---|---|---|
committer | Richard Huveneers <[email protected]> | 2020-06-13 11:13:44 +0200 |
commit | c16c8ed319e48fd18c5510d9106c86bf52f2151a (patch) | |
tree | cb757bd2ebfb417649f510f8e9f72b91510d4b7b /src/lib/prov/commoncrypto | |
parent | e2d9d3ca9368bbe1449af64fcd3c86d0ab8740ef (diff) |
Fix 32-bit update parameter overflow
Diffstat (limited to 'src/lib/prov/commoncrypto')
-rw-r--r-- | src/lib/prov/commoncrypto/commoncrypto_hash.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/prov/commoncrypto/commoncrypto_hash.cpp b/src/lib/prov/commoncrypto/commoncrypto_hash.cpp index a2125c6db..5849c1429 100644 --- a/src/lib/prov/commoncrypto/commoncrypto_hash.cpp +++ b/src/lib/prov/commoncrypto/commoncrypto_hash.cpp @@ -71,8 +71,14 @@ class CommonCrypto_HashFunction final : public HashFunction private: void add_data(const uint8_t input[], size_t length) override { - if(m_info.update(&m_ctx, input, length) != 1) - throw CommonCrypto_Error("CC_" + m_info.name + "_Update"); + /* update len parameter is 32 bit unsigned integer, feed input in parts */ + while (length > 0) + { + CC_LONG update_len = (length > 0xFFFFFFFFUL) ? 0xFFFFFFFFUL : (CC_LONG) length; + m_info.update(&m_ctx, input, update_len); + input += update_len; + length -= update_len; + } } void final_result(uint8_t output[]) override |