From 0790908cb0dd035f6dfe5bb27ecddb9af1596f5e Mon Sep 17 00:00:00 2001 From: Janne Johansson Date: Thu, 22 Jun 2017 16:11:29 +0300 Subject: [PATCH] MatrixSSL 3.9.3 --- Makefile | 9 + apps/ssl/client.c | 63 +- apps/ssl/runClient.sh | 18 +- common.mk | 53 +- configs/default/cryptoConfig.h | 7 +- configs/default/matrixsslConfig.h | 16 + configs/noecc/cryptoConfig.h | 7 +- configs/noecc/matrixsslConfig.h | 16 + configs/psk/cryptoConfig.h | 7 +- configs/psk/matrixsslConfig.h | 16 + configs/rsaonly/cryptoConfig.h | 7 +- configs/rsaonly/matrixsslConfig.h | 16 + configs/tls/cryptoConfig.h | 7 +- configs/tls/matrixsslConfig.h | 16 + core/POSIX/osdep.c | 103 +- core/psbuf.c | 10 + core/psbuf.h | 35 + crypto/cryptoApi.h | 35 +- crypto/cryptolib.h | 35 + crypto/keyformat/asn1.c | 49 + crypto/keyformat/asn1.h | 2 + crypto/keyformat/pkcs.c | 80 +- crypto/keyformat/x509.c | 1512 ++++++++++++-------- crypto/keyformat/x509.h | 4 + crypto/layer/layer.h | 5 +- crypto/layer/matrix.c | 21 +- crypto/pubkey/ecc.c | 4 +- crypto/pubkey/pubkey.c | 180 ++- crypto/pubkey/pubkey.h | 3 +- crypto/test/Makefile | 8 + crypto/test/algorithmTest.c | 9 +- crypto/test/cryptoOpen.c | 55 + crypto/test/cryptoOpenTest.sh | 119 ++ crypto/test/ocspTest.c | 565 ++++++++ crypto/test/ocspTestData.h | 950 ++++++++++++ doc/CHANGES_v3.9.html | 29 + doc/CHANGES_v3.9.md | 74 + doc/CHANGES_v3.9.txt | 82 ++ doc/MatrixSSL_GettingStarted.pdf | Bin 870555 -> 484372 bytes doc/matrixssl_dev_guide.md | 730 ++++++---- makefiles/libsodium_support.mk | 65 + makefiles/prepkg.mk | 59 + makefiles/rules.mk | 38 + makefiles/testsupp.mk | 16 + matrixssl/cipherSuite.c | 6 + matrixssl/hsDecode.c | 9 + matrixssl/matrixssl.c | 161 ++- matrixssl/matrixsslApi.c | 5 + matrixssl/matrixsslApi.h | 14 + matrixssl/matrixssllib.h | 11 + matrixssl/version.h | 4 +- release_notes-3-9-1-open.html | 20 - release_notes-3-9-3-open.html | 49 + testkeys/DSA/DSA_KEY_1024_160.pem | 12 + testkeys/DSA/DSA_KEY_2048_160.pem | 20 + testkeys/DSA/DSA_KEY_2048_224.pem | 20 + testkeys/DSA/DSA_KEY_2048_256.der | Bin 0 -> 857 bytes testkeys/DSA/DSA_KEY_2048_256.p8 | Bin 0 -> 661 bytes testkeys/DSA/DSA_KEY_2048_256.pem | 20 + testkeys/DSA/DSA_PARAMETERS_1024_160.pem | 9 + testkeys/DSA/DSA_PARAMETERS_2048_160.pem | 14 + testkeys/DSA/DSA_PUB_1024_160.pem | 12 + testkeys/DSA/DSA_PUB_2048_160.pem | 20 + testkeys/DSA/DSA_PUB_2048_224.pem | 20 + testkeys/DSA/DSA_PUB_2048_256.pem | 20 + testkeys/DSA/DSA_SIGN_abc_1024_160.h | 7 + testkeys/DSA/DSA_SIGN_abc_2048_160.h | 7 + testkeys/DSA/DSA_SIGN_abc_2048_224.h | 9 + testkeys/DSA/DSA_SIGN_abc_2048_256.h | 9 + testkeys/RSA/2048_RSA_KEY.p8 | Bin 0 -> 1261 bytes thirdparty/README | 5 + xcode/client.xcodeproj/project.pbxproj | 4 +- xcode/core.xcodeproj/project.pbxproj | 6 +- xcode/crypto.xcodeproj/project.pbxproj | 54 +- xcode/dtlsClient.xcodeproj/project.pbxproj | 4 +- xcode/dtlsServer.xcodeproj/project.pbxproj | 4 +- xcode/matrixssl.xcodeproj/project.pbxproj | 8 +- xcode/server.xcodeproj/project.pbxproj | 4 +- xcode/sshServer.xcodeproj/project.pbxproj | 298 ++++ xcode/sslTest.xcodeproj/project.pbxproj | 4 +- 80 files changed, 4908 insertions(+), 1096 deletions(-) create mode 100644 crypto/test/cryptoOpen.c create mode 100755 crypto/test/cryptoOpenTest.sh create mode 100644 crypto/test/ocspTest.c create mode 100644 crypto/test/ocspTestData.h create mode 100644 makefiles/libsodium_support.mk create mode 100644 makefiles/prepkg.mk create mode 100644 makefiles/rules.mk create mode 100644 makefiles/testsupp.mk delete mode 100644 release_notes-3-9-1-open.html create mode 100644 release_notes-3-9-3-open.html create mode 100644 testkeys/DSA/DSA_KEY_1024_160.pem create mode 100644 testkeys/DSA/DSA_KEY_2048_160.pem create mode 100644 testkeys/DSA/DSA_KEY_2048_224.pem create mode 100644 testkeys/DSA/DSA_KEY_2048_256.der create mode 100644 testkeys/DSA/DSA_KEY_2048_256.p8 create mode 100644 testkeys/DSA/DSA_KEY_2048_256.pem create mode 100644 testkeys/DSA/DSA_PARAMETERS_1024_160.pem create mode 100644 testkeys/DSA/DSA_PARAMETERS_2048_160.pem create mode 100644 testkeys/DSA/DSA_PUB_1024_160.pem create mode 100644 testkeys/DSA/DSA_PUB_2048_160.pem create mode 100644 testkeys/DSA/DSA_PUB_2048_224.pem create mode 100644 testkeys/DSA/DSA_PUB_2048_256.pem create mode 100644 testkeys/DSA/DSA_SIGN_abc_1024_160.h create mode 100644 testkeys/DSA/DSA_SIGN_abc_2048_160.h create mode 100644 testkeys/DSA/DSA_SIGN_abc_2048_224.h create mode 100644 testkeys/DSA/DSA_SIGN_abc_2048_256.h create mode 100644 testkeys/RSA/2048_RSA_KEY.p8 create mode 100644 thirdparty/README create mode 100644 xcode/sshServer.xcodeproj/project.pbxproj diff --git a/Makefile b/Makefile index 128b945..8f2ff21 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,8 @@ # non-FIPS Mode of operation. # make all-combined Compile MatrixSSL FIPS Edition allowing run-time # selection of FIPS or non-FIPS mode. +# make all-openssl-compat A configuration specially tailored for use +# with the OpenSSL compatibility layer. # make all-combined-default-nonfips The same than make all combined, but # non-FIPS mode is the default. # @@ -164,6 +166,10 @@ all-combined-fulltest: make combined-fulltest-config make all +all-openssl-compat: + make openssl-compat-config + make all + ifneq (,$(findstring clean,$(MAKECMDGOALS))) SUBARGS:=clean endif @@ -247,3 +253,6 @@ clean: clobber: clean clean-config +# Always use common.mk for possible additional rules and processing. +COMMON_MK_NO_TARGETS:=1 +include common.mk diff --git a/apps/ssl/client.c b/apps/ssl/client.c index b64061c..886d805 100644 --- a/apps/ssl/client.c +++ b/apps/ssl/client.c @@ -62,9 +62,9 @@ If supporting client authentication, pick ONE identity to auto select a certificate and private key that support desired algorithms. */ -/* #define ID_RSA / * RSA Certificate and Key * / */ -/* #define ID_ECDH_ECDSA / * EC Certificate and Key * / */ -/* #define ID_ECDH_RSA / * EC Key with RSA signed certificate * / */ +/* #define ID_RSA */ /* RSA Certificate and Key */ +/* #define ID_ECDH_ECDSA */ /* EC Certificate and Key */ +/* #define ID_ECDH_RSA */ /* EC Key with RSA signed certificate */ # if !defined(ID_RSA) && !defined(ID_ECDH_ECDSA) && !defined(ID_ECDH_RSA) /* Choose a default identity based on which algorithms are supported. */ @@ -82,12 +82,28 @@ # endif /* !ID_RSA && !ID_ECDH_ECDSA && !ID_ECDH_RSA */ # define USE_HEADER_KEYS -# define ALLOW_ANON_CONNECTIONS 1 +# define ALLOW_ANON_CONNECTIONS 0 # define CRL_MAX_LENGTH 1048576 /* Maximum length for CRL: 1 megabyte. */ /* If the algorithm type is supported, load a CA for it */ # ifdef USE_ECC_CIPHER_SUITE +/* + If ALLOW_CA_BUNDLE_PARTIAL_PARSE is defined, we can simply try to load + all EC CA certs, even if we are not able to parse all of them. +*/ +# ifdef ALLOW_CA_BUNDLE_PARTIAL_PARSE +# ifdef USE_HEADER_KEYS +# include "testkeys/EC/ALL_EC_CAS.h" +# else +static char ecCAFile[] = "../../testkeys/EC/ALL_EC_CAS.pem"; +# endif /* USE_HEADER_KEYS */ +# else /* !(ALLOW_CA_BUNDLE_PARTIAL_PARSE) */ +/* + If ALLOW_CA_BUNDLE_PARTIAL_PARSE is not defined, we need the following, + ugly code to load only those CA bundles, where each cert is supported + by the present configuration. +*/ # if defined(USE_SECP192R1) && defined(USE_SECP224R1) && defined(USE_SECP521R1) # ifdef USE_HEADER_KEYS # include "testkeys/EC/ALL_EC_CAS.h" @@ -152,6 +168,8 @@ static char ecCAFile[] = "../../testkeys/EC/ALL_EC_CAS_EXCEPT_P192_P224_AND_P521 # endif /* USE_HEADER_KEYS */ # endif /* !USE_SECP192R1 && USE_SECP224R1 && !USE_SECP521R1 */ +#endif /* ALLOW_CA_BUNDLE_PARTIAL_PARSE */ + # ifndef USE_HEADER_KEYS /* Pointer to filename. We shall increment this when we need to @@ -237,6 +255,8 @@ static char *pEcdhRsaPrivkeyFile = ecdhRsaPrivkeyFile; # ifdef REHANDSHAKE_TEST static int g_rehandshakeFlag = 0; # endif + +static char *g_ca_file; # endif /* USE_HEADER_KEYS */ /* @@ -421,6 +441,13 @@ static int32 httpsClientConnection(sslKeys_t *keys, sslSessionId_t *sid, if (g_max_verify_depth != 0) options.validateCertsOpts.max_verify_depth = g_max_verify_depth; + /* + Do not allow the server to pick different version than what + we select here. Break the connection attempt with a protocol_version + alert if ServerHello.server_version < ClientHello.client_version. + */ + options.clientRejectVersionDowngrade = 1; + matrixSslNewHelloExtension(&extension, NULL); matrixSslCreateSNIext(NULL, (unsigned char *) g_ip, (uint32) strlen(g_ip), &ext, &extLen); @@ -1017,7 +1044,7 @@ static int32 process_cmd_options(int32 argc, char **argv) g_keepalive = 0; opterr = 0; - while ((optionChar = getopt(argc, argv, "ab:c:dhk:Km:n:p:r:s:u:V:e:")) != -1) + while ((optionChar = getopt(argc, argv, "ab:C:c:de:hk:Km:n:p:r:s:u:V:")) != -1) { switch (optionChar) { @@ -1039,6 +1066,15 @@ static int32 process_cmd_options(int32 argc, char **argv) snprintf(g_path, sizeof(g_path), "/bytes?%u", g_bytes_requested); break; + case 'C': +#ifdef USE_HEADER_KEYS + printf("USE_HEADER_KEYS not compatible with CA file option\n"); +#else + g_ca_file = optarg; + printf("Using CA file: %s\n", g_ca_file); +#endif + break; + case 'c': /* Convert the cipherListString into an array of cipher numbers. */ cipherListString = optarg; @@ -1135,7 +1171,6 @@ int32 main(int32 argc, char **argv) sslSessionId_t *sid = NULL; struct g_sslstats stats; unsigned char *CAstream; - # if defined(USE_HEADER_KEYS) && !defined(ID_RSA) const unsigned char *key_buf; int32 key_buf_len; @@ -1143,6 +1178,7 @@ int32 main(int32 argc, char **argv) # ifndef USE_HEADER_KEYS unsigned char *tmp_buf; int32 tmp_buf_len; + char *pCA; # endif /* USE_HEADER_KEYS */ # ifdef WIN32 WSADATA wsaData; @@ -1373,9 +1409,13 @@ int32 main(int32 argc, char **argv) { pRsaPrivkeyFile = NULL; } + if (g_ca_file != NULL) + pCA = g_ca_file; + else + pCA = (char*)CAstream; - if ((rc = matrixSslLoadRsaKeys(keys, pRsaCertFile, pRsaPrivkeyFile, NULL, - (char *) CAstream)) < 0) + if ((rc = matrixSslLoadRsaKeys(keys, pRsaCertFile, pRsaPrivkeyFile, + NULL, pCA) < 0)) { _psTrace("No certificate material loaded. Exiting\n"); if (CAstream) @@ -1400,8 +1440,13 @@ int32 main(int32 argc, char **argv) pEcdhRsaPrivkeyFile = NULL; } + if (g_ca_file != NULL) + pCA = g_ca_file; + else + pCA = (char*)CAstream; + if ((rc = matrixSslLoadEcKeys(keys, pEcdhRsaCertFile, pEcdhRsaPrivkeyFile, - NULL, (char *) CAstream)) < 0) + NULL, pCA)) < 0) { _psTrace("No certificate material loaded. Exiting\n"); if (CAstream) diff --git a/apps/ssl/runClient.sh b/apps/ssl/runClient.sh index c4793eb..e2a9f9e 100755 --- a/apps/ssl/runClient.sh +++ b/apps/ssl/runClient.sh @@ -1,23 +1,31 @@ #!/bin/sh -# Some cipher suites +if [ "X$CIPHER_SUITE" = "X" ] +then +# Set cipher suite CIPHER_SUITE="47" #AES128-SHA #CIPHER_SUITE="5" #RC4128-SHA #CIPHER_SUITE="4" #RC4128-MD5 #CIPHER_SUITE="60" #AES128-SHA256 -#CIPHER_SUITE="10" #DES-CBC3-SHA -#CIPHER_SUITE="141" #PSK_AES256-SHA +#CIPHER_SUITE="10" #DES-CBC3-SHA +#CIPHER_SUITE="141" #PSK_AES256-SHA #CIPHER_SUITE="49156" #ECDH_ECDSA-AES128-SHA #CIPHER_SUITE="49162" #ECDHE_ECDSA-AES256-SHA #CIPHER_SUITE="156" #RSA AES128-GCM-SHA256 #CIPHER_SUITE="157" #RSA AES256-GCM-SHA384 #CIPHER_SUITE="57" #DHE_RSA AES256-SHA #CIPHER_SUITE="49195" #ECDHE_ECDSA-AES128-GCM-SHA256 -#CIPHER_SUITE="49196" #ECDHE_ECDSA-AES256-GCM-SHA384 - +#CIPHER_SUITE="49196" #ECDHE_ECDSA-AES256-GCM-SHA384 +#CIPHER_SUITE="52243" #TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 +#CIPHER_SUITE="52244" #TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 +fi + +if [ "X$PROTOCOL_VERSION" = "X" ] +then #PROTOCOL_VERSION="1" #TLS1.0 #PROTOCOL_VERSION="2" #TLS1.1 PROTOCOL_VERSION="3" #TLS1.2 +fi IPADDR="127.0.0.1" PORT="4433" diff --git a/common.mk b/common.mk index 095d9c5..8778b60 100644 --- a/common.mk +++ b/common.mk @@ -1,15 +1,17 @@ ## # Common Makefile definitions. # @version $Format:%h%d$ -# Copyright (c) 2013-2016 INSIDE Secure Corporation. All Rights Reserved. +# Copyright (c) 2013-2017 INSIDE Secure Corporation. All Rights Reserved. # #------------------------------------------------------------------------------- +# Allow building inclusion paths relative to location of common.mk file. +COMMON_MK_PATH:=$(dir $(lastword $(MAKEFILE_LIST))) # Allow extra CFLAGS, CPPFLAGS and LDFLAGS to be used. -LDFLAGS += $(EXTRA_LDFLAGS) -CFLAGS += $(CFLAGS_STANDARD) $(CFLAGS_PLATFORM) $(CFLAGS_ADDITIONAL) $(CFLAGS_WARNINGS) $(CFLAGS_CPU) $(CFLAGS_ASM) $(CFLAGS_PROFILE) $(DEBUGGABLE) $(EXTRA_CFLAGS) -CPPFLAGS += $(CPPFLAGS_STANDARD) $(CPPFLAGS_PLATFORM) $(CPPFLAGS_ADDITIONAL) $(CPPFLAGS_WARNINGS) $(CPPFLAGS_CPPPU) $(CPPFLAGS_ASM) $(CPPFLAGS_PROFILE) $(DEBUGGABLE) $(EXTRA_CPPFLAGS) +LDFLAGS += $(EXTRA_LDFLAGS) $(LDFLAGS_MAKEFILES) +CFLAGS += $(CFLAGS_STANDARD) $(CFLAGS_PLATFORM) $(CFLAGS_ADDITIONAL) $(CFLAGS_WARNINGS) $(CFLAGS_CPU) $(CFLAGS_ASM) $(CFLAGS_PROFILE) $(CFLAGS_MAKEFILES) $(DEBUGGABLE) $(EXTRA_CFLAGS) +CPPFLAGS += $(CPPFLAGS_STANDARD) $(CPPFLAGS_PLATFORM) $(CPPFLAGS_ADDITIONAL) $(CPPFLAGS_WARNINGS) $(CPPFLAGS_CPPPU) $(CPPFLAGS_ASM) $(CPPFLAGS_PROFILE) $(CPPFLAGS_MAKEFILES) $(DEBUGGABLE) $(EXTRA_CPPFLAGS) #------------------------------------------------------------------------------- ## Makefile variables that must be defined in this file @@ -131,6 +133,7 @@ ifndef MATRIX_DEBUG endif CFLAGS+=$(OPT) $(C_STD) +ifeq "$(COMMON_MK_NO_TARGETS)" "" default: $(BUILD) debug: @@ -138,6 +141,7 @@ debug: release: @$(MAKE) $(JOBS) compile +endif ifeq ($(SSH_PACKAGE),1) CFLAGS+=-DSSH_PACKAGE @@ -290,22 +294,8 @@ ifdef USE_OPENSSL_CRYPTO endif #endif -#ifdef USE_LIBSODIUM_CRYPTO -#USE_LIBSODIUM_CRYPTO:=1 -ifdef USE_LIBSODIUM_CRYPTO - LIBSODIUM_ROOT:=/opt/libsodium-1.0.8/src/libsodium - ifdef LIBSODIUM_ROOT - # Statically link against a given libsodium - CFLAGS+=-I$(LIBSODIUM_ROOT)/include - LDFLAGS+=$(LIBSODIUM_ROOT)/.libs/libsodium.a - endif - ifndef LIBSODIUM_ROOT - $(error Please define LIBSODIUM_ROOT) - endif - CFLAGS+=-DUSE_LIBSODIUM_CRYPTO - STROPTS+=", USE_LIBSODIUM_CRYPTO" -endif -#endif +# Include optional support for libsodium +-include $(COMMON_MK_PATH)/makefiles/libsodium_support.mk # Linux Target ifneq (,$(findstring -linux,$(CCARCH))) @@ -346,7 +336,30 @@ OBJS=$(SRC:.c=.o) $(SRC:.S:*.o) # Remove extra spaces in CFLAGS #CFLAGS=$(strip $(CFLAGS)) +ifneq (,$(filter defines,$(MAKECMDGOALS))) # Display the precompiler defines for the current build settings +# The rule is only available if explicitly requested on command line. + defines: :| $(CC) $(CFLAGS) -dM -E -x c - +endif +# Introduce here paths to additional build files (services) available. +use_prepkg_mk=$(MATRIXSSL_ROOT)/makefiles/prepkg.mk +use_testsupp_mk=$(MATRIXSSL_ROOT)/makefiles/testsupp.mk +use_rules_mk=$(MATRIXSSL_ROOT)/makefiles/rules.mk + +# Provide names of built packages for interpackage references +# Note: Some of these may not be built in some cases. +LIBCORE_S_A=$(MATRIXSSL_ROOT)/core/libcore_s$(A) +LIBCRYPT_S_A=$(MATRIXSSL_ROOT)/crypto/libcrypt_s$(A) +LIBCMS_S_A=$(MATRIXSSL_ROOT)/crypto/cms/libcms_s$(A) +LIBSSL_S_A=$(MATRIXSSL_ROOT)/matrixssl/libssl_s$(A) + +# Optional external libraries +LIBZ=-lz +LIBDL=-ldl +LIBTHREAD=-lpthread + +# When linking use default compiler front-end +CC_LD=$(CC) diff --git a/configs/default/cryptoConfig.h b/configs/default/cryptoConfig.h index e3e8a1c..7ec451c 100644 --- a/configs/default/cryptoConfig.h +++ b/configs/default/cryptoConfig.h @@ -120,9 +120,12 @@ # define USE_AES_CBC # define USE_AES_GCM -# ifdef USE_LIBSODIUM +/** If you want new ciphersuites specified in RFC 7539 enable this. + Currently CHACHA20-based cipher suites are only supported by the newest + TLS clients and servers. These cipher suites are not allowed in FIPS + mode of operation. +*/ /* #define USE_CHACHA20_POLY1305 */ -# endif /** @security 3DES is still relatively secure, however is deprecated for TLS */ # define USE_3DES diff --git a/configs/default/matrixsslConfig.h b/configs/default/matrixsslConfig.h index 3d1af9d..8ef6140 100644 --- a/configs/default/matrixsslConfig.h +++ b/configs/default/matrixsslConfig.h @@ -83,6 +83,8 @@ extern "C" { # define USE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384/**< @security NIST_MAY */ # define USE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256/**< @security NIST_SHOULD */ # define USE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384/**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral ECC DH keys, RSA certificates */ @@ -93,6 +95,8 @@ extern "C" { # define USE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384/**< @security NIST_MAY */ # define USE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256/**< @security NIST_SHOULD */ # define USE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384/**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral Diffie-Hellman ciphersuites, with RSA certificates */ @@ -242,6 +246,18 @@ extern "C" { */ /* #define SERVER_WILL_ACCEPT_EMPTY_CLIENT_CERT_MSG */ +/******************************************************************************/ +/** + Allow partial parsing of CA certificate bundles. By default, loading of + CA files via matrixSslLoadRsaKeys, etc. will fail if the bundle contains + a certificate not supported by MatrixSSL's current configuration. When + this define is enabled, the parsing of some CA certificates is allowed fail. + When parsing of a CA cert fails, a dummy psX509Cert_t with will be added + to the CAcerts list. Consult the parseStatus members for details on why + the parsing of a specific certificate failed. + */ +/* #define ALLOW_CA_BUNDLE_PARTIAL_PARSE */ + /******************************************************************************/ /** Enable the Application Layer Protocol Negotiation extension. diff --git a/configs/noecc/cryptoConfig.h b/configs/noecc/cryptoConfig.h index 6787340..130c3ff 100644 --- a/configs/noecc/cryptoConfig.h +++ b/configs/noecc/cryptoConfig.h @@ -120,9 +120,12 @@ # define USE_AES_CBC # define USE_AES_GCM -# ifdef USE_LIBSODIUM +/** If you want new ciphersuites specified in RFC 7539 enable this. + Currently CHACHA20-based cipher suites are only supported by the newest + TLS clients and servers. These cipher suites are not allowed in FIPS + mode of operation. +*/ /* #define USE_CHACHA20_POLY1305 */ -# endif /** @security 3DES is still relatively secure, however is deprecated for TLS */ # define USE_3DES diff --git a/configs/noecc/matrixsslConfig.h b/configs/noecc/matrixsslConfig.h index 4d80c58..bb9f2c7 100644 --- a/configs/noecc/matrixsslConfig.h +++ b/configs/noecc/matrixsslConfig.h @@ -83,6 +83,8 @@ extern "C" { /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 *//**< @security NIST_MAY */ /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 *//**< @security NIST_SHOULD */ /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 *//**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral ECC DH keys, RSA certificates */ @@ -93,6 +95,8 @@ extern "C" { /* #define USE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 *//**< @security NIST_MAY */ /* #define USE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 *//**< @security NIST_SHOULD */ /* #define USE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 *//**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral Diffie-Hellman ciphersuites, with RSA certificates */ @@ -242,6 +246,18 @@ extern "C" { */ /* #define SERVER_WILL_ACCEPT_EMPTY_CLIENT_CERT_MSG */ +/******************************************************************************/ +/** + Allow partial parsing of CA certificate bundles. By default, loading of + CA files via matrixSslLoadRsaKeys, etc. will fail if the bundle contains + a certificate not supported by MatrixSSL's current configuration. When + this define is enabled, the parsing of some CA certificates is allowed fail. + When parsing of a CA cert fails, a dummy psX509Cert_t with will be added + to the CAcerts list. Consult the parseStatus members for details on why + the parsing of a specific certificate failed. + */ +/* #define ALLOW_CA_BUNDLE_PARTIAL_PARSE */ + /******************************************************************************/ /** Enable the Application Layer Protocol Negotiation extension. diff --git a/configs/psk/cryptoConfig.h b/configs/psk/cryptoConfig.h index 5a3c7d0..ec332b3 100644 --- a/configs/psk/cryptoConfig.h +++ b/configs/psk/cryptoConfig.h @@ -120,9 +120,12 @@ # define USE_AES_CBC /* #define USE_AES_GCM */ -# ifdef USE_LIBSODIUM +/** If you want new ciphersuites specified in RFC 7539 enable this. + Currently CHACHA20-based cipher suites are only supported by the newest + TLS clients and servers. These cipher suites are not allowed in FIPS + mode of operation. +*/ /* #define USE_CHACHA20_POLY1305 */ -# endif /** @security 3DES is still relatively secure, however is deprecated for TLS */ /* #define USE_3DES */ diff --git a/configs/psk/matrixsslConfig.h b/configs/psk/matrixsslConfig.h index 682785a..8bc1755 100644 --- a/configs/psk/matrixsslConfig.h +++ b/configs/psk/matrixsslConfig.h @@ -83,6 +83,8 @@ extern "C" { /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 *//**< @security NIST_MAY */ /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 *//**< @security NIST_SHOULD */ /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 *//**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral ECC DH keys, RSA certificates */ @@ -93,6 +95,8 @@ extern "C" { /* #define USE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 *//**< @security NIST_MAY */ /* #define USE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 *//**< @security NIST_SHOULD */ /* #define USE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 *//**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral Diffie-Hellman ciphersuites, with RSA certificates */ @@ -242,6 +246,18 @@ extern "C" { */ /* #define SERVER_WILL_ACCEPT_EMPTY_CLIENT_CERT_MSG */ +/******************************************************************************/ +/** + Allow partial parsing of CA certificate bundles. By default, loading of + CA files via matrixSslLoadRsaKeys, etc. will fail if the bundle contains + a certificate not supported by MatrixSSL's current configuration. When + this define is enabled, the parsing of some CA certificates is allowed fail. + When parsing of a CA cert fails, a dummy psX509Cert_t with will be added + to the CAcerts list. Consult the parseStatus members for details on why + the parsing of a specific certificate failed. + */ +/* #define ALLOW_CA_BUNDLE_PARTIAL_PARSE */ + /******************************************************************************/ /** Enable the Application Layer Protocol Negotiation extension. diff --git a/configs/rsaonly/cryptoConfig.h b/configs/rsaonly/cryptoConfig.h index b506cd4..7943a94 100644 --- a/configs/rsaonly/cryptoConfig.h +++ b/configs/rsaonly/cryptoConfig.h @@ -120,9 +120,12 @@ # define USE_AES_CBC # define USE_AES_GCM -# ifdef USE_LIBSODIUM +/** If you want new ciphersuites specified in RFC 7539 enable this. + Currently CHACHA20-based cipher suites are only supported by the newest + TLS clients and servers. These cipher suites are not allowed in FIPS + mode of operation. +*/ /* #define USE_CHACHA20_POLY1305 */ -# endif /** @security 3DES is still relatively secure, however is deprecated for TLS */ # define USE_3DES diff --git a/configs/rsaonly/matrixsslConfig.h b/configs/rsaonly/matrixsslConfig.h index b724133..fd0ff94 100644 --- a/configs/rsaonly/matrixsslConfig.h +++ b/configs/rsaonly/matrixsslConfig.h @@ -83,6 +83,8 @@ extern "C" { /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 *//**< @security NIST_MAY */ /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 *//**< @security NIST_SHOULD */ /* #define USE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 *//**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral ECC DH keys, RSA certificates */ @@ -93,6 +95,8 @@ extern "C" { /* #define USE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 *//**< @security NIST_MAY */ /* #define USE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 *//**< @security NIST_SHOULD */ /* #define USE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 *//**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral Diffie-Hellman ciphersuites, with RSA certificates */ @@ -242,6 +246,18 @@ extern "C" { */ /* #define SERVER_WILL_ACCEPT_EMPTY_CLIENT_CERT_MSG */ +/******************************************************************************/ +/** + Allow partial parsing of CA certificate bundles. By default, loading of + CA files via matrixSslLoadRsaKeys, etc. will fail if the bundle contains + a certificate not supported by MatrixSSL's current configuration. When + this define is enabled, the parsing of some CA certificates is allowed fail. + When parsing of a CA cert fails, a dummy psX509Cert_t with will be added + to the CAcerts list. Consult the parseStatus members for details on why + the parsing of a specific certificate failed. + */ +/* #define ALLOW_CA_BUNDLE_PARTIAL_PARSE */ + /******************************************************************************/ /** Enable the Application Layer Protocol Negotiation extension. diff --git a/configs/tls/cryptoConfig.h b/configs/tls/cryptoConfig.h index d5a856e..1e9e064 100644 --- a/configs/tls/cryptoConfig.h +++ b/configs/tls/cryptoConfig.h @@ -120,9 +120,12 @@ # define USE_AES_CBC # define USE_AES_GCM -# ifdef USE_LIBSODIUM +/** If you want new ciphersuites specified in RFC 7539 enable this. + Currently CHACHA20-based cipher suites are only supported by the newest + TLS clients and servers. These cipher suites are not allowed in FIPS + mode of operation. +*/ /* #define USE_CHACHA20_POLY1305 */ -# endif /** @security 3DES is still relatively secure, however is deprecated for TLS */ # define USE_3DES diff --git a/configs/tls/matrixsslConfig.h b/configs/tls/matrixsslConfig.h index 3d1af9d..8ef6140 100644 --- a/configs/tls/matrixsslConfig.h +++ b/configs/tls/matrixsslConfig.h @@ -83,6 +83,8 @@ extern "C" { # define USE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384/**< @security NIST_MAY */ # define USE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256/**< @security NIST_SHOULD */ # define USE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384/**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral ECC DH keys, RSA certificates */ @@ -93,6 +95,8 @@ extern "C" { # define USE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384/**< @security NIST_MAY */ # define USE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256/**< @security NIST_SHOULD */ # define USE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384/**< @security NIST_SHOULD */ +/** CHACHA20-POLY1305 cipher suites according to old draft. + Do not enable except for compatibility with obsolete software. */ /* #define USE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 */ /** Ephemeral Diffie-Hellman ciphersuites, with RSA certificates */ @@ -242,6 +246,18 @@ extern "C" { */ /* #define SERVER_WILL_ACCEPT_EMPTY_CLIENT_CERT_MSG */ +/******************************************************************************/ +/** + Allow partial parsing of CA certificate bundles. By default, loading of + CA files via matrixSslLoadRsaKeys, etc. will fail if the bundle contains + a certificate not supported by MatrixSSL's current configuration. When + this define is enabled, the parsing of some CA certificates is allowed fail. + When parsing of a CA cert fails, a dummy psX509Cert_t with will be added + to the CAcerts list. Consult the parseStatus members for details on why + the parsing of a specific certificate failed. + */ +/* #define ALLOW_CA_BUNDLE_PARTIAL_PARSE */ + /******************************************************************************/ /** Enable the Application Layer Protocol Negotiation extension. diff --git a/core/POSIX/osdep.c b/core/POSIX/osdep.c index 1b47d6d..a09056a 100644 --- a/core/POSIX/osdep.c +++ b/core/POSIX/osdep.c @@ -469,34 +469,127 @@ void osdepTraceClose(void) { } +FILE *_psGetTraceFile(void) +{ + static FILE *tracefile = NULL; +#ifdef USE_MULTITHREADING + static pthread_mutex_t tracefile_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif /* USE_MULTITHREADING */ + + if (tracefile == NULL) + { + const char *str; + +#ifdef USE_MULTITHREADING + pthread_mutex_lock(&tracefile_mutex); +#endif /* USE_MULTITHREADING */ + + if (tracefile == NULL) + { + str = getenv("PSCORE_DEBUG_FILE"); + if (str != NULL) + { + tracefile = fopen(str, "w"); + if (!tracefile) + { + fprintf( + stderr, + "%s: Unable to open file %s, %s.\n", + __func__, + str, + "producing log to standard output"); + tracefile = stdout; + } + } + else + { + str = getenv("PSCORE_DEBUG_FILE_APPEND"); + } + + if (tracefile == NULL && str != NULL) + { + tracefile = fopen(str, "a"); + if (!tracefile) + { + fprintf( + stderr, + "%s: Unable to open file %s, %s.\n", + __func__, + str, + "producing log to standard output"); + tracefile = stdout; + } + } + + if (tracefile == NULL) + { + /* Default: output to standard output. */ + tracefile = stdout; + } + } + + if (tracefile) + { + setvbuf(tracefile, NULL, _IONBF, 0); + } + +#ifdef USE_MULTITHREADING + pthread_mutex_unlock(&tracefile_mutex); +#endif /* USE_MULTITHREADING */ + } + return tracefile; +} + void _psTrace(const char *msg) { - printf("%s", msg); + FILE *tracefile = _psGetTraceFile(); + + if (tracefile) + { + fprintf(tracefile, "%s", msg); + } } /* message should contain one %s, unless value is NULL */ void _psTraceStr(const char *message, const char *value) { + FILE *tracefile = _psGetTraceFile(); if (value) { - printf(message, value); + if (tracefile) + { + fprintf(tracefile, message, value); + } } else { - printf("%s", message); + if (tracefile) + { + fprintf(tracefile, "%s", message); + } } } /* message should contain one %d */ void _psTraceInt(const char *message, int32 value) { - printf(message, value); + FILE *tracefile = _psGetTraceFile(); + + if (tracefile) + { + fprintf(tracefile, message, value); + } } /* message should contain one %p */ void _psTracePtr(const char *message, const void *value) { - printf(message, value); + FILE *tracefile = _psGetTraceFile(); + + if (tracefile) + { + fprintf(tracefile, message, value); + } } /******************************************************************************/ diff --git a/core/psbuf.c b/core/psbuf.c index 88e85dc..36bb2f2 100644 --- a/core/psbuf.c +++ b/core/psbuf.c @@ -301,9 +301,11 @@ void assert_subbuf(psDynBuf_t *sub) assert(sub->buf.buf + sub->buf.size >= db->buf.start && sub->buf.buf + sub->buf.size <= db->buf.end); +#ifdef PSBUF_DEBUG_WITH_MEMSET /* For debugging: Mark head and tail visually. */ memset(sub->buf.buf, '(', sub->buf.start - sub->buf.buf); memset(sub->buf.end, ')', sub->buf.buf + sub->buf.size - sub->buf.end); +#endif /* PSBUF_DEBUG_WITH_MEMSET */ } static void *psDynBufGrow(psDynBuf_t *db, size_t head_sz, size_t tail_sz) @@ -339,9 +341,11 @@ static void *psDynBufGrow(psDynBuf_t *db, size_t head_sz, size_t tail_sz) headroom, filled, tailroom, headroom + head_sz, filled, tailroom + tail_sz, offset, offset_tail); assert_subbuf(db); +#ifdef PSBUF_DEBUG_WITH_MEMSET /* For debugging: */ memset(db->buf.buf, '{', headroom); memset(db->buf.end, '}', tailroom); +#endif /* PSBUF_DEBUG_WITH_MEMSET */ loc = psDynBufGrow(db->master, 0, head_sz + tail_sz); if (loc) @@ -371,9 +375,11 @@ static void *psDynBufGrow(psDynBuf_t *db, size_t head_sz, size_t tail_sz) db->buf.size, db->buf.start - db->buf.buf, db->buf.end - db->buf.start, db->buf.buf + db->buf.size - db->buf.end); +#ifdef PSBUF_DEBUG_WITH_MEMSET /* For debugging: */ memset(db->buf.buf, '<', head_sz + headroom); memset(db->buf.end, '>', tail_sz + tailroom); +#endif /* PSBUF_DEBUG_WITH_MEMSET */ } else { @@ -523,7 +529,9 @@ void *psDynBufSubInit(psDynBuf_t *db, psDynBuf_t *sub, size_t capacity) sub->pool = NULL; sub->master = db; sub->err = 0; +#ifdef PSBUF_DEBUG_WITH_MEMSET memset(sub->buf.buf, '#', capacity); +#endif /* PSBUF_DEBUG_WITH_MEMSET */ assert_subbuf(sub); } else @@ -553,7 +561,9 @@ void *psDynBufSubInitAt(psDynBuf_t *db, psDynBuf_t *sub, size_t at, sub->pool = NULL; sub->master = db; sub->err = 0; +#ifdef PSBUF_DEBUG_WITH_MEMSET memset(sub->buf.buf, '#', length); +#endif /* PSBUF_DEBUG_WITH_MEMSET */ assert_subbuf(sub); } else diff --git a/core/psbuf.h b/core/psbuf.h index e502073..f3ce92d 100644 --- a/core/psbuf.h +++ b/core/psbuf.h @@ -163,6 +163,17 @@ static __inline void *psDynBufAppendBuf(psDynBuf_t *db, const psBuf_t *b) return psDynBufAppendOctets(db, b->start, b->end - b->start); } +static __inline void *psDynBufAppendParseBuf(psDynBuf_t *db, + const psParseBuf_t *pb) +{ + if (!pb || pb->err) + { + db->err++; + return NULL; + } + return psDynBufAppendBuf(db, &(pb->buf)); +} + static __inline void *psDynBufIncorporateDynBuf(psDynBuf_t *db, psDynBuf_t *db2) { size_t len; @@ -202,6 +213,30 @@ void *psDynBufSubFinish(psDynBuf_t *sub); char *psDynBufAppendAsn1TagGen(psDynBuf_t *db, unsigned char tag, const unsigned char *bytes, size_t len); +static inline +char *psDynBufAppendAsn1IntegerSmall(psDynBuf_t *db, signed char byte) +{ + unsigned char bytes[1]; + + bytes[0] = (unsigned char) byte; + return psDynBufAppendAsn1TagGen(db, 0x02, bytes, 1); +} + +static inline +char *psDynBufAppendAsn1OctetString(psDynBuf_t *db, + const unsigned char *bytes, size_t len) +{ + return psDynBufAppendAsn1TagGen(db, 0x04, bytes, len); +} + +static inline +char *psDynBufAppendAsn1Oid(psDynBuf_t *db, + const unsigned char *oidbytes, size_t len) +{ + /* Note: oidbytes shall not include OID identifier (6) or length. */ + return psDynBufAppendAsn1TagGen(db, 0x06, oidbytes, len); +} + char *psDynBufBeginConstructedTag(psDynBuf_t *db, psDynBuf_t *sub); char *psDynBufEndConstructedTag(psDynBuf_t *sub, unsigned char tag); diff --git a/crypto/cryptoApi.h b/crypto/cryptoApi.h index e1ab7c2..607c719 100644 --- a/crypto/cryptoApi.h +++ b/crypto/cryptoApi.h @@ -81,6 +81,11 @@ extern "C" { # define PS_MESSAGE_UNSUPPORTED -42 /* Request/Response format/type is unsupported. */ # define PS_VERSION_UNSUPPORTED -43 /* Request/Response version is unsupported. */ +# define PS_SELFTEST_FAILED -44 /* Selftest, such as FIPS 140-2 + Powerup selftest has failed. + Software initialization has + failed. */ + /** Public return value codes for OCSP. These are additional possible return values from OCSP parsing. @@ -359,6 +364,28 @@ static __inline void psMd5Sha1Cpy(psMd5Sha1_t *d, const psMd5Sha1_t *s) } # endif /* USE_MD5SHA1 */ +# ifdef USE_SHA224 +/******************************************************************************/ +/* Pre-init should be called for uninitialized, e.g. function local + digest contexts, before calling the initialization function. */ +static __inline void psSha224PreInit(psSha256_t *sha224) +{ + /* Nothing to pre-initialize for native crypto. */ +} +PSPUBLIC void psSha224Init(psSha256_t *sha224); +PSPUBLIC void psSha224Update(psSha256_t *sha224, + const unsigned char *buf, uint32_t len); +PSPUBLIC void psSha224Final(psSha256_t * sha224, + unsigned char hash[SHA224_HASHLEN]); +static __inline void psSha224Sync(psSha256_t *md, int sync_all) +{ +} +static __inline void psSha224Cpy(psSha256_t *d, const psSha256_t *s) +{ + memcpy(d, s, sizeof(psSha256_t)); +} +# endif /* USE_SHA224 */ + # ifdef USE_SHA256 /******************************************************************************/ /* Pre-init should be called for uninitialized, e.g. function local @@ -558,9 +585,13 @@ PSPUBLIC void psClearPubKey(psPubKey_t *key); PSPUBLIC int32_t psNewPubKey(psPool_t *pool, uint8_t type, psPubKey_t **key); PSPUBLIC void psDeletePubKey(psPubKey_t **key); PSPUBLIC int32_t psParseUnknownPrivKey(psPool_t *pool, int pemOrDer, - char *keyfile, char *password, psPubKey_t *privkey); + const char *keyfile, const char *password, + psPubKey_t *privkey); +PSPUBLIC int32_t psParseUnknownPrivKeyMem(psPool_t *pool, + unsigned char *keyBuf, int32 keyBufLen, + const char *password, psPubKey_t *privkey); PSPUBLIC int32_t psParseUnknownPubKey(psPool_t *pool, int pemOrDer, - char *keyfile, const char *password, psPubKey_t *pubkey); + char *keyfile, const char *password, psPubKey_t *pubkey); # endif # ifdef USE_RSA diff --git a/crypto/cryptolib.h b/crypto/cryptolib.h index 7d0eac0..e47fb94 100644 --- a/crypto/cryptolib.h +++ b/crypto/cryptolib.h @@ -135,6 +135,9 @@ extern int32_t psGetPrngLocked(unsigned char *bytes, psSize_t size, # define OID_SHA1_ALG_STR "1.3.14.3.2.26" # define OID_SHA1_ALG 88 # define OID_SHA1_ALG_HEX "\x06\x05\x2B\x0E\x03\x02\x1A" +# define OID_SHA224_ALG_STR "2.16.840.1.101.3.4.2.4" +# define OID_SHA224_ALG (417 + OID_COLLISION) +# define OID_SHA224_ALG_HEX "\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04" # define OID_SHA256_ALG_STR "2.16.840.1.101.3.4.2.1" # define OID_SHA256_ALG 414 # define OID_SHA256_ALG_HEX "\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01" @@ -170,6 +173,9 @@ extern int32_t psGetPrngLocked(unsigned char *bytes, psSize_t size, # define OID_RSASSA_PSS_STR "1.2.840.113549.1.1.10" # define OID_RSASSA_PSS (654 + OID_COLLISION) # define OID_RSASSA_PSS_HEX "\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x0A" +# define OID_SHA224_RSA_SIG_STR "1.2.840.113549.1.1.14" +# define OID_SHA224_RSA_SIG (658 + OID_COLLISION) +# define OID_SHA224_RSA_SIG_HEX "\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x0E" # define OID_SHA256_RSA_SIG_STR "1.2.840.113549.1.1.11" # define OID_SHA256_RSA_SIG (655 + OID_COLLISION) # define OID_SHA256_RSA_SIG_HEX "\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x0B" @@ -338,6 +344,34 @@ extern int32_t psGetPrngLocked(unsigned char *bytes, psSize_t size, # define OID_BASIC_OCSP_RESPONSE 117 # define OID_BASIC_OCSP_RESPONSE_HEX "\x06\x09\x2B\x06\x01\x05\x05\x07\x30\x01\x01" +/* These definitions are for MatrixCMS (optional component). */ +# define OID_ECKA_EG_X963KDF_SHA256_STR "0.4.0.127.0.7.1.1.5.1.1.3" +# define OID_ECKA_EG_X963KDF_SHA256 150 +# define OID_ECKA_EG_X963KDF_SHA256_HEX "\x06\x0B\x04\x00\x7F\x00\x07\x01\x01\x05\x01\x01\x03" +# define OID_ECKA_EG_X963KDF_SHA384_STR "0.4.0.127.0.7.1.1.5.1.1.4" +# define OID_ECKA_EG_X963KDF_SHA384 151 +# define OID_ECKA_EG_X963KDF_SHA384_HEX "\x06\x0B\x04\x00\x7F\x00\x07\x01\x01\x05\x01\x01\x04" +# define OID_ECKA_EG_X963KDF_SHA512_STR "0.4.0.127.0.7.1.1.5.1.1.5" +# define OID_ECKA_EG_X963KDF_SHA512 152 +# define OID_ECKA_EG_X963KDF_SHA512_HEX "\x06\x0B\x04\x00\x7F\x00\x07\x01\x01\x05\x01\x01\x05" +# define OID_DHSINGLEPASS_STDDH_SHA1KDF_SCHEME_STR "1.3.133.16.840.63.0.2" +# define OID_DHSINGLEPASS_STDDH_SHA1KDF_SCHEME 464 +# define OID_DHSINGLEPASS_STDDH_SHA1KDF_SCHEME_HEX "\x06\x09\x2B\x81\x05\x10\x86\x48\x3F\x00\x02" +# define OID_DHSINGLEPASS_COFACTORDH_SHA1KDF_SCHEME_STR "1.3.133.16.840.63.0.3" +# define OID_DHSINGLEPASS_COFACTORDH_SHA1KDF_SCHEME 465 +# define OID_DHSINGLEPASS_COFACTORDH_SHA1KDF_SCHEME_HEX "\x06\x09\x2B\x81\x05\x10\x86\x48\x3F\x00\x03" +# define OID_MQVSINGLEPASS_SHA1KDF_SCHEME_STR "1.3.133.16.840.63.0.16" +# define OID_MQVSINGLEPASS_SHA1KDF_SCHEME 478 +# define OID_MQVSINGLEPASS_SHA1KDF_SCHEME_HEX "\x06\x09\x2B\x81\x05\x10\x86\x48\x3F\x00\x10" +# define OID_DHSINGLEPASS_STDDH_SHA256KDF_SCHEME_STR "1.3.132.1.11.1" +# define OID_DHSINGLEPASS_STDDH_SHA256KDF_SCHEME 189 +# define OID_DHSINGLEPASS_STDDH_SHA256KDF_SCHEME_HEX "\x06\x06\x2B\x81\x04\x01\x0B\x01" +# define OID_DHSINGLEPASS_STDDH_SHA384KDF_SCHEME_STR "1.3.132.1.11.2" +# define OID_DHSINGLEPASS_STDDH_SHA384KDF_SCHEME 190 +# define OID_DHSINGLEPASS_STDDH_SHA384KDF_SCHEME_HEX "\x06\x06\x2B\x81\x04\x01\x0B\x02" +# define OID_DHSINGLEPASS_STDDH_SHA512KDF_SCHEME_STR "1.3.132.1.11.3" +# define OID_DHSINGLEPASS_STDDH_SHA512KDF_SCHEME 191 +# define OID_DHSINGLEPASS_STDDH_SHA512KDF_SCHEME_HEX "\x06\x06\x2B\x81\x04\x01\x0B\x03" # define PBE12 1 # define PBES2 2 @@ -354,6 +388,7 @@ extern int32_t psGetPrngLocked(unsigned char *bytes, psSize_t size, # define PKCS1_SHA256_ID 2 # define PKCS1_SHA384_ID 3 # define PKCS1_SHA512_ID 4 +# define PKCS1_SHA224_ID 5 # endif /******************************************************************************/ diff --git a/crypto/keyformat/asn1.c b/crypto/keyformat/asn1.c index af54118..ce19d9a 100644 --- a/crypto/keyformat/asn1.c +++ b/crypto/keyformat/asn1.c @@ -34,6 +34,44 @@ #include "../cryptoImpl.h" +/* Compute tag length when it is known that p points to valid ASN.1 DER + encoding, no larger than 16 megabytes. */ +uint32_t getAsnTagLenUnsafe(const unsigned char *p) +{ + uint32_t len; + + /* Return 0 for uninitialized data or NULL. */ + if (p == NULL || *p == 0) + { + return 0; + } + len = p[1]; + if (len >= 0x80) + { + unsigned char lenbytes[3] = { 0, 0, 0 }; /* Size up-to 16 Mbytes. */ + len -= 0x80; /* Compute number of bytes in encoding. */ + if (len == 0 || len >= 4) + { + /* Although the function is "Unsafe", check for too long + length encoding, because in future some parser may accept + input > 4 gigabytes. */ + return 0; /* Too large length. */ + } + /* Note: */ + memcpy(lenbytes + 3 - len, p + 2, len); + len = + len + 2 + + ((lenbytes[0] << 16) | + (lenbytes[1] << 8) | + (lenbytes[2] << 0)); + } + else + { + len += 2; /* Tag and length byte. */ + } + return len; +} + /******************************************************************************/ /* On success, p will be updated to point to first character of value and @@ -470,6 +508,7 @@ static void checkAsnOidDatabase(int32_t *oi, switch (*oi) { case OID_SHA1_ALG: oid_hex = OID_SHA1_ALG_HEX; break; + case OID_SHA224_ALG: oid_hex = OID_SHA224_ALG_HEX; break; case OID_SHA256_ALG: oid_hex = OID_SHA256_ALG_HEX; break; case OID_SHA384_ALG: oid_hex = OID_SHA384_ALG_HEX; break; case OID_SHA512_ALG: oid_hex = OID_SHA512_ALG_HEX; break; @@ -481,6 +520,7 @@ static void checkAsnOidDatabase(int32_t *oi, case OID_SHA1_RSA_SIG2: oid_hex = OID_SHA1_RSA_SIG2_HEX; break; case OID_ID_MGF1: oid_hex = OID_ID_MGF1_HEX; break; case OID_RSASSA_PSS: oid_hex = OID_RSASSA_PSS_HEX; break; + case OID_SHA224_RSA_SIG: oid_hex = OID_SHA224_RSA_SIG_HEX; break; case OID_SHA256_RSA_SIG: oid_hex = OID_SHA256_RSA_SIG_HEX; break; case OID_SHA384_RSA_SIG: oid_hex = OID_SHA384_RSA_SIG_HEX; break; case OID_SHA512_RSA_SIG: oid_hex = OID_SHA512_RSA_SIG_HEX; break; @@ -532,6 +572,15 @@ static void checkAsnOidDatabase(int32_t *oi, case OID_PKCS7_ENCRYPTED_DATA: oid_hex = OID_PKCS7_ENCRYPTED_DATA_HEX; break; case OID_OCSP: oid_hex = OID_OCSP_HEX; break; case OID_BASIC_OCSP_RESPONSE: oid_hex = OID_BASIC_OCSP_RESPONSE_HEX; break; + case OID_ECKA_EG_X963KDF_SHA256: oid_hex = OID_ECKA_EG_X963KDF_SHA256_HEX; break; + case OID_ECKA_EG_X963KDF_SHA384: oid_hex = OID_ECKA_EG_X963KDF_SHA384_HEX; break; + case OID_ECKA_EG_X963KDF_SHA512: oid_hex = OID_ECKA_EG_X963KDF_SHA512_HEX; break; + case OID_DHSINGLEPASS_STDDH_SHA1KDF_SCHEME: oid_hex = OID_DHSINGLEPASS_STDDH_SHA1KDF_SCHEME_HEX; break; + case OID_DHSINGLEPASS_COFACTORDH_SHA1KDF_SCHEME: oid_hex = OID_DHSINGLEPASS_COFACTORDH_SHA1KDF_SCHEME_HEX; break; + case OID_MQVSINGLEPASS_SHA1KDF_SCHEME: oid_hex = OID_MQVSINGLEPASS_SHA1KDF_SCHEME_HEX; break; + case OID_DHSINGLEPASS_STDDH_SHA256KDF_SCHEME: oid_hex = OID_DHSINGLEPASS_STDDH_SHA256KDF_SCHEME_HEX; break; + case OID_DHSINGLEPASS_STDDH_SHA384KDF_SCHEME: oid_hex = OID_DHSINGLEPASS_STDDH_SHA384KDF_SCHEME_HEX; break; + case OID_DHSINGLEPASS_STDDH_SHA512KDF_SCHEME: oid_hex = OID_DHSINGLEPASS_STDDH_SHA512KDF_SCHEME_HEX; break; default: /* No possible matches: bitwise-add not found constant to OID. */ *oi |= OID_NOT_FOUND; diff --git a/crypto/keyformat/asn1.h b/crypto/keyformat/asn1.h index f9c8b13..645430a 100644 --- a/crypto/keyformat/asn1.h +++ b/crypto/keyformat/asn1.h @@ -80,6 +80,8 @@ enum # define ASN_UNKNOWN_LEN 65533 +extern uint32_t getAsnTagLenUnsafe(const unsigned char *p); + extern int32_t getAsnLength(const unsigned char **p, psSize_t size, psSize_t *valLen); extern int32_t getAsnLength32(const unsigned char **p, uint32_t size, diff --git a/crypto/keyformat/pkcs.c b/crypto/keyformat/pkcs.c index 3a5949a..f1a725e 100644 --- a/crypto/keyformat/pkcs.c +++ b/crypto/keyformat/pkcs.c @@ -170,6 +170,22 @@ int32_t pkcs1Unpad(const unsigned char *in, psSize_t inlen, #ifdef USE_PRIVATE_KEY_PARSING # ifdef USE_PKCS8 + +static int32 pkcs8parse_unknown( + psPool_t *pool, + unsigned char *buf, + int32 size, + psPubKey_t *key) +{ + /* When PKCS #8 header appears correct, but format is not + RSA or ECDSA this function is called. + The function may be extended to parse public key formats usually + not processed by MatrixSSL. */ + + psTraceCrypto("Unsupported public key type in PKCS#8 parse\n"); + return PS_UNSUPPORTED_FAIL; +} + /******************************************************************************/ /** Parse PKCS#8 format keys (from DER formatted binary) @@ -190,7 +206,6 @@ int32 psPkcs8ParsePrivBin(psPool_t *pool, unsigned char *buf, int32 size, const unsigned char *end, *p; int32 version, oi; psSize_t seqlen, len, plen; - # ifdef USE_ECC int32 coi; const psEccCurve_t *eccSet; @@ -213,6 +228,8 @@ int32 psPkcs8ParsePrivBin(psPool_t *pool, unsigned char *buf, int32 size, if (pass) { + psSize_t i; + # ifdef USE_PKCS5 /* An encrypted PKCS#8 key has quite a bit more information we must parse We actually parse a good bit of PKCS#5 structures here @@ -324,6 +341,50 @@ int32 psPkcs8ParsePrivBin(psPool_t *pool, unsigned char *buf, int32 size, /* @security SECURITY - we zero out des3 key when done with it */ memset_s(&ctx, sizeof(psCipherContext_t), 0x0, sizeof(psCipherContext_t)); memset_s(desKeyBin, DES3_KEYLEN, 0x0, DES3_KEYLEN); + + /* Remove padding. + This implementation allows up-to 16 bytes padding, for + compatibility with 3DES and AES algorithms. */ + /* Start by checking length. */ + /* coverity[dead_error_condition] */ + /* With the current value for MIN_ECC_BITS and MIN_RSA_BITS + this path can never be taken. This code path is ready in + case the values change in the future. */ + if (len < 1) + { + /* coverity[dead_error_begin] */ + psTraceCrypto("PKCS#8 padding error\n"); + return PS_FAILURE; + } + plen = (unsigned char) p[len - 1]; + if (plen < 1 || plen > 16) + { + psTraceCrypto("PKCS#8 padding error\n"); + return PS_FAILURE; + } + /* coverity[dead_error_condition] */ + /* With the current value for MIN_ECC_BITS and MIN_RSA_BITS + this path can never be taken. This code path is ready in + case the values change in the future. */ + if (len < plen) + { + /* coverity[dead_error_begin] */ + psTraceCrypto("PKCS#8 padding error\n"); + return PS_FAILURE; + } + for(i = 0; i < plen; i++) + { + if (p[len - i - 1] != (unsigned char) plen) + { + psTraceCrypto("PKCS#8 padding error\n"); + return PS_FAILURE; + } + } + + /* The padding has been processed. */ + size = len - plen; + end = p + size; + buf = (unsigned char *)p; # else /* !USE_PKCS5 */ /* The private key is encrypted, but PKCS5 support has been turned off @@ -360,8 +421,7 @@ int32 psPkcs8ParsePrivBin(psPool_t *pool, unsigned char *buf, int32 size, # ifdef USE_ECC if (oi != OID_ECDSA_KEY_ALG && oi != OID_RSA_KEY_ALG) { - psTraceCrypto("Unsupported public key type in PKCS#8 parse\n"); - return PS_UNSUPPORTED_FAIL; + return pkcs8parse_unknown(pool, buf, size, key); } if (oi == OID_ECDSA_KEY_ALG) { @@ -392,8 +452,7 @@ int32 psPkcs8ParsePrivBin(psPool_t *pool, unsigned char *buf, int32 size, # else if (oi != OID_RSA_KEY_ALG || plen != 0) { - psTraceCrypto("Unsupported public key type in PKCS#8 parse\n"); - return PS_UNSUPPORTED_FAIL; + return pkcs8parse_unknown(pool, buf, size, key); } # endif /* PrivateKey Octet Stream */ @@ -456,14 +515,11 @@ int32 psPkcs8ParsePrivBin(psPool_t *pool, unsigned char *buf, int32 size, p += len; plen = (int32) (end - p); } - /* Any remaining bytes should be non ASN.1 bytes that correspond - to the 3DES block padding */ - while (p < end) + + if (plen > 0) { - if (*p++ != (char) plen) - { - goto PKCS8_FAIL; - } + /* Unexpected extra data remains. Treat it as an error. */ + goto PKCS8_FAIL; } } diff --git a/crypto/keyformat/x509.c b/crypto/keyformat/x509.c index 17f9ff0..8083f55 100644 --- a/crypto/keyformat/x509.c +++ b/crypto/keyformat/x509.c @@ -191,6 +191,7 @@ int32 psX509ParseCertFile(psPool_t *pool, char *fileName, unsigned char *fileBuf; psList_t *fileList, *currentFile, *x509list, *frontX509; psX509Cert_t *currentCert, *firstCert, *prevCert; + int32 numParsed = 0; *outcert = NULL; /* @@ -234,20 +235,33 @@ int32 psX509ParseCertFile(psPool_t *pool, char *fileName, frontX509 = x509list; /* Recurse each individual cert buffer from within the file - */ + + If partial parse of cert bundles is not allowed, the failure + to load any of the certificates causes the whole function + call to fail. If partial parse of cert bundles is allowed, + parse as many as we can and return the number of parsed certs. +*/ while (x509list != NULL) { - if ((err = psX509ParseCert(pool, x509list->item, x509list->len, - ¤tCert, flags)) < PS_SUCCESS) + err = psX509ParseCert(pool, x509list->item, x509list->len, + ¤tCert, flags); + if (err < 0) { - psX509FreeCert(currentCert); - psFreeList(fileList, pool); - psFreeList(frontX509, pool); - if (firstCert) + if (!(flags & CERT_ALLOW_BUNDLE_PARTIAL_PARSE)) { - psX509FreeCert(firstCert); + psX509FreeCert(currentCert); + psFreeList(fileList, pool); + psFreeList(frontX509, pool); + if (firstCert) + { + psX509FreeCert(firstCert); + } + return err; } - return err; + } + else + { + numParsed++; } x509list = x509list->next; @@ -269,7 +283,7 @@ int32 psX509ParseCertFile(psPool_t *pool, char *fileName, *outcert = firstCert; - return PS_SUCCESS; + return numParsed; } /******************************************************************************/ @@ -616,6 +630,704 @@ PSPUBLIC int32 psX509GetCertPublicKeyDer(psX509Cert_t *cert, return PS_SUCCESS; } +/* + Parse a single, DER-encoded ASN.1 Certificate. + + Preconditions: + - *pp points to the first octet of a DER-encoded Certificate. + - the length of the DER-encoded Certificate is size octets. + - cert points to an allocated and zeroized psX509Cert_t struct. + + Postconditions: + - *pp == (pp_orig + size), where pp_orig is the original (input) + value of *pp. + - If return value is PS_SUCCESS, cert will contain a parsed + and usable certificate. + - If return value is < 0, cert->parseStatus will contain information + about the reason of the parse failure. + + @param[in] Pointer to a memory pool + @param[in,out] pp Pointer to a pointer pointing to the first octet + of a DER-encoded Certificate. After parsing has completed, the underlying + pointer will be updated to point to the octet after the final octet + of the Certificate. + @param[in] size Size of the DER buffer in bytes. + @param[in] cert An allocated psX509Cert_t struct to be filled. + with the parsed Certificate data. + @param[in] flags +*/ +static int parse_single_cert(psPool_t *pool, const unsigned char **pp, + uint32 size, const unsigned char *far_end, + psX509Cert_t *cert, int32 flags) +{ +# ifdef USE_CERT_PARSE + const unsigned char *tbsCertStart; + unsigned char sha1KeyHash[SHA1_HASH_SIZE]; + psDigestContext_t hashCtx; + psSize_t certLen; + const unsigned char *p_subject_pubkey_info; + size_t subject_pubkey_info_header_len; +# endif /* USE_CERT_PARSE */ + const unsigned char *certStart, *certEnd, *end, *p; + int32_t rc, func_rc; + uint32_t oneCertLen; + psSize_t len, plen; + + /* + Initialize the cert structure.*/ + cert->pool = pool; + cert->parseStatus = PS_X509_PARSE_FAIL; /* Default to fail status */ +# ifdef USE_CERT_PARSE + cert->extensions.bc.cA = CA_UNDEFINED; +# endif /* USE_CERT_PARSE */ + + p = *pp; + certStart = p; + end = p + size; + + func_rc = PS_SUCCESS; + + if ((rc = getAsnSequence32(&p, (uint32_t) (far_end - p), &oneCertLen, 0)) + < 0) + { + psTraceCrypto("Initial cert parse error\n"); + func_rc = rc; + goto out; + } + /* The whole list of certs could be > 64K bytes, but we still + restrict individual certs to 64KB */ + if (oneCertLen > 0xFFFF) + { + psAssert(oneCertLen <= 0xFFFF); + func_rc = PS_FAILURE; + goto out; + } + end = p + oneCertLen; + + /* + If the user has specified to keep the ASN.1 buffer in the X.509 + structure, now is the time to account for it + */ + if (flags & CERT_STORE_UNPARSED_BUFFER) + { + cert->binLen = oneCertLen + (int32) (p - certStart); + cert->unparsedBin = psMalloc(pool, cert->binLen); + if (cert->unparsedBin == NULL) + { + psError("Memory allocation error in psX509ParseCert\n"); + func_rc = PS_MEM_FAIL; + goto out; + } + memcpy(cert->unparsedBin, certStart, cert->binLen); + } + +# ifdef ENABLE_CA_CERT_HASH + /* We use the cert_sha1_hash type for the Trusted CA Indication so + run a SHA1 has over the entire Certificate DER encoding. */ + psSha1PreInit(&hashCtx.sha1); + psSha1Init(&hashCtx.sha1); + psSha1Update(&hashCtx.sha1, certStart, + oneCertLen + (int32) (p - certStart)); + psSha1Final(&hashCtx.sha1, cert->sha1CertHash); +# endif + +# ifdef USE_CERT_PARSE + tbsCertStart = p; +# endif /* USE_CERT_PARSE */ + /* + TBSCertificate ::= SEQUENCE { + version [0] EXPLICIT Version DEFAULT v1, + serialNumber CertificateSerialNumber, + signature AlgorithmIdentifier, + issuer Name, + validity Validity, + subject Name, + subjectPublicKeyInfo SubjectPublicKeyInfo, + issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, + -- If present, version shall be v2 or v3 + subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, + -- If present, version shall be v2 or v3 + extensions [3] EXPLICIT Extensions OPTIONAL + -- If present, version shall be v3 } + */ + if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) + { + psTraceCrypto("ASN sequence parse error\n"); + func_rc = rc; + goto out; + } + certEnd = p + len; +# ifdef USE_CERT_PARSE + /* + Start parsing TBSCertificate contents. + */ + certLen = certEnd - tbsCertStart; + /* + Version ::= INTEGER { v1(0), v2(1), v3(2) } + */ + if ((rc = getExplicitVersion(&p, (uint32) (end - p), 0, &cert->version)) + < 0) + { + psTraceCrypto("ASN version parse error\n"); + func_rc = rc; + goto out; + } + switch (cert->version) + { + case 0: + case 1: +# ifndef ALLOW_VERSION_1_ROOT_CERT_PARSE + psTraceCrypto("ERROR: v1 and v2 certificate versions insecure\n"); + cert->parseStatus = PS_X509_UNSUPPORTED_VERSION; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; +# else + /* Allow locally stored, trusted version 1 and version 2 certificates + to be parsed. The SSL layer code will still reject non v3 + certificates that arrive over-the-wire. */ + /* Version 1 certificates do not have basic constraints to + specify a CA flag or path length. Here, the CA flag is implied + since v1 certs can only be loaded as root. We explicitly set + the pathLengthConstraint to allow up to 2 intermediate certs. + This can be adjusted to allow more or less intermediate certs. */ + cert->extensions.bc.pathLenConstraint = 2; + break; +# endif /* ALLOW_VERSION_1_ROOT_CERT_PARSE */ + case 2: + /* Typical case of v3 cert */ + break; + default: + psTraceIntCrypto("ERROR: unknown certificate version: %d\n", + cert->version); + cert->parseStatus = PS_X509_UNSUPPORTED_VERSION; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } + /* + CertificateSerialNumber ::= INTEGER + There is a special return code for a missing serial number that + will get written to the parse warning flag + */ + if ((rc = getSerialNum(pool, &p, (uint32) (end - p), &cert->serialNumber, + &cert->serialNumberLen)) < 0) + { + psTraceCrypto("ASN serial number parse error\n"); + func_rc = rc; + goto out; + } + /* + AlgorithmIdentifier ::= SEQUENCE { + algorithm OBJECT IDENTIFIER, + parameters ANY DEFINED BY algorithm OPTIONAL } + */ + if ((rc = getAsnAlgorithmIdentifier(&p, (uint32) (end - p), + &cert->certAlgorithm, &plen)) < 0) + { + psTraceCrypto("Couldn't parse algorithm identifier for certAlgorithm\n"); + cert->parseStatus = PS_X509_ALG_ID; + func_rc = rc; + goto out; + } + if (plen != 0) + { +# ifdef USE_PKCS1_PSS + if (cert->certAlgorithm == OID_RSASSA_PSS) + { + /* RSASSA-PSS-params ::= SEQUENCE { + hashAlgorithm [0] HashAlgorithm DEFAULT sha1, + maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, + saltLength [2] INTEGER DEFAULT 20, + trailerField [3] TrailerField DEFAULT trailerFieldBC + } + */ + if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) + { + psTraceCrypto("ASN sequence parse error\n"); + func_rc = rc; + goto out; + } + /* Always set the defaults before parsing */ + cert->pssHash = PKCS1_SHA1_ID; + cert->maskGen = OID_ID_MGF1; + cert->saltLen = SHA1_HASH_SIZE; + /* Something other than defaults to parse here? */ + if (len > 0) + { + if ((rc = getRsaPssParams(&p, len, cert, 0)) < 0) + { + func_rc = rc; + goto out; + } + } + } + else + { + psTraceCrypto("Unsupported X.509 certAlgorithm\n"); + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } +# else + psTraceCrypto("Unsupported X.509 certAlgorithm\n"); + func_rc = PS_UNSUPPORTED_FAIL; + goto out; +# endif + } + /* + Name ::= CHOICE { + RDNSequence } + + RDNSequence ::= SEQUENCE OF RelativeDistinguishedName + + RelativeDistinguishedName ::= SET OF AttributeTypeAndValue + + AttributeTypeAndValue ::= SEQUENCE { + type AttributeType, + value AttributeValue } + + AttributeType ::= OBJECT IDENTIFIER + + AttributeValue ::= ANY DEFINED BY AttributeType + */ + if ((rc = psX509GetDNAttributes(pool, &p, (uint32) (end - p), + &cert->issuer, flags)) < 0) + { + psTraceCrypto("Couldn't parse issuer DN attributes\n"); + cert->parseStatus = PS_X509_ISSUER_DN; + func_rc = rc; + goto out; + } + /* + Validity ::= SEQUENCE { + notBefore Time, + notAfter Time } + */ + if ((rc = getTimeValidity(pool, &p, (uint32) (end - p), + &cert->notBeforeTimeType, &cert->notAfterTimeType, + &cert->notBefore, &cert->notAfter)) < 0) + { + psTraceCrypto("Couldn't parse validity\n"); + func_rc = rc; + goto out; + } + + /* SECURITY - platforms without a date function will always succeed */ + if ((rc = validateDateRange(cert)) < 0) + { + psTraceCrypto("Validity date check failed\n"); + cert->parseStatus = PS_X509_DATE; + func_rc = rc; + goto out; + } + /* + Subject DN + */ + cert->subjectKeyDerOffsetIntoUnparsedBin = (uint16_t) (p - certStart); + if ((rc = psX509GetDNAttributes(pool, &p, (uint32) (end - p), + &cert->subject, flags)) < 0) + { + psTraceCrypto("Couldn't parse subject DN attributes\n"); + cert->parseStatus = PS_X509_SUBJECT_DN; + func_rc = rc; + goto out; + } + /* + SubjectPublicKeyInfo ::= SEQUENCE { + algorithm AlgorithmIdentifier, + subjectPublicKey BIT STRING } + */ + p_subject_pubkey_info = p; + + cert->publicKeyDerOffsetIntoUnparsedBin = (uint16_t) (p - certStart); + + if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) + { + psTraceCrypto("Couldn't get ASN sequence for pubKeyAlgorithm\n"); + func_rc = rc; + goto out; + } + subject_pubkey_info_header_len = (p - p_subject_pubkey_info); + cert->publicKeyDerLen = len + subject_pubkey_info_header_len; + + if ((rc = getAsnAlgorithmIdentifier(&p, (uint32) (end - p), + &cert->pubKeyAlgorithm, &plen)) < 0) + { + psTraceCrypto("Couldn't parse algorithm id for pubKeyAlgorithm\n"); + func_rc = rc; + goto out; + } + + /* Populate with correct type based on pubKeyAlgorithm OID */ + switch (cert->pubKeyAlgorithm) + { +# ifdef USE_ECC + case OID_ECDSA_KEY_ALG: + if (plen == 0 || plen > (int32) (end - p)) + { + psTraceCrypto("Bad params on EC OID\n"); + func_rc = PS_PARSE_FAIL; + goto out; + } + psInitPubKey(pool, &cert->publicKey, PS_ECC); + if ((rc = getEcPubKey(pool, &p, (uint16_t) (end - p), + &cert->publicKey.key.ecc, sha1KeyHash)) < 0) + { + if (rc == PS_UNSUPPORTED_FAIL) + { + cert->parseStatus = PS_X509_UNSUPPORTED_ECC_CURVE; + } + func_rc = PS_PARSE_FAIL; + goto out; + } + /* keysize will be the size of the public ecc key (2 * privateLen) */ + cert->publicKey.keysize = psEccSize(&cert->publicKey.key.ecc); + if (cert->publicKey.keysize < (MIN_ECC_BITS / 8)) + { + psTraceIntCrypto("ECC key size < %d\n", MIN_ECC_BITS); + psClearPubKey(&cert->publicKey); + cert->parseStatus = PS_X509_WEAK_KEY; + func_rc = PS_PARSE_FAIL; + goto out; + } + break; +# endif +# ifdef USE_RSA + case OID_RSA_KEY_ALG: + psAssert(plen == 0); /* No parameters on RSA pub key OID */ + psInitPubKey(pool, &cert->publicKey, PS_RSA); + if ((rc = psRsaParseAsnPubKey(pool, &p, (uint16_t) (end - p), + &cert->publicKey.key.rsa, sha1KeyHash)) < 0) + { + psTraceCrypto("Couldn't get RSA pub key from cert\n"); + cert->parseStatus = PS_X509_MISSING_RSA; + func_rc = rc; + goto out; + } + cert->publicKey.keysize = psRsaSize(&cert->publicKey.key.rsa); + + if (cert->publicKey.keysize < (MIN_RSA_BITS / 8)) + { + psTraceIntCrypto("RSA key size < %d\n", MIN_RSA_BITS); + psClearPubKey(&cert->publicKey); + cert->parseStatus = PS_X509_WEAK_KEY; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } + + break; +# endif + default: + /* Note 645:RSA, 515:DSA, 518:ECDSA, 32969:GOST */ + psTraceIntCrypto( + "Unsupported public key algorithm in cert parse: %d\n", + cert->pubKeyAlgorithm); + cert->parseStatus = PS_X509_UNSUPPORTED_KEY_ALG; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } + +# ifdef USE_OCSP + /* A sha1 hash of the public key is useful for OCSP */ + memcpy(cert->sha1KeyHash, sha1KeyHash, SHA1_HASH_SIZE); +# endif + + /* As the next three values are optional, we can do a specific test here */ + if (*p != (ASN_SEQUENCE | ASN_CONSTRUCTED)) + { + if (getImplicitBitString(pool, &p, (uint32) (end - p), + IMPLICIT_ISSUER_ID, &cert->uniqueIssuerId, + &cert->uniqueIssuerIdLen) < 0 || + getImplicitBitString(pool, &p, (uint32) (end - p), + IMPLICIT_SUBJECT_ID, &cert->uniqueSubjectId, + &cert->uniqueSubjectIdLen) < 0 || + getExplicitExtensions(pool, &p, (uint32) (end - p), + EXPLICIT_EXTENSION, &cert->extensions, 0) < 0) + { + psTraceCrypto("There was an error parsing a certificate\n" + "extension. This is likely caused by an\n" + "extension format that is not currently\n" + "recognized. Please email support\n" + "to add support for the extension.\n"); + cert->parseStatus = PS_X509_UNSUPPORTED_EXT; + func_rc = PS_PARSE_FAIL; + goto out; + } + } + + /* This is the end of the cert. Do a check here to be certain */ + if (certEnd != p) + { + psTraceCrypto("Error. Expecting end of cert\n"); + cert->parseStatus = PS_X509_EOF; + func_rc = PS_LIMIT_FAIL; + goto out; + } + + /* Reject any cert without a distinguishedName or subjectAltName */ + if (cert->subject.commonName == NULL && + cert->subject.country == NULL && + cert->subject.state == NULL && + cert->subject.organization == NULL && + cert->subject.orgUnit == NULL && + cert->subject.domainComponent == NULL && + cert->extensions.san == NULL) + { + psTraceCrypto("Error. Cert has no name information\n"); + cert->parseStatus = PS_X509_MISSING_NAME; + func_rc = PS_PARSE_FAIL; + goto out; + } +# else /* No TBSCertificate parsing. */ + p = certEnd; +# endif /* USE_CERT_PARSE (end of TBSCertificate parsing) */ + + /* Certificate signature info */ + if ((rc = getAsnAlgorithmIdentifier(&p, (uint32) (end - p), + &cert->sigAlgorithm, &plen)) < 0) + { + psTraceCrypto("Couldn't get algorithm identifier for sigAlgorithm\n"); + func_rc = rc; + goto out; + } + + if (plen != 0) + { +# ifdef USE_PKCS1_PSS + if (cert->sigAlgorithm == OID_RSASSA_PSS) + { + /* RSASSA-PSS-params ::= SEQUENCE { + hashAlgorithm [0] HashAlgorithm DEFAULT sha1, + maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, + saltLength [2] INTEGER DEFAULT 20, + trailerField [3] TrailerField DEFAULT trailerFieldBC + } + */ + if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) + { + psTraceCrypto("ASN sequence parse error\n"); + func_rc = rc; + goto out; + } + /* Something other than defaults to parse here? */ + if (len > 0) + { + if ((rc = getRsaPssParams(&p, len, cert, 1)) < 0) + { + func_rc = rc; + goto out; + } + } + } + else + { + psTraceCrypto("Unsupported X.509 sigAlgorithm\n"); + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } +# else + psTraceCrypto("Unsupported X.509 sigAlgorithm\n"); + func_rc = PS_UNSUPPORTED_FAIL; + goto out; +# endif /* USE_PKCS1_PSS */ + } +# ifdef USE_CERT_PARSE + /* + https://tools.ietf.org/html/rfc5280#section-4.1.1.2 + This field MUST contain the same algorithm identifier as the + signature field in the sequence tbsCertificate (Section 4.1.2.3). + */ + if (cert->certAlgorithm != cert->sigAlgorithm) + { + psTraceIntCrypto("Parse error: mismatched sig alg (tbs = %d ", + cert->certAlgorithm); + psTraceIntCrypto("sig = %d)\n", cert->sigAlgorithm); + cert->parseStatus = PS_X509_SIG_MISMATCH; + func_rc = PS_PARSE_FAIL; + goto out; + } + /* + Compute the hash of the cert here for CA validation + */ + switch (cert->certAlgorithm) + { +# ifdef ENABLE_MD5_SIGNED_CERTS +# ifdef USE_MD2 + case OID_MD2_RSA_SIG: + psMd2Init(&hashCtx.md2); + psMd2Update(&hashCtx.md2, tbsCertStart, certLen); + psMd2Final(&hashCtx.md2, cert->sigHash); + break; +# endif /* USE_MD2 */ + case OID_MD5_RSA_SIG: + psMd5Init(&hashCtx.md5); + psMd5Update(&hashCtx.md5, tbsCertStart, certLen); + psMd5Final(&hashCtx.md5, cert->sigHash); + break; +# endif +# ifdef ENABLE_SHA1_SIGNED_CERTS + case OID_SHA1_RSA_SIG: + case OID_SHA1_RSA_SIG2: +# ifdef USE_ECC + case OID_SHA1_ECDSA_SIG: +# endif + psSha1PreInit(&hashCtx.sha1); + psSha1Init(&hashCtx.sha1); + psSha1Update(&hashCtx.sha1, tbsCertStart, certLen); + psSha1Final(&hashCtx.sha1, cert->sigHash); + break; +# endif +# ifdef USE_SHA224 + case OID_SHA224_RSA_SIG: +# ifdef USE_ECC + case OID_SHA224_ECDSA_SIG: +# endif + psSha224PreInit(&hashCtx.sha256); + psSha224Init(&hashCtx.sha256); + psSha224Update(&hashCtx.sha256, tbsCertStart, certLen); + psSha224Final(&hashCtx.sha256, cert->sigHash); + break; +# endif +# ifdef USE_SHA256 + case OID_SHA256_RSA_SIG: +# ifdef USE_ECC + case OID_SHA256_ECDSA_SIG: +# endif + psSha256PreInit(&hashCtx.sha256); + psSha256Init(&hashCtx.sha256); + psSha256Update(&hashCtx.sha256, tbsCertStart, certLen); + psSha256Final(&hashCtx.sha256, cert->sigHash); + break; +# endif +# ifdef USE_SHA384 + case OID_SHA384_RSA_SIG: +# ifdef USE_ECC + case OID_SHA384_ECDSA_SIG: +# endif + psSha384PreInit(&hashCtx.sha384); + psSha384Init(&hashCtx.sha384); + psSha384Update(&hashCtx.sha384, tbsCertStart, certLen); + psSha384Final(&hashCtx.sha384, cert->sigHash); + break; +# endif +# ifdef USE_SHA512 + case OID_SHA512_RSA_SIG: +# ifdef USE_ECC + case OID_SHA512_ECDSA_SIG: +# endif + psSha512PreInit(&hashCtx.sha512); + psSha512Init(&hashCtx.sha512); + psSha512Update(&hashCtx.sha512, tbsCertStart, certLen); + psSha512Final(&hashCtx.sha512, cert->sigHash); + break; +# endif +# ifdef USE_PKCS1_PSS + case OID_RSASSA_PSS: + switch (cert->pssHash) + { +# ifdef ENABLE_MD5_SIGNED_CERTS + case PKCS1_MD5_ID: + psMd5Init(&hashCtx.md5); + psMd5Update(&hashCtx.md5, tbsCertStart, certLen); + psMd5Final(&hashCtx.md5, cert->sigHash); + break; +# endif +# ifdef ENABLE_SHA1_SIGNED_CERTS + case PKCS1_SHA1_ID: + psSha1PreInit(&hashCtx.sha1); + psSha1Init(&hashCtx.sha1); + psSha1Update(&hashCtx.sha1, tbsCertStart, certLen); + psSha1Final(&hashCtx.sha1, cert->sigHash); + break; +# endif +# ifdef USE_SHA224 + case PKCS1_SHA224_ID: + psSha224PreInit(&hashCtx.sha256); + psSha224Init(&hashCtx.sha256); + psSha224Update(&hashCtx.sha256, tbsCertStart, certLen); + psSha224Final(&hashCtx.sha256, cert->sigHash); + break; +# endif +# ifdef USE_SHA256 + case PKCS1_SHA256_ID: + psSha256PreInit(&hashCtx.sha256); + psSha256Init(&hashCtx.sha256); + psSha256Update(&hashCtx.sha256, tbsCertStart, certLen); + psSha256Final(&hashCtx.sha256, cert->sigHash); + break; +# endif +# ifdef USE_SHA384 + case PKCS1_SHA384_ID: + psSha384PreInit(&hashCtx.sha384); + psSha384Init(&hashCtx.sha384); + psSha384Update(&hashCtx.sha384, tbsCertStart, certLen); + psSha384Final(&hashCtx.sha384, cert->sigHash); + break; +# endif +# ifdef USE_SHA512 + case PKCS1_SHA512_ID: + psSha512PreInit(&hashCtx.sha512); + psSha512Init(&hashCtx.sha512); + psSha512Update(&hashCtx.sha512, tbsCertStart, certLen); + psSha512Final(&hashCtx.sha512, cert->sigHash); + break; +# endif + default: + psTraceIntCrypto("Unsupported pssHash algorithm: %d\n", + cert->pssHash); + cert->parseStatus = PS_X509_UNSUPPORTED_SIG_ALG; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } /* switch pssHash */ + break; +# endif /* USE_PKCS1_PSS */ + + default: + /* Note 1670:MD2 */ + psTraceIntCrypto("Unsupported cert algorithm: %d\n", + cert->certAlgorithm); + cert->parseStatus = PS_X509_UNSUPPORTED_SIG_ALG; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + + } /* switch certAlgorithm */ + + /* 6 empty bytes is plenty enough to know if sigHash didn't calculate */ + if (memcmp(cert->sigHash, "\0\0\0\0\0\0", 6) == 0) + { + psTraceIntCrypto("No library signature alg support for cert: %d\n", + cert->certAlgorithm); + cert->parseStatus = PS_X509_UNSUPPORTED_SIG_ALG; + func_rc = PS_UNSUPPORTED_FAIL; + goto out; + } +# endif /* USE_CERT_PARSE */ + + if ((rc = psX509GetSignature(pool, &p, (uint32) (end - p), + &cert->signature, &cert->signatureLen)) < 0) + { + psTraceCrypto("Couldn't parse signature\n"); + cert->parseStatus = PS_X509_SIGNATURE; + func_rc = rc; + goto out; + } + +# ifndef USE_CERT_PARSE + /* Some APIs need certAlgorithm.*/ + cert->certAlgorithm = cert->sigAlgorithm; +# endif /* !USE_CERT_PARSE */ + +out: + if (func_rc == PS_SUCCESS) + { + cert->parseStatus = PS_X509_PARSE_SUCCESS; + psAssert(p == end); /* Must have parsed everything. */ + } + psAssert(p <= end); /* Must not have parsed too much. */ + + *pp = end; + + return func_rc; +} + /******************************************************************************/ /* Parse an X509 v3 ASN.1 certificate stream @@ -632,26 +1344,19 @@ int32 psX509ParseCert(psPool_t *pool, const unsigned char *pp, uint32 size, psX509Cert_t **outcert, int32 flags) { psX509Cert_t *cert; - const unsigned char *p, *end, *far_end, *certStart; - psSize_t len; - uint32_t oneCertLen; + const unsigned char *p, *far_end; int32_t parsing, rc; - const unsigned char *certEnd; - psSize_t plen; + int32_t numCerts = 0; + int32_t numParsedCerts = 0; -# ifdef USE_CERT_PARSE - const unsigned char *tbsCertStart; - unsigned char sha1KeyHash[SHA1_HASH_SIZE]; - psDigestContext_t hashCtx; - psSize_t certLen; - const unsigned char *p_subject_pubkey_info; - size_t subject_pubkey_info_header_len; -# endif /* USE_CERT_PARSE */ /* Allocate the cert structure right away. User MUST always call psX509FreeCert regardless of whether this function succeeds. memset is important because the test for NULL is what is used - to determine what to free + to determine what to free. + + If the input stream consists of multiple certs, the rest of + the psX509Cert_t structs will be allocated in parse_single_cert(). */ *outcert = cert = psMalloc(pool, sizeof(psX509Cert_t)); if (cert == NULL) @@ -660,11 +1365,6 @@ int32 psX509ParseCert(psPool_t *pool, const unsigned char *pp, uint32 size, return PS_MEM_FAIL; } memset(cert, 0x0, sizeof(psX509Cert_t)); - cert->pool = pool; - cert->parseStatus = PS_X509_PARSE_FAIL; /* Default to fail status */ -# ifdef USE_CERT_PARSE - cert->extensions.bc.cA = CA_UNDEFINED; -# endif /* USE_CERT_PARSE */ # ifdef ALWAYS_KEEP_CERT_DER flags |= CERT_STORE_UNPARSED_BUFFER; @@ -672,591 +1372,44 @@ int32 psX509ParseCert(psPool_t *pool, const unsigned char *pp, uint32 size, p = pp; far_end = p + size; -/* - Certificate ::= SEQUENCE { - tbsCertificate TBSCertificate, - signatureAlgorithm AlgorithmIdentifier, - signatureValue BIT STRING } - */ + parsing = 1; while (parsing) { - certStart = p; - if ((rc = getAsnSequence32(&p, (uint32_t) (far_end - p), &oneCertLen, 0)) - < 0) + /* + Certificate ::= SEQUENCE { + tbsCertificate TBSCertificate, + signatureAlgorithm AlgorithmIdentifier, + signatureValue BIT STRING } + */ + rc = parse_single_cert(pool, &p, size, far_end, cert, flags); + if (rc == PS_SUCCESS) { - psTraceCrypto("Initial cert parse error\n"); - return rc; + numParsedCerts++; } - /* The whole list of certs could be > 64K bytes, but we still - restrict individual certs to 64KB */ - if (oneCertLen > 0xFFFF) + else { - psAssert(oneCertLen <= 0xFFFF); - return PS_FAILURE; - } - end = p + oneCertLen; -/* - If the user has specified to keep the ASN.1 buffer in the X.509 - structure, now is the time to account for it - */ - if (flags & CERT_STORE_UNPARSED_BUFFER) - { - cert->binLen = oneCertLen + (int32) (p - certStart); - cert->unparsedBin = psMalloc(pool, cert->binLen); - if (cert->unparsedBin == NULL) + psAssert(cert->parseStatus != PS_X509_PARSE_SUCCESS); + + if (!(flags & CERT_ALLOW_BUNDLE_PARTIAL_PARSE)) { - psError("Memory allocation error in psX509ParseCert\n"); - return PS_MEM_FAIL; - } - memcpy(cert->unparsedBin, certStart, cert->binLen); - } - -# ifdef ENABLE_CA_CERT_HASH - /* We use the cert_sha1_hash type for the Trusted CA Indication so - run a SHA1 has over the entire Certificate DER encoding. */ - psSha1PreInit(&hashCtx.sha1); - psSha1Init(&hashCtx.sha1); - psSha1Update(&hashCtx.sha1, certStart, - oneCertLen + (int32) (p - certStart)); - psSha1Final(&hashCtx.sha1, cert->sha1CertHash); -# endif - -# ifdef USE_CERT_PARSE - tbsCertStart = p; -# endif /* USE_CERT_PARSE */ -/* - TBSCertificate ::= SEQUENCE { - version [0] EXPLICIT Version DEFAULT v1, - serialNumber CertificateSerialNumber, - signature AlgorithmIdentifier, - issuer Name, - validity Validity, - subject Name, - subjectPublicKeyInfo SubjectPublicKeyInfo, - issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, - -- If present, version shall be v2 or v3 - subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, - -- If present, version shall be v2 or v3 - extensions [3] EXPLICIT Extensions OPTIONAL - -- If present, version shall be v3 } - */ - if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) - { - psTraceCrypto("ASN sequence parse error\n"); - return rc; - } - certEnd = p + len; -# ifdef USE_CERT_PARSE -/* - Start parsing TBSCertificate contents. - */ - certLen = certEnd - tbsCertStart; -/* - Version ::= INTEGER { v1(0), v2(1), v3(2) } - */ - if ((rc = getExplicitVersion(&p, (uint32) (end - p), 0, &cert->version)) - < 0) - { - psTraceCrypto("ASN version parse error\n"); - return rc; - } - switch (cert->version) - { - case 0: - case 1: -# ifndef ALLOW_VERSION_1_ROOT_CERT_PARSE - psTraceCrypto("ERROR: v1 and v2 certificate versions insecure\n"); - cert->parseStatus = PS_X509_UNSUPPORTED_VERSION; - return PS_PARSE_FAIL; -# else - /* Allow locally stored, trusted version 1 and version 2 certificates - to be parsed. The SSL layer code will still reject non v3 - certificates that arrive over-the-wire. */ - /* Version 1 certificates do not have basic constraints to - specify a CA flag or path length. Here, the CA flag is implied - since v1 certs can only be loaded as root. We explicitly set - the pathLengthConstraint to allow up to 2 intermediate certs. - This can be adjusted to allow more or less intermediate certs. */ - cert->extensions.bc.pathLenConstraint = 2; - break; -# endif /* ALLOW_VERSION_1_ROOT_CERT_PARSE */ - case 2: - /* Typical case of v3 cert */ - break; - default: - psTraceIntCrypto("ERROR: unknown certificate version: %d\n", - cert->version); - cert->parseStatus = PS_X509_UNSUPPORTED_VERSION; - return PS_PARSE_FAIL; - } -/* - CertificateSerialNumber ::= INTEGER - There is a special return code for a missing serial number that - will get written to the parse warning flag - */ - if ((rc = getSerialNum(pool, &p, (uint32) (end - p), &cert->serialNumber, - &cert->serialNumberLen)) < 0) - { - psTraceCrypto("ASN serial number parse error\n"); - return rc; - } -/* - AlgorithmIdentifier ::= SEQUENCE { - algorithm OBJECT IDENTIFIER, - parameters ANY DEFINED BY algorithm OPTIONAL } - */ - if ((rc = getAsnAlgorithmIdentifier(&p, (uint32) (end - p), - &cert->certAlgorithm, &plen)) < 0) - { - psTraceCrypto("Couldn't parse algorithm identifier for certAlgorithm\n"); - cert->parseStatus = PS_X509_ALG_ID; - return rc; - } - if (plen != 0) - { -# ifdef USE_PKCS1_PSS - if (cert->certAlgorithm == OID_RSASSA_PSS) - { - /* RSASSA-PSS-params ::= SEQUENCE { - hashAlgorithm [0] HashAlgorithm DEFAULT sha1, - maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, - saltLength [2] INTEGER DEFAULT 20, - trailerField [3] TrailerField DEFAULT trailerFieldBC - } - */ - if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) - { - psTraceCrypto("ASN sequence parse error\n"); - return rc; - } - /* Always set the defaults before parsing */ - cert->pssHash = PKCS1_SHA1_ID; - cert->maskGen = OID_ID_MGF1; - cert->saltLen = SHA1_HASH_SIZE; - /* Something other than defaults to parse here? */ - if (len > 0) - { - if ((rc = getRsaPssParams(&p, len, cert, 0)) < 0) - { - return rc; - } - } - } - else - { - psTraceCrypto("Unsupported X.509 certAlgorithm\n"); - return PS_UNSUPPORTED_FAIL; - } -# else - psTraceCrypto("Unsupported X.509 certAlgorithm\n"); - return PS_UNSUPPORTED_FAIL; -# endif - } -/* - Name ::= CHOICE { - RDNSequence } - - RDNSequence ::= SEQUENCE OF RelativeDistinguishedName - - RelativeDistinguishedName ::= SET OF AttributeTypeAndValue - - AttributeTypeAndValue ::= SEQUENCE { - type AttributeType, - value AttributeValue } - - AttributeType ::= OBJECT IDENTIFIER - - AttributeValue ::= ANY DEFINED BY AttributeType - */ - if ((rc = psX509GetDNAttributes(pool, &p, (uint32) (end - p), - &cert->issuer, flags)) < 0) - { - psTraceCrypto("Couldn't parse issuer DN attributes\n"); - cert->parseStatus = PS_X509_ISSUER_DN; - return rc; - } -/* - Validity ::= SEQUENCE { - notBefore Time, - notAfter Time } - */ - if ((rc = getTimeValidity(pool, &p, (uint32) (end - p), - &cert->notBeforeTimeType, &cert->notAfterTimeType, - &cert->notBefore, &cert->notAfter)) < 0) - { - psTraceCrypto("Couldn't parse validity\n"); - return rc; - } - - /* SECURITY - platforms without a date function will always succeed */ - if ((rc = validateDateRange(cert)) < 0) - { - psTraceCrypto("Validity date check failed\n"); - cert->parseStatus = PS_X509_DATE; - return rc; - } -/* - Subject DN - */ - cert->subjectKeyDerOffsetIntoUnparsedBin = (uint16_t) (p - certStart); - if ((rc = psX509GetDNAttributes(pool, &p, (uint32) (end - p), - &cert->subject, flags)) < 0) - { - psTraceCrypto("Couldn't parse subject DN attributes\n"); - cert->parseStatus = PS_X509_SUBJECT_DN; - return rc; - } -/* - SubjectPublicKeyInfo ::= SEQUENCE { - algorithm AlgorithmIdentifier, - subjectPublicKey BIT STRING } - */ - p_subject_pubkey_info = p; - - cert->publicKeyDerOffsetIntoUnparsedBin = (uint16_t) (p - certStart); - - if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) - { - psTraceCrypto("Couldn't get ASN sequence for pubKeyAlgorithm\n"); - return rc; - } - subject_pubkey_info_header_len = (p - p_subject_pubkey_info); - cert->publicKeyDerLen = len + subject_pubkey_info_header_len; - - if ((rc = getAsnAlgorithmIdentifier(&p, (uint32) (end - p), - &cert->pubKeyAlgorithm, &plen)) < 0) - { - psTraceCrypto("Couldn't parse algorithm id for pubKeyAlgorithm\n"); - return rc; - } - - /* Populate with correct type based on pubKeyAlgorithm OID */ - switch (cert->pubKeyAlgorithm) - { -# ifdef USE_ECC - case OID_ECDSA_KEY_ALG: - if (plen == 0 || plen > (int32) (end - p)) - { - psTraceCrypto("Bad params on EC OID\n"); - return PS_PARSE_FAIL; - } - psInitPubKey(pool, &cert->publicKey, PS_ECC); - if ((rc = getEcPubKey(pool, &p, (uint16_t) (end - p), - &cert->publicKey.key.ecc, sha1KeyHash)) < 0) - { - if (rc == PS_UNSUPPORTED_FAIL) - { - cert->parseStatus = PS_X509_UNSUPPORTED_ECC_CURVE; - } - return PS_PARSE_FAIL; - } - /* keysize will be the size of the public ecc key (2 * privateLen) */ - cert->publicKey.keysize = psEccSize(&cert->publicKey.key.ecc); - if (cert->publicKey.keysize < (MIN_ECC_BITS / 8)) - { - psTraceIntCrypto("ECC key size < %d\n", MIN_ECC_BITS); - psClearPubKey(&cert->publicKey); - cert->parseStatus = PS_X509_WEAK_KEY; - return PS_PARSE_FAIL; - } - break; -# endif -# ifdef USE_RSA - case OID_RSA_KEY_ALG: - psAssert(plen == 0); /* No parameters on RSA pub key OID */ - psInitPubKey(pool, &cert->publicKey, PS_RSA); - if ((rc = psRsaParseAsnPubKey(pool, &p, (uint16_t) (end - p), - &cert->publicKey.key.rsa, sha1KeyHash)) < 0) - { - psTraceCrypto("Couldn't get RSA pub key from cert\n"); - cert->parseStatus = PS_X509_MISSING_RSA; return rc; } - cert->publicKey.keysize = psRsaSize(&cert->publicKey.key.rsa); - - if (cert->publicKey.keysize < (MIN_RSA_BITS / 8)) - { - psTraceIntCrypto("RSA key size < %d\n", MIN_RSA_BITS); - psClearPubKey(&cert->publicKey); - cert->parseStatus = PS_X509_WEAK_KEY; - return PS_PARSE_FAIL; - } - - break; -# endif - default: - /* Note 645:RSA, 515:DSA, 518:ECDSA, 32969:GOST */ - psTraceIntCrypto( - "Unsupported public key algorithm in cert parse: %d\n", - cert->pubKeyAlgorithm); - cert->parseStatus = PS_X509_UNSUPPORTED_KEY_ALG; - return PS_UNSUPPORTED_FAIL; } -# ifdef USE_OCSP - /* A sha1 hash of the public key is useful for OCSP */ - memcpy(cert->sha1KeyHash, sha1KeyHash, SHA1_HASH_SIZE); -# endif + numCerts++; - /* As the next three values are optional, we can do a specific test here */ - if (*p != (ASN_SEQUENCE | ASN_CONSTRUCTED)) - { - if (getImplicitBitString(pool, &p, (uint32) (end - p), - IMPLICIT_ISSUER_ID, &cert->uniqueIssuerId, - &cert->uniqueIssuerIdLen) < 0 || - getImplicitBitString(pool, &p, (uint32) (end - p), - IMPLICIT_SUBJECT_ID, &cert->uniqueSubjectId, - &cert->uniqueSubjectIdLen) < 0 || - getExplicitExtensions(pool, &p, (uint32) (end - p), - EXPLICIT_EXTENSION, &cert->extensions, 0) < 0) - { - psTraceCrypto("There was an error parsing a certificate\n" - "extension. This is likely caused by an\n" - "extension format that is not currently\n" - "recognized. Please email support\n" - "to add support for the extension.\n"); - cert->parseStatus = PS_X509_UNSUPPORTED_EXT; - return PS_PARSE_FAIL; - } - } + /* + Check whether we reached the end of the input DER stream. - /* This is the end of the cert. Do a check here to be certain */ - if (certEnd != p) - { - psTraceCrypto("Error. Expecting end of cert\n"); - cert->parseStatus = PS_X509_EOF; - return PS_LIMIT_FAIL; - } - - /* Reject any cert without a distinguishedName or subjectAltName */ - if (cert->subject.commonName == NULL && - cert->subject.country == NULL && - cert->subject.state == NULL && - cert->subject.organization == NULL && - cert->subject.orgUnit == NULL && - cert->subject.domainComponent == NULL && - cert->extensions.san == NULL) - { - psTraceCrypto("Error. Cert has no name information\n"); - cert->parseStatus = PS_X509_MISSING_NAME; - return PS_PARSE_FAIL; - } -# else /* No TBSCertificate parsing. */ - p = certEnd; -# endif /* USE_CERT_PARSE (end of TBSCertificate parsing) */ - - /* Certificate signature info */ - if ((rc = getAsnAlgorithmIdentifier(&p, (uint32) (end - p), - &cert->sigAlgorithm, &plen)) < 0) - { - psTraceCrypto("Couldn't get algorithm identifier for sigAlgorithm\n"); - return rc; - } - - if (plen != 0) - { -# ifdef USE_PKCS1_PSS - if (cert->sigAlgorithm == OID_RSASSA_PSS) - { - /* RSASSA-PSS-params ::= SEQUENCE { - hashAlgorithm [0] HashAlgorithm DEFAULT sha1, - maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, - saltLength [2] INTEGER DEFAULT 20, - trailerField [3] TrailerField DEFAULT trailerFieldBC - } - */ - if ((rc = getAsnSequence(&p, (uint32) (end - p), &len)) < 0) - { - psTraceCrypto("ASN sequence parse error\n"); - return rc; - } - /* Something other than defaults to parse here? */ - if (len > 0) - { - if ((rc = getRsaPssParams(&p, len, cert, 1)) < 0) - { - return rc; - } - } - } - else - { - psTraceCrypto("Unsupported X.509 sigAlgorithm\n"); - return PS_UNSUPPORTED_FAIL; - } -# else - psTraceCrypto("Unsupported X.509 sigAlgorithm\n"); - return PS_UNSUPPORTED_FAIL; -# endif /* USE_PKCS1_PSS */ - } -# ifdef USE_CERT_PARSE -/* - https://tools.ietf.org/html/rfc5280#section-4.1.1.2 - This field MUST contain the same algorithm identifier as the - signature field in the sequence tbsCertificate (Section 4.1.2.3). - */ - if (cert->certAlgorithm != cert->sigAlgorithm) - { - psTraceIntCrypto("Parse error: mismatched sig alg (tbs = %d ", - cert->certAlgorithm); - psTraceIntCrypto("sig = %d)\n", cert->sigAlgorithm); - cert->parseStatus = PS_X509_SIG_MISMATCH; - return PS_CERT_AUTH_FAIL; - } -/* - Compute the hash of the cert here for CA validation - */ - switch (cert->certAlgorithm) - { -# ifdef ENABLE_MD5_SIGNED_CERTS -# ifdef USE_MD2 - case OID_MD2_RSA_SIG: - psMd2Init(&hashCtx.md2); - psMd2Update(&hashCtx.md2, tbsCertStart, certLen); - psMd2Final(&hashCtx.md2, cert->sigHash); - break; -# endif /* USE_MD2 */ - case OID_MD5_RSA_SIG: - psMd5Init(&hashCtx.md5); - psMd5Update(&hashCtx.md5, tbsCertStart, certLen); - psMd5Final(&hashCtx.md5, cert->sigHash); - break; -# endif -# ifdef ENABLE_SHA1_SIGNED_CERTS - case OID_SHA1_RSA_SIG: - case OID_SHA1_RSA_SIG2: -# ifdef USE_ECC - case OID_SHA1_ECDSA_SIG: -# endif - psSha1PreInit(&hashCtx.sha1); - psSha1Init(&hashCtx.sha1); - psSha1Update(&hashCtx.sha1, tbsCertStart, certLen); - psSha1Final(&hashCtx.sha1, cert->sigHash); - break; -# endif -# ifdef USE_SHA256 - case OID_SHA256_RSA_SIG: -# ifdef USE_ECC - case OID_SHA256_ECDSA_SIG: -# endif - psSha256PreInit(&hashCtx.sha256); - psSha256Init(&hashCtx.sha256); - psSha256Update(&hashCtx.sha256, tbsCertStart, certLen); - psSha256Final(&hashCtx.sha256, cert->sigHash); - break; -# endif -# ifdef USE_SHA384 - case OID_SHA384_RSA_SIG: -# ifdef USE_ECC - case OID_SHA384_ECDSA_SIG: -# endif - psSha384PreInit(&hashCtx.sha384); - psSha384Init(&hashCtx.sha384); - psSha384Update(&hashCtx.sha384, tbsCertStart, certLen); - psSha384Final(&hashCtx.sha384, cert->sigHash); - break; -# endif -# ifdef USE_SHA512 - case OID_SHA512_RSA_SIG: -# ifdef USE_ECC - case OID_SHA512_ECDSA_SIG: -# endif - psSha512PreInit(&hashCtx.sha512); - psSha512Init(&hashCtx.sha512); - psSha512Update(&hashCtx.sha512, tbsCertStart, certLen); - psSha512Final(&hashCtx.sha512, cert->sigHash); - break; -# endif -# ifdef USE_PKCS1_PSS - case OID_RSASSA_PSS: - switch (cert->pssHash) - { -# ifdef ENABLE_MD5_SIGNED_CERTS - case PKCS1_MD5_ID: - psMd5Init(&hashCtx.md5); - psMd5Update(&hashCtx.md5, tbsCertStart, certLen); - psMd5Final(&hashCtx.md5, cert->sigHash); - break; -# endif -# ifdef ENABLE_SHA1_SIGNED_CERTS - case PKCS1_SHA1_ID: - psSha1PreInit(&hashCtx.sha1); - psSha1Init(&hashCtx.sha1); - psSha1Update(&hashCtx.sha1, tbsCertStart, certLen); - psSha1Final(&hashCtx.sha1, cert->sigHash); - break; -# endif -# ifdef USE_SHA256 - case PKCS1_SHA256_ID: - psSha256PreInit(&hashCtx.sha256); - psSha256Init(&hashCtx.sha256); - psSha256Update(&hashCtx.sha256, tbsCertStart, certLen); - psSha256Final(&hashCtx.sha256, cert->sigHash); - break; -# endif -# ifdef USE_SHA384 - case PKCS1_SHA384_ID: - psSha384PreInit(&hashCtx.sha384); - psSha384Init(&hashCtx.sha384); - psSha384Update(&hashCtx.sha384, tbsCertStart, certLen); - psSha384Final(&hashCtx.sha384, cert->sigHash); - break; -# endif -# ifdef USE_SHA512 - case PKCS1_SHA512_ID: - psSha512PreInit(&hashCtx.sha512); - psSha512Init(&hashCtx.sha512); - psSha512Update(&hashCtx.sha512, tbsCertStart, certLen); - psSha512Final(&hashCtx.sha512, cert->sigHash); - break; -# endif - default: - psTraceIntCrypto("Unsupported pssHash algorithm: %d\n", - cert->pssHash); - cert->parseStatus = PS_X509_UNSUPPORTED_SIG_ALG; - return PS_UNSUPPORTED_FAIL; - - } /* switch pssHash */ - break; -# endif /* USE_PKCS1_PSS */ - - default: - /* Note 1670:MD2 */ - psTraceIntCrypto("Unsupported cert algorithm: %d\n", - cert->certAlgorithm); - cert->parseStatus = PS_X509_UNSUPPORTED_SIG_ALG; - return PS_UNSUPPORTED_FAIL; - - } /* switch certAlgorithm */ - - /* 6 empty bytes is plenty enough to know if sigHash didn't calculate */ - if (memcmp(cert->sigHash, "\0\0\0\0\0\0", 6) == 0) - { - psTraceIntCrypto("No library signature alg support for cert: %d\n", - cert->certAlgorithm); - return PS_UNSUPPORTED_FAIL; - } -# endif /* USE_CERT_PARSE */ - - if ((rc = psX509GetSignature(pool, &p, (uint32) (end - p), - &cert->signature, &cert->signatureLen)) < 0) - { - psTraceCrypto("Couldn't parse signature\n"); - cert->parseStatus = PS_X509_SIGNATURE; - return rc; - } - -# ifndef USE_CERT_PARSE - /* Some APIs need certAlgorithm.*/ - cert->certAlgorithm = cert->sigAlgorithm; -# endif /* !USE_CERT_PARSE */ - -/* - The ability to parse additional chained certs is a PKI product - feature addition. Chaining in MatrixSSL is handled internally. - */ - if ((p != far_end) && (p < (far_end + 1))) + An additional sanity check is to ensure that there are least + MIN_CERT_SIZE bytes left in the stream. We wish to avoid + having to call parse_single_cert for any residual garbage + in the stream. + */ + #define MIN_CERT_SIZE 256 + if ((p != far_end) && (p < (far_end + 1)) + && (far_end - p) > MIN_CERT_SIZE) { if (*p == 0x0 && *(p + 1) == 0x0) { @@ -1282,8 +1435,28 @@ int32 psX509ParseCert(psPool_t *pool, const unsigned char *pp, uint32 size, parsing = 0; } } - cert->parseStatus = PS_X509_PARSE_SUCCESS; - return (int32) (p - pp); + + if (numParsedCerts == 0) + return PS_PARSE_FAIL; + + if (flags & CERT_ALLOW_BUNDLE_PARTIAL_PARSE) + { + /* + Return number of successfully parsed certs. + Note: this flag is never set when called from the SSL layer. + */ + psTraceIntCrypto("Parsed %d certs", numParsedCerts); + psTraceIntCrypto(" from a total of %d certs\n", numCerts); + return numParsedCerts; + } + else + { + /* + Return length of parsed DER stream. + Some functions in the SSL layer require this. + */ + return (int32) (p - pp); + } } # ifdef USE_CERT_PARSE @@ -2265,7 +2438,8 @@ static int32_t parseGeneralNames(psPool_t *pool, const unsigned char **buf, p = *buf; end = p + len; - while (len > 0) +# define MIN_GENERALNAME_LEN 3 /* 1 tag, 1 length octet, 1 content octet.*/ + while (len > MIN_GENERALNAME_LEN) { if (firstName == NULL) { @@ -2354,7 +2528,15 @@ static int32_t parseGeneralNames(psPool_t *pool, const unsigned char **buf, } /* TODO - validate *p == STRING type? */ p++; /* Jump over TYPE */ - len -= (p - save); + if (len <= (p - save)) + { + psTraceCrypto("ASN len error in parseGeneralNames\n"); + return PS_PARSE_FAIL; + } + else + { + len -= (p - save); + } break; case GN_EMAIL: strncpy((char *) activeName->name, "email", @@ -2402,7 +2584,15 @@ static int32_t parseGeneralNames(psPool_t *pool, const unsigned char **buf, psTraceCrypto("ASN len error in parseGeneralNames\n"); return PS_PARSE_FAIL; } - len -= (p - save); + if (len <= (p - save)) + { + psTraceCrypto("ASN len error in parseGeneralNames\n"); + return PS_PARSE_FAIL; + } + else + { + len -= (p - save); + } if (len < activeName->dataLen) { psTraceCrypto("ASN len error in parseGeneralNames\n"); @@ -3021,14 +3211,15 @@ int32_t parsePolicyMappings(psPool_t *pool, } p += len; - pol_map->issuerDomainPolicy = psMalloc(pool, len * sizeof(uint32_t)); - memset(pol_map->issuerDomainPolicy, 0, len * sizeof(uint32_t)); + pol_map->issuerDomainPolicy = psMalloc(pool, + oidlen * sizeof(uint32_t)); + memset(pol_map->issuerDomainPolicy, 0, oidlen * sizeof(uint32_t)); for (i = 0; i < oidlen; i++) { pol_map->issuerDomainPolicy[i] = oid[i]; } - pol_map->issuerDomainPolicyLen = len; + pol_map->issuerDomainPolicyLen = oidlen; /* Parse subjectDomainPolicy OID. */ if (*p++ != ASN_OID) @@ -3051,14 +3242,15 @@ int32_t parsePolicyMappings(psPool_t *pool, } p += len; - pol_map->subjectDomainPolicy = psMalloc(pool, len * sizeof(uint32_t)); - memset(pol_map->subjectDomainPolicy, 0, len * sizeof(uint32_t)); + pol_map->subjectDomainPolicy = psMalloc(pool, + oidlen * sizeof(uint32_t)); + memset(pol_map->subjectDomainPolicy, 0, oidlen * sizeof(uint32_t)); for (i = 0; i < oidlen; i++) { pol_map->subjectDomainPolicy[i] = oid[i]; } - pol_map->subjectDomainPolicyLen = len; + pol_map->subjectDomainPolicyLen = oidlen; ++num_mappings; } @@ -4998,7 +5190,7 @@ int32 psX509AuthenticateCert(psPool_t *pool, psX509Cert_t *subjectCert, psX509Cert_t *ic, *sc; int32 sigType, rc; uint32 sigLen; - void *rsaData; + void *rsaData = NULL; # ifdef USE_ECC int32 sigStat; @@ -5156,6 +5348,12 @@ int32 psX509AuthenticateCert(psPool_t *pool, psX509Cert_t *subjectCert, sigType = RSA_TYPE_SIG; break; # endif +# ifdef USE_SHA224 + case OID_SHA224_RSA_SIG: + sigLen = 10 + SHA224_HASH_SIZE + 9; + sigType = RSA_TYPE_SIG; + break; +# endif # ifdef USE_SHA256 case OID_SHA256_RSA_SIG: sigLen = 10 + SHA256_HASH_SIZE + 9; @@ -5182,6 +5380,12 @@ int32 psX509AuthenticateCert(psPool_t *pool, psX509Cert_t *subjectCert, sigType = ECDSA_TYPE_SIG; break; # endif +# ifdef USE_SHA224 + case OID_SHA224_ECDSA_SIG: + sigLen = SHA224_HASH_SIZE; + sigType = ECDSA_TYPE_SIG; + break; +# endif # ifdef USE_SHA256 case OID_SHA256_ECDSA_SIG: sigLen = SHA256_HASH_SIZE; @@ -5216,6 +5420,11 @@ int32 psX509AuthenticateCert(psPool_t *pool, psX509Cert_t *subjectCert, sigLen = SHA1_HASH_SIZE; break; # endif +# ifdef USE_SHA224 + case PKCS1_SHA224_ID: + sigLen = SHA224_HASH_SIZE; + break; +# endif # ifdef USE_SHA256 case PKCS1_SHA256_ID: sigLen = SHA256_HASH_SIZE; @@ -5269,8 +5478,6 @@ int32 psX509AuthenticateCert(psPool_t *pool, psX509Cert_t *subjectCert, } memcpy(tempSig, sc->signature, sc->signatureLen); - rsaData = NULL; - if ((rc = psRsaDecryptPub(pkiPool, &ic->publicKey.key.rsa, tempSig, sc->signatureLen, sigOut, sigLen, rsaData)) < 0) { @@ -5322,7 +5529,6 @@ int32 psX509AuthenticateCert(psPool_t *pool, psX509Cert_t *subjectCert, # ifdef USE_ECC if (sigType == ECDSA_TYPE_SIG) { - rsaData = NULL; if ((rc = psEccDsaVerify(pkiPool, &ic->publicKey.key.ecc, sc->sigHash, sigLen, @@ -5535,6 +5741,15 @@ static int32_t x509ConfirmSignature(const unsigned char *sigHash, } break; # endif +# ifdef USE_SHA224 + case OID_SHA224_ALG: + if (len != SHA224_HASH_SIZE) + { + psTraceCrypto("SHA224_HASH_SIZE error in x509ConfirmSignature\n"); + return PS_LIMIT_FAIL; + } + break; +# endif # ifdef USE_SHA256 case OID_SHA256_ALG: if (len != SHA256_HASH_SIZE) @@ -5840,6 +6055,9 @@ static int32_t ocspParseBasicResponse(psPool_t *pool, uint32_t len, # endif # ifdef USE_SHA384 psSha384_t sha3; +# endif +# ifdef USE_SHA512 + psSha512_t sha512; # endif psSize_t glen, plen; uint32_t blen; @@ -6051,16 +6269,30 @@ static int32_t ocspParseBasicResponse(psPool_t *pool, uint32_t len, case OID_SHA1_ECDSA_SIG: # endif res->hashLen = SHA1_HASH_SIZE; + psSha1PreInit(&sha); psSha1Init(&sha); psSha1Update(&sha, startRes, (int32) (endRes - startRes)); psSha1Final(&sha, res->hashResult); break; +# ifdef USE_SHA224 + case OID_SHA224_RSA_SIG: +# ifdef USE_ECC + case OID_SHA224_ECDSA_SIG: +# endif + res->hashLen = SHA224_HASH_SIZE; + psSha224PreInit(&sha2); + psSha224Init(&sha2); + psSha224Update(&sha2, startRes, (int32) (endRes - startRes)); + psSha224Final(&sha2, res->hashResult); + break; +# endif # ifdef USE_SHA256 case OID_SHA256_RSA_SIG: # ifdef USE_ECC case OID_SHA256_ECDSA_SIG: # endif res->hashLen = SHA256_HASH_SIZE; + psSha256PreInit(&sha2); psSha256Init(&sha2); psSha256Update(&sha2, startRes, (int32) (endRes - startRes)); psSha256Final(&sha2, res->hashResult); @@ -6072,10 +6304,23 @@ static int32_t ocspParseBasicResponse(psPool_t *pool, uint32_t len, case OID_SHA384_ECDSA_SIG: # endif res->hashLen = SHA384_HASH_SIZE; + psSha384PreInit(&sha3); psSha384Init(&sha3); psSha384Update(&sha3, startRes, (int32) (endRes - startRes)); psSha384Final(&sha3, res->hashResult); break; +# endif +# ifdef USE_SHA512 + case OID_SHA512_RSA_SIG: +# ifdef USE_ECC + case OID_SHA512_ECDSA_SIG: +# endif + res->hashLen = SHA512_HASH_SIZE; + psSha512PreInit(&sha512); + psSha512Init(&sha512); + psSha512Update(&sha512, startRes, (int32) (endRes - startRes)); + psSha512Final(&sha512, res->hashResult); + break; # endif default: psTraceCrypto("No support for sigAlg in OCSP ResponseData\n"); @@ -6514,6 +6759,8 @@ static int32_t parseOcspReq(const void *data, size_t datalen, return psParseBufFinish(&ocspRequest); } +#define RESPONDER_NAME_MAX_LENGTH 1024 + static int32_t ocspMatchResponderCert(const psOcspResponse_t *response, const psX509Cert_t *curr) { @@ -6529,12 +6776,15 @@ static int32_t ocspMatchResponderCert(const psOcspResponse_t *response, { uint32_t len; /* Obtain the length of name tag including header. - Note: responderName has already been validated during parsing. */ - const unsigned char *p = response->responderName + 1; - if (getAsnLength32(&p, 4, &len, 0) < 0) - return PS_FAILURE; /* Should not happen. */ + Note: responderName has already been validated during parsing, + so getAsnTagLenUnsafe is ok. + */ + len = getAsnTagLenUnsafe(response->responderName); - len = (uint32_t) (p + len - response->responderName); + if (len < 2 || len > RESPONDER_NAME_MAX_LENGTH) + { + return PS_FAILURE; + } /* Match certificate using subject name. */ if (curr->unparsedBin == NULL || @@ -6809,6 +7059,16 @@ int32_t psOcspResponseValidate(psPool_t *pool, psX509Cert_t *trustedOCSP, /* Finally do the sig validation */ switch (response->sigAlg) { +# ifdef USE_SHA224 + case OID_SHA224_RSA_SIG: + sigOutLen = SHA224_HASH_SIZE; + sigType = PS_RSA; + break; + case OID_SHA224_ECDSA_SIG: + sigOutLen = SHA224_HASH_SIZE; + sigType = PS_ECC; + break; +# endif # ifdef USE_SHA256 case OID_SHA256_RSA_SIG: sigOutLen = SHA256_HASH_SIZE; @@ -6828,6 +7088,16 @@ int32_t psOcspResponseValidate(psPool_t *pool, psX509Cert_t *trustedOCSP, sigOutLen = SHA384_HASH_SIZE; sigType = PS_ECC; break; +# endif +# ifdef USE_SHA512 + case OID_SHA512_RSA_SIG: + sigOutLen = SHA512_HASH_SIZE; + sigType = PS_RSA; + break; + case OID_SHA512_ECDSA_SIG: + sigOutLen = SHA512_HASH_SIZE; + sigType = PS_ECC; + break; # endif case OID_SHA1_RSA_SIG: case OID_SHA1_RSA_SIG2: diff --git a/crypto/keyformat/x509.h b/crypto/keyformat/x509.h index cda303d..ae0092c 100644 --- a/crypto/keyformat/x509.h +++ b/crypto/keyformat/x509.h @@ -64,6 +64,10 @@ enum /* Parsing flags */ # define CERT_STORE_UNPARSED_BUFFER 0x1 # define CERT_STORE_DN_BUFFER 0x2 +/** Allow parsing of a certificate bundle (a concatenated PEM file + or a DER stream) to succeed even when some certs could not be + supported by MatrixSSL. */ +# define CERT_ALLOW_BUNDLE_PARTIAL_PARSE 0x4 # ifdef USE_CERT_PARSE diff --git a/crypto/layer/layer.h b/crypto/layer/layer.h index 04f9b77..381d0c9 100644 --- a/crypto/layer/layer.h +++ b/crypto/layer/layer.h @@ -155,11 +155,14 @@ /* #undef USE_MATRIX_CHACHA20_POLY1305 / * @note, not defined in matrix crypto * / */ # define USE_LIBSODIUM_CHACHA20_POLY1305 # endif - + +/* libsodium AES-GCM is not automatically enabled. + libsodium AES-GCM offers only 256-bit AES-GCM, where as TLS uses 128/256. # ifdef USE_MATRIX_AES_GCM # undef USE_MATRIX_AES_GCM # define USE_LIBSODIUM_AES_GCM # endif +*/ # ifdef USE_MATRIX_SHA256 # undef USE_MATRIX_SHA256 diff --git a/crypto/layer/matrix.c b/crypto/layer/matrix.c index b09fc75..ea06515 100644 --- a/crypto/layer/matrix.c +++ b/crypto/layer/matrix.c @@ -46,34 +46,45 @@ static char g_config[32] = "N"; int32_t psCryptoOpen(const char *config) { uint32_t clen; - + if (*g_config == 'Y') { return PS_SUCCESS; /* Function has been called previously */ } + /* 'config' is cryptoconfig + coreconfig */ - strncpy(g_config, PSCRYPTO_CONFIG, sizeof(g_config) - 1); clen = strlen(PSCRYPTO_CONFIG) - strlen(PSCORE_CONFIG); - if (strncmp(g_config, config, clen) != 0) + if (strncmp(PSCRYPTO_CONFIG, config, clen) != 0) { psErrorStr( "Crypto config mismatch.\n" \ "Library: " PSCRYPTO_CONFIG \ "\nCurrent: %s\n", config); - return -1; + return PS_FAILURE; } if (psCoreOpen(config + clen) < 0) { psError("pscore open failure\n"); return PS_FAILURE; } + #ifdef USE_FLPS_BINDING flps_binding(); + /* Check if FIPS Library Open failed. */ + if ((int)CLS_LibStatus(flps_getCLS()) < 0) + { + return PS_SELFTEST_FAILED; + } #endif /* USE_FLPS_BINDING */ + psOpenPrng(); #ifdef USE_CRL psCrlOpen(); #endif - return 0; + + /* Everything successful, store configuration. */ + strncpy(g_config, PSCRYPTO_CONFIG, sizeof(g_config) - 1); + + return PS_SUCCESS; } void psCryptoClose(void) diff --git a/crypto/pubkey/ecc.c b/crypto/pubkey/ecc.c index 40decab..febeeb8 100644 --- a/crypto/pubkey/ecc.c +++ b/crypto/pubkey/ecc.c @@ -450,6 +450,7 @@ int32_t getEcPubKey(psPool_t *pool, const unsigned char **pp, psSize_t len, Standard form - SHA-1 hash of the value of the BIT STRING subjectPublicKey [excluding the tag, length, and number of unused bits] */ + psSha1PreInit(&dc.sha1); psSha1Init(&dc.sha1); psSha1Update(&dc.sha1, p, arcLen); psSha1Final(&dc.sha1, sha1KeyHash); @@ -464,7 +465,8 @@ int32_t getEcPubKey(psPool_t *pool, const unsigned char **pp, psSize_t len, p += arcLen; *pp = p; - return 0; + + return PS_SUCCESS; } /** diff --git a/crypto/pubkey/pubkey.c b/crypto/pubkey/pubkey.c index b3181de..12ad0af 100644 --- a/crypto/pubkey/pubkey.c +++ b/crypto/pubkey/pubkey.c @@ -119,6 +119,94 @@ void psDeletePubKey(psPubKey_t **key) # ifdef USE_PRIVATE_KEY_PARSING # ifdef MATRIX_USE_FILE_SYSTEM # if defined(USE_ECC) && defined(USE_RSA) +/* + Trial and error private key parse for when ECC or RSA is unknown. + keyBuf must point to a buffer of length keyBufLen, containing + a DER-encoded key. + + Return codes: + 1 RSA key + 2 ECC key + < 0 error + */ +int32_t psParseUnknownPrivKeyMem(psPool_t *pool, + unsigned char *keyBuf, int32 keyBufLen, + const char *password, psPubKey_t *privkey) +{ + psRsaKey_t *rsakey; + psEccKey_t *ecckey; + int32_t keytype = 1; + psBool_t notRsaKey; + + if (keyBuf == NULL || keyBufLen <= 0) + return PS_ARG_FAIL; + + privkey->keysize = 0; + rsakey = &privkey->key.rsa; + ecckey = &privkey->key.ecc; + + /* Examine data to ensure parses which could not succeed are not tried. */ + + /* Guess if this can be RSA key based on length of encoding and content. + Even the smallest (obsolete 512-bit modulus) RSA private keys are > + 256 bytes. + */ + notRsaKey = keyBufLen < 257 || keyBuf[0] != 0x30 || keyBuf[1] < 0x82; + + /* A raw RSAPrivateKey? */ + if (notRsaKey != PS_FALSE || + psRsaParsePkcs1PrivKey(pool, keyBuf, keyBufLen, rsakey) + < PS_SUCCESS) + { + /* A raw ECPrivateKey? */ + if (psEccParsePrivKey(pool, keyBuf, keyBufLen, ecckey, NULL) + < PS_SUCCESS) + { +# ifdef USE_PKCS8 + /* A PKCS #8 PrivateKeyInfo containing an ECPrivateKey? */ + if (psPkcs8ParsePrivBin(pool, keyBuf, keyBufLen, + (char*)password, privkey)) + { +# endif /* USE_PKCS8 */ + /* Nothing worked. */ + psTraceCrypto("Unable to parse private key. " \ + "Supported formats are RSAPrivateKey, " \ + "ECPrivateKey and PKCS #8.\n"); + return PS_FAILURE; +# ifdef USE_PKCS8 + } + if (privkey->type == PS_RSA) + { + keytype = 1; + } + else if (privkey->type == PS_ECC) + { + keytype = 2; + } + goto parsed; +# endif /* USE_PKCS8 */ + } + keytype = 2; + } + +# ifdef USE_PKCS8 +parsed: +# endif /* USE_PKCS8 */ + if (keytype == 1) + { + privkey->type = PS_RSA; + privkey->keysize = psRsaSize(&privkey->key.rsa); + } + else + { + privkey->type = PS_ECC; + privkey->keysize = psEccSize(&privkey->key.ecc); + } + privkey->pool = pool; + + return keytype; +} + /* Trial and error private key parse for when ECC or RSA is unknown. pemOrDer should be 1 if PEM @@ -126,16 +214,18 @@ void psDeletePubKey(psPubKey_t **key) Return codes: 1 RSA key 2 ECC key - -1 error + < 0 error */ -int32_t psParseUnknownPrivKey(psPool_t *pool, int pemOrDer, char *keyfile, - char *password, psPubKey_t *privkey) +int32_t psParseUnknownPrivKey(psPool_t *pool, int pemOrDer, + const char *keyfile, const char *password, + psPubKey_t *privkey) { psRsaKey_t *rsakey; psEccKey_t *ecckey; int keytype = 1; unsigned char *keyBuf; int32 keyBufLen; + int32_t rc; privkey->keysize = 0; rsakey = &privkey->key.rsa; @@ -152,7 +242,7 @@ int32_t psParseUnknownPrivKey(psPool_t *pool, int pemOrDer, char *keyfile, { psTraceStrCrypto("Unable to parse private key file %s\n", keyfile); - return -1; + return PS_FAILURE; } keytype = 2; } @@ -169,61 +259,33 @@ int32_t psParseUnknownPrivKey(psPool_t *pool, int pemOrDer, char *keyfile, psTraceStrCrypto("Unable to open private key file %s\n", keyfile); return -1; } - /* A raw RSAPrivateKey? */ - if (psRsaParsePkcs1PrivKey(pool, keyBuf, keyBufLen, rsakey) - < PS_SUCCESS) + rc = psParseUnknownPrivKeyMem(pool, keyBuf, keyBufLen, password, + privkey); + psFree(keyBuf, pool); + + /* Continue examining result of private key parsing. */ + if (rc < 0) { - /* A raw ECPrivateKey? */ - if (psEccParsePrivKey(pool, keyBuf, keyBufLen, ecckey, NULL) - < PS_SUCCESS) - { -# ifdef USE_PKCS8 - /* A PKCS #8 PrivateKeyInfo containing an ECPrivateKey? */ - if (psPkcs8ParsePrivBin(pool, keyBuf, keyBufLen, password, - privkey)) - { -# endif /* USE_PKCS8 */ - /* Nothing worked. */ - psTraceCrypto("Unable to parse private key. " \ - "Supported formats are RSAPrivateKey, " \ - "ECPrivateKey and PKCS #8.\n"); - psFree(keyBuf, pool); - return -1; - } -# ifdef USE_PKCS8 - if (privkey->type == PS_RSA) - { - keytype = 1; - } - else if (privkey->type == PS_ECC) - { - keytype = 2; - } - goto parsed; -# endif /* USE_PKCS8 */ + psTraceStrCrypto("Unable to parse private key file %s\n", keyfile); + return -1; } - keytype = 2; + keytype = rc; + goto out; /* psParseUnknownPrivKeyMem already set up everything. */ + } + + if (keytype == 1) + { + privkey->type = PS_RSA; + privkey->keysize = psRsaSize(&privkey->key.rsa); } else { - keytype = 1; + privkey->type = PS_ECC; + privkey->keysize = psEccSize(&privkey->key.ecc); } -parsed: - psFree(keyBuf, pool); -} - -if (keytype == 1) -{ - privkey->type = PS_RSA; - privkey->keysize = psRsaSize(&privkey->key.rsa); -} -else -{ - privkey->type = PS_ECC; - privkey->keysize = psEccSize(&privkey->key.ecc); -} -privkey->pool = pool; -return keytype; + privkey->pool = pool; +out: + return keytype; } /* Trial and error public key parse for when ECC or RSA is unknown. @@ -426,6 +488,16 @@ psRes_t psComputeHashForSig(const unsigned char *dataBegin, psSha1Final(&hash.sha1, hashOut); *hashOutLen = SHA1_HASH_SIZE; break; +#ifdef USE_SHA224 + case OID_SHA224_RSA_SIG: + case OID_SHA224_ECDSA_SIG: + psSha224PreInit(&hash.sha256); + psSha224Init(&hash.sha256); + psSha224Update(&hash.sha256, dataBegin, dataLen); + psSha224Final(&hash.sha256, hashOut); + *hashOutLen = SHA224_HASH_SIZE; + break; +#endif /* USE_SHA224 */ case OID_SHA256_RSA_SIG: case OID_SHA256_ECDSA_SIG: psSha256PreInit(&hash.sha256); @@ -437,7 +509,7 @@ psRes_t psComputeHashForSig(const unsigned char *dataBegin, # ifdef USE_SHA384 case OID_SHA384_RSA_SIG: case OID_SHA384_ECDSA_SIG: - psSha512PreInit(&hash.sha512); + psSha384PreInit(&hash.sha384); psSha384Init(&hash.sha384); psSha384Update(&hash.sha384, dataBegin, dataLen); psSha384Final(&hash.sha384, hashOut); diff --git a/crypto/pubkey/pubkey.h b/crypto/pubkey/pubkey.h index 1c3da50..36c6f58 100644 --- a/crypto/pubkey/pubkey.h +++ b/crypto/pubkey/pubkey.h @@ -165,7 +165,8 @@ enum PACKED PS_RSA, PS_DSA, PS_ECC, - PS_DH + PS_DH, + PS_CL_PK /* A public key for CL Library. May contain any key format. */ }; /** Signature types */ diff --git a/crypto/test/Makefile b/crypto/test/Makefile index 3a817da..313dee6 100644 --- a/crypto/test/Makefile +++ b/crypto/test/Makefile @@ -17,6 +17,11 @@ VECTOR_EXE:=algorithmTest$(E) SPEED_EXE:=throughputTest$(E) EXE:=$(VECTOR_EXE) $(SPEED_EXE) +CRYPTOOPEN_SRC:=cryptoOpen.c +CRYPTOOPEN_EXE:=cryptoOpen$(E) +SRC+=$(CRYPTOOPEN_SRC) +EXE+=$(CRYPTOOPEN_EXE) + include $(MATRIXSSL_ROOT)/common.mk # Linked files @@ -39,6 +44,9 @@ $(SPEED_EXE): $(SPEED_SRC:.c=.o) $(STATICS) $(VECTOR_EXE): $(VECTOR_SRC:.c=.o) $(STATICS) $(CC) -o $@ $^ $(LDFLAGS) +$(CRYPTOOPEN_EXE): $(CRYPTOOPEN_SRC:.c=.o) $(STATICS) + $(CC) -o $@ $^ $(LDFLAGS) + clean: rm -f $(EXE) $(OBJS) if [ -e rsaperf ]; then $(MAKE) clean --directory=rsaperf;fi diff --git a/crypto/test/algorithmTest.c b/crypto/test/algorithmTest.c index 001b21a..4a77c8f 100644 --- a/crypto/test/algorithmTest.c +++ b/crypto/test/algorithmTest.c @@ -2581,7 +2581,7 @@ int32 psSha224Test(void) int i; unsigned char tmp[28]; - psDigestContext_t md; + psSha256_t md; for (i = 0; i < (int) (sizeof(tests) / sizeof(tests[0])); i++) { @@ -5286,6 +5286,13 @@ static test_t tests[] = { #endif , "***** SHA1 TESTS *****" }, +#ifdef USE_SHA224 + { psSha224Test +#else + { NULL +#endif + , "***** SHA224 TESTS *****" }, + #ifdef USE_SHA256 { psSha256Test #else diff --git a/crypto/test/cryptoOpen.c b/crypto/test/cryptoOpen.c new file mode 100644 index 0000000..0d82a43 --- /dev/null +++ b/crypto/test/cryptoOpen.c @@ -0,0 +1,55 @@ +#include +#include "crypto/cryptoApi.h" + +int main(void) +{ + psSha256_t md; + int i; + unsigned char out[32 + 2]; + unsigned char txt[3] = { 'a', 'b', 'c' }; + const unsigned char expect[32 + 2] = + { + 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, + 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, + 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad, + 0xfe, 0xfe /* bytes unmodified. */ + }; + unsigned char sum; + psRes_t res; + + memset(out, 0xfe, 32 + 2); + + /* Try opening cryptographic library. */ + res = psCryptoOpen(PSCRYPTO_CONFIG); + if (res == PS_SELFTEST_FAILED) + { + fprintf(stdout, "Library initialization failed: Self-test failure\n"); + return 2; + } + else if (res < PS_SUCCESS) + { + fprintf(stdout, "Library initialization failed\n"); + return 2; + } + + /* Things appear ok. Ensure they are: */ + psSha256PreInit(&md); /* Pre-init before first use. */ + psSha256Init(&md); + psSha256Update(&md, txt, 3); + psSha256Final(&md, out); + + sum = 0; + for(i = 0; i < 32 + 2; i++) + { + sum |= out[i] ^ expect[i]; + } + + if (sum != 0) + { + fprintf(stderr, "Library is broken.\n"); + return 3; + } + + fprintf(stderr, "Successful init.\n"); + return 0; +} diff --git a/crypto/test/cryptoOpenTest.sh b/crypto/test/cryptoOpenTest.sh new file mode 100755 index 0000000..0fc5831 --- /dev/null +++ b/crypto/test/cryptoOpenTest.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +# Try various corruptions on libsafezone-sw-fips.so. +# Intented to be mainly used with CL built with CFLAGS_CLC=-DCLC_VERIFY. + +if [ "X$1" = "X--all" ];then +try_cryptoOpen() +{ + echo -n Default:" " + ./cryptoOpen + ret=$? + if [ X$ret != X0 ]; + then + echo "[Return value: $ret]" + fi + echo -n FL:" " + ./cryptoOpen fl + ret=$? + if [ X$ret != X0 ]; + then + echo "[Return value: $ret]" + fi + echo -n SL:" " + ./cryptoOpen sl + ret=$? + if [ X$ret != X0 ]; + then + echo "[Return value: $ret]" + fi +} +elif [ "X$1" = "X" ];then + try_cryptoOpen() + { + ./cryptoOpen + ret=$? + if [ X$ret != X0 ]; + then + echo "[Return value: $ret]" + fi + } +else + echo "Usage: $0 [--all]" >&2 + exit 1 +fi + +unset NO_SAFEZONE_FIPS + +echo "*** TEST CASE #1: FL File does not exist" +unset LD_LIBRARY_PATH +try_cryptoOpen + +echo "*** TEST CASE #2: Empty LD_LIBRARY_PATH" +export LD_LIBRARY_PATH= +try_cryptoOpen + +rm -rf /tmp/x86-64-libs +mkdir /tmp/x86-64-libs \ + /tmp/x86-64-libs/{nocheck,pad,corrupt1,corrupt2,corrupt_chk,wrong_chk,check} + +echo "*** TEST CASE #3: No checksum" +LIBDIR=/tmp/x86-64-libs/nocheck +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +try_cryptoOpen + +echo "*** TEST CASE #4: Extraneous data in library file." +LIBDIR=/tmp/x86-64-libs/pad +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +../check-lib/create-check-lib.sh $LIBFILE >/dev/null 2>/dev/null +head -c 1024 /dev/zero >>$LIBFILE # Append block of zero bytes +try_cryptoOpen + +echo "*** TEST CASE #5: Corrupt FIPS Library .so file" +LIBDIR=/tmp/x86-64-libs/corrupt1 +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +../check-lib/create-check-lib.sh $LIBFILE >/dev/null 2>/dev/null +dd if=/dev/zero of=$LIBFILE oflag=seek_bytes seek=4096 bs=1M count=1 # Alter large block of file. +try_cryptoOpen + +echo "*** TEST CASE #6: Corrupt [bus error] FIPS Library .so file" +LIBDIR=/tmp/x86-64-libs/corrupt2 +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +../check-lib/create-check-lib.sh $LIBFILE >/dev/null 2>/dev/null +dd if=/dev/zero of=$LIBFILE oflag=seek_bytes seek=2251216 bs=2048 count=1 # Alter a block at critical part of file. +try_cryptoOpen + +echo "*** TEST CASE #7: Corrupt checksum file" +LIBDIR=/tmp/x86-64-libs/corrupt_chk +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +../check-lib/create-check-lib.sh $LIBFILE >/dev/null 2>/dev/null +dd if=/dev/zero of="$LIBFILE".check bs=16 count=1 +try_cryptoOpen + +echo "*** TEST CASE #8: Wrong checksum file" +LIBDIR=/tmp/x86-64-libs/wrong_chk +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/i686-linux-gnu/libsafezone-sw-fips.so $LIBFILE +../check-lib/create-check-lib.sh $LIBFILE >/dev/null 2>/dev/null +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +dd if=/dev/zero of="$LIBFILE".check bs=16 count=1 +try_cryptoOpen + +echo "*** TEST CASE #9: All ok test case." +LIBDIR=/tmp/x86-64-libs/check +LIBFILE=$LIBDIR/libsafezone-sw-fips.so +export LD_LIBRARY_PATH=$LIBDIR +cp -r ../../../FIPSLib11/lib/x86_64-linux-gnu/libsafezone-sw-fips.so $LIBFILE +../check-lib/create-check-lib.sh $LIBFILE >/dev/null 2>/dev/null +try_cryptoOpen diff --git a/crypto/test/ocspTest.c b/crypto/test/ocspTest.c new file mode 100644 index 0000000..93717f9 --- /dev/null +++ b/crypto/test/ocspTest.c @@ -0,0 +1,565 @@ +/* ocspTest.c + * + * Test OCSP APIs. + */ + +/***************************************************************************** +* Copyright (c) 2017 INSIDE Secure Oy. All Rights Reserved. +* +* This confidential and proprietary software may be used only as authorized +* by a licensing agreement from INSIDE Secure. +* +* The entire notice above must be reproduced on all authorized copies that +* may only be made to the extent permitted by a licensing agreement from +* INSIDE Secure. +*****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "crypto/cryptoApi.h" +#include "core/coreApi.h" + +#include "ocspTestData.h" + +#define MAX_EXTRA_INFO 128 +typedef enum { OK, FAILED, WEAK, SKIPPED } TEST_RESULT; + +int write_debug_files; + +# define NOT_SUPPORTED(func_proto) func_proto { \ + return failf("Functionality is currently missing"); \ +} \ + extern int require_semicolon[1] + +static char extra_info[MAX_EXTRA_INFO]; + +int test(int condition) +{ + /* This function is provided as convenience for setting + breakpoint(s). */ + return condition; +} + +int fail(void) +{ + /* This function is provided as convenience for setting + breakpoint(s). */ + return FAILED; +} + +int failf(const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vsnprintf(extra_info, sizeof(extra_info), fmt, va); + va_end(va); + return FAILED; +} + +int okf(const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vsnprintf(extra_info, sizeof(extra_info), fmt, va); + va_end(va); + return OK; +} + +int fail_at(const char *file, int line, const char *cond) +{ + /* This function is provided as convenience for setting + breakpoint(s) and for debug output. */ + fprintf(stderr, "Failure detected at %s:%d: %s\n", file, line, cond); + return fail(); +} + +#define FAIL_IF(condition) \ + do { \ + if (test(condition)) { \ + return fail_at(__FILE__, __LINE__, #condition); } \ + } while (0) + +/* Check existance of function. Fails if the function does not exist. */ +#define CHECK_EXISTS(fun) \ + do { \ + void *ptr = &fun; \ + if (!ptr) { \ + return failf("Unable to locate function "#fun "\n"); \ + } \ + } while (0) + +/* #define VERBOSE(...) do { printf(__VA_ARGS__); } */ +#define VERBOSE(...) do { } while (0) + +/* Give alias (alternative name) for function. */ +#define TEST_ALT_NAME(new_name, old_name) \ + TEST_RESULT new_name(void) \ + { \ + return old_name(); \ + } \ + TEST_RESULT new_name(void) + +/* Test is intended to run only once and cache the results. + This is to be used TEST_ALT_NAME(). + Warning: this macro may call return (i.e. affect control flow). */ +#define TEST_ONCE(fun) \ + do \ + { \ + static unsigned long long test_once_called_times = 0; \ + static TEST_RESULT test_once_result_cached = SKIPPED; \ + test_once_called_times ++; \ + \ + switch (test_once_called_times) \ + { \ + case 1: \ + /* Ensure correct function name used. */ \ + assert(strcmp(#fun, __func__) == 0); \ + test_once_result_cached = fun (); \ + /* fall-through */ \ + default: \ + return test_once_result_cached; \ + case 2: \ + /* actual execution of the function. */ \ + break; \ + } \ + } while (0) \ + +void opt_WRITE_FILE(const char *target, + const void *data, + size_t data_length) +{ + FILE *f; + + if (!write_debug_files) + { + return; /* Do not produce debugging files. */ + } + + f = fopen(target, "w"); + if (f) + { + if (fwrite(data, data_length, 1, f) != 1) + { + fprintf(stderr, "write error\n"); + exit(1); + } + fprintf(stderr, "(Written %lu data bytes to %s)\n", + (long unsigned int) data_length, target); + } + fclose(f); +} + +TEST_RESULT TEST_psOcspRequestWrite(void) +{ + psRes_t res; + psX509Cert_t *revoked_psX509certificate; + psX509Cert_t *issuer_psX509certificate; + uint32 requestLen; + unsigned char *request = NULL; + + res = psX509ParseCert( + NULL, + revoked_certificate, + sizeof revoked_certificate, + &revoked_psX509certificate, 0); + FAIL_IF(res < 0); + res = psX509ParseCert( + NULL, + intermediate_certificate, + sizeof intermediate_certificate, + &issuer_psX509certificate, 0); + FAIL_IF(res < 0); + res = psOcspRequestWrite(MATRIX_NO_POOL, + revoked_psX509certificate, + issuer_psX509certificate, + &request, &requestLen, NULL); + FAIL_IF(res < 0); + opt_WRITE_FILE("/tmp/request", request, requestLen); + FAIL_IF(memcmp(request, ocsp_request, sizeof ocsp_request) != 0); + psX509FreeCert(revoked_psX509certificate); + psX509FreeCert(issuer_psX509certificate); + psFree(request, MATRIX_NO_POOL); + return OK; +} + +TEST_RESULT TEST_psOcspParseResponse(void) +{ + psRes_t res; + psX509Cert_t *revoked_psX509certificate; + psX509Cert_t *issuer_psX509certificate; + unsigned char *p = ocsp_response; + int resp_len = ocsp_response_len; + int32_t res32; + psOcspResponse_t response; + + res = psX509ParseCert( + NULL, + revoked_certificate, + sizeof revoked_certificate, + &revoked_psX509certificate, 0); + FAIL_IF(res < 0); + res = psX509ParseCert( + NULL, + intermediate_certificate, + sizeof intermediate_certificate, + &issuer_psX509certificate, 0); + FAIL_IF(res < 0); + + res32 = psOcspParseResponse(NULL, resp_len, &p, p + resp_len, + &response); + FAIL_IF(res32 < 0); + FAIL_IF(psOcspResponseGetStatus(res32) != 0); + psOcspResponseUninit(&response); + psX509FreeCert(revoked_psX509certificate); + psX509FreeCert(issuer_psX509certificate); + return OK; +} + +TEST_RESULT TEST_psOcspResponseCheckDatesCommon( + unsigned char *p, + int resp_len, + psRes_t res_expect, + struct tm *timeNow_p, + struct tm *ProducedAt_p, + struct tm *thisUpdate_p, + struct tm *nextUpdate_p) +{ + psRes_t res; + psX509Cert_t *revoked_psX509certificate; + psX509Cert_t *issuer_psX509certificate; + int32_t res32; + psOcspResponse_t response; + int32 index = 0; + + res = psX509ParseCert( + NULL, + revoked_certificate, + sizeof revoked_certificate, + &revoked_psX509certificate, 0); + FAIL_IF(res < 0); + res = psX509ParseCert( + NULL, + intermediate_certificate, + sizeof intermediate_certificate, + &issuer_psX509certificate, 0); + FAIL_IF(res < 0); + + res32 = psOcspParseResponse(NULL, resp_len, &p, p + resp_len, + &response); + FAIL_IF(res32 < 0); + res32 = psOcspResponseCheckDates(&response, + index, + timeNow_p, + ProducedAt_p, + thisUpdate_p, + nextUpdate_p, + PS_OCSP_TIME_LINGER); + + FAIL_IF(res32 != res_expect); + psOcspResponseUninit(&response); + psX509FreeCert(revoked_psX509certificate); + psX509FreeCert(issuer_psX509certificate); + return OK; +} + +TEST_RESULT TEST_psOcspResponseCheckDates(void) +{ + struct tm timeNow = { 0 }; + struct tm ProducedAt = { 0 }; + struct tm thisUpdate = { 0 }; + struct tm nextUpdate = { 0 }; + TEST_RESULT res; + + res = TEST_psOcspResponseCheckDatesCommon( + ocsp_response, + ocsp_response_len, + PS_SUCCESS, + &timeNow, + &ProducedAt, + &thisUpdate, + &nextUpdate); + + if (res == OK) + { + FAIL_IF( + ProducedAt.tm_year != 117 || + ProducedAt.tm_mon != 2 || + ProducedAt.tm_mday != 27 || + ProducedAt.tm_hour != 6 || + ProducedAt.tm_min != 0 || + ProducedAt.tm_sec != 0); + + FAIL_IF( + thisUpdate.tm_year != 117 || + thisUpdate.tm_mon != 2 || + thisUpdate.tm_mday != 27 || + thisUpdate.tm_hour != 6 || + thisUpdate.tm_min != 0 || + thisUpdate.tm_sec != 0); + + FAIL_IF( + nextUpdate.tm_year != 117 || + nextUpdate.tm_mon != 2 || + nextUpdate.tm_mday != 27 || + nextUpdate.tm_hour != 6 || + nextUpdate.tm_min != 5 || + nextUpdate.tm_sec != 0); + } + return res; +} + +TEST_RESULT TEST_psOcspResponseCheckDates_future(void) +{ + struct tm timeNow = { 0 }; + struct tm ProducedAt = { 0 }; + struct tm thisUpdate = { 0 }; + struct tm nextUpdate = { 0 }; + TEST_RESULT res; + + res = TEST_psOcspResponseCheckDatesCommon( + ocsp_response_future, + ocsp_response_future_len, + PS_TIMEOUT_FAIL, + &timeNow, + &ProducedAt, + &thisUpdate, + &nextUpdate); + + if (res == OK) + { + FAIL_IF( + ProducedAt.tm_year != 117 || + ProducedAt.tm_mon != 2 || + ProducedAt.tm_mday != 28 || + ProducedAt.tm_hour != 4 || + ProducedAt.tm_min != 13 || + ProducedAt.tm_sec != 8); + + FAIL_IF( + thisUpdate.tm_year != 117 || + thisUpdate.tm_mon != 2 || + thisUpdate.tm_mday != 28 || + thisUpdate.tm_hour != 4 || + thisUpdate.tm_min != 13 || + thisUpdate.tm_sec != 8); + + FAIL_IF( + nextUpdate.tm_year != 117 || + nextUpdate.tm_mon != 2 || + nextUpdate.tm_mday != 28 || + nextUpdate.tm_hour != 4 || + nextUpdate.tm_min != 18 || + nextUpdate.tm_sec != 8); + } + return res; +} + +TEST_RESULT TEST_psOcspResponseValidateCommon( + unsigned char *p, + int resp_len, + psRes_t res_expect, + psValidateOCSPResponseOptions_t *opts_p) +{ + psRes_t res; + psX509Cert_t *revoked_psX509certificate; + psX509Cert_t *issuer_psX509certificate; + int32_t res32; + psOcspResponse_t response; + + res = psX509ParseCert( + NULL, + revoked_certificate, + sizeof revoked_certificate, + &revoked_psX509certificate, 0); + FAIL_IF(res < 0); + res = psX509ParseCert( + NULL, + intermediate_certificate, + sizeof intermediate_certificate, + &issuer_psX509certificate, 0); + FAIL_IF(res < 0); + + res32 = psOcspParseResponse(NULL, resp_len, &p, p + resp_len, + &response); + FAIL_IF(res32 < 0); + res32 = psOcspResponseValidate( + NULL, + issuer_psX509certificate, + revoked_psX509certificate, + &response, + opts_p); + FAIL_IF(res32 != res_expect); + psOcspResponseUninit(&response); + psX509FreeCert(revoked_psX509certificate); + psX509FreeCert(issuer_psX509certificate); + return OK; +} + +TEST_RESULT TEST_psOcspResponseValidate(void) +{ + return TEST_psOcspResponseValidateCommon( + ocsp_response, + ocsp_response_len, + PS_CERT_AUTH_FAIL_REVOKED, + NULL); +} + +TEST_RESULT TEST_psOcspResponseValidate_future(void) +{ + return TEST_psOcspResponseValidateCommon( + ocsp_response_future, + ocsp_response_future_len, + PS_FAILURE, /* The response is invalid (in future). */ + NULL); +} + +TEST_RESULT TEST_psOcspResponseValidate_sha512(void) +{ + return TEST_psOcspResponseValidateCommon( + ocsp_response_sha512, + ocsp_response_sha512_len, + PS_CERT_AUTH_FAIL_REVOKED, + NULL); +} + +int test_match(int argc, char **argv, const char *string) +{ + int i; + + if (argc == 1) + { + return 1; + } + + for (i = 1; i < argc; i++) + { + if (argv[i] != NULL && !strcmp(argv[i], string)) + { + argv[i] = NULL; + return 1; + } + } + + return 0; +} + +#define TEST(fun) \ + do { \ + int res; \ + if (argc == 2 && argv[1] != NULL && \ + !strcmp(argv[1], "--list")) { \ + printf("%s\n", #fun); \ + break; \ + } else if (test_match(argc, argv, #fun)) { \ + printf("%s ... ", #fun); \ + fflush(stdout); \ + res = fun(); \ + counter[(int) res]++; \ + printf("%s%s%s%s\n", res == OK ? "OK" : \ + res == WEAK ? "OK (but size considered weak)" : \ + res == SKIPPED ? "OK (not supported)" : \ + "FAILED", extra_info[0] ? " (" : "", extra_info, \ + extra_info[0] ? ")" : ""); \ + extra_info[0] = 0; \ + } \ + } while (0) + +int main(int argc, char **argv) +{ + int counter[4] = { 0, 0, 0, 0 }; + int do_list = 0; + + time_t currentTime = time(NULL); + if (currentTime < 1490594400 || currentTime > 1490594420) + { + fprintf(stderr, "This test is designed to run via faketime.\n" + "Please set time to 2017-03-27 09:00:00 EET.\n"); + exit(1); + } + +#ifdef USE_MTRACE + if (getenv("MALLOC_TRACE")) + { + mtrace(); + } +#endif /* USE_MTRACE */ + + if (argc == 2 && !strcmp(argv[1], "--list")) + { + printf("Tests available:\n"); + do_list = 1; + } + else + { + printf("Testing OCSP:\n"); + } + + /* Init the MatrixSSL's crypto library */ + if (psCryptoOpen(PSCRYPTO_CONFIG) < PS_SUCCESS) + { + fprintf(stderr, "psCryptoOpen failed: unable to test ocsp.\n"); + exit(1); + } + +/* Template: TEST(TEST_function); */ + + TEST(TEST_psOcspRequestWrite); + TEST(TEST_psOcspParseResponse); + TEST(TEST_psOcspResponseCheckDates); + TEST(TEST_psOcspResponseCheckDates_future); + TEST(TEST_psOcspResponseValidate); + TEST(TEST_psOcspResponseValidate_future); + TEST(TEST_psOcspResponseValidate_sha512); + + /* Add test invocations here... */ + +#ifdef USE_MTRACE + if (getenv("MALLOC_TRACE")) + { + muntrace(); + } +#endif /* USE_MTRACE */ + + psCryptoClose(); + + if (do_list) + { + return 0; + } + + counter[(int) OK] += counter[(int) WEAK]; + { + int counter_sum = counter[(int) OK] + counter[(int) WEAK] + + counter[(int) FAILED] + counter[(int) SKIPPED]; + printf("Ok tests: %d/%d\n", counter[(int) OK], counter_sum); + if (counter[(int) WEAK]) + { + printf("... %d of Ok tests resulted \"WEAK security\" warning\n", + counter[(int) WEAK]); + } + if (counter[(int) FAILED]) + { + printf("Failed tests: %d/%d\n", counter[(int) FAILED], counter_sum); + } + if (counter[(int) SKIPPED]) + { + printf("Skipped tests: %d/%d\n", counter[(int) SKIPPED], + counter_sum); + } + } + counter[(int) OK] += counter[(int) SKIPPED]; + return counter[(int) OK] == 0 || counter[(int) FAILED] != 0; +} + + +/* end of file ocspTest.c */ + + diff --git a/crypto/test/ocspTestData.h b/crypto/test/ocspTestData.h new file mode 100644 index 0000000..0d97ec5 --- /dev/null +++ b/crypto/test/ocspTestData.h @@ -0,0 +1,950 @@ +/* ocspTestData.h + * + * Large inlined data containing keys and certificates and OCSP messages. + */ + +/***************************************************************************** +* Copyright (c) 2017 INSIDE Secure Oy. All Rights Reserved. +* +* This confidential and proprietary software may be used only as authorized +* by a licensing agreement from INSIDE Secure. +* +* The entire notice above must be reproduced on all authorized copies that +* may only be made to the extent permitted by a licensing agreement from +* INSIDE Secure. +*****************************************************************************/ + +#ifndef OCSP_TEST_DATA_H +#define OCSP_TEST_DATA_H 1 +#else +#error "ocspTestData.h multiply included" +#endif /* OCSP_TEST_DATA_H */ + +/* subject:/C=FI/ST=Uusimaa/L=Helsinki/O=INSIDE Secure Oy/OU=INSIDE Secure Test/CN=revoked.example.com/emailAddress=support@matrixssl.org */ +/* issuer :/C=FI/ST=Uusimaa/O=INSIDE Secure Oy/OU=INSIDE Secure Test Certificate Authority/CN=INSIDE Secure Test Intermediate CA/emailAddress=support@matrixssl.org */ +unsigned char revoked_subject_name[177]={ +0x30,0x81,0xAE,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49, +0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75,0x73,0x69,0x6D, +0x61,0x61,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x0C,0x08,0x48,0x65,0x6C, +0x73,0x69,0x6E,0x6B,0x69,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0A,0x0C,0x10, +0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x4F,0x79, +0x31,0x1B,0x30,0x19,0x06,0x03,0x55,0x04,0x0B,0x0C,0x12,0x49,0x4E,0x53,0x49,0x44, +0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x31,0x1C,0x30, +0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,0x72,0x65,0x76,0x6F,0x6B,0x65,0x64,0x2E, +0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x31,0x24,0x30,0x22,0x06, +0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x15,0x73,0x75,0x70,0x70, +0x6F,0x72,0x74,0x40,0x6D,0x61,0x74,0x72,0x69,0x78,0x73,0x73,0x6C,0x2E,0x6F,0x72, +0x67, +}; +unsigned char revoked_public_key[294]={ +0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01, +0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01, +0x00,0xCB,0x6F,0xE7,0xE8,0x91,0xC8,0xBF,0xA2,0x87,0xDD,0x72,0x4C,0x99,0x66,0xB2, +0xEE,0x92,0xDD,0x40,0x4A,0xB0,0xDA,0x71,0x77,0x32,0x95,0xD8,0x3F,0x7B,0xC9,0x69, +0xD7,0xA4,0x64,0x6E,0xB8,0x0F,0xFE,0x74,0x8F,0xEB,0xF2,0xD4,0x27,0x11,0xE5,0x38, +0x0C,0x50,0x3C,0xC8,0x6B,0x5F,0x95,0x8D,0x79,0xB1,0xBE,0xBE,0x0D,0x66,0x3F,0xB4, +0x32,0x2D,0x8E,0x2C,0x3B,0x43,0xEE,0x48,0xC2,0x38,0x41,0x15,0xC2,0xC3,0x8B,0xB8, +0x3C,0x1D,0x9C,0x69,0xE7,0x30,0x37,0xD9,0x55,0xFE,0x20,0x99,0xB2,0x0B,0xC1,0x4F, +0xA4,0x6D,0x44,0xF2,0x7E,0x17,0x21,0x27,0x79,0xE9,0x11,0x4E,0x4E,0xA3,0x6B,0x17, +0x33,0x74,0x63,0x98,0x49,0x87,0xB5,0x73,0xD0,0xBC,0x1E,0x99,0xB4,0x09,0x6E,0xE0, +0xC9,0x69,0x1D,0xCD,0xC5,0x7F,0x5E,0x96,0x7B,0xC2,0x61,0xA3,0xF1,0x19,0x51,0x4F, +0x1F,0xB1,0x07,0x28,0x49,0x0A,0x7A,0x8A,0xF7,0x52,0xC2,0x77,0x91,0x4B,0x76,0xC0, +0x8B,0x8B,0x99,0x78,0x47,0x4C,0x7C,0x05,0xE9,0x1A,0x55,0xA9,0xA1,0xAA,0xCA,0x1F, +0x5A,0x8A,0x46,0x66,0x53,0x59,0x22,0x2F,0x69,0xC4,0xBD,0xA5,0x33,0x4D,0xA4,0x39, +0x85,0x90,0xEC,0x46,0xF4,0xBA,0x83,0x1E,0x6A,0x20,0x33,0x74,0xA0,0x15,0x0F,0x9D, +0xA4,0x0C,0xDC,0x4F,0xED,0xDF,0x01,0x2A,0x93,0xF3,0x45,0xE6,0x31,0x51,0x34,0xD1, +0xCE,0x2D,0x89,0xA1,0x3D,0x02,0xA3,0x7A,0xB1,0x76,0x46,0x7D,0xED,0xEB,0x60,0xF7, +0xF3,0x4F,0xCE,0x16,0x90,0x2D,0x44,0x92,0x83,0xF4,0x44,0x5B,0xD4,0x0A,0x76,0x54, +0xDD,0x02,0x03,0x01,0x00,0x01, +}; +unsigned char revoked_certificate[1676]={ +0x30,0x82,0x06,0x88,0x30,0x82,0x04,0x70,0xA0,0x03,0x02,0x01,0x02,0x02,0x02,0x10, +0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00, +0x30,0x81,0xC0,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49, +0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75,0x73,0x69,0x6D, +0x61,0x61,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0A,0x0C,0x10,0x49,0x4E,0x53, +0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x4F,0x79,0x31,0x31,0x30, +0x2F,0x06,0x03,0x55,0x04,0x0B,0x0C,0x28,0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53, +0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69, +0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79, +0x31,0x2B,0x30,0x29,0x06,0x03,0x55,0x04,0x03,0x0C,0x22,0x49,0x4E,0x53,0x49,0x44, +0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x20,0x49,0x6E, +0x74,0x65,0x72,0x6D,0x65,0x64,0x69,0x61,0x74,0x65,0x20,0x43,0x41,0x31,0x24,0x30, +0x22,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x15,0x73,0x75, +0x70,0x70,0x6F,0x72,0x74,0x40,0x6D,0x61,0x74,0x72,0x69,0x78,0x73,0x73,0x6C,0x2E, +0x6F,0x72,0x67,0x30,0x1E,0x17,0x0D,0x31,0x36,0x30,0x38,0x32,0x39,0x30,0x35,0x35, +0x37,0x35,0x30,0x5A,0x17,0x0D,0x32,0x30,0x31,0x30,0x30,0x37,0x30,0x35,0x35,0x37, +0x35,0x30,0x5A,0x30,0x81,0xAE,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13, +0x02,0x46,0x49,0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75, +0x73,0x69,0x6D,0x61,0x61,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x0C,0x08, +0x48,0x65,0x6C,0x73,0x69,0x6E,0x6B,0x69,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04, +0x0A,0x0C,0x10,0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65, +0x20,0x4F,0x79,0x31,0x1B,0x30,0x19,0x06,0x03,0x55,0x04,0x0B,0x0C,0x12,0x49,0x4E, +0x53,0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74, +0x31,0x1C,0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x0C,0x13,0x72,0x65,0x76,0x6F,0x6B, +0x65,0x64,0x2E,0x65,0x78,0x61,0x6D,0x70,0x6C,0x65,0x2E,0x63,0x6F,0x6D,0x31,0x24, +0x30,0x22,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x15,0x73, +0x75,0x70,0x70,0x6F,0x72,0x74,0x40,0x6D,0x61,0x74,0x72,0x69,0x78,0x73,0x73,0x6C, +0x2E,0x6F,0x72,0x67,0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86, +0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A, +0x02,0x82,0x01,0x01,0x00,0xCB,0x6F,0xE7,0xE8,0x91,0xC8,0xBF,0xA2,0x87,0xDD,0x72, +0x4C,0x99,0x66,0xB2,0xEE,0x92,0xDD,0x40,0x4A,0xB0,0xDA,0x71,0x77,0x32,0x95,0xD8, +0x3F,0x7B,0xC9,0x69,0xD7,0xA4,0x64,0x6E,0xB8,0x0F,0xFE,0x74,0x8F,0xEB,0xF2,0xD4, +0x27,0x11,0xE5,0x38,0x0C,0x50,0x3C,0xC8,0x6B,0x5F,0x95,0x8D,0x79,0xB1,0xBE,0xBE, +0x0D,0x66,0x3F,0xB4,0x32,0x2D,0x8E,0x2C,0x3B,0x43,0xEE,0x48,0xC2,0x38,0x41,0x15, +0xC2,0xC3,0x8B,0xB8,0x3C,0x1D,0x9C,0x69,0xE7,0x30,0x37,0xD9,0x55,0xFE,0x20,0x99, +0xB2,0x0B,0xC1,0x4F,0xA4,0x6D,0x44,0xF2,0x7E,0x17,0x21,0x27,0x79,0xE9,0x11,0x4E, +0x4E,0xA3,0x6B,0x17,0x33,0x74,0x63,0x98,0x49,0x87,0xB5,0x73,0xD0,0xBC,0x1E,0x99, +0xB4,0x09,0x6E,0xE0,0xC9,0x69,0x1D,0xCD,0xC5,0x7F,0x5E,0x96,0x7B,0xC2,0x61,0xA3, +0xF1,0x19,0x51,0x4F,0x1F,0xB1,0x07,0x28,0x49,0x0A,0x7A,0x8A,0xF7,0x52,0xC2,0x77, +0x91,0x4B,0x76,0xC0,0x8B,0x8B,0x99,0x78,0x47,0x4C,0x7C,0x05,0xE9,0x1A,0x55,0xA9, +0xA1,0xAA,0xCA,0x1F,0x5A,0x8A,0x46,0x66,0x53,0x59,0x22,0x2F,0x69,0xC4,0xBD,0xA5, +0x33,0x4D,0xA4,0x39,0x85,0x90,0xEC,0x46,0xF4,0xBA,0x83,0x1E,0x6A,0x20,0x33,0x74, +0xA0,0x15,0x0F,0x9D,0xA4,0x0C,0xDC,0x4F,0xED,0xDF,0x01,0x2A,0x93,0xF3,0x45,0xE6, +0x31,0x51,0x34,0xD1,0xCE,0x2D,0x89,0xA1,0x3D,0x02,0xA3,0x7A,0xB1,0x76,0x46,0x7D, +0xED,0xEB,0x60,0xF7,0xF3,0x4F,0xCE,0x16,0x90,0x2D,0x44,0x92,0x83,0xF4,0x44,0x5B, +0xD4,0x0A,0x76,0x54,0xDD,0x02,0x03,0x01,0x00,0x01,0xA3,0x82,0x01,0x9A,0x30,0x82, +0x01,0x96,0x30,0x09,0x06,0x03,0x55,0x1D,0x13,0x04,0x02,0x30,0x00,0x30,0x11,0x06, +0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,0x04,0x04,0x03,0x02,0x06,0x40, +0x30,0x33,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,0x04,0x26,0x16, +0x24,0x4F,0x70,0x65,0x6E,0x53,0x53,0x4C,0x20,0x47,0x65,0x6E,0x65,0x72,0x61,0x74, +0x65,0x64,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66, +0x69,0x63,0x61,0x74,0x65,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14, +0x71,0x00,0x98,0x99,0x35,0x07,0xBB,0xA0,0xA3,0xF9,0x30,0x4C,0x6E,0x21,0x13,0x7B, +0x8F,0xCB,0x2B,0x64,0x30,0x81,0xB8,0x06,0x03,0x55,0x1D,0x23,0x04,0x81,0xB0,0x30, +0x81,0xAD,0x80,0x14,0x64,0x15,0xE2,0x5E,0x3E,0x88,0x1A,0xDD,0x6D,0x29,0x3D,0x1A, +0xE5,0x74,0xE2,0xDB,0x4F,0xF3,0x06,0xB4,0xA1,0x81,0x90,0xA4,0x81,0x8D,0x30,0x81, +0x8A,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49,0x31,0x10, +0x30,0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75,0x73,0x69,0x6D,0x61,0x61, +0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x0C,0x08,0x48,0x65,0x6C,0x73,0x69, +0x6E,0x6B,0x69,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0A,0x0C,0x10,0x49,0x4E, +0x53,0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x4F,0x79,0x31,0x15, +0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x0C,0x0C,0x54,0x65,0x73,0x74,0x20,0x52,0x6F, +0x6F,0x74,0x20,0x43,0x41,0x31,0x24,0x30,0x22,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7, +0x0D,0x01,0x09,0x01,0x16,0x15,0x73,0x75,0x70,0x70,0x6F,0x72,0x74,0x40,0x6D,0x61, +0x74,0x72,0x69,0x78,0x73,0x73,0x6C,0x2E,0x6F,0x72,0x67,0x82,0x02,0x10,0x00,0x30, +0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30, +0x13,0x06,0x03,0x55,0x1D,0x25,0x04,0x0C,0x30,0x0A,0x06,0x08,0x2B,0x06,0x01,0x05, +0x05,0x07,0x03,0x01,0x30,0x42,0x06,0x03,0x55,0x1D,0x1F,0x04,0x3B,0x30,0x39,0x30, +0x37,0xA0,0x35,0xA0,0x33,0x86,0x31,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x69,0x6E, +0x73,0x69,0x64,0x65,0x73,0x65,0x63,0x75,0x72,0x65,0x2D,0x74,0x65,0x73,0x74,0x2E, +0x63,0x6F,0x6D,0x2F,0x69,0x6E,0x74,0x65,0x72,0x6D,0x65,0x64,0x69,0x61,0x74,0x65, +0x2E,0x63,0x72,0x6C,0x2E,0x70,0x65,0x6D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86, +0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x02,0x01,0x00,0x04,0x9C,0x8F,0xB6, +0x23,0x70,0x3F,0x2A,0x1F,0x50,0x96,0x87,0x4F,0xFD,0xCD,0xCE,0x68,0x68,0xA0,0xF9, +0xD4,0xD3,0xB2,0xD6,0xB2,0x5C,0x14,0x6A,0x32,0x23,0xC5,0x62,0x3C,0x90,0x5E,0xAF, +0x25,0x70,0xA3,0xA4,0x65,0xF3,0x3C,0xBB,0xB4,0xF6,0xC1,0x1F,0x1B,0x45,0xE3,0xA7, +0xF7,0x24,0xA4,0x4F,0x69,0x61,0x39,0xD4,0xCC,0x4B,0x04,0x52,0x90,0xA0,0xE8,0x1E, +0xD1,0xAC,0xE7,0x50,0x7D,0x55,0xD2,0x72,0x70,0x20,0xF7,0xF2,0x4C,0xB7,0x17,0xF7, +0x6E,0xA6,0xEA,0xEC,0x4E,0x41,0x51,0x5A,0x4A,0xB2,0x3E,0x0C,0xF8,0xDD,0xD2,0x1F, +0x8A,0xCE,0xC8,0xBE,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0x57, +0x5C,0xF1,0x0C,0x8F,0x0B,0x66,0x75,0xDA,0x1D,0x4E,0xBF,0x5F,0xCD,0x17,0x3F,0x33, +0x86,0xFD,0xED,0xF3,0x3C,0x66,0x98,0x11,0x66,0x8E,0x50,0x65,0x59,0x22,0x38,0x1B, +0xAD,0xBF,0x32,0x8B,0xBF,0x0F,0x0D,0x71,0x43,0xB1,0xE3,0x20,0xE3,0xBB,0xE0,0xBA, +0x90,0xEE,0xD7,0x4E,0x03,0x86,0x72,0x75,0xBE,0x52,0x50,0xD4,0x88,0x81,0xD5,0x8A, +0x91,0x16,0x70,0xD4,0x30,0xF9,0x44,0xB0,0x2D,0xDE,0xE4,0xBA,0xE7,0xEA,0xE4,0x1E, +0x98,0xA4,0xD9,0xA7,0xA2,0x19,0xBE,0x20,0xBF,0x08,0xFF,0xB3,0x1E,0xCF,0x26,0x95, +0x14,0x39,0xBA,0xD6,0xBD,0x63,0xFD,0x7B,0xCC,0xE2,0x9C,0x4E,0x27,0x65,0xB4,0x55, +0x86,0xEC,0x07,0x19,0xB1,0x8B,0xE8,0x05,0xB5,0x4C,0xF6,0x3A,0xB0,0x9C,0x8B,0x50, +0x91,0xD9,0x6D,0xD3,0x08,0x24,0x0D,0x6E,0xDD,0x84,0x38,0x95,0x8C,0xA7,0xD0,0x4F, +0x7F,0xF2,0xBF,0x45,0x40,0x6A,0x1E,0x71,0xB3,0xEA,0xC8,0xAF,0xEF,0xF6,0xFC,0x34, +0x9D,0xD9,0xE5,0xE8,0x3B,0xE8,0xD1,0x2B,0xAC,0x12,0x2C,0x02,0x97,0xC2,0xB3,0x62, +0xCC,0x3F,0xF6,0xA3,0x3F,0x7C,0x34,0xCD,0xBE,0xC7,0x15,0x43, +}; + +/* subject:/C=FI/ST=Uusimaa/O=INSIDE Secure Oy/OU=INSIDE Secure Test Certificate Authority/CN=INSIDE Secure Test Intermediate CA/emailAddress=support@matrixssl.org */ +/* issuer :/C=FI/ST=Uusimaa/L=Helsinki/O=INSIDE Secure Oy/CN=Test Root CA/emailAddress=support@matrixssl.org */ +unsigned char intermediate_subject_name[195]={ +0x30,0x81,0xC0,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49, +0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75,0x73,0x69,0x6D, +0x61,0x61,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0A,0x0C,0x10,0x49,0x4E,0x53, +0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x4F,0x79,0x31,0x31,0x30, +0x2F,0x06,0x03,0x55,0x04,0x0B,0x0C,0x28,0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53, +0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69, +0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79, +0x31,0x2B,0x30,0x29,0x06,0x03,0x55,0x04,0x03,0x0C,0x22,0x49,0x4E,0x53,0x49,0x44, +0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x20,0x49,0x6E, +0x74,0x65,0x72,0x6D,0x65,0x64,0x69,0x61,0x74,0x65,0x20,0x43,0x41,0x31,0x24,0x30, +0x22,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x15,0x73,0x75, +0x70,0x70,0x6F,0x72,0x74,0x40,0x6D,0x61,0x74,0x72,0x69,0x78,0x73,0x73,0x6C,0x2E, +0x6F,0x72,0x67, +}; +unsigned char intermediate_public_key[550]={ +0x30,0x82,0x02,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01, +0x01,0x05,0x00,0x03,0x82,0x02,0x0F,0x00,0x30,0x82,0x02,0x0A,0x02,0x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x46,0x02,0x68,0xD5,0xDC,0x2C,0x81,0x4D,0xB9,0xB4,0xA8,0xAC,0xE7,0x19,0xDD, +0x3D,0x7A,0x18,0x5F,0x19,0x08,0xDA,0x32,0xD6,0x88,0x3F,0x02,0x91,0x8B,0x88,0x82, +0x11,0xB2,0xD9,0x81,0x16,0x8C,0x92,0xDA,0xA1,0x8D,0x4B,0x7A,0xE2,0xD1,0x1E,0x6B, +0x31,0x27,0x60,0xBA,0x26,0x47,0x32,0xE5,0xBD,0x41,0x5B,0x29,0xB4,0x79,0xFB,0xCB, +0xF3,0x99,0xFE,0x79,0x3F,0xB2,0x60,0xAA,0xC7,0x09,0x8B,0xDA,0x18,0x54,0x56,0x66, +0x41,0x02,0x03,0x01,0x00,0x01, +}; +unsigned char intermediate_certificate[1586]={ +0x30,0x82,0x06,0x2E,0x30,0x82,0x04,0x16,0xA0,0x03,0x02,0x01,0x02,0x02,0x02,0x10, +0x00,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00, +0x30,0x81,0x8A,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49, +0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75,0x73,0x69,0x6D, +0x61,0x61,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x0C,0x08,0x48,0x65,0x6C, +0x73,0x69,0x6E,0x6B,0x69,0x31,0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0A,0x0C,0x10, +0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x4F,0x79, +0x31,0x15,0x30,0x13,0x06,0x03,0x55,0x04,0x03,0x0C,0x0C,0x54,0x65,0x73,0x74,0x20, +0x52,0x6F,0x6F,0x74,0x20,0x43,0x41,0x31,0x24,0x30,0x22,0x06,0x09,0x2A,0x86,0x48, +0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x15,0x73,0x75,0x70,0x70,0x6F,0x72,0x74,0x40, +0x6D,0x61,0x74,0x72,0x69,0x78,0x73,0x73,0x6C,0x2E,0x6F,0x72,0x67,0x30,0x1E,0x17, +0x0D,0x31,0x36,0x30,0x38,0x32,0x39,0x30,0x35,0x33,0x32,0x31,0x35,0x5A,0x17,0x0D, +0x32,0x36,0x30,0x38,0x32,0x37,0x30,0x35,0x33,0x32,0x31,0x35,0x5A,0x30,0x81,0xC0, +0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x46,0x49,0x31,0x10,0x30, +0x0E,0x06,0x03,0x55,0x04,0x08,0x0C,0x07,0x55,0x75,0x73,0x69,0x6D,0x61,0x61,0x31, +0x19,0x30,0x17,0x06,0x03,0x55,0x04,0x0A,0x0C,0x10,0x49,0x4E,0x53,0x49,0x44,0x45, +0x20,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x4F,0x79,0x31,0x31,0x30,0x2F,0x06,0x03, +0x55,0x04,0x0B,0x0C,0x28,0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53,0x65,0x63,0x75, +0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63, +0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x31,0x2B,0x30, +0x29,0x06,0x03,0x55,0x04,0x03,0x0C,0x22,0x49,0x4E,0x53,0x49,0x44,0x45,0x20,0x53, +0x65,0x63,0x75,0x72,0x65,0x20,0x54,0x65,0x73,0x74,0x20,0x49,0x6E,0x74,0x65,0x72, +0x6D,0x65,0x64,0x69,0x61,0x74,0x65,0x20,0x43,0x41,0x31,0x24,0x30,0x22,0x06,0x09, +0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x15,0x73,0x75,0x70,0x70,0x6F, +0x72,0x74,0x40,0x6D,0x61,0x74,0x72,0x69,0x78,0x73,0x73,0x6C,0x2E,0x6F,0x72,0x67, +0x30,0x82,0x02,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01, +0x01,0x05,0x00,0x03,0x82,0x02,0x0F,0x00,0x30,0x82,0x02,0x0A,0x02,0x82,0x02,0x01, +0x00,0xAC,0x06,0x37,0xA9,0x4F,0xC3,0x93,0xA6,0xCB,0x56,0x04,0xA8,0x7B,0x5B,0x52, +0xDB,0xFD,0x3D,0xD1,0xC8,0x76,0xC9,0x11,0x77,0x11,0xCA,0x9F,0x7C,0xEE,0x40,0xC6, +0x1D,0x3A,0xF1,0x98,0x97,0x8A,0x34,0xB6,0x77,0x05,0xE2,0x98,0x80,0x1D,0x73,0xB9, +0x00,0xD4,0x83,0xE8,0xB0,0xAE,0x06,0xB4,0xC0,0x36,0x6F,0x62,0xEE,0x25,0x8F,0xE5, +0x26,0x29,0x5E,0xBB,0xFB,0x95,0x7F,0x59,0xE8,0x15,0xBF,0xD1,0x56,0xDA,0x75,0xC4, +0xA8,0xA0,0x16,0x7A,0xE2,0x1D,0xBC,0xA4,0xAF,0xF5,0xB6,0x4F,0x1E,0x85,0xF6,0x4C, +0x94,0xD7,0x79,0x2C,0xC4,0x5E,0xEA,0xEE,0x0B,0x8D,0x4F,0x5E,0x4E,0xD4,0x78,0x4D, +0x28,0x02,0x5C,0xA0,0x34,0x14,0x47,0x60,0x82,0x6B,0x39,0x2E,0x3C,0xAE,0x59,0x4B, +0xD6,0xB5,0x56,0xEB,0xF9,0xE9,0x34,0x4F,0x50,0xF0,0x67,0x05,0x58,0xDF,0x03,0x44, +0xC3,0x71,0x19,0x90,0x57,0xAB,0xF7,0x5C,0x7B,0xFB,0xCA,0xF0,0x1A,0xE9,0x29,0x12, +0xA4,0xC4,0x09,0x90,0xF3,0x87,0xA2,0x30,0xDD,0x52,0xB3,0x92,0x3E,0x55,0x3E,0xBD, +0xE5,0x30,0x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0x9B,0x3E,0x7E,0x54,0x98, +0xBF,0x3D,0x46,0xA9,0x75,0x57,0x4C,0x74,0x28,0x6C,0xDA,0x1F,0xA0,0xE0,0xC9,0x99, +0x51,0x6D,0x72,0xA0,0xAF,0x80,0x51,0x52,0x44,0x80,0x6E,0xE3,0xF9,0x5A,0xA8,0x4E, +0xDB,0x46,0x02,0x68,0xD5,0xDC,0x2C,0x81,0x4D,0xB9,0xB4,0xA8,0xAC,0xE7,0x19,0xDD, +0x3D,0x7A,0x18,0x5F,0x19,0x08,0xDA,0x32,0xD6,0x88,0x3F,0x02,0x91,0x8B,0x88,0x82, +0x11,0xB2,0xD9,0x81,0x16,0x8C,0x92,0xDA,0xA1,0x8D,0x4B,0x7A,0xE2,0xD1,0x1E,0x6B, +0x31,0x27,0x60,0xBA,0x26,0x47,0x32,0xE5,0xBD,0x41,0x5B,0x29,0xB4,0x79,0xFB,0xCB, +0xF3,0x99,0xFE,0x79,0x3F,0xB2,0x60,0xAA,0xC7,0x09,0x8B,0xDA,0x18,0x54,0x56,0x66, +0x41,0x02,0x03,0x01,0x00,0x01,0xA3,0x66,0x30,0x64,0x30,0x1D,0x06,0x03,0x55,0x1D, +0x0E,0x04,0x16,0x04,0x14,0x64,0x15,0xE2,0x5E,0x3E,0x88,0x1A,0xDD,0x6D,0x29,0x3D, +0x1A,0xE5,0x74,0xE2,0xDB,0x4F,0xF3,0x06,0xB4,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23, +0x04,0x18,0x30,0x16,0x80,0x14,0x3E,0x8B,0xE8,0xAB,0x4F,0x28,0x03,0x89,0x9D,0x5C, +0x37,0xA8,0xC4,0xCF,0x0D,0xDD,0x61,0x2C,0x98,0x7A,0x30,0x12,0x06,0x03,0x55,0x1D, +0x13,0x01,0x01,0xFF,0x04,0x08,0x30,0x06,0x01,0x01,0xFF,0x02,0x01,0x00,0x30,0x0E, +0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,0x86,0x30,0x0D, +0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,0x05,0x00,0x03,0x82,0x02, +0x01,0x00,0x64,0xBA,0x52,0x03,0xD0,0x1B,0x26,0x58,0xD2,0x26,0xAE,0xAB,0x4B,0x83, +0xD6,0xAD,0x42,0xA8,0xD9,0xF4,0x75,0x12,0xEC,0x72,0x54,0xDF,0xD6,0xFB,0x53,0xAF, +0x52,0xE3,0x5A,0xB5,0x64,0x8E,0x71,0xFF,0xBB,0x52,0xE4,0x50,0xEA,0xDD,0xF9,0x7D, +0xA3,0x73,0xB7,0x89,0x51,0x23,0xA9,0x72,0x42,0x77,0xF8,0xB4,0x28,0x41,0xA0,0x12, +0xD8,0x2B,0x81,0x22,0x95,0xA2,0x87,0x17,0x6B,0xE2,0xB7,0xAA,0x15,0x74,0xBF,0x82, +0x02,0x65,0x59,0x37,0x40,0x4D,0x6D,0xE2,0x52,0xCF,0x89,0xBB,0xEF,0xEF,0xCA,0xAA, +0x9D,0xCD,0x71,0xDD,0xCF,0x01,0xB2,0xB7,0x02,0x0F,0x8F,0xFB,0x5B,0xC0,0x6B,0x4A, +0xE5,0x5E,0xAF,0xA3,0xE8,0x5D,0xD8,0x99,0xF2,0xD9,0xF5,0x5A,0xA8,0xD0,0x0A,0x6C, +0x1E,0x0A,0x50,0x45,0x61,0xC6,0x97,0x70,0x23,0x27,0xC9,0x8E,0xE4,0x24,0xCF,0x2B, +0x1A,0x44,0x0E,0x17,0x7D,0xFE,0xF5,0xC4,0xDB,0x62,0xCA,0x06,0xDD,0x3F,0x3D,0x84, +0x8D,0x0C,0x17,0x15,0x3F,0xF5,0xF5,0x51,0x37,0x82,0xA6,0x7A,0xBF,0xF5,0xA1,0x5E, +0xA5,0x8D,0x9B,0xA6,0x17,0x8F,0xF4,0xBF,0xE7,0x75,0xB0,0x81,0x62,0x98,0xA9,0xEC, +0xB3,0x04,0xB1,0xE3,0x19,0x58,0xC3,0x47,0x9F,0x2D,0xA5,0x2A,0xB1,0xAA,0x91,0x08, +0xD1,0xAF,0x50,0xAE,0xAD,0x47,0x53,0xB0,0xAD,0x75,0x2A,0x04,0x0F,0x27,0x85,0x49, +0x92,0x74,0xB1,0x2B,0x5E,0x35,0x7E,0xF2,0x77,0xF7,0x93,0x3B,0x45,0x97,0x6B,0x79, +0xD4,0x32,0xC0,0x20,0x5A,0x76,0xA5,0x2A,0x37,0xC7,0x1B,0x96,0x4F,0xC2,0xBE,0x66, +0x45,0xBC,0xC2,0x43,0xB7,0x5B,0x3B,0x16,0x82,0x7F,0x7E,0x1C,0x91,0xD9,0x2D,0x4F, +0x6C,0x50,0x6E,0xBF,0xE4,0x38,0x80,0x58,0x6D,0x58,0x1F,0x71,0x83,0xDA,0xFF,0x84, +0x24,0xBF,0x95,0x52,0x4F,0x81,0x42,0xA7,0xCC,0x30,0xFB,0x6B,0x94,0x81,0xF9,0x8A, +0x2F,0xF8,0x54,0x36,0x58,0x91,0x10,0x57,0x4B,0x99,0x3C,0xFF,0x74,0x58,0xF8,0x19, +0x00,0x98,0x75,0xF6,0x38,0x83,0x46,0xD9,0xB9,0xD0,0xFB,0x49,0x4A,0xD8,0xD1,0xD7, +0xDC,0x2C,0x2A,0xF5,0xE3,0x87,0xBB,0xEE,0x27,0xE3,0x3D,0xEC,0xAF,0x8E,0xFD,0x9B, +0x53,0x3E,0x52,0xF6,0x92,0xD6,0x60,0x00,0xB8,0x76,0x68,0x23,0x4D,0x16,0xA2,0x51, +0x2F,0x5B,0x3D,0xF6,0xA7,0x8F,0xB8,0xBE,0x12,0x93,0x2D,0x51,0xCC,0xCC,0x57,0xAC, +0xB5,0x12,0x23,0xC5,0x5B,0x76,0x67,0xD3,0x6A,0xCE,0x7D,0x28,0x04,0x84,0x1F,0x16, +0x66,0x78,0xB8,0x9A,0x12,0x3E,0xF0,0x38,0x1F,0xE5,0x0C,0x12,0x71,0xAC,0x1F,0xE5, +0x39,0xE1,0x0F,0xF2,0xAB,0x90,0xC9,0x84,0xAC,0x33,0x67,0x36,0xF9,0x20,0xF8,0xC9, +0xEF,0x15,0xF3,0xC7,0x26,0x23,0xB8,0xC4,0x57,0x23,0xAC,0x8C,0xE4,0xFC,0x8F,0xD1, +0xF2,0x14,0xBD,0x88,0x8F,0x3F,0xEE,0x0C,0x93,0xFE,0x63,0xFB,0x8B,0x7D,0x55,0xCB, +0x7F,0x3F,0xF4,0x40,0x25,0x1F,0xDB,0xB4,0xA3,0xDF,0x04,0xEE,0x1A,0xFA,0xFC,0x96, +0x72,0xF8,0x13,0xB2,0xEC,0x40,0x65,0x60,0xE7,0x80,0xBD,0x2C,0x57,0xDF,0xD5,0xA2, +0xDA,0x00,0xEB,0x4D,0x4F,0xB4,0xCA,0xCA,0x20,0x11,0x97,0x41,0x66,0x63,0x5E,0x64, +0xC8,0x2E, +}; + +/* Stored basic OCSP request. */ +unsigned char ocsp_request[] = { + 0x30, 0x43, 0x30, 0x41, 0x30, 0x3f, 0x30, 0x3d, 0x30, 0x3b, 0x30, 0x09, + 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x82, + 0x94, 0x68, 0x3e, 0xa5, 0xf1, 0x04, 0x9e, 0xc6, 0x2b, 0x2b, 0x02, 0xa5, + 0xdd, 0x04, 0x7c, 0x1a, 0xfa, 0xf8, 0x0f, 0x04, 0x14, 0x64, 0x15, 0xe2, + 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, 0x3d, 0x1a, 0xe5, 0x74, 0xe2, + 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x02, 0x02, 0x10, 0x01 +}; +unsigned int ocsp_request_len = 69; + +/* Stored basic OCSP response (revoked certificate). + + Generated using OpenSSL OCSP responder: openssl ocsp -resp_key_id -index ../../index.txt -VAfile ../../certs/ocsp.insidesecure-test.com.cert.pem -CA ../../certs/ca-chain.cert.pem -rsigner ../../certs/ocsp.insidesecure-test.com.cert.pem -rkey ../../private/ocsp.insidesecure-test.com.key-nopass.pem -nmin 5 -noverify -reqin /tmp/request -respout /tmp/response. */ + +unsigned char ocsp_response_future[] = { + 0x30, 0x82, 0x09, 0x4a, 0x0a, 0x01, 0x00, 0xa0, 0x82, 0x09, 0x43, 0x30, + 0x82, 0x09, 0x3f, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, + 0x01, 0x01, 0x04, 0x82, 0x09, 0x30, 0x30, 0x82, 0x09, 0x2c, 0x30, 0x81, + 0xa1, 0xa2, 0x16, 0x04, 0x14, 0x78, 0xe4, 0xb1, 0x1a, 0x09, 0xef, 0x04, + 0x88, 0x8b, 0x67, 0xbb, 0x81, 0x70, 0xe0, 0x18, 0x01, 0x36, 0xe4, 0x60, + 0xb3, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, 0x30, 0x33, 0x32, 0x38, 0x30, + 0x34, 0x31, 0x33, 0x30, 0x38, 0x5a, 0x30, 0x76, 0x30, 0x74, 0x30, 0x3b, + 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, + 0x14, 0x82, 0x94, 0x68, 0x3e, 0xa5, 0xf1, 0x04, 0x9e, 0xc6, 0x2b, 0x2b, + 0x02, 0xa5, 0xdd, 0x04, 0x7c, 0x1a, 0xfa, 0xf8, 0x0f, 0x04, 0x14, 0x64, + 0x15, 0xe2, 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, 0x3d, 0x1a, 0xe5, + 0x74, 0xe2, 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x02, 0x02, 0x10, 0x01, 0xa1, + 0x11, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x36, 0x30, 0x38, 0x32, 0x39, 0x30, + 0x35, 0x35, 0x38, 0x35, 0x33, 0x5a, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, + 0x30, 0x33, 0x32, 0x38, 0x30, 0x34, 0x31, 0x33, 0x30, 0x38, 0x5a, 0xa0, + 0x11, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, 0x30, 0x33, 0x32, 0x38, 0x30, + 0x34, 0x31, 0x38, 0x30, 0x38, 0x5a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, + 0x01, 0x00, 0x8a, 0x8e, 0x03, 0x6c, 0x4b, 0x83, 0xa9, 0xd0, 0x3a, 0x6a, + 0xd2, 0xae, 0x2d, 0x6c, 0x9d, 0x4b, 0xb2, 0xd1, 0xbd, 0x80, 0xc0, 0xf8, + 0x24, 0x1d, 0x5d, 0x31, 0x43, 0x53, 0x07, 0xee, 0x32, 0x56, 0x78, 0x07, + 0x28, 0xbe, 0x26, 0x5f, 0x54, 0x3c, 0x8b, 0xdf, 0x0d, 0xc6, 0x3b, 0xb1, + 0xc9, 0xbc, 0x4d, 0xba, 0x04, 0x1d, 0x47, 0xa5, 0x6d, 0x12, 0x1a, 0xb7, + 0xec, 0x45, 0x72, 0x79, 0x25, 0x95, 0x77, 0x06, 0xf5, 0x55, 0x6b, 0xa3, + 0x73, 0xf0, 0x55, 0x3a, 0x9a, 0x2a, 0x67, 0xfb, 0xb2, 0x79, 0xa4, 0x5f, + 0xee, 0x9a, 0xd8, 0x9a, 0x51, 0xd7, 0x6c, 0x3b, 0x83, 0x15, 0x59, 0x7c, + 0xbb, 0x08, 0xdb, 0x45, 0x42, 0xb9, 0x75, 0x08, 0x86, 0x54, 0x19, 0x8f, + 0x55, 0x93, 0x8e, 0x27, 0x12, 0x8f, 0xb8, 0xdd, 0x61, 0xc0, 0x86, 0xfe, + 0x39, 0x57, 0x83, 0xfc, 0x5a, 0x8c, 0xe3, 0xb6, 0x31, 0x57, 0xb0, 0x29, + 0x9f, 0x47, 0xae, 0x76, 0x92, 0x6f, 0x05, 0x5b, 0xde, 0xac, 0x63, 0x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, 0xc3, 0xfd, 0x65, 0x46, 0x08, 0xbe, 0x44, 0xa0, 0x82, + 0x06, 0x70, 0x30, 0x82, 0x06, 0x6c, 0x30, 0x82, 0x06, 0x68, 0x30, 0x82, + 0x04, 0x50, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x10, 0x02, 0x30, + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, + 0x05, 0x00, 0x30, 0x81, 0xc0, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x04, 0x06, 0x13, 0x02, 0x46, 0x49, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, + 0x55, 0x04, 0x08, 0x0c, 0x07, 0x55, 0x75, 0x73, 0x69, 0x6d, 0x61, 0x61, + 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x10, 0x49, + 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, + 0x20, 0x4f, 0x79, 0x31, 0x31, 0x30, 0x2f, 0x06, 0x03, 0x55, 0x04, 0x0b, + 0x0c, 0x28, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, + 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x2b, 0x30, 0x29, 0x06, 0x03, + 0x55, 0x04, 0x03, 0x0c, 0x22, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, + 0x20, 0x43, 0x41, 0x31, 0x24, 0x30, 0x22, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x15, 0x73, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x40, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x73, 0x73, + 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, + 0x38, 0x32, 0x39, 0x30, 0x36, 0x30, 0x38, 0x30, 0x31, 0x5a, 0x17, 0x0d, + 0x31, 0x39, 0x30, 0x35, 0x32, 0x36, 0x30, 0x36, 0x30, 0x38, 0x30, 0x31, + 0x5a, 0x30, 0x81, 0xb5, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, + 0x06, 0x13, 0x02, 0x46, 0x49, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, + 0x04, 0x08, 0x0c, 0x07, 0x55, 0x75, 0x73, 0x69, 0x6d, 0x61, 0x61, 0x31, + 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x08, 0x48, 0x65, + 0x6c, 0x73, 0x69, 0x6e, 0x6b, 0x69, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, + 0x55, 0x04, 0x0a, 0x0c, 0x10, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x4f, 0x79, 0x31, 0x1b, 0x30, + 0x19, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x12, 0x49, 0x4e, 0x53, 0x49, + 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, + 0x73, 0x74, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, + 0x1a, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x69, 0x64, 0x65, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x2e, + 0x63, 0x6f, 0x6d, 0x31, 0x24, 0x30, 0x22, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x15, 0x73, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x40, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x73, 0x73, + 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, + 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, + 0x01, 0x00, 0xdd, 0xbb, 0xb9, 0x27, 0x84, 0xb2, 0x02, 0x93, 0xdc, 0x68, + 0xe6, 0x06, 0x56, 0xe8, 0xed, 0xcc, 0x4b, 0x0b, 0x11, 0x05, 0x20, 0x72, + 0x1a, 0x1a, 0x08, 0x09, 0xc2, 0x60, 0x33, 0x79, 0x4b, 0xeb, 0xfb, 0x7f, + 0xa1, 0xf3, 0x22, 0xc2, 0xf7, 0x71, 0xe7, 0x0a, 0x5b, 0x81, 0xd1, 0x20, + 0x0a, 0x85, 0xfb, 0x0e, 0x66, 0x33, 0x35, 0x2b, 0x8d, 0x78, 0xf5, 0xd6, + 0x43, 0x0b, 0xe5, 0xce, 0xf8, 0x4a, 0x47, 0x88, 0x03, 0x14, 0x16, 0xb7, + 0xbf, 0x1c, 0xf8, 0x95, 0x9b, 0xac, 0xec, 0x07, 0x9e, 0xa4, 0x91, 0x59, + 0x89, 0xe1, 0xe1, 0xee, 0xaf, 0x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0xc8, 0x7d, 0x21, 0xe9, + 0x05, 0x25, 0xe3, 0xc0, 0x4a, 0x1a, 0x69, 0x95, 0xed, 0xa8, 0xb1, 0x8c, + 0x60, 0xb5, 0xee, 0xd7, 0x36, 0x49, 0x2b, 0xd3, 0x00, 0x04, 0xda, 0x16, + 0x41, 0xa3, 0xd0, 0x38, 0x1b, 0xf2, 0xfc, 0x23, 0x22, 0xcf, 0xe4, 0x62, + 0xee, 0x95, 0x3f, 0x0f, 0x7f, 0x89, 0xb0, 0x56, 0x20, 0x3e, 0xd9, 0xff, + 0x14, 0x91, 0xe7, 0x32, 0x1f, 0xcd, 0x55, 0x7a, 0x1a, 0x43, 0x02, 0x03, + 0x01, 0x00, 0x01, 0xa3, 0x75, 0x30, 0x73, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, + 0x0e, 0x04, 0x16, 0x04, 0x14, 0x78, 0xe4, 0xb1, 0x1a, 0x09, 0xef, 0x04, + 0x88, 0x8b, 0x67, 0xbb, 0x81, 0x70, 0xe0, 0x18, 0x01, 0x36, 0xe4, 0x60, + 0xb3, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x64, 0x15, 0xe2, 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, + 0x3d, 0x1a, 0xe5, 0x74, 0xe2, 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x30, 0x0e, + 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, + 0x07, 0x80, 0x30, 0x16, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x01, 0x01, 0xff, + 0x04, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, + 0x03, 0x09, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x04, 0xd8, + 0x13, 0x9f, 0x61, 0x0c, 0xcc, 0x49, 0x72, 0xf9, 0x66, 0x62, 0xb6, 0xdc, + 0x10, 0x7e, 0x44, 0x2e, 0x07, 0x44, 0x0a, 0x75, 0x00, 0xf7, 0x85, 0x95, + 0x11, 0x8b, 0xc7, 0xd3, 0xf6, 0x67, 0x4f, 0x14, 0x80, 0x93, 0x3b, 0xb0, + 0x35, 0xa3, 0x55, 0xef, 0xe8, 0xb5, 0x0c, 0x37, 0xaa, 0xc2, 0x86, 0x4b, + 0x59, 0x69, 0x5b, 0x87, 0x05, 0xe7, 0x5e, 0x20, 0x32, 0x16, 0x62, 0xe1, + 0xeb, 0x04, 0x47, 0xec, 0x77, 0x46, 0x08, 0x72, 0xe2, 0xd7, 0x8c, 0xb4, + 0xd8, 0x33, 0x2c, 0x26, 0xee, 0xb1, 0x30, 0xe6, 0xe8, 0x97, 0xde, 0x21, + 0x71, 0x25, 0xcd, 0x83, 0xee, 0x6c, 0x59, 0x7a, 0x75, 0x0f, 0xdb, 0x89, + 0x21, 0x72, 0x47, 0xe2, 0x0a, 0x8a, 0xb4, 0x10, 0x4e, 0xd1, 0xb9, 0x54, + 0x5e, 0xd1, 0x9d, 0x99, 0xe9, 0x4d, 0x99, 0x74, 0x62, 0x92, 0xe1, 0x68, + 0x5a, 0xb4, 0x8e, 0x4d, 0x46, 0xc4, 0x04, 0x1d, 0xc0, 0x5f, 0xf9, 0xa0, + 0x08, 0x88, 0x2c, 0x49, 0xdf, 0x39, 0x39, 0x9c, 0x6b, 0xdc, 0x7c, 0x61, + 0xd3, 0x26, 0xf3, 0x3c, 0xd2, 0x5e, 0xf5, 0xee, 0x5d, 0x91, 0x47, 0x7f, + 0x0e, 0xee, 0x77, 0x81, 0x23, 0x72, 0x62, 0xcf, 0x01, 0x68, 0x4e, 0x8c, + 0x78, 0xb8, 0x47, 0xb8, 0x33, 0x6f, 0x0f, 0x38, 0x41, 0x41, 0x42, 0x6e, + 0x25, 0xe9, 0xb1, 0x3d, 0x3a, 0x2f, 0x4e, 0x01, 0xa0, 0xfd, 0x98, 0x2a, + 0x96, 0x94, 0xc6, 0xd6, 0x81, 0x68, 0x2a, 0x8d, 0x06, 0x85, 0x9e, 0x3e, + 0x13, 0xf1, 0x21, 0xef, 0xf3, 0x87, 0xc8, 0xc1, 0xf1, 0x16, 0x21, 0x49, + 0x45, 0x2c, 0xa4, 0x85, 0x15, 0x3d, 0xfc, 0x0e, 0x39, 0x75, 0xe8, 0x8c, + 0x23, 0xba, 0x2d, 0x24, 0x9f, 0x72, 0xfb, 0x37, 0x89, 0xbb, 0x02, 0x90, + 0xd1, 0x1f, 0x93, 0x4d, 0xdb, 0x8d, 0x25, 0x87, 0xff, 0x62, 0xc9, 0x38, + 0x4c, 0x87, 0xfe, 0xa2, 0xec, 0x00, 0x29, 0x3e, 0xa0, 0x6c, 0x4f, 0x6c, + 0x91, 0x8b, 0x61, 0xad, 0xbe, 0xa7, 0x34, 0x4d, 0xd3, 0xc6, 0xae, 0x04, + 0x57, 0x78, 0xf1, 0x9d, 0x46, 0x93, 0x8f, 0x70, 0x64, 0xea, 0x64, 0x93, + 0xb3, 0x06, 0xb3, 0xbb, 0x58, 0x88, 0xd7, 0x27, 0x55, 0xe0, 0x47, 0x94, + 0x13, 0x0c, 0xb5, 0x8c, 0xc0, 0x15, 0x04, 0x8c, 0x3a, 0xd5, 0x83, 0xe0, + 0x1d, 0x69, 0x63, 0x3e, 0xa5, 0x52, 0x06, 0xe2, 0x74, 0xcb, 0x21, 0xbb, + 0x5f, 0x54, 0xa1, 0xce, 0x82, 0x5a, 0xfb, 0x02, 0x70, 0x55, 0x32, 0x16, + 0x40, 0xfd, 0xcf, 0x2a, 0xb1, 0xf1, 0x12, 0x7b, 0xe0, 0x05, 0x14, 0xd4, + 0xdf, 0x56, 0xc0, 0x12, 0x59, 0xcd, 0xe1, 0x2f, 0xf1, 0xac, 0x70, 0x1a, + 0x59, 0x5e, 0xb0, 0x7c, 0xa3, 0xa9, 0x09, 0x49, 0xd2, 0x32, 0x71, 0x5a, + 0xb7, 0xc9, 0x8a, 0xac, 0x75, 0xa5, 0x9f, 0x49, 0xc9, 0xb7, 0xd3, 0xa9, + 0x6d, 0x13, 0xc4, 0xba, 0x92, 0x71, 0xb8, 0x48, 0xe4, 0x59, 0x62, 0x03, + 0xa0, 0x35, 0x67, 0xf5, 0xe2, 0x12, 0x18, 0xf8, 0xa8, 0xff, 0x80, 0x67, + 0x77, 0xfb, 0x2a, 0x01, 0x88, 0x90, 0x9c, 0x3d, 0xd4, 0x0a, 0xb0, 0x70, + 0xd8, 0x3d, 0x57, 0x67, 0xba, 0xcb, 0x55, 0x53, 0x65, 0x44, 0x9e, 0xba, + 0x46, 0x50, 0x58, 0x0e, 0x80, 0x74, 0xa2, 0x3c, 0xb4, 0x05, 0x3d, 0x1f, + 0x23, 0x37, 0x61, 0x21, 0x30, 0x61, 0xba, 0x2b, 0x72, 0x2c, 0xac, 0xc2, + 0xdc, 0x4c, 0xd7, 0x8b, 0x6d, 0xdd, 0xe8, 0x40, 0x35, 0x4f, 0xa9, 0xf7, + 0x31, 0xe7, 0xca, 0xca, 0xb3, 0x2c, 0xda, 0x79, 0x78, 0x8e, 0x74, 0x25, + 0x46, 0xf3, 0xf0, 0x00, 0xbb, 0x3f, 0x50, 0x07, 0x23, 0x97, 0x17, 0xd1, + 0x59, 0xe0, 0x6c, 0xc8, 0x27, 0x1b, 0xb5, 0xcb, 0x77, 0x1a, 0x83, 0xf4, + 0x1d, 0xfd, 0xa6, 0xf8, 0x05, 0xc8 +}; +unsigned int ocsp_response_future_len = 2382; + +/* Stored basic OCSP response (revoked certificate). */ +unsigned char ocsp_response[] = { + 0x30, 0x82, 0x09, 0x4a, 0x0a, 0x01, 0x00, 0xa0, 0x82, 0x09, 0x43, 0x30, + 0x82, 0x09, 0x3f, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, + 0x01, 0x01, 0x04, 0x82, 0x09, 0x30, 0x30, 0x82, 0x09, 0x2c, 0x30, 0x81, + 0xa1, 0xa2, 0x16, 0x04, 0x14, 0x78, 0xe4, 0xb1, 0x1a, 0x09, 0xef, 0x04, + 0x88, 0x8b, 0x67, 0xbb, 0x81, 0x70, 0xe0, 0x18, 0x01, 0x36, 0xe4, 0x60, + 0xb3, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, 0x30, 0x33, 0x32, 0x37, 0x30, + 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x76, 0x30, 0x74, 0x30, 0x3b, + 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, + 0x14, 0x82, 0x94, 0x68, 0x3e, 0xa5, 0xf1, 0x04, 0x9e, 0xc6, 0x2b, 0x2b, + 0x02, 0xa5, 0xdd, 0x04, 0x7c, 0x1a, 0xfa, 0xf8, 0x0f, 0x04, 0x14, 0x64, + 0x15, 0xe2, 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, 0x3d, 0x1a, 0xe5, + 0x74, 0xe2, 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x02, 0x02, 0x10, 0x01, 0xa1, + 0x11, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x36, 0x30, 0x38, 0x32, 0x39, 0x30, + 0x35, 0x35, 0x38, 0x35, 0x33, 0x5a, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, + 0x30, 0x33, 0x32, 0x37, 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0xa0, + 0x11, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, 0x30, 0x33, 0x32, 0x37, 0x30, + 0x36, 0x30, 0x35, 0x30, 0x30, 0x5a, 0x30, 0x0d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04, 0x50, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x10, 0x02, 0x30, + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, + 0x05, 0x00, 0x30, 0x81, 0xc0, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x04, 0x06, 0x13, 0x02, 0x46, 0x49, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, + 0x55, 0x04, 0x08, 0x0c, 0x07, 0x55, 0x75, 0x73, 0x69, 0x6d, 0x61, 0x61, + 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x10, 0x49, + 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, + 0x20, 0x4f, 0x79, 0x31, 0x31, 0x30, 0x2f, 0x06, 0x03, 0x55, 0x04, 0x0b, + 0x0c, 0x28, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, + 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x2b, 0x30, 0x29, 0x06, 0x03, + 0x55, 0x04, 0x03, 0x0c, 0x22, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, + 0x20, 0x43, 0x41, 0x31, 0x24, 0x30, 0x22, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x15, 0x73, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x40, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x73, 0x73, + 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, + 0x38, 0x32, 0x39, 0x30, 0x36, 0x30, 0x38, 0x30, 0x31, 0x5a, 0x17, 0x0d, + 0x31, 0x39, 0x30, 0x35, 0x32, 0x36, 0x30, 0x36, 0x30, 0x38, 0x30, 0x31, + 0x5a, 0x30, 0x81, 0xb5, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, + 0x06, 0x13, 0x02, 0x46, 0x49, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, + 0x04, 0x08, 0x0c, 0x07, 0x55, 0x75, 0x73, 0x69, 0x6d, 0x61, 0x61, 0x31, + 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x08, 0x48, 0x65, + 0x6c, 0x73, 0x69, 0x6e, 0x6b, 0x69, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, + 0x55, 0x04, 0x0a, 0x0c, 0x10, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x4f, 0x79, 0x31, 0x1b, 0x30, + 0x19, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x12, 0x49, 0x4e, 0x53, 0x49, + 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, + 0x73, 0x74, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, + 0x1a, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x69, 0x64, 0x65, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x2e, + 0x63, 0x6f, 0x6d, 0x31, 0x24, 0x30, 0x22, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x15, 0x73, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x40, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x73, 0x73, + 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, + 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, + 0x01, 0x00, 0xdd, 0xbb, 0xb9, 0x27, 0x84, 0xb2, 0x02, 0x93, 0xdc, 0x68, + 0xe6, 0x06, 0x56, 0xe8, 0xed, 0xcc, 0x4b, 0x0b, 0x11, 0x05, 0x20, 0x72, + 0x1a, 0x1a, 0x08, 0x09, 0xc2, 0x60, 0x33, 0x79, 0x4b, 0xeb, 0xfb, 0x7f, + 0xa1, 0xf3, 0x22, 0xc2, 0xf7, 0x71, 0xe7, 0x0a, 0x5b, 0x81, 0xd1, 0x20, + 0x0a, 0x85, 0xfb, 0x0e, 0x66, 0x33, 0x35, 0x2b, 0x8d, 0x78, 0xf5, 0xd6, + 0x43, 0x0b, 0xe5, 0xce, 0xf8, 0x4a, 0x47, 0x88, 0x03, 0x14, 0x16, 0xb7, + 0xbf, 0x1c, 0xf8, 0x95, 0x9b, 0xac, 0xec, 0x07, 0x9e, 0xa4, 0x91, 0x59, + 0x89, 0xe1, 0xe1, 0xee, 0xaf, 0x4c, 0x7a, 0x98, 0x64, 0x27, 0xe8, 0x63, + 0x0e, 0xd7, 0x75, 0x50, 0x35, 0x6a, 0x53, 0xba, 0x42, 0xb9, 0xc0, 0x11, + 0x1d, 0x6c, 0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36, 0x49, 0x2b, 0xd3, 0x00, 0x04, 0xda, 0x16, + 0x41, 0xa3, 0xd0, 0x38, 0x1b, 0xf2, 0xfc, 0x23, 0x22, 0xcf, 0xe4, 0x62, + 0xee, 0x95, 0x3f, 0x0f, 0x7f, 0x89, 0xb0, 0x56, 0x20, 0x3e, 0xd9, 0xff, + 0x14, 0x91, 0xe7, 0x32, 0x1f, 0xcd, 0x55, 0x7a, 0x1a, 0x43, 0x02, 0x03, + 0x01, 0x00, 0x01, 0xa3, 0x75, 0x30, 0x73, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, + 0x0e, 0x04, 0x16, 0x04, 0x14, 0x78, 0xe4, 0xb1, 0x1a, 0x09, 0xef, 0x04, + 0x88, 0x8b, 0x67, 0xbb, 0x81, 0x70, 0xe0, 0x18, 0x01, 0x36, 0xe4, 0x60, + 0xb3, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x64, 0x15, 0xe2, 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, + 0x3d, 0x1a, 0xe5, 0x74, 0xe2, 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x30, 0x0e, + 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, + 0x07, 0x80, 0x30, 0x16, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x01, 0x01, 0xff, + 0x04, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, + 0x03, 0x09, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x04, 0xd8, + 0x13, 0x9f, 0x61, 0x0c, 0xcc, 0x49, 0x72, 0xf9, 0x66, 0x62, 0xb6, 0xdc, + 0x10, 0x7e, 0x44, 0x2e, 0x07, 0x44, 0x0a, 0x75, 0x00, 0xf7, 0x85, 0x95, + 0x11, 0x8b, 0xc7, 0xd3, 0xf6, 0x67, 0x4f, 0x14, 0x80, 0x93, 0x3b, 0xb0, + 0x35, 0xa3, 0x55, 0xef, 0xe8, 0xb5, 0x0c, 0x37, 0xaa, 0xc2, 0x86, 0x4b, + 0x59, 0x69, 0x5b, 0x87, 0x05, 0xe7, 0x5e, 0x20, 0x32, 0x16, 0x62, 0xe1, + 0xeb, 0x04, 0x47, 0xec, 0x77, 0x46, 0x08, 0x72, 0xe2, 0xd7, 0x8c, 0xb4, + 0xd8, 0x33, 0x2c, 0x26, 0xee, 0xb1, 0x30, 0xe6, 0xe8, 0x97, 0xde, 0x21, + 0x71, 0x25, 0xcd, 0x83, 0xee, 0x6c, 0x59, 0x7a, 0x75, 0x0f, 0xdb, 0x89, + 0x21, 0x72, 0x47, 0xe2, 0x0a, 0x8a, 0xb4, 0x10, 0x4e, 0xd1, 0xb9, 0x54, + 0x5e, 0xd1, 0x9d, 0x99, 0xe9, 0x4d, 0x99, 0x74, 0x62, 0x92, 0xe1, 0x68, + 0x5a, 0xb4, 0x8e, 0x4d, 0x46, 0xc4, 0x04, 0x1d, 0xc0, 0x5f, 0xf9, 0xa0, + 0x08, 0x88, 0x2c, 0x49, 0xdf, 0x39, 0x39, 0x9c, 0x6b, 0xdc, 0x7c, 0x61, + 0xd3, 0x26, 0xf3, 0x3c, 0xd2, 0x5e, 0xf5, 0xee, 0x5d, 0x91, 0x47, 0x7f, + 0x0e, 0xee, 0x77, 0x81, 0x23, 0x72, 0x62, 0xcf, 0x01, 0x68, 0x4e, 0x8c, + 0x78, 0xb8, 0x47, 0xb8, 0x33, 0x6f, 0x0f, 0x38, 0x41, 0x41, 0x42, 0x6e, + 0x25, 0xe9, 0xb1, 0x3d, 0x3a, 0x2f, 0x4e, 0x01, 0xa0, 0xfd, 0x98, 0x2a, + 0x96, 0x94, 0xc6, 0xd6, 0x81, 0x68, 0x2a, 0x8d, 0x06, 0x85, 0x9e, 0x3e, + 0x13, 0xf1, 0x21, 0xef, 0xf3, 0x87, 0xc8, 0xc1, 0xf1, 0x16, 0x21, 0x49, + 0x45, 0x2c, 0xa4, 0x85, 0x15, 0x3d, 0xfc, 0x0e, 0x39, 0x75, 0xe8, 0x8c, + 0x23, 0xba, 0x2d, 0x24, 0x9f, 0x72, 0xfb, 0x37, 0x89, 0xbb, 0x02, 0x90, + 0xd1, 0x1f, 0x93, 0x4d, 0xdb, 0x8d, 0x25, 0x87, 0xff, 0x62, 0xc9, 0x38, + 0x4c, 0x87, 0xfe, 0xa2, 0xec, 0x00, 0x29, 0x3e, 0xa0, 0x6c, 0x4f, 0x6c, + 0x91, 0x8b, 0x61, 0xad, 0xbe, 0xa7, 0x34, 0x4d, 0xd3, 0xc6, 0xae, 0x04, + 0x57, 0x78, 0xf1, 0x9d, 0x46, 0x93, 0x8f, 0x70, 0x64, 0xea, 0x64, 0x93, + 0xb3, 0x06, 0xb3, 0xbb, 0x58, 0x88, 0xd7, 0x27, 0x55, 0xe0, 0x47, 0x94, + 0x13, 0x0c, 0xb5, 0x8c, 0xc0, 0x15, 0x04, 0x8c, 0x3a, 0xd5, 0x83, 0xe0, + 0x1d, 0x69, 0x63, 0x3e, 0xa5, 0x52, 0x06, 0xe2, 0x74, 0xcb, 0x21, 0xbb, + 0x5f, 0x54, 0xa1, 0xce, 0x82, 0x5a, 0xfb, 0x02, 0x70, 0x55, 0x32, 0x16, + 0x40, 0xfd, 0xcf, 0x2a, 0xb1, 0xf1, 0x12, 0x7b, 0xe0, 0x05, 0x14, 0xd4, + 0xdf, 0x56, 0xc0, 0x12, 0x59, 0xcd, 0xe1, 0x2f, 0xf1, 0xac, 0x70, 0x1a, + 0x59, 0x5e, 0xb0, 0x7c, 0xa3, 0xa9, 0x09, 0x49, 0xd2, 0x32, 0x71, 0x5a, + 0xb7, 0xc9, 0x8a, 0xac, 0x75, 0xa5, 0x9f, 0x49, 0xc9, 0xb7, 0xd3, 0xa9, + 0x6d, 0x13, 0xc4, 0xba, 0x92, 0x71, 0xb8, 0x48, 0xe4, 0x59, 0x62, 0x03, + 0xa0, 0x35, 0x67, 0xf5, 0xe2, 0x12, 0x18, 0xf8, 0xa8, 0xff, 0x80, 0x67, + 0x77, 0xfb, 0x2a, 0x01, 0x88, 0x90, 0x9c, 0x3d, 0xd4, 0x0a, 0xb0, 0x70, + 0xd8, 0x3d, 0x57, 0x67, 0xba, 0xcb, 0x55, 0x53, 0x65, 0x44, 0x9e, 0xba, + 0x46, 0x50, 0x58, 0x0e, 0x80, 0x74, 0xa2, 0x3c, 0xb4, 0x05, 0x3d, 0x1f, + 0x23, 0x37, 0x61, 0x21, 0x30, 0x61, 0xba, 0x2b, 0x72, 0x2c, 0xac, 0xc2, + 0xdc, 0x4c, 0xd7, 0x8b, 0x6d, 0xdd, 0xe8, 0x40, 0x35, 0x4f, 0xa9, 0xf7, + 0x31, 0xe7, 0xca, 0xca, 0xb3, 0x2c, 0xda, 0x79, 0x78, 0x8e, 0x74, 0x25, + 0x46, 0xf3, 0xf0, 0x00, 0xbb, 0x3f, 0x50, 0x07, 0x23, 0x97, 0x17, 0xd1, + 0x59, 0xe0, 0x6c, 0xc8, 0x27, 0x1b, 0xb5, 0xcb, 0x77, 0x1a, 0x83, 0xf4, + 0x1d, 0xfd, 0xa6, 0xf8, 0x05, 0xc8 +}; +unsigned int ocsp_response_len = 2382; + +/* Response with SHA-512 hash algorithm, generated using: + faketime '2017-03-27 09:00:00' openssl ocsp -rmd sha512 -resp_key_id -index ../../index.txt -VAfile ../../certs/ocsp.insidesecure-test.com.cert.pem -CA ../../certs/ca-chain.cert.pem -rsigner ../../certs/ocsp.insidesecure-test.com.cert.pem -rkey ../../private/ocsp.insidesecure-test.com.key-nopass.pem -nmin 5 -noverify -reqin /tmp/request -respout /tmp/response -resp_text */ +unsigned char ocsp_response_sha512[] = { + 0x30, 0x82, 0x09, 0x4a, 0x0a, 0x01, 0x00, 0xa0, 0x82, 0x09, 0x43, 0x30, + 0x82, 0x09, 0x3f, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, + 0x01, 0x01, 0x04, 0x82, 0x09, 0x30, 0x30, 0x82, 0x09, 0x2c, 0x30, 0x81, + 0xa1, 0xa2, 0x16, 0x04, 0x14, 0x78, 0xe4, 0xb1, 0x1a, 0x09, 0xef, 0x04, + 0x88, 0x8b, 0x67, 0xbb, 0x81, 0x70, 0xe0, 0x18, 0x01, 0x36, 0xe4, 0x60, + 0xb3, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, 0x30, 0x33, 0x32, 0x37, 0x30, + 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x76, 0x30, 0x74, 0x30, 0x3b, + 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, + 0x14, 0x82, 0x94, 0x68, 0x3e, 0xa5, 0xf1, 0x04, 0x9e, 0xc6, 0x2b, 0x2b, + 0x02, 0xa5, 0xdd, 0x04, 0x7c, 0x1a, 0xfa, 0xf8, 0x0f, 0x04, 0x14, 0x64, + 0x15, 0xe2, 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, 0x3d, 0x1a, 0xe5, + 0x74, 0xe2, 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x02, 0x02, 0x10, 0x01, 0xa1, + 0x11, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x36, 0x30, 0x38, 0x32, 0x39, 0x30, + 0x35, 0x35, 0x38, 0x35, 0x33, 0x5a, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, + 0x30, 0x33, 0x32, 0x37, 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0xa0, + 0x11, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x37, 0x30, 0x33, 0x32, 0x37, 0x30, + 0x36, 0x30, 0x35, 0x30, 0x30, 0x5a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0d, 0x05, 0x00, 0x03, 0x82, 0x02, + 0x01, 0x00, 0xb2, 0x55, 0xd2, 0xee, 0x3a, 0xc7, 0xe1, 0x00, 0xa2, 0xef, + 0xa8, 0xa0, 0x66, 0x27, 0x64, 0xf9, 0x4a, 0xfc, 0xf0, 0x34, 0xc3, 0x94, + 0xd3, 0x8c, 0x9f, 0x85, 0x37, 0x31, 0x6a, 0x7b, 0xc0, 0x0f, 0x7c, 0x13, + 0xc7, 0xdd, 0x4b, 0xf1, 0xd2, 0xd0, 0xfd, 0xa9, 0x8c, 0x4a, 0x24, 0x28, + 0xe1, 0xa5, 0x13, 0x02, 0xf6, 0x18, 0x50, 0x05, 0xc3, 0x6c, 0x53, 0x6e, + 0xe1, 0xf0, 0xeb, 0x5b, 0xef, 0xea, 0x20, 0x54, 0x36, 0x9f, 0x45, 0x82, + 0x1b, 0x41, 0x92, 0x0f, 0xbf, 0xa2, 0xa8, 0x85, 0x5c, 0x06, 0x2d, 0x37, + 0xb4, 0x7c, 0x07, 0x60, 0x78, 0xe8, 0x66, 0x6b, 0xa7, 0x3e, 0xea, 0x5c, + 0xb2, 0x86, 0xe8, 0x77, 0x18, 0x9b, 0xdb, 0x6d, 0xdd, 0x62, 0x6a, 0x40, + 0xf8, 0xe3, 0x1b, 0x67, 0x69, 0xb4, 0x7d, 0x60, 0x02, 0x72, 0x53, 0xfd, + 0x11, 0x16, 0xb8, 0xeb, 0x18, 0x9d, 0x0c, 0xa9, 0xdc, 0x59, 0xce, 0x41, + 0xcd, 0xf8, 0xd7, 0xfa, 0xef, 0x0d, 0x41, 0x52, 0x12, 0xd7, 0x4e, 0x22, + 0x5d, 0x9a, 0xdf, 0xa8, 0x2a, 0x11, 0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82, + 0x06, 0x70, 0x30, 0x82, 0x06, 0x6c, 0x30, 0x82, 0x06, 0x68, 0x30, 0x82, + 0x04, 0x50, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x10, 0x02, 0x30, + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, + 0x05, 0x00, 0x30, 0x81, 0xc0, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x04, 0x06, 0x13, 0x02, 0x46, 0x49, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, + 0x55, 0x04, 0x08, 0x0c, 0x07, 0x55, 0x75, 0x73, 0x69, 0x6d, 0x61, 0x61, + 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x10, 0x49, + 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, + 0x20, 0x4f, 0x79, 0x31, 0x31, 0x30, 0x2f, 0x06, 0x03, 0x55, 0x04, 0x0b, + 0x0c, 0x28, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, + 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x65, 0x72, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x2b, 0x30, 0x29, 0x06, 0x03, + 0x55, 0x04, 0x03, 0x0c, 0x22, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, + 0x20, 0x43, 0x41, 0x31, 0x24, 0x30, 0x22, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x15, 0x73, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x40, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x73, 0x73, + 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, + 0x38, 0x32, 0x39, 0x30, 0x36, 0x30, 0x38, 0x30, 0x31, 0x5a, 0x17, 0x0d, + 0x31, 0x39, 0x30, 0x35, 0x32, 0x36, 0x30, 0x36, 0x30, 0x38, 0x30, 0x31, + 0x5a, 0x30, 0x81, 0xb5, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, + 0x06, 0x13, 0x02, 0x46, 0x49, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, + 0x04, 0x08, 0x0c, 0x07, 0x55, 0x75, 0x73, 0x69, 0x6d, 0x61, 0x61, 0x31, + 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x08, 0x48, 0x65, + 0x6c, 0x73, 0x69, 0x6e, 0x6b, 0x69, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, + 0x55, 0x04, 0x0a, 0x0c, 0x10, 0x49, 0x4e, 0x53, 0x49, 0x44, 0x45, 0x20, + 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x4f, 0x79, 0x31, 0x1b, 0x30, + 0x19, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x12, 0x49, 0x4e, 0x53, 0x49, + 0x44, 0x45, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, + 0x73, 0x74, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, + 0x1a, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x69, 0x6e, 0x73, 0x69, 0x64, 0x65, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x2e, + 0x63, 0x6f, 0x6d, 0x31, 0x24, 0x30, 0x22, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x15, 0x73, 0x75, 0x70, 0x70, + 0x6f, 0x72, 0x74, 0x40, 0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x73, 0x73, + 0x6c, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, + 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, + 0x01, 0x00, 0xdd, 0xbb, 0xb9, 0x27, 0x84, 0xb2, 0x02, 0x93, 0xdc, 0x68, + 0xe6, 0x06, 0x56, 0xe8, 0xed, 0xcc, 0x4b, 0x0b, 0x11, 0x05, 0x20, 0x72, + 0x1a, 0x1a, 0x08, 0x09, 0xc2, 0x60, 0x33, 0x79, 0x4b, 0xeb, 0xfb, 0x7f, + 0xa1, 0xf3, 0x22, 0xc2, 0xf7, 0x71, 0xe7, 0x0a, 0x5b, 0x81, 0xd1, 0x20, + 0x0a, 0x85, 0xfb, 0x0e, 0x66, 0x33, 0x35, 0x2b, 0x8d, 0x78, 0xf5, 0xd6, + 0x43, 0x0b, 0xe5, 0xce, 0xf8, 0x4a, 0x47, 0x88, 0x03, 0x14, 0x16, 0xb7, + 0xbf, 0x1c, 0xf8, 0x95, 0x9b, 0xac, 0xec, 0x07, 0x9e, 0xa4, 0x91, 0x59, + 0x89, 0xe1, 0xe1, 0xee, 0xaf, 0x4c, 0x7a, 0x98, 0x64, 0x27, 0xe8, 0x63, + 0x0e, 0xd7,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4a, 0x1a, 0x69, 0x95, 0xed, 0xa8, 0xb1, 0x8c, + 0x60, 0xb5, 0xee, 0xd7, 0x36, 0x49, 0x2b, 0xd3, 0x00, 0x04, 0xda, 0x16, + 0x41, 0xa3, 0xd0, 0x38, 0x1b, 0xf2, 0xfc, 0x23, 0x22, 0xcf, 0xe4, 0x62, + 0xee, 0x95, 0x3f, 0x0f, 0x7f, 0x89, 0xb0, 0x56, 0x20, 0x3e, 0xd9, 0xff, + 0x14, 0x91, 0xe7, 0x32, 0x1f, 0xcd, 0x55, 0x7a, 0x1a, 0x43, 0x02, 0x03, + 0x01, 0x00, 0x01, 0xa3, 0x75, 0x30, 0x73, 0x30, 0x09, 0x06, 0x03, 0x55, + 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, + 0x0e, 0x04, 0x16, 0x04, 0x14, 0x78, 0xe4, 0xb1, 0x1a, 0x09, 0xef, 0x04, + 0x88, 0x8b, 0x67, 0xbb, 0x81, 0x70, 0xe0, 0x18, 0x01, 0x36, 0xe4, 0x60, + 0xb3, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x64, 0x15, 0xe2, 0x5e, 0x3e, 0x88, 0x1a, 0xdd, 0x6d, 0x29, + 0x3d, 0x1a, 0xe5, 0x74, 0xe2, 0xdb, 0x4f, 0xf3, 0x06, 0xb4, 0x30, 0x0e, + 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, + 0x07, 0x80, 0x30, 0x16, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x01, 0x01, 0xff, + 0x04, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, + 0x03, 0x09, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x04, 0xd8, + 0x13, 0x9f, 0x61, 0x0c, 0xcc, 0x49, 0x72, 0xf9, 0x66, 0x62, 0xb6, 0xdc, + 0x10, 0x7e, 0x44, 0x2e, 0x07, 0x44, 0x0a, 0x75, 0x00, 0xf7, 0x85, 0x95, + 0x11, 0x8b, 0xc7, 0xd3, 0xf6, 0x67, 0x4f, 0x14, 0x80, 0x93, 0x3b, 0xb0, + 0x35, 0xa3, 0x55, 0xef, 0xe8, 0xb5, 0x0c, 0x37, 0xaa, 0xc2, 0x86, 0x4b, + 0x59, 0x69, 0x5b, 0x87, 0x05, 0xe7, 0x5e, 0x20, 0x32, 0x16, 0x62, 0xe1, + 0xeb, 0x04, 0x47, 0xec, 0x77, 0x46, 0x08, 0x72, 0xe2, 0xd7, 0x8c, 0xb4, + 0xd8, 0x33, 0x2c, 0x26, 0xee, 0xb1, 0x30, 0xe6, 0xe8, 0x97, 0xde, 0x21, + 0x71, 0x25, 0xcd, 0x83, 0xee, 0x6c, 0x59, 0x7a, 0x75, 0x0f, 0xdb, 0x89, + 0x21, 0x72, 0x47, 0xe2, 0x0a, 0x8a, 0xb4, 0x10, 0x4e, 0xd1, 0xb9, 0x54, + 0x5e, 0xd1, 0x9d, 0x99, 0xe9, 0x4d, 0x99, 0x74, 0x62, 0x92, 0xe1, 0x68, + 0x5a, 0xb4, 0x8e, 0x4d, 0x46, 0xc4, 0x04, 0x1d, 0xc0, 0x5f, 0xf9, 0xa0, + 0x08, 0x88, 0x2c, 0x49, 0xdf, 0x39, 0x39, 0x9c, 0x6b, 0xdc, 0x7c, 0x61, + 0xd3, 0x26, 0xf3, 0x3c, 0xd2, 0x5e, 0xf5, 0xee, 0x5d, 0x91, 0x47, 0x7f, + 0x0e, 0xee, 0x77, 0x81, 0x23, 0x72, 0x62, 0xcf, 0x01, 0x68, 0x4e, 0x8c, + 0x78, 0xb8, 0x47, 0xb8, 0x33, 0x6f, 0x0f, 0x38, 0x41, 0x41, 0x42, 0x6e, + 0x25, 0xe9, 0xb1, 0x3d, 0x3a, 0x2f, 0x4e, 0x01, 0xa0, 0xfd, 0x98, 0x2a, + 0x96, 0x94, 0xc6, 0xd6, 0x81, 0x68, 0x2a, 0x8d, 0x06, 0x85, 0x9e, 0x3e, + 0x13, 0xf1, 0x21, 0xef, 0xf3, 0x87, 0xc8, 0xc1, 0xf1, 0x16, 0x21, 0x49, + 0x45, 0x2c, 0xa4, 0x85, 0x15, 0x3d, 0xfc, 0x0e, 0x39, 0x75, 0xe8, 0x8c, + 0x23, 0xba, 0x2d, 0x24, 0x9f, 0x72, 0xfb, 0x37, 0x89, 0xbb, 0x02, 0x90, + 0xd1, 0x1f, 0x93, 0x4d, 0xdb, 0x8d, 0x25, 0x87, 0xff, 0x62, 0xc9, 0x38, + 0x4c, 0x87, 0xfe, 0xa2, 0xec, 0x00, 0x29, 0x3e, 0xa0, 0x6c, 0x4f, 0x6c, + 0x91, 0x8b, 0x61, 0xad, 0xbe, 0xa7, 0x34, 0x4d, 0xd3, 0xc6, 0xae, 0x04, + 0x57, 0x78, 0xf1, 0x9d, 0x46, 0x93, 0x8f, 0x70, 0x64, 0xea, 0x64, 0x93, + 0xb3, 0x06, 0xb3, 0xbb, 0x58, 0x88, 0xd7, 0x27, 0x55, 0xe0, 0x47, 0x94, + 0x13, 0x0c, 0xb5, 0x8c, 0xc0, 0x15, 0x04, 0x8c, 0x3a, 0xd5, 0x83, 0xe0, + 0x1d, 0x69, 0x63, 0x3e, 0xa5, 0x52, 0x06, 0xe2, 0x74, 0xcb, 0x21, 0xbb, + 0x5f, 0x54, 0xa1, 0xce, 0x82, 0x5a, 0xfb, 0x02, 0x70, 0x55, 0x32, 0x16, + 0x40, 0xfd, 0xcf, 0x2a, 0xb1, 0xf1, 0x12, 0x7b, 0xe0, 0x05, 0x14, 0xd4, + 0xdf, 0x56, 0xc0, 0x12, 0x59, 0xcd, 0xe1, 0x2f, 0xf1, 0xac, 0x70, 0x1a, + 0x59, 0x5e, 0xb0, 0x7c, 0xa3, 0xa9, 0x09, 0x49, 0xd2, 0x32, 0x71, 0x5a, + 0xb7, 0xc9, 0x8a, 0xac, 0x75, 0xa5, 0x9f, 0x49, 0xc9, 0xb7, 0xd3, 0xa9, + 0x6d, 0x13, 0xc4, 0xba, 0x92, 0x71, 0xb8, 0x48, 0xe4, 0x59, 0x62, 0x03, + 0xa0, 0x35, 0x67, 0xf5, 0xe2, 0x12, 0x18, 0xf8, 0xa8, 0xff, 0x80, 0x67, + 0x77, 0xfb, 0x2a, 0x01, 0x88, 0x90, 0x9c, 0x3d, 0xd4, 0x0a, 0xb0, 0x70, + 0xd8, 0x3d, 0x57, 0x67, 0xba, 0xcb, 0x55, 0x53, 0x65, 0x44, 0x9e, 0xba, + 0x46, 0x50, 0x58, 0x0e, 0x80, 0x74, 0xa2, 0x3c, 0xb4, 0x05, 0x3d, 0x1f, + 0x23, 0x37, 0x61, 0x21, 0x30, 0x61, 0xba, 0x2b, 0x72, 0x2c, 0xac, 0xc2, + 0xdc, 0x4c, 0xd7, 0x8b, 0x6d, 0xdd, 0xe8, 0x40, 0x35, 0x4f, 0xa9, 0xf7, + 0x31, 0xe7, 0xca, 0xca, 0xb3, 0x2c, 0xda, 0x79, 0x78, 0x8e, 0x74, 0x25, + 0x46, 0xf3, 0xf0, 0x00, 0xbb, 0x3f, 0x50, 0x07, 0x23, 0x97, 0x17, 0xd1, + 0x59, 0xe0, 0x6c, 0xc8, 0x27, 0x1b, 0xb5, 0xcb, 0x77, 0x1a, 0x83, 0xf4, + 0x1d, 0xfd, 0xa6, 0xf8, 0x05, 0xc8 +}; +unsigned int ocsp_response_sha512_len = 2382; diff --git a/doc/CHANGES_v3.9.html b/doc/CHANGES_v3.9.html index 93dfddf..9ab7dfe 100644 --- a/doc/CHANGES_v3.9.html +++ b/doc/CHANGES_v3.9.html @@ -9,6 +9,35 @@

