mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
AES CTR-DRGB: do not leak timing information
Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11147)
This commit is contained in:
parent
96218269f4
commit
069165d106
@ -21,19 +21,15 @@
|
||||
*/
|
||||
static void inc_128(RAND_DRBG_CTR *ctr)
|
||||
{
|
||||
int i;
|
||||
unsigned char c;
|
||||
unsigned char *p = &ctr->V[15];
|
||||
unsigned char *p = &ctr->V[0];
|
||||
u32 n = 16, c = 1;
|
||||
|
||||
for (i = 0; i < 16; i++, p--) {
|
||||
c = *p;
|
||||
c++;
|
||||
*p = c;
|
||||
if (c != 0) {
|
||||
/* If we didn't wrap around, we're done. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
do {
|
||||
--n;
|
||||
c += p[n];
|
||||
p[n] = (u8)c;
|
||||
c >>= 8;
|
||||
} while (n);
|
||||
}
|
||||
|
||||
static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen)
|
||||
|
Loading…
Reference in New Issue
Block a user