]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - gcm/gcm128.c
new and more compact aes
[avr-crypto-lib.git] / gcm / gcm128.c
index 1f71046228b90c6746767b3b6ab42853dfbaeb0b..73c1b91b2695e8abb123019b02dc6147723d307b 100644 (file)
@@ -1,7 +1,7 @@
 /* gcm128.c */
 /*
     This file is part of the AVR-Crypto-Lib.
-    Copyright (C) 2006-2015 Daniel Otte (daniel.otte@rub.de)
+    Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -254,7 +254,7 @@ void gcm128_decrypt_block(
 {
     uint8_t tmp[BLOCK_BYTES];
     ghash128_block(&ctx->ghash_ctx, src);
-    inc32(&ctx->ctr[11]);
+    inc32(&ctx->ctr[BLOCK_BYTES - COUNT_BYTES]);
     memcpy(tmp, ctx->ctr, BLOCK_BYTES);
     bcal_cipher_enc(tmp, &ctx->cipher_ctx);
     memxor(tmp, src, BLOCK_BYTES);
@@ -286,7 +286,7 @@ void gcm128_decrypt_final_block(
             tmp[length_b / 8] &= 0xff << (8 - (length_b & 7));
         }
         ghash128_block(&ctx->ghash_ctx, tmp);
-        inc32(&ctx->ctr[11]);
+        inc32(&ctx->ctr[BLOCK_BYTES - COUNT_BYTES]);
         memcpy(tmp, ctx->ctr, BLOCK_BYTES);
         bcal_cipher_enc(tmp, &ctx->cipher_ctx);
         memxor(tmp, src, BLOCK_BYTES);