diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-01-19 18:28:56 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-01-19 18:28:56 -0500 |
commit | 347c0e56c64b245aa177cddd35e17a52e061e205 (patch) | |
tree | 2a45c8d72c52ba498b3c7f9d3907a6a5ab7ded60 /tweetnacl.cpp | |
parent | befd04312d8bdf2363921bf5ccb1393f5852a9a3 (diff) | |
download | cryptopp-git-347c0e56c64b245aa177cddd35e17a52e061e205.tar.gz |
Clear Coverity finding CID 186949
The finding is "Overflowed return value", and it is rooted in the constant time code bit manipulations
Diffstat (limited to 'tweetnacl.cpp')
-rw-r--r-- | tweetnacl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tweetnacl.cpp b/tweetnacl.cpp index 8348c3ed..9114ef8c 100644 --- a/tweetnacl.cpp +++ b/tweetnacl.cpp @@ -72,11 +72,13 @@ static void ts64(uint8_t *x,uint64_t u) for (i = 7;i >= 0;--i) { x[i] = u; u >>= 8; }
}
+// Extra cast due to Coverity CID 186949
static int verify_n(const uint8_t *x,const uint8_t *y,uint32_t n)
{
uint32_t i,d = 0;
for(i=0; i<n; ++i) d |= x[i]^y[i];
- return (1 & ((d - 1) >> 8)) - 1;
+ const int32_t v = (int32_t) d;
+ return (1 & ((uint32_t)(v - 1) >> 8)) - 1;
}
int crypto_verify_16(const uint8_t *x,const uint8_t *y)
@@ -892,4 +894,4 @@ int crypto_sign_open(uint8_t *m,uint64_t *mlen,const uint8_t *sm,uint64_t n,cons NAMESPACE_END // CryptoPP
NAMESPACE_END // NaCl
-#endif // NO_OS_DEPENDENCE
\ No newline at end of file +#endif // NO_OS_DEPENDENCE
|