acvpparser
acvpparser copied to clipboard
Buffer alloc error with ECDH test vector
Error ''' ACVPParser (17:26:45) Warning [parser/stringhelper.c:alloc_buf:132]: Allocate an already allocated buffer! ACVPParser (17:26:45) Debug [backends/backend_openssl3.c:openssl_pkey_get_bn_bytes:71]: Failure with return code -14 '''
Env OS: 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux version: ''' ACVP Parser executing the crypto implementation openssl ACVP Parser version: ACVPParser/2.1.6 ''' ''' openssl list -providers Providers: default name: OpenSSL Default Provider version: 3.1.6 status: active fips name: OpenSSL FIPS Provider version: 3.1.6 status: active ''' Input test vector ''' [ { "acvVersion": "1.0" }, { "vsId": 2241895, "algorithm": "KAS-ECC", "mode": "CDH-Component", "revision": "Sp800-56Ar3", "isSample": true, "testGroups": [ { "tgId": 1, "testType": "AFT", "curve": "P-224", "tests": [ { "tcId": 1, "publicServerX": "005E622F7130019B3495622097A25E2CF2D53486A4683636ACD73594", "publicServerY": "9E16A91A0EA5EC218155DC59215309A5BEED8C5A4D9246FA51E1C057" }, { "tcId": 2, "publicServerX": "DE75212567E07079CCEB362558D70ADB9B32D779EEE9B6A7EAA2BC68", "publicServerY": "9A421EA9DEC33970564CF2586597BE443ED04F318E3F5B1256B0A7AB" } ] } ] } ] '''
Am Freitag, 12. April 2024, 16:21:25 MESZ schrieb Leo Wang:
Hi Leo,
Error ''' ACVPParser (17:26:45) Warning [parser/stringhelper.c:alloc_buf:132]: Allocate an already allocated buffer!
ACVPParser (17:26:45) Debug
[backends/backend_openssl3.c:openssl_pkey_get_bn_bytes:71]: Failure with return code -14 '''
Could you please provide some more logs following this one as this function is called in several places. Thanks.
Ciao Stephan
The issue should be reproducible with the given json. Here are the back trace of the buf alloc
Breakpoint 2, alloc_buf (size=size@entry=28, buf=buf@entry=0x7fffffffc218) at parser/stringhelper.c:130
130 {
(gdb) bt #0 alloc_buf (size=size@entry=28, buf=buf@entry=0x7fffffffc218) at parser/stringhelper.c:130
#1 0x0000555555590997 in openssl_pkey_get_bn_bytes (pkey=pkey@entry=0x55555568c290, name=name@entry=0x5555555a14cb "priv", out=out@entry=0x7fffffffc218) at backends/backend_openssl3.c:71
#2 0x00005555555915af in openssl_ecdh_ss_common (cipher=18014398526259200, Qxrem=0x7fffffffc1f8, Qyrem=0x7fffffffc208, privloc=0x7fffffffc218, Qxloc=0x7fffffffc228, Qyloc=0x7fffffffc238, hashzz=0x7fffffffc248) at backends/backend_openssl3.c:928
#3 0x0000555555592049 in openssl_ecdh_ss (data=<optimized out>, parsed_flags=<optimized out>) at backends/backend_openssl3.c:1024
#4 0x00005555555668bc in exec_test (testresults=0x55555567a2f0, testvector=0x5555555c4a80, parsed_flags=8796093022209, processdata=0x7fffffffc070) at parser/parser_common.c:393
#5 parse_array (testresults=0x55555567a2f0, parsed_flags=8796093022209, readdata=0x5555555ed8e0, entry=0x7fffffffc510) at parser/parser_common.c:826
#6 parse_one_entry (testresults=0x55555567a2f0, parsed_flags=8796093022209, readdata=0x5555555ed8e0, entry=0x7fffffffc510) at parser/parser_common.c:1043
#7 parse_all_processdata (processdata=processdata@entry=0x7fffffffc1b0, readdata=readdata@entry=0x5555555ed8e0, parsed_flags=parsed_flags@entry=8796093022209, testresults=0x55555567a2f0, testresults@entry=0x555555679da0) at parser/parser_common.c:1139
#8 0x00005555555645b1 in parse_array (testresults=0x555555679da0, parsed_flags=8796093022208, readdata=0x5555555ea280, entry=0x7fffffffc550) at parser/parser_common.c:821
#9 parse_one_entry (testresults=0x555555679da0, parsed_flags=8796093022208, readdata=0x5555555ea280, entry=0x7fffffffc550) at parser/parser_common.c:1043
#10 parse_all_processdata (processdata=processdata@entry=0x7fffffffc1d0, readdata=0x5555555ea280, parsed_flags=8796093022208, testresults=testresults@entry=0x555555679da0) at parser/parser_common.c:1139 #11 0x0000555555567ff9 in process_json (processdata=processdata@entry=0x7fffffffc1d0, exp_version=exp_version@entry=0x55555559c2fc "1.0", in=in@entry=0x5555555e9e50, out=out@entry=0x555555679440) at parser/parser_common.c:1199
#12 0x000055555556f45f in ecdh_tester (in=0x5555555e9e50, out=0x555555679440, cipher=<optimized out>) at parser/parser_ecdh.c:280
#13 0x0000555555561a02 in perform_testing (infile=<optimized out>, outfile=0x7fffffffe331 "/tmp/r.j") at parser/parser.c:173
#14 0x000055555555e7be in main (argc=<optimized out>, argv=<optimized out>) at parser/parser.c:916
Alloc the same buf for the second time
Breakpoint 2, alloc_buf (size=size@entry=28, buf=buf@entry=0x7fffffffc218) at parser/stringhelper.c:130
130 {
(gdb) bt
#0 alloc_buf (size=size@entry=28, buf=buf@entry=0x7fffffffc218) at parser/stringhelper.c:130
#1 0x0000555555590997 in openssl_pkey_get_bn_bytes (pkey=pkey@entry=0x55555568c290, name=name@entry=0x5555555a14cb "priv", out=out@entry=0x7fffffffc218) at backends/backend_openssl3.c:71
#2 0x00005555555915af in openssl_ecdh_ss_common (cipher=18014398526259200, Qxrem=0x7fffffffc1f8, Qyrem=0x7fffffffc208, privloc=0x7fffffffc218, Qxloc=0x7fffffffc228, Qyloc=0x7fffffffc238, hashzz=0x7fffffffc248)
at backends/backend_openssl3.c:928
#3 0x0000555555592049 in openssl_ecdh_ss (data=<optimized out>, parsed_flags=<optimized out>) at backends/backend_openssl3.c:1024
#4 0x00005555555668bc in exec_test (testresults=0x55555567a2f0, testvector=0x5555555c1580, parsed_flags=8796093022209, processdata=0x7fffffffc070) at parser/parser_common.c:393
#5 parse_array (testresults=0x55555567a2f0, parsed_flags=8796093022209, readdata=0x5555555ed8e0, entry=0x7fffffffc510) at parser/parser_common.c:826
#6 parse_one_entry (testresults=0x55555567a2f0, parsed_flags=8796093022209, readdata=0x5555555ed8e0, entry=0x7fffffffc510) at parser/parser_common.c:1043
#7 parse_all_processdata (processdata=processdata@entry=0x7fffffffc1b0, readdata=readdata@entry=0x5555555ed8e0, parsed_flags=parsed_flags@entry=8796093022209, testresults=0x55555567a2f0, testresults@entry=0x555555679da0)
at parser/parser_common.c:1139
#8 0x00005555555645b1 in parse_array (testresults=0x555555679da0, parsed_flags=8796093022208, readdata=0x5555555ea280, entry=0x7fffffffc550) at parser/parser_common.c:821
#9 parse_one_entry (testresults=0x555555679da0, parsed_flags=8796093022208, readdata=0x5555555ea280, entry=0x7fffffffc550) at parser/parser_common.c:1043
#10 parse_all_processdata (processdata=processdata@entry=0x7fffffffc1d0, readdata=0x5555555ea280, parsed_flags=8796093022208, testresults=testresults@entry=0x555555679da0) at parser/parser_common.c:1139
#11 0x0000555555567ff9 in process_json (processdata=processdata@entry=0x7fffffffc1d0, exp_version=exp_version@entry=0x55555559c2fc "1.0", in=in@entry=0x5555555e9e50, out=out@entry=0x555555679440) at parser/parser_common.c:1199
#12 0x000055555556f45f in ecdh_tester (in=0x5555555e9e50, out=0x555555679440, cipher=<optimized out>) at parser/parser_ecdh.c:280
#13 0x0000555555561a02 in perform_testing (infile=<optimized out>, outfile=0x7fffffffe331 "/tmp/r.j") at parser/parser.c:173
#14 0x000055555555e7be in main (argc=<optimized out>, argv=<optimized out>) at parser/parser.c:916
(gdb) c
Continuing.
Breakpoint 2, alloc_buf (size=28, buf=0x7fffffffc218) at parser/stringhelper.c:132
132 logger(LOGGER_WARN, "Allocate an already allocated buffer!\n");
Fixed