@@ -155,7 +155,6 @@ static aes_status_t aes_gcm_crypt(aes_gcm_counter_t *out, const iv_t nonce, cons
155155 uint32_t * cnt = NULL ;
156156 size_t NR = 0 , blocks = 0 , i = 0 ;
157157
158- // Copie locale du nonce pour pouvoir incrémenter le compteur
159158 memcpy (nonce_local , nonce , 16 );
160159
161160 cnt = (uint32_t * )(nonce_local + 0xC );
@@ -168,18 +167,15 @@ static aes_status_t aes_gcm_crypt(aes_gcm_counter_t *out, const iv_t nonce, cons
168167
169168 hash_subkey = create_hash_subkey (NR , ctx );
170169
171- // Calculer E(K, J0) pour le tag
172170 feedback = _mm_loadu_si128 ((__m128i * )nonce_local );
173171 j0_encrypted = aes_block_enc (feedback , & ctx -> key , NR );
174172
175173 * cnt += 0x01000000 ;
176174
177- // Chiffrer/Déchiffrer les données avec J1, J2, J3, ...
178175 blocks = (i_sz & 0xF ? - ~(i_sz >> 0x4 ) : (i_sz >> 0x4 ));
179176
180177 for (i = 0 ; i < blocks ; i ++ ) {
181178
182- // Prefetching
183179 _mm_prefetch ((__m128i * )(in + 0x20 ), _MM_HINT_T0 );
184180
185181 state = _mm_loadu_si128 ( & ((__m128i * )in )[i ]);
@@ -193,13 +189,10 @@ static aes_status_t aes_gcm_crypt(aes_gcm_counter_t *out, const iv_t nonce, cons
193189
194190 _mm_storeu_si128 (& ((__m128i * )out -> out )[i ], state );
195191
196- // Incrémenter pour le prochain bloc (big endian)
192+ // Incrément counter (big endian)
197193 * cnt += 0x01000000 ;
198194 }
199195
200- // Calculer GHASH sur le ciphertext (toujours)
201- // Pour encryption: ciphertext = out->out (résultat du CTR)
202- // Pour decryption: ciphertext = in (entrée)
203196 ghash = compute_ghash (hash_subkey , aad , aad_len , is_decrypt ? in : out -> out , i_sz );
204197
205198 // Tag final = GHASH XOR E(K, J0)
@@ -216,5 +209,4 @@ aes_status_t aes_gcm_enc(aes_gcm_counter_t *out, const iv_t nonce, const byte_t
216209aes_status_t aes_gcm_dec (aes_gcm_counter_t * out , const iv_t nonce , const byte_t * restrict aad , size_t aad_len , const byte_t * restrict in , size_t i_sz , const aes_ctx_t * ctx )
217210{
218211 return (aes_gcm_crypt (out , nonce , aad , aad_len , in , i_sz , ctx , TRUE));
219- }
220-
212+ }
0 commit comments