MatrixSSL 3.9 changelog

+

Changes between 3.9.2 and 3.9.3 [June 2017]

+

Fix serious buffer handling vulnerabilities along with other smaller bug fixes.

+
    +
  • Fixed buffer overflow vulnerability in parsePolicyMappings and buffer underflow in parseGeneralNames. Vulnerabilities discovered by Aleksandar Nikolic of Cisco Talos.

  • +
  • psX509ParseCert modified not to call parse_single_cert when there are only a few bytes remaining.

  • +
  • Fix compilation when USE_PKCS8 is not defined.

  • +
  • Added common makefiles directory for reusable makefile components.

  • +
  • Added new result code PS_SELFTEST_FAILED for detecting psCryptoOpen() failure due to self-test failure of underlying cryptographic primitivers.

  • +
  • Debugging build log output can be redirected to a file using PSCORE_DEBUG_FILE/PSCORE_DEBUG_FILE_APPEND/FLPS_DEBUG_FILE/ FLPS_DEBUG_FILE_APPEND environment variables.

  • +
  • New example configuration for use of libopenssl-compat. This configuration enables TLS 1.0, which is common to use with libopenssl-compat.

  • +
  • Add client side option for rejecting version downgrade during TLS handshake.

  • +
  • ECDSA cipher suites were errorneously rejected by client using CAs with only RSA certificates.

  • +
  • Small improvements to psBuf and psDynBuf functions.

  • +
  • CMS library improvements, support for multiple recipients with authenticated encrypted data.

  • +
  • CMS library improvements, support for zero or multiple signers for signed data.

  • +
  • Signed data can now contain X.509 CRLs.

  • +
  • Fixed handling of OCSP responses using OCSP responderName.

  • +
  • Fixed memory leak in freeing of OCSP requestor id.

  • +
  • MatrixSSL client sometimes prevented ECDSA cipher suites from being used due to flaw in key material compatibility test. The test has been removed.

  • +
