1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-10-31 23:30:25 +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, void _libssh2_aes_ctr_increment(unsigned char *ctr,
size_t length) size_t length)
{ {
if (length == 0) unsigned char *pc;
return; unsigned int val, carry;
size_t i = (length - 1);
while (ctr[i]++ == 0xFF) { pc = ctr + length - 1;
if (i == 0) carry = 1;
break;
i--; 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 { struct _libssh2_wincng_cipher_type {
BCRYPT_ALG_HANDLE *phAlg; BCRYPT_ALG_HANDLE *phAlg;
unsigned long dwKeyLength; unsigned long dwKeyLength;
int useIV; int useIV; /* TODO: Convert to bool when a C89 compatible bool type is defined */
int ctrMode; int ctrMode;
}; };