1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Allow crypto IVs with leading zero. Close #2928, fix #2640

This commit is contained in:
nnposter
2024-09-13 21:36:46 +00:00
parent 51b5a50004
commit 3d99250c83
2 changed files with 8 additions and 4 deletions

View File

@@ -22,6 +22,10 @@ o [NSE][GH#2925][GH#2917][GH#2924] Testing for acceptance of SSH keys for
o [NSE][GH#2919][GH#2917] Scripts were not able to load SSH public keys.
from a file. [nnposter]
o [NSE][GH#2928][GH#2640] Encryption/decryption performed by the OpenSSL NSE
module did not work correctly when the IV started with a null byte.
[nnposter]
o [NSE][GH#2901][GH#2744][GH#2745] Arbitrary separator in stdnse.tohex() is now
supported. Script smb-protocols now reports SMB dialects correctly.
[nnposter]

View File

@@ -387,10 +387,10 @@ static int l_encrypt(lua_State *L) /** encrypt( string algorithm, string key, st
size_t key_len, iv_len, data_len;
const unsigned char *key = (unsigned char *) luaL_checklstring( L, 2, &key_len );
const unsigned char *iv = (unsigned char *) luaL_optlstring( L, 3, "", &iv_len );
const unsigned char *iv = (unsigned char *) luaL_optlstring( L, 3, NULL, &iv_len );
const unsigned char *data = (unsigned char *) luaL_checklstring( L, 4, &data_len );
int padding = lua_toboolean( L, 5 );
if (iv[0] == '\0')
if (!iv_len)
iv = NULL;
#if HAVE_OPAQUE_STRUCTS
@@ -449,10 +449,10 @@ static int l_decrypt(lua_State *L) /** decrypt( string algorithm, string key, st
size_t key_len, iv_len, data_len;
const unsigned char *key = (unsigned char *) luaL_checklstring( L, 2, &key_len );
const unsigned char *iv = (unsigned char *) luaL_optlstring( L, 3, "", &iv_len );
const unsigned char *iv = (unsigned char *) luaL_optlstring( L, 3, NULL, &iv_len );
const unsigned char *data = (unsigned char *) luaL_checklstring( L, 4, &data_len );
int padding = lua_toboolean( L, 5 );
if (iv[0] == '\0')
if (!iv_len)
iv = NULL;
#if HAVE_OPAQUE_STRUCTS