|
|
aa8173 |
diff -up openssl-1.0.2k/ssl/fatalerrtest.c.ssl-err openssl-1.0.2k/ssl/fatalerrtest.c
|
|
|
aa8173 |
--- openssl-1.0.2k/ssl/fatalerrtest.c.ssl-err 2017-12-13 14:17:46.730350538 +0100
|
|
|
aa8173 |
+++ openssl-1.0.2k/ssl/fatalerrtest.c 2017-12-13 14:18:54.879940227 +0100
|
|
|
aa8173 |
@@ -0,0 +1,109 @@
|
|
|
aa8173 |
+/*
|
|
|
aa8173 |
+ * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
aa8173 |
+ *
|
|
|
aa8173 |
+ * Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
aa8173 |
+ * this file except in compliance with the License. You can obtain a copy
|
|
|
aa8173 |
+ * in the file LICENSE in the source distribution or at
|
|
|
aa8173 |
+ * https://www.openssl.org/source/license.html
|
|
|
aa8173 |
+ */
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+#include <openssl/ssl.h>
|
|
|
aa8173 |
+#include <openssl/err.h>
|
|
|
aa8173 |
+#include "ssltestlib.h"
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+int main(int argc, char *argv[])
|
|
|
aa8173 |
+{
|
|
|
aa8173 |
+ SSL_CTX *sctx = NULL, *cctx = NULL;
|
|
|
aa8173 |
+ SSL *sssl = NULL, *cssl = NULL;
|
|
|
aa8173 |
+ const char *msg = "Dummy";
|
|
|
aa8173 |
+ BIO *err = NULL, *wbio = NULL;
|
|
|
aa8173 |
+ int ret = 1, len;
|
|
|
aa8173 |
+ char buf[80];
|
|
|
aa8173 |
+ unsigned char dummyrec[] = {
|
|
|
aa8173 |
+ 0x17, 0x03, 0x03, 0x00, 0x05, 'D', 'u', 'm', 'm', 'y'
|
|
|
aa8173 |
+ };
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ if (argc != 3) {
|
|
|
aa8173 |
+ printf("Incorrect number of parameters\n");
|
|
|
aa8173 |
+ return 1;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ SSL_library_init();
|
|
|
aa8173 |
+ SSL_load_error_strings();
|
|
|
aa8173 |
+ err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
|
|
aa8173 |
+ CRYPTO_malloc_debug_init();
|
|
|
aa8173 |
+ CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
|
|
|
aa8173 |
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ if (!create_ssl_ctx_pair(SSLv23_method(), SSLv23_method(), &sctx, &cctx,
|
|
|
aa8173 |
+ argv[1], argv[2])) {
|
|
|
aa8173 |
+ printf("Failed to create SSL_CTX pair\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ /*
|
|
|
aa8173 |
+ * Deliberately set the cipher lists for client and server to be different
|
|
|
aa8173 |
+ * to force a handshake failure.
|
|
|
aa8173 |
+ */
|
|
|
aa8173 |
+ if (!SSL_CTX_set_cipher_list(sctx, "AES128-SHA")
|
|
|
aa8173 |
+ || !SSL_CTX_set_cipher_list(cctx, "AES256-SHA")) {
|
|
|
aa8173 |
+ printf("Failed to set cipher lists\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ if (!create_ssl_objects(sctx, cctx, &sssl, &cssl, NULL, NULL)) {
|
|
|
aa8173 |
+ printf("Failed to create SSL objectx\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ wbio = SSL_get_wbio(cssl);
|
|
|
aa8173 |
+ if (wbio == NULL) {
|
|
|
aa8173 |
+ printf("Unexpected NULL bio received\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ if (create_ssl_connection(sssl, cssl)) {
|
|
|
aa8173 |
+ printf("Unexpected success creating a connection\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ ERR_clear_error();
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ /* Inject a plaintext record from client to server */
|
|
|
aa8173 |
+ if (BIO_write(wbio, dummyrec, sizeof(dummyrec)) <= 0) {
|
|
|
aa8173 |
+ printf("Unexpected failure injecting dummy record\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ /* SSL_read()/SSL_write should fail because of a previous fatal error */
|
|
|
aa8173 |
+ if ((len = SSL_read(sssl, buf, sizeof(buf) - 1)) > 0) {
|
|
|
aa8173 |
+ buf[len] = '\0';
|
|
|
aa8173 |
+ printf("Unexpected success reading data: %s\n", buf);
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+ if (SSL_write(sssl, msg, strlen(msg)) > 0) {
|
|
|
aa8173 |
+ printf("Unexpected success writing data\n");
|
|
|
aa8173 |
+ goto err;
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ ret = 0;
|
|
|
aa8173 |
+ err:
|
|
|
aa8173 |
+ SSL_free(sssl);
|
|
|
aa8173 |
+ SSL_free(cssl);
|
|
|
aa8173 |
+ SSL_CTX_free(sctx);
|
|
|
aa8173 |
+ SSL_CTX_free(cctx);
|
|
|
aa8173 |
+ ERR_print_errors_fp(stderr);
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ if (ret) {
|
|
|
aa8173 |
+ printf("Fatal err test: FAILED\n");
|
|
|
aa8173 |
+ }
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ ERR_free_strings();
|
|
|
aa8173 |
+ ERR_remove_thread_state(NULL);
|
|
|
aa8173 |
+ EVP_cleanup();
|
|
|
aa8173 |
+ CRYPTO_cleanup_all_ex_data();
|
|
|
aa8173 |
+ CRYPTO_mem_leaks(err);
|
|
|
aa8173 |
+ BIO_free(err);
|
|
|
aa8173 |
+
|
|
|
aa8173 |
+ return ret;
|
|
|
aa8173 |
+}
|
|
|
aa8173 |
diff -up openssl-1.0.2k/ssl/Makefile.ssl-err openssl-1.0.2k/ssl/Makefile
|
|
|
aa8173 |
--- openssl-1.0.2k/ssl/Makefile.ssl-err 2017-03-09 17:59:42.832617740 +0100
|
|
|
aa8173 |
+++ openssl-1.0.2k/ssl/Makefile 2017-12-13 14:17:46.729350514 +0100
|
|
|
aa8173 |
@@ -15,7 +15,8 @@ KRB5_INCLUDES=
|
|
|
aa8173 |
CFLAGS= $(INCLUDES) $(CFLAG)
|
|
|
aa8173 |
|
|
|
aa8173 |
GENERAL=Makefile README ssl-lib.com install.com
|
|
|
aa8173 |
-TEST=ssltest.c heartbeat_test.c clienthellotest.c sslv2conftest.c dtlstest.c bad_dtls_test.c
|
|
|
aa8173 |
+TEST=ssltest.c heartbeat_test.c clienthellotest.c sslv2conftest.c dtlstest.c \
|
|
|
aa8173 |
+ bad_dtls_test.c fatalerrtest.c
|
|
|
aa8173 |
APPS=
|
|
|
aa8173 |
|
|
|
aa8173 |
LIB=$(TOP)/libssl.a
|
|
|
aa8173 |
diff -up openssl-1.0.2k/ssl/ssl.h.ssl-err openssl-1.0.2k/ssl/ssl.h
|
|
|
aa8173 |
--- openssl-1.0.2k/ssl/ssl.h.ssl-err 2017-03-09 17:59:26.177229502 +0100
|
|
|
aa8173 |
+++ openssl-1.0.2k/ssl/ssl.h 2017-12-13 14:17:07.341431733 +0100
|
|
|
aa8173 |
@@ -1683,7 +1683,7 @@ extern "C" {
|
|
|
aa8173 |
# define SSL_ST_BEFORE 0x4000
|
|
|
aa8173 |
# define SSL_ST_OK 0x03
|
|
|
aa8173 |
# define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT)
|
|
|
aa8173 |
-# define SSL_ST_ERR 0x05
|
|
|
aa8173 |
+# define SSL_ST_ERR (0x05|SSL_ST_INIT)
|
|
|
aa8173 |
|
|
|
aa8173 |
# define SSL_CB_LOOP 0x01
|
|
|
aa8173 |
# define SSL_CB_EXIT 0x02
|
|
|
aa8173 |
diff -up openssl-1.0.2k/test/Makefile.ssl-err openssl-1.0.2k/test/Makefile
|
|
|
aa8173 |
--- openssl-1.0.2k/test/Makefile.ssl-err 2017-03-09 17:59:45.580681798 +0100
|
|
|
aa8173 |
+++ openssl-1.0.2k/test/Makefile 2017-12-13 14:17:46.731350561 +0100
|
|
|
aa8173 |
@@ -73,6 +73,7 @@ CLIENTHELLOTEST= clienthellotest
|
|
|
aa8173 |
BADDTLSTEST= bad_dtls_test
|
|
|
aa8173 |
SSLV2CONFTEST = sslv2conftest
|
|
|
aa8173 |
DTLSTEST = dtlstest
|
|
|
aa8173 |
+FATALERRTEST = fatalerrtest
|
|
|
aa8173 |
|
|
|
aa8173 |
TESTS= alltests
|
|
|
aa8173 |
|
|
|
aa8173 |
@@ -87,7 +88,7 @@ EXE= $(BNTEST)$(EXE_EXT) $(ECTEST)$(EXE_
|
|
|
aa8173 |
$(ASN1TEST)$(EXE_EXT) $(V3NAMETEST)$(EXE_EXT) $(HEARTBEATTEST)$(EXE_EXT) \
|
|
|
aa8173 |
$(CONSTTIMETEST)$(EXE_EXT) $(VERIFYEXTRATEST)$(EXE_EXT) \
|
|
|
aa8173 |
$(CLIENTHELLOTEST)$(EXE_EXT) $(SSLV2CONFTEST)$(EXE_EXT) $(DTLSTEST)$(EXE_EXT) \
|
|
|
aa8173 |
- $(BADDTLSTEST)$(EXE_EXT)
|
|
|
aa8173 |
+ $(BADDTLSTEST)$(EXE_EXT) $(FATALERRTEST)$(EXE_EXT)
|
|
|
aa8173 |
|
|
|
aa8173 |
# $(METHTEST)$(EXE_EXT)
|
|
|
aa8173 |
|
|
|
aa8173 |
@@ -102,7 +103,7 @@ OBJ= $(BNTEST).o $(ECTEST).o $(ECDSATES
|
|
|
aa8173 |
$(EVPTEST).o $(EVPEXTRATEST).o $(IGETEST).o $(JPAKETEST).o $(ASN1TEST).o $(V3NAMETEST).o \
|
|
|
aa8173 |
$(HEARTBEATTEST).o $(CONSTTIMETEST).o $(VERIFYEXTRATEST).o \
|
|
|
aa8173 |
$(CLIENTHELLOTEST).o $(SSLV2CONFTEST).o $(DTLSTEST).o ssltestlib.o \
|
|
|
aa8173 |
- $(BADDTLSTEST).o
|
|
|
aa8173 |
+ $(BADDTLSTEST).o $(FATALERRTEST).o
|
|
|
aa8173 |
|
|
|
aa8173 |
SRC= $(BNTEST).c $(ECTEST).c $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \
|
|
|
aa8173 |
$(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \
|
|
|
aa8173 |
@@ -114,7 +115,7 @@ SRC= $(BNTEST).c $(ECTEST).c $(ECDSATES
|
|
|
aa8173 |
$(EVPTEST).c $(EVPEXTRATEST).c $(IGETEST).c $(JPAKETEST).c $(SRPTEST).c $(ASN1TEST).c \
|
|
|
aa8173 |
$(V3NAMETEST).c $(HEARTBEATTEST).c $(CONSTTIMETEST).c $(VERIFYEXTRATEST).c \
|
|
|
aa8173 |
$(CLIENTHELLOTEST).c $(SSLV2CONFTEST).c $(DTLSTEST).c ssltestlib.c \
|
|
|
aa8173 |
- $(BADDTLSTEST).c
|
|
|
aa8173 |
+ $(BADDTLSTEST).c $(FATALERRTEST).c
|
|
|
aa8173 |
|
|
|
aa8173 |
EXHEADER=
|
|
|
aa8173 |
HEADER= testutil.h ssltestlib.h $(EXHEADER)
|
|
|
aa8173 |
@@ -159,7 +160,7 @@ alltests: \
|
|
|
aa8173 |
test_ss test_ca test_engine test_evp test_evp_extra test_ssl test_tsa test_ige \
|
|
|
aa8173 |
test_jpake test_srp test_cms test_ocsp test_v3name test_heartbeat \
|
|
|
aa8173 |
test_constant_time test_verify_extra test_clienthello test_sslv2conftest \
|
|
|
aa8173 |
- test_dtls test_bad_dtls
|
|
|
aa8173 |
+ test_dtls test_bad_dtls test_fatalerr
|
|
|
aa8173 |
|
|
|
aa8173 |
test_evp: $(EVPTEST)$(EXE_EXT) evptests.txt
|
|
|
aa8173 |
../util/shlib_wrap.sh ./$(EVPTEST) evptests.txt
|
|
|
aa8173 |
@@ -372,6 +373,10 @@ test_bad_dtls: $(BADDTLSTEST)$(EXE_EXT)
|
|
|
aa8173 |
@echo $(START) $@
|
|
|
aa8173 |
../util/shlib_wrap.sh ./$(BADDTLSTEST)
|
|
|
aa8173 |
|
|
|
aa8173 |
+test_fatalerr: $(FATALERRTEST)$(EXE_EXT)
|
|
|
aa8173 |
+ @echo $(START) $@
|
|
|
aa8173 |
+ ../util/shlib_wrap.sh ./$(FATALERRTEST) ../apps/server.pem ../apps/server.pem
|
|
|
aa8173 |
+
|
|
|
aa8173 |
test_sslv2conftest: $(SSLV2CONFTEST)$(EXE_EXT)
|
|
|
aa8173 |
@echo $(START) $@
|
|
|
aa8173 |
../util/shlib_wrap.sh ./$(SSLV2CONFTEST)
|
|
|
aa8173 |
@@ -560,6 +565,9 @@ $(CLIENTHELLOTEST)$(EXE_EXT): $(CLIENTHE
|
|
|
aa8173 |
$(BADDTLSTEST)$(EXE_EXT): $(BADDTLSTEST).o
|
|
|
aa8173 |
@target=$(BADDTLSTEST) $(BUILD_CMD)
|
|
|
aa8173 |
|
|
|
aa8173 |
+$(FATALERRTEST)$(EXE_EXT): $(FATALERRTEST).o ssltestlib.o $(DLIBSSL) $(DLIBCRYPTO)
|
|
|
aa8173 |
+ @target=$(FATALERRTEST); exobj=ssltestlib.o; $(BUILD_CMD)
|
|
|
aa8173 |
+
|
|
|
aa8173 |
$(SSLV2CONFTEST)$(EXE_EXT): $(SSLV2CONFTEST).o
|
|
|
aa8173 |
@target=$(SSLV2CONFTEST) $(BUILD_CMD)
|
|
|
aa8173 |
|
|
|
aa8173 |
@@ -779,6 +787,25 @@ exptest.o: ../include/openssl/opensslcon
|
|
|
aa8173 |
exptest.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
|
|
|
aa8173 |
exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
|
|
|
aa8173 |
exptest.o: ../include/openssl/symhacks.h exptest.c
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/buffer.h ../include/openssl/comp.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/crypto.h ../include/openssl/dtls1.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/err.h ../include/openssl/evp.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/hmac.h ../include/openssl/kssl.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/pem.h ../include/openssl/pem2.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/srtp.h ../include/openssl/ssl.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
|
|
|
aa8173 |
+fatalerrtest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
|
|
|
aa8173 |
+fatalerrtest.o: fatalerrtest.c ssltestlib.h
|
|
|
aa8173 |
heartbeat_test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
|
|
|
aa8173 |
heartbeat_test.o: ../include/openssl/buffer.h ../include/openssl/comp.h
|
|
|
aa8173 |
heartbeat_test.o: ../include/openssl/crypto.h ../include/openssl/dsa.h
|