aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov/commoncrypto
diff options
context:
space:
mode:
authorRichard Huveneers <[email protected]>2020-06-13 11:13:44 +0200
committerRichard Huveneers <[email protected]>2020-06-13 11:13:44 +0200
commitc16c8ed319e48fd18c5510d9106c86bf52f2151a (patch)
treecb757bd2ebfb417649f510f8e9f72b91510d4b7b /src/lib/prov/commoncrypto
parente2d9d3ca9368bbe1449af64fcd3c86d0ab8740ef (diff)
Fix 32-bit update parameter overflow
Diffstat (limited to 'src/lib/prov/commoncrypto')
-rw-r--r--src/lib/prov/commoncrypto/commoncrypto_hash.cpp10
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