1
0
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:
Thomas
2017-02-13 10:02:25 +01:00
committed by Marc Hoersken
parent 2de14f8f9a
commit 674299c346
2 changed files with 12 additions and 8 deletions

View File

@@ -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;
}
}

View File

@@ -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;
};