mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
nfqws2: allow any size iv_len in aes_gcm
This commit is contained in:
@@ -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 use_len; // byte count to process, up to 16 bytes
|
||||||
size_t i; // local loop iterator
|
size_t i; // local loop iterator
|
||||||
|
|
||||||
if (iv_len!=12) return -1;
|
|
||||||
|
|
||||||
// since the context might be reused under the same key
|
// since the context might be reused under the same key
|
||||||
// we zero the working buffers for this next new process
|
// we zero the working buffers for this next new process
|
||||||
memset(ctx->y, 0x00, sizeof(ctx->y));
|
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
|
prepare the gcm context with the keying material, we simply
|
||||||
invoke each of the three GCM sub-functions in turn...
|
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;
|
int ret;
|
||||||
if ((ret=gcm_start(ctx, mode, iv, iv_len, add, add_len))) return 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
|
size_t i; // our local iterator
|
||||||
int ret;
|
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
|
we use GCM_DECRYPT_AND_TAG (above) to perform our decryption
|
||||||
|
|||||||
@@ -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);
|
luaL_error(L, "aes_gcm: wrong key length %u. should be 16,24,32.", (unsigned)key_len);
|
||||||
size_t iv_len;
|
size_t iv_len;
|
||||||
const uint8_t *iv = (uint8_t*)lua_reqlstring(L,3,&iv_len);
|
const uint8_t *iv = (uint8_t*)lua_reqlstring(L,3,&iv_len);
|
||||||
if (iv_len!=12)
|
if (!iv_len)
|
||||||
luaL_error(L, "aes_gcm: wrong iv length %u. should be 12.", (unsigned)iv_len);
|
luaL_error(L, "aes_gcm: zero iv length");
|
||||||
size_t input_len;
|
size_t input_len;
|
||||||
const uint8_t *input = (uint8_t*)lua_reqlstring(L,4,&input_len);
|
const uint8_t *input = (uint8_t*)lua_reqlstring(L,4,&input_len);
|
||||||
size_t add_len=0;
|
size_t add_len=0;
|
||||||
|
|||||||
Reference in New Issue
Block a user