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