From a8b8641a2028689feebbb5d4d7d20447ad5ffa4d Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 5 May 2017 15:16:59 +0200 Subject: tests: check decoding with ASN1_DECODE_FLAG_ALLOW_INCORRECT_TIME flag Signed-off-by: Nikos Mavrogiannopoulos --- tests/Makefile.am | 1 + tests/cert-invalid-time.der | Bin 0 -> 1136 bytes tests/decoding | 14 ++++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/cert-invalid-time.der diff --git a/tests/Makefile.am b/tests/Makefile.am index bea3310..0b45543 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,6 +25,7 @@ LDADD = ../lib/libtasn1.la ../gl/libgnu.la EXTRA_DIST = Test_parser.asn Test_tree.asn Test_tree_asn1_tab.c mscat.asn \ Test_encoding.asn pkix.asn TestIndef.p12 choice.asn coding-decoding2.asn \ TestIndef2.p12 TestIndef3.der TestCertOctetOverflow.der \ + cert-invalid-time.der \ libtasn1.supp ocsp-basic-response.der spc_pe_image_data.der \ invalid-x509/id-000000.der invalid-x509/id-000001.der \ invalid-x509/id-000002.der invalid-x509/id-000003.der \ diff --git a/tests/cert-invalid-time.der b/tests/cert-invalid-time.der new file mode 100644 index 0000000..994ea3f Binary files /dev/null and b/tests/cert-invalid-time.der differ diff --git a/tests/decoding b/tests/decoding index dd2c685..200a8b8 100755 --- a/tests/decoding +++ b/tests/decoding @@ -28,4 +28,18 @@ if test $? != 1;then exit 1 fi +# test decoding of certificate with invalid time field +$VALGRIND $ASN1DECODING -s $ASN1PKIX cert-invalid-time.der PKIX1.Certificate +if test $? != 1;then + echo "Decoding with invalid time succeeded when not expected" + exit 1 +fi + +# test decoding of certificate with invalid time field +$VALGRIND $ASN1DECODING -t $ASN1PKIX cert-invalid-time.der PKIX1.Certificate +if test $? != 0;then + echo "Decoding with invalid time failed when not expected" + exit 1 +fi + exit 0 -- cgit v1.2.1