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