diff --git a/nfq2/crypto/gcm.c b/nfq2/crypto/gcm.c index 8180072..398b77c 100644 --- a/nfq2/crypto/gcm.c +++ b/nfq2/crypto/gcm.c @@ -258,8 +258,6 @@ int gcm_start(gcm_context *ctx, // pointer to user-provided GCM context size_t use_len; // byte count to process, up to 16 bytes size_t i; // local loop iterator - if (iv_len!=12) return -1; - // since the context might be reused under the same key // we zero the working buffers for this next new process memset(ctx->y, 0x00, sizeof(ctx->y)); @@ -447,7 +445,7 @@ int gcm_crypt_and_tag( prepare the gcm context with the keying material, we simply invoke each of the three GCM sub-functions in turn... */ - if (iv_len!=12 || tag_len>16) return -1; + if (tag_len>16) return -1; int ret; if ((ret=gcm_start(ctx, mode, iv, iv_len, add, add_len))) return ret; @@ -485,7 +483,7 @@ int gcm_auth_decrypt( size_t i; // our local iterator int ret; - if (iv_len!=12 || tag_len>16) return -1; + if (tag_len>16) return -1; /* we use GCM_DECRYPT_AND_TAG (above) to perform our decryption diff --git a/nfq2/lua.c b/nfq2/lua.c index 728a488..d21b112 100644 --- a/nfq2/lua.c +++ b/nfq2/lua.c @@ -686,8 +686,8 @@ static int luacall_aes_gcm(lua_State *L) luaL_error(L, "aes_gcm: wrong key length %u. should be 16,24,32.", (unsigned)key_len); size_t iv_len; const uint8_t *iv = (uint8_t*)lua_reqlstring(L,3,&iv_len); - if (iv_len!=12) - luaL_error(L, "aes_gcm: wrong iv length %u. should be 12.", (unsigned)iv_len); + if (!iv_len) + luaL_error(L, "aes_gcm: zero iv length"); size_t input_len; const uint8_t *input = (uint8_t*)lua_reqlstring(L,4,&input_len); size_t add_len=0;