- xfr-tsig, unit test for tsig sign every couple packets, and verify that.

This commit is contained in:
W.C.A. Wijngaards
2025-09-10 15:26:57 +02:00
parent 7b59014ba3
commit 63aa70ab32
2 changed files with 428 additions and 8 deletions
+16 -6
View File
@@ -128,7 +128,7 @@ static int vtest = 0;
* expected result, the result of the verify call is compared with
* the expected result2, and the test fails if not equal.
*
* tsig-sign-reply-xfr <num> <time> <expected rcode>
* tsig-sign-reply-xfr <num> <time> <expected rcode> <nth>
* packet
* <hex>
* endpacket
@@ -142,7 +142,9 @@ static int vtest = 0;
* used with tsig-sign-reply-xfr and the output is checked with
* the checkhex.
* The expected rcode is from tsig_verify_query. The expected from
* call is from tsig_sign_reply_xfr.
* call is from tsig_sign_reply_xfr. The nth value 0 or 1 means
* sign every packet, but >= 2 signs after a series of unsigned
* packets.
* tsig-verify-reply-xfr <num> <key> <time> <result>
* packet
* <hex>
@@ -1035,8 +1037,9 @@ handle_tsig_sign_reply_xfr(char* line, FILE* in, const char* fname,
struct tsig_key_table* key_table, struct sldns_buffer* pkt)
{
char* arg = get_arg_on_line(line, "tsig-sign-reply-xfr");
char* s, *numstr, *timestr, *expected_rcode_str, *expectedstr2;
int expected_rcode, expected_result2, ret, num, i;
char* s, *numstr, *timestr, *expected_rcode_str, *expectedstr2,
*nthstr;
int expected_rcode, expected_result2, ret, num, i, nth;
uint64_t timepoint;
struct tsig_data* tsig;
size_t pos;
@@ -1049,6 +1052,7 @@ handle_tsig_sign_reply_xfr(char* line, FILE* in, const char* fname,
numstr = get_next_arg_on_line(&s);
timestr = get_next_arg_on_line(&s);
expected_rcode_str = get_next_arg_on_line(&s);
nthstr = get_next_arg_on_line(&s);
num = atoi(numstr);
if(num == 0 && strcmp(numstr, "0") != 0)
@@ -1062,12 +1066,17 @@ handle_tsig_sign_reply_xfr(char* line, FILE* in, const char* fname,
strcmp(expected_rcode_str, "RCODE0") != 0)
fatal_exit("expected rcode argument for %s",
expected_rcode_str);
nth = atoi(nthstr);
if(nth == 0 && strcmp(nthstr, "0") != 0)
fatal_exit("expected int argument for %s", nthstr);
if(nth == 0)
nth = 1;
if(vtest) {
char bufrc[16];
sldns_wire2str_rcode_buf(expected_rcode, bufrc, sizeof(bufrc));
printf("tsig-sign-reply-xfr with %d %d %s\n", num,
(int)timepoint, bufrc);
printf("tsig-sign-reply-xfr with %d %d %s %d\n", num,
(int)timepoint, bufrc, nth);
}
/* Verify the query in the packet buffer. Use that TSIG to sign
@@ -1089,6 +1098,7 @@ handle_tsig_sign_reply_xfr(char* line, FILE* in, const char* fname,
ret, expected_rcode, bufrc);
}
unit_assert(ret == expected_rcode);
tsig->every_nth = nth;
/* Sign the reply packets. */
for(i=0; i<num; i++) {
+412 -2
View File
@@ -118,8 +118,8 @@ endpacket
packet
1c9600000001000000000002076578616d706c6503636f6d0000fc000100002910000000000000000474657374036b65790000fa00ff00000000003d0b686d61632d73686132353600000068c01a52012c00202f017432ef8f8ef3dab9be9f9c4765eda7939f0485dfe384206e97e13acbd8f91c9600000000
endpacket
# <number of packets> <time> <rcode for query process>
tsig-sign-reply-xfr 24 1757420114 NOERROR
# <number of packets> <time> <rcode for query process> <every nth>
tsig-sign-reply-xfr 24 1757420114 NOERROR 1
# packet 1
# unsigned input before the TSIG is added
# (without TSIG so, ARcount 02->01, RR TSIG 0474657374036b657900.. deleted.)
@@ -807,3 +807,413 @@ packet
endpacket
call 1757422133 0 1
# end of tsig-verify-reply-xfr test, example.com AXFR with TSIG every couple packets, with NTH 3.
# tsig-sign-reply-xfr test, with sign every NTH 4.
# the incoming query, example.com AXFR
packet
1c9600000001000000000002076578616d706c6503636f6d0000fc000100002910000000000000000474657374036b65790000fa00ff00000000003d0b686d61632d73686132353600000068c01a52012c00202f017432ef8f8ef3dab9be9f9c4765eda7939f0485dfe384206e97e13acbd8f91c9600000000
endpacket
# <number of packets> <time> <rcode for query process> <every nth>
tsig-sign-reply-xfr 24 1757420114 NOERROR 4
# packet 1
# unsigned input before the TSIG is added
# (without TSIG so, ARcount 02->01, RR TSIG 0474657374036b657900.. deleted.)
packet
1c9684000001000200000001076578616d706c6503636f6d0000fc0001c00c0006000100000e100023c00c0a686f73746d6173746572c00c5cd7fffe00000e10000003840012750000000708c00c0001000100000e1000043ed26e0700002904d0000000000000
endpacket
# call information of the TSIG routine.
# <timepoint> <expected function return value>
call 1757420114 1
# check for output packet that is the result of TSIG signature.
check-packet
1c9684000001000200000002076578616d706c6503636f6d0000fc0001c00c0006000100000e100023c00c0a686f73746d6173746572c00c5cd7fffe00000e10000003840012750000000708c00c0001000100000e1000043ed26e0700002904d00000000000000474657374036b65790000fa00ff00000000003d0b686d61632d73686132353600000068c01a52012c00200fe349e19b5b3e952c097db0dfef9430734da92125ab1d4542d450774f352b4d1c9600000000
endpacket
# packet 2
packet
1c9684000000000200000000076578616d706c6503636f6d000002000100000e100005026e73c00cc00c000f000100000e1000070005026d78c00c
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000076578616d706c6503636f6d000002000100000e100005026e73c00cc00c000f000100000e1000070005026d78c00c
endpacket
# packet 3
packet
1c96840000000002000000000131026161076578616d706c6503636f6d000001000100000e1000047f000001023130c00e0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c96840000000002000000000131026161076578616d706c6503636f6d000001000100000e1000047f000001023130c00e0001000100000e1000047f000001
endpacket
# packet 4
packet
1c9684000000000200000000023131026161076578616d706c6503636f6d000001000100000e1000047f000001023132c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023131026161076578616d706c6503636f6d000001000100000e1000047f000001023132c00f0001000100000e1000047f000001
endpacket
# packet 5
packet
1c9684000000000200000000023133026161076578616d706c6503636f6d000001000100000e1000047f000001023134c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1C9684000000000200000001023133026161076578616D706C6503636F6D000001000100000E1000047F000001023134C00F0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C0020EA1EA499445B22973D520C943E9C74862BC6199756C6EEEAEDB910B5B95F5DDE1C9600000000
endpacket
# packet 6
packet
1c9684000000000200000000023135026161076578616d706c6503636f6d000001000100000e1000047f000001023136c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023135026161076578616d706c6503636f6d000001000100000e1000047f000001023136c00f0001000100000e1000047f000001
endpacket
# packet 7
packet
1c9684000000000200000000023137026161076578616d706c6503636f6d000001000100000e1000047f000001023138c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023137026161076578616d706c6503636f6d000001000100000e1000047f000001023138c00f0001000100000e1000047f000001
endpacket
# packet 8
packet
1c9684000000000200000000023139026161076578616d706c6503636f6d000001000100000e1000047f0000010132c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023139026161076578616d706c6503636f6d000001000100000e1000047f0000010132c00f0001000100000e1000047f000001
endpacket
# packet 9
packet
1c9684000000000200000000023230026161076578616d706c6503636f6d000001000100000e1000047f000001023231c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1C9684000000000200000001023230026161076578616D706C6503636F6D000001000100000E1000047F000001023231C00F0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C00206BE65187F773EA73C625ADF32ECA31BD924B12BA2D5FAAB19E889D71D6E491F91C9600000000
endpacket
# packet 10
packet
1c9684000000000200000000023232026161076578616d706c6503636f6d000001000100000e1000047f000001023233c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023232026161076578616d706c6503636f6d000001000100000e1000047f000001023233c00f0001000100000e1000047f000001
endpacket
# packet 11
packet
1c9684000000000200000000023234026161076578616d706c6503636f6d000001000100000e1000047f000001023235c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023234026161076578616d706c6503636f6d000001000100000e1000047f000001023235c00f0001000100000e1000047f000001
endpacket
# packet 12
packet
1c9684000000000200000000023236026161076578616d706c6503636f6d000001000100000e1000047f000001023237c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000023236026161076578616d706c6503636f6d000001000100000e1000047f000001023237c00f0001000100000e1000047f000001
endpacket
# packet 13
packet
1c9684000000000200000000023238026161076578616d706c6503636f6d000001000100000e1000047f000001023239c00f0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1C9684000000000200000001023238026161076578616D706C6503636F6D000001000100000E1000047F000001023239C00F0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C00206B1322C8E58155267B7A4FBBEA955EAF6D9A84C64AC3DCC32F155823C6F76F111C9600000000
endpacket
# packet 14
packet
1c96840000000002000000000133026161076578616d706c6503636f6d000001000100000e1000047f000001023330c00e0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c96840000000002000000000133026161076578616d706c6503636f6d000001000100000e1000047f000001023330c00e0001000100000e1000047f000001
endpacket
# packet 15
packet
1c96840000000002000000000134026161076578616d706c6503636f6d000001000100000e1000047f0000010135c00e0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c96840000000002000000000134026161076578616d706c6503636f6d000001000100000e1000047f0000010135c00e0001000100000e1000047f000001
endpacket
# packet 16
packet
1c96840000000002000000000136026161076578616d706c6503636f6d000001000100000e1000047f0000010137c00e0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1c96840000000002000000000136026161076578616d706c6503636f6d000001000100000e1000047f0000010137c00e0001000100000e1000047f000001
endpacket
# packet 17
packet
1c96840000000002000000000138026161076578616d706c6503636f6d000001000100000e1000047f0000010139c00e0001000100000e1000047f000001
endpacket
call 1757420114 1
check-packet
1C96840000000002000000010138026161076578616D706C6503636F6D000001000100000E1000047F0000010139C00E0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C00209103348E4D403BCC1EC78E8CCAA664DCE265114FAD039BCC026A75C5F774924C1C9600000000
endpacket
# packet 18
packet
1c9684000000000200000000012a01630164076578616d706c6503636f6d000010000100000e1000222174657874207265636f72642077697468206d61696c207065726d697373696f6e73c00c000f000100000e1000070005026d78c012
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000012a01630164076578616d706c6503636f6d000010000100000e1000222174657874207265636f72642077697468206d61696c207065726d697373696f6e73c00c000f000100000e1000070005026d78c012
endpacket
# packet 19
packet
1c968400000000020000000004646f6e65076578616d706c6503636f6d000001000100000e100004010101010166c0110027000100000e10001101780166076578616d706c6503636f6d00
endpacket
call 1757420114 1
check-packet
1c968400000000020000000004646f6e65076578616d706c6503636f6d000001000100000e100004010101010166c0110027000100000e10001101780166076578616d706c6503636f6d00
endpacket
# packet 20
packet
1c9684000000000200000000026d78076578616d706c6503636f6d000001000100000e1000043ed26e07026e73c00f0001000100000e1000043ed26e07
endpacket
call 1757420114 1
check-packet
1c9684000000000200000000026d78076578616d706c6503636f6d000001000100000e1000043ed26e07026e73c00f0001000100000e1000043ed26e07
endpacket
# packet 21
packet
1c9684000000000200000000027274076578616d706c6503636f6d000010000100000e1000130261620263640665662267682202696a026b6c03727432c00f0010000100000e10000d06616263646566056768696a6b
endpacket
call 1757420114 1
check-packet
1C9684000000000200000001027274076578616D706C6503636F6D000010000100000E1000130261620263640665662267682202696A026B6C03727432C00F0010000100000E10000D06616263646566056768696A6B0474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C0020991A6D7C00BAF001961905D3977AEDB8205C0301EAE0B66D0E79580FD7E4AFBA1C9600000000
endpacket
# packet 22
packet
1c968400000000020000000003727433076578616d706c6503636f6d000010000100000e10001202616202636402656602676802696a026b6c03727434c0100010000100000e10000d06616263646566056768696a6b
endpacket
call 1757420114 1
check-packet
1c968400000000020000000003727433076578616d706c6503636f6d000010000100000e10001202616202636402656602676802696a026b6c03727434c0100010000100000e10000d06616263646566056768696a6b
endpacket
# packet 23
packet
1c96840000000002000000000178076578616d706c6503636f6d000027000100000e10000f0179076578616d706c6503636f6d0003666f6f0179c00e0005000100000e10000704646f6e65c00e
endpacket
call 1757420114 1
check-packet
1c96840000000002000000000178076578616d706c6503636f6d000027000100000e10000f0179076578616d706c6503636f6d0003666f6f0179c00e0005000100000e10000704646f6e65c00e
endpacket
# packet 24
packet
1c9684000000000100000000076578616d706c6503636f6d000006000100000e100023c00c0a686f73746d6173746572c00c5cd7fffe00000e10000003840012750000000708
endpacket
call 1757420114 1
check-packet
1C9684000000000100000001076578616D706C6503636F6D000006000100000E100023C00C0A686F73746D6173746572C00C5CD7FFFE00000E100000038400127500000007080474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C002016157B504809CE8A6BD6E785C431A6D784787B41BEBC0FB3F83CEB7D5E2722F01C9600000000
endpacket
# end of tsig-sign-reply-xfr test, example.com AXFR, with sign every NTH 4.
# tsig-verify-reply-xfr test, example.com AXFR with TSIG every NTH from
# signed sequence
# The signed sequence is from tsig-sign-reply-xfr.
# the query packet.
packet
1c9600000001000000000001076578616d706c6503636f6d0000fc00010000291000000000000000
endpacket
# <number of packets> <keyname> <time> <tsig-sign-query result>
tsig-verify-reply-xfr 24 test.key 1757420114 1
# packet 1
packet
1c9684000001000200000002076578616d706c6503636f6d0000fc0001c00c0006000100000e100023c00c0a686f73746d6173746572c00c5cd7fffe00000e10000003840012750000000708c00c0001000100000e1000043ed26e0700002904d00000000000000474657374036b65790000fa00ff00000000003d0b686d61632d73686132353600000068c01a52012c00200fe349e19b5b3e952c097db0dfef9430734da92125ab1d4542d450774f352b4d1c9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 2
packet
1c9684000000000200000000076578616d706c6503636f6d000002000100000e100005026e73c00cc00c000f000100000e1000070005026d78c00c
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 3
packet
1c96840000000002000000000131026161076578616d706c6503636f6d000001000100000e1000047f000001023130c00e0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 4
packet
1c9684000000000200000000023131026161076578616d706c6503636f6d000001000100000e1000047f000001023132c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 5
packet
1C9684000000000200000001023133026161076578616D706C6503636F6D000001000100000E1000047F000001023134C00F0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C0020EA1EA499445B22973D520C943E9C74862BC6199756C6EEEAEDB910B5B95F5DDE1C9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 6
packet
1c9684000000000200000000023135026161076578616d706c6503636f6d000001000100000e1000047f000001023136c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 7
packet
1c9684000000000200000000023137026161076578616d706c6503636f6d000001000100000e1000047f000001023138c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 8
packet
1c9684000000000200000000023139026161076578616d706c6503636f6d000001000100000e1000047f0000010132c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 9
packet
1C9684000000000200000001023230026161076578616D706C6503636F6D000001000100000E1000047F000001023231C00F0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C00206BE65187F773EA73C625ADF32ECA31BD924B12BA2D5FAAB19E889D71D6E491F91C9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 10
packet
1c9684000000000200000000023232026161076578616d706c6503636f6d000001000100000e1000047f000001023233c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 11
packet
1c9684000000000200000000023234026161076578616d706c6503636f6d000001000100000e1000047f000001023235c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 12
packet
1c9684000000000200000000023236026161076578616d706c6503636f6d000001000100000e1000047f000001023237c00f0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 13
packet
1C9684000000000200000001023238026161076578616D706C6503636F6D000001000100000E1000047F000001023239C00F0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C00206B1322C8E58155267B7A4FBBEA955EAF6D9A84C64AC3DCC32F155823C6F76F111C9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 14
packet
1c96840000000002000000000133026161076578616d706c6503636f6d000001000100000e1000047f000001023330c00e0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 15
packet
1c96840000000002000000000134026161076578616d706c6503636f6d000001000100000e1000047f0000010135c00e0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 16
packet
1c96840000000002000000000136026161076578616d706c6503636f6d000001000100000e1000047f0000010137c00e0001000100000e1000047f000001
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 17
packet
1C96840000000002000000010138026161076578616D706C6503636F6D000001000100000E1000047F0000010139C00E0001000100000E1000047F0000010474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C00209103348E4D403BCC1EC78E8CCAA664DCE265114FAD039BCC026A75C5F774924C1C9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 18
packet
1c9684000000000200000000012a01630164076578616d706c6503636f6d000010000100000e1000222174657874207265636f72642077697468206d61696c207065726d697373696f6e73c00c000f000100000e1000070005026d78c012
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 19
packet
1c968400000000020000000004646f6e65076578616d706c6503636f6d000001000100000e100004010101010166c0110027000100000e10001101780166076578616d706c6503636f6d00
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 20
packet
1c9684000000000200000000026d78076578616d706c6503636f6d000001000100000e1000043ed26e07026e73c00f0001000100000e1000043ed26e07
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 21
packet
1C9684000000000200000001027274076578616D706C6503636F6D000010000100000E1000130261620263640665662267682202696A026B6C03727432C00F0010000100000E10000D06616263646566056768696A6B0474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C0020991A6D7C00BAF001961905D3977AEDB8205C0301EAE0B66D0E79580FD7E4AFBA1C9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 22
packet
1c968400000000020000000003727433076578616d706c6503636f6d000010000100000e10001202616202636402656602676802696a026b6c03727434c0100010000100000e10000d06616263646566056768696a6b
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 23
packet
1c96840000000002000000000178076578616d706c6503636f6d000027000100000e10000f0179076578616d706c6503636f6d0003666f6f0179c00e0005000100000e10000704646f6e65c00e
endpacket
# <time> <last_packet> <function result>
call 1757420114 0 1
# packet 24
packet
1C9684000000000100000001076578616D706C6503636F6D000006000100000E100023C00C0A686F73746D6173746572C00C5CD7FFFE00000E100000038400127500000007080474657374036B65790000FA00FF00000000003D0B686D61632D73686132353600000068C01A52012C002016157B504809CE8A6BD6E785C431A6D784787B41BEBC0FB3F83CEB7D5E2722F01C9600000000
endpacket
# <time> <last_packet> <function result>
call 1757420114 1 1
# end of tsig-verify-reply-xfr test, example.com AXFR with TSIG every NTH from
# signed sequence