+

Changes between 3.9.1 and 3.9.2

+

3.9.2. only released as a part of SafeZone FIPS SW SDK.

+
    +
  • Added support for OCSP response with SHA-512 signature.

  • +
  • psPkcs8ParsePrivBin() function now supports any SafeZone CL library supported PKCS #8 key formats, in addition to PKCS #8 keys ordinarily supported by MatrixSSL. (Only applicable to MatrixSSL FIPS Edition.)

  • +
  • Added matrixSslLoadKeys and matrixSslLoadKeysMem. This key loading function can be used in situations where the type of private key (RSA or EC) to load is unknown.

  • +
  • Added support for loading CA bundles containing both supported and unsupported certificates. Previously, the loading of a CA bundle failed if any of the certificates could not be fully parsed by MatrixSSL, due to e.g. disabled v1 certificate support. The new feature can be enabled by defining ALLOW_CA_BUNDLE_PARTIAL_PARSE in matrixsslConfig.h. Also the crypto-level psX509ParseCert and psX509ParseCertFile functions support the same feature when passed the CERT_ALLOW_BUNDLE_PARTIAL_PARSE flag.

  • +
  • Added support for RSA-SHA224 and ECDSA-SHA224 signatures in CSR generation, CSR parsing and certificate generation. Expanded X.509 Generation API test.

  • +

Changes between 3.9.0 and 3.9.1