Browse Source

Fix GCM counter reuse

GCM should error out after processing (2^32)-1 blocks / (2^39)-256 bits
Steffen Jaeckel 9 years ago
parent
commit
7d418b34b3
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/encauth/gcm/gcm_process.c

+ 5 - 0
src/encauth/gcm/gcm_process.c

@@ -49,6 +49,11 @@ int gcm_process(gcm_state *gcm,
       return err;
    }
 
+   /* 0xFFFFFFFE0 = ((2^39)-256)/8 */
+   if (gcm->pttotlen / 8 + (ulong64)gcm->buflen + (ulong64)ptlen >= CONST64(0xFFFFFFFE0)) {
+      return CRYPT_INVALID_ARG;
+   }
+
    /* in AAD mode? */
    if (gcm->mode == LTC_GCM_MODE_AAD) {
       /* let's process the AAD */