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:
		
							
								
								
									
										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, | 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; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user