mirror of
https://github.com/status-im/sqlcipher.git
synced 2025-02-24 01:38:09 +00:00
improvements to memory comparison
This commit is contained in:
parent
9a6807e1b6
commit
273558efc6
@ -139,15 +139,15 @@ int sqlcipher_ismemset(const unsigned char *a0, unsigned char value, int len) {
|
||||
return noMatch;
|
||||
}
|
||||
|
||||
/* fixed time memory comparison routine */
|
||||
/* constant time memory comparison routine. returns 0 if match, 1 if no match */
|
||||
int sqlcipher_memcmp(const unsigned char *a0, const unsigned char *a1, int len) {
|
||||
int i = 0, noMatch = 0;
|
||||
int i = 0, result = 0;
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
noMatch = (noMatch || (a0[i] != a1[i]));
|
||||
result |= a0[i] ^ a1[i];
|
||||
}
|
||||
|
||||
return noMatch;
|
||||
return (result != 0);
|
||||
}
|
||||
|
||||
/* generate a defined number of pseudorandom bytes */
|
||||
|
Loading…
x
Reference in New Issue
Block a user