Skip to content

Commit d28ef9e

Browse files
committed
wo#7449 . added lo06-verifybadsigs test case
This unit test case is a clone of lo02-verifysigs. However, instead of testing successful sign/verify operation, it applies various corruptions to the signature and validates that verify_signed_hash() can handle the error. Special thanks to Sze Yiu Chau of Purdue University ([email protected]) who reported the issue.
1 parent c36bf6c commit d28ef9e

File tree

6 files changed

+1890
-0
lines changed

6 files changed

+1890
-0
lines changed

tests/unit/libopenswan/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ clean check:
2222
@${MAKE} -C lo03-includesecrets $@
2323
@${MAKE} -C lo04-verifypubkeys $@
2424
@${MAKE} -C lo05-datatot $@
25+
@${MAKE} -C lo06-verifybadsigs $@
2526

2627

2728

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gdbinit
2+
OUTPUT
3+
verifybadsigs
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# OpenS/WAN testing makefile
2+
# Copyright (C) 2018 Bart Trojanowski <[email protected]>
3+
# Copyright (C) 2014 Michael Richardson <[email protected]>
4+
# Copyright (C) 2002 Michael Richardson <[email protected]>
5+
#
6+
# This program is free software; you can redistribute it and/or modify it
7+
# under the terms of the GNU General Public License as published by the
8+
# Free Software Foundation; either version 2 of the License, or (at your
9+
# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10+
#
11+
# This program is distributed in the hope that it will be useful, but
12+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13+
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
# for more details.
15+
16+
OPENSWANSRCDIR?=$(shell cd ../../../..; pwd)
17+
srcdir?=${OPENSWANSRCDIR}/tests/unit/libpluto/lp01-spdbtest
18+
include $(OPENSWANSRCDIR)/Makefile.inc
19+
20+
EXTRAFLAGS+=${USERCOMPILE} ${PORTINCLUDE}
21+
EXTRAFLAGS+=-I${OPENSWANSRCDIR}/programs/pluto
22+
EXTRAFLAGS+=-I${OPENSWANSRCDIR}/include/pluto
23+
EXTRAFLAGS+=-I${OPENSWANSRCDIR}/include
24+
EXTRALIBS+=${LIBOSWLOG} ${LIBOPENSWAN} ${LIBOSWLOG} ${LIBOSWKEYS}
25+
EXTRALIBS+=${NSS_LIBS} ${FIPS_LIBS} ${LIBGMP} ${CRYPTOLIBS}
26+
27+
EXTRAFLAGS+=${NSS_FLAGS} ${FIPS_FLAGS}
28+
EXTRAFLAGS+=${NSS_HDRDIRS} ${FIPS_HDRDIRS}
29+
30+
TESTNUMBER=lo06-verifybadsigs
31+
TESTNAME=verifybadsigs
32+
UNITTESTARGS=
33+
34+
check: ${TESTNAME}
35+
@mkdir -p OUTPUT
36+
${COREULIMIT} && ./${TESTNAME} ${UNITTESTARGS} >OUTPUT/${TESTNAME}.txt 2>&1
37+
diff OUTPUT/${TESTNAME}.txt output.txt
38+
@: recordresults lib-$testobj "$testexpect" "$stat" lib-$testobj false
39+
40+
.PHONY: ${TESTNAME}
41+
${TESTNAME}: ${TESTNAME}.c
42+
@echo CC ${TESTNAME}.c
43+
@${CC} -o ${TESTNAME} ${EXTRAFLAGS} ${TESTNAME}.c ${EXTRALIBS} ${EXTRALIBS}
44+
@echo "file ${TESTNAME}" >.gdbinit
45+
@echo "set args "${UNITTESTARGS} >>.gdbinit
46+
47+
update:
48+
cp OUTPUT/${TESTNAME}.txt output.txt
49+
50+
51+
initiate:
52+
(echo ': RSA {'; ${OBJDIRTOP}/programs/rsasigkey/rsasigkey --random /dev/urandom 512 --hostname fivetwelve; echo ' }') >key-0512.secrets
53+
(echo ': RSA {'; ${OBJDIRTOP}/programs/rsasigkey/rsasigkey --random /dev/urandom 1024 --hostname fivetwelve; echo ' }') >key-1024.secrets
54+
(echo ': RSA {'; ${OBJDIRTOP}/programs/rsasigkey/rsasigkey --random /dev/urandom 2048 --hostname fivetwelve; echo ' }') >key-2048.secrets
55+
(echo ': RSA {'; ${OBJDIRTOP}/programs/rsasigkey/rsasigkey --random /dev/urandom 3072 --hostname fivetwelve; echo ' }') >key-3072.secrets
56+
(echo ': RSA {'; ${OBJDIRTOP}/programs/rsasigkey/rsasigkey --random /dev/urandom 4096 --hostname fivetwelve; echo ' }') >key-4096.secrets
57+
(echo ': RSA {'; ${OBJDIRTOP}/programs/rsasigkey/rsasigkey --random /dev/urandom 8192 --hostname fivetwelve; echo ' }') >key-8192.secrets
58+
59+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This unit test case is a clone of lo02-verifysigs. However, instead of testing
2+
successful sign/verify operation, it applies various corruptions to the signature
3+
and validates that verify_signed_hash() can handle the error.
4+
5+
This test reuses *.secrets files from ../lo02-verifysigs

0 commit comments

Comments
 (0)