mirror of
https://github.com/libssh2/libssh2.git
synced 2025-10-30 12:05:34 +03:00
misc: use time constant implementation for AES CTR increment
This commit is contained in:
18
src/misc.c
18
src/misc.c
@@ -662,12 +662,16 @@ void _libssh2_xor_data(unsigned char *output,
|
||||
void _libssh2_aes_ctr_increment(unsigned char *ctr,
|
||||
size_t length)
|
||||
{
|
||||
if (length == 0)
|
||||
return;
|
||||
size_t i = (length - 1);
|
||||
while (ctr[i]++ == 0xFF) {
|
||||
if (i == 0)
|
||||
break;
|
||||
i--;
|
||||
unsigned char *pc;
|
||||
unsigned int val, carry;
|
||||
|
||||
pc = ctr + length - 1;
|
||||
carry = 1;
|
||||
|
||||
while(pc >= ctr)
|
||||
{
|
||||
val = (unsigned int)*pc + carry;
|
||||
*pc-- = val & 0xFF;
|
||||
carry = val >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ struct _libssh2_wincng_cipher_ctx {
|
||||
struct _libssh2_wincng_cipher_type {
|
||||
BCRYPT_ALG_HANDLE *phAlg;
|
||||
unsigned long dwKeyLength;
|
||||
int useIV;
|
||||
int useIV; /* TODO: Convert to bool when a C89 compatible bool type is defined */
|
||||
int ctrMode;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user