Import OpenSSL 1.0.2p
This commit is contained in:
@@ -74,7 +74,7 @@ BADDTLSTEST= bad_dtls_test
|
||||
SSLV2CONFTEST = sslv2conftest
|
||||
DTLSTEST = dtlstest
|
||||
FATALERRTEST = fatalerrtest
|
||||
|
||||
X509TIMETEST = x509_time_test
|
||||
TESTS= alltests
|
||||
|
||||
EXE= $(BNTEST)$(EXE_EXT) $(ECTEST)$(EXE_EXT) $(ECDSATEST)$(EXE_EXT) $(ECDHTEST)$(EXE_EXT) $(IDEATEST)$(EXE_EXT) \
|
||||
@@ -88,7 +88,7 @@ EXE= $(BNTEST)$(EXE_EXT) $(ECTEST)$(EXE_EXT) $(ECDSATEST)$(EXE_EXT) $(ECDHTEST)
|
||||
$(ASN1TEST)$(EXE_EXT) $(V3NAMETEST)$(EXE_EXT) $(HEARTBEATTEST)$(EXE_EXT) \
|
||||
$(CONSTTIMETEST)$(EXE_EXT) $(VERIFYEXTRATEST)$(EXE_EXT) \
|
||||
$(CLIENTHELLOTEST)$(EXE_EXT) $(SSLV2CONFTEST)$(EXE_EXT) $(DTLSTEST)$(EXE_EXT) \
|
||||
$(BADDTLSTEST)$(EXE_EXT) $(FATALERRTEST)$(EXE_EXT)
|
||||
$(BADDTLSTEST)$(EXE_EXT) $(FATALERRTEST)$(EXE_EXT) $(X509TIMETEST)$(EXE_EXT)
|
||||
|
||||
# $(METHTEST)$(EXE_EXT)
|
||||
|
||||
@@ -103,7 +103,7 @@ OBJ= $(BNTEST).o $(ECTEST).o $(ECDSATEST).o $(ECDHTEST).o $(IDEATEST).o \
|
||||
$(EVPTEST).o $(EVPEXTRATEST).o $(IGETEST).o $(JPAKETEST).o $(ASN1TEST).o $(V3NAMETEST).o \
|
||||
$(HEARTBEATTEST).o $(CONSTTIMETEST).o $(VERIFYEXTRATEST).o \
|
||||
$(CLIENTHELLOTEST).o $(SSLV2CONFTEST).o $(DTLSTEST).o ssltestlib.o \
|
||||
$(BADDTLSTEST).o $(FATALERRTEST).o
|
||||
$(BADDTLSTEST).o $(FATALERRTEST).o $(X509TIMETEST).o
|
||||
|
||||
SRC= $(BNTEST).c $(ECTEST).c $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \
|
||||
$(MD2TEST).c $(MD4TEST).c $(MD5TEST).c \
|
||||
@@ -115,7 +115,7 @@ SRC= $(BNTEST).c $(ECTEST).c $(ECDSATEST).c $(ECDHTEST).c $(IDEATEST).c \
|
||||
$(EVPTEST).c $(EVPEXTRATEST).c $(IGETEST).c $(JPAKETEST).c $(SRPTEST).c $(ASN1TEST).c \
|
||||
$(V3NAMETEST).c $(HEARTBEATTEST).c $(CONSTTIMETEST).c $(VERIFYEXTRATEST).c \
|
||||
$(CLIENTHELLOTEST).c $(SSLV2CONFTEST).c $(DTLSTEST).c ssltestlib.c \
|
||||
$(BADDTLSTEST).c $(FATALERRTEST).c
|
||||
$(BADDTLSTEST).c $(FATALERRTEST).c $(X509TIMETEST).c
|
||||
|
||||
EXHEADER=
|
||||
HEADER= testutil.h ssltestlib.h $(EXHEADER)
|
||||
@@ -160,7 +160,7 @@ alltests: \
|
||||
test_ss test_ca test_engine test_evp test_evp_extra test_ssl test_tsa test_ige \
|
||||
test_jpake test_srp test_cms test_ocsp test_v3name test_heartbeat \
|
||||
test_constant_time test_verify_extra test_clienthello test_sslv2conftest \
|
||||
test_dtls test_bad_dtls test_fatalerr
|
||||
test_dtls test_bad_dtls test_fatalerr test_x509_time
|
||||
|
||||
test_evp: $(EVPTEST)$(EXE_EXT) evptests.txt
|
||||
../util/shlib_wrap.sh ./$(EVPTEST) evptests.txt
|
||||
@@ -378,6 +378,10 @@ test_fatalerr: $(FATALERRTEST)$(EXE_EXT)
|
||||
@echo $(START) $@
|
||||
../util/shlib_wrap.sh ./$(FATALERRTEST) ../apps/server.pem ../apps/server.pem
|
||||
|
||||
test_x509_time: $(X509TIMETEST)$(EXE_EXT)
|
||||
@echo $(START) $@
|
||||
../util/shlib_wrap.sh ./$(X509TIMETEST)
|
||||
|
||||
test_sslv2conftest: $(SSLV2CONFTEST)$(EXE_EXT)
|
||||
@echo $(START) $@
|
||||
../util/shlib_wrap.sh ./$(SSLV2CONFTEST)
|
||||
@@ -569,6 +573,9 @@ $(BADDTLSTEST)$(EXE_EXT): $(BADDTLSTEST).o
|
||||
$(FATALERRTEST)$(EXE_EXT): $(FATALERRTEST).o ssltestlib.o $(DLIBSSL) $(DLIBCRYPTO)
|
||||
@target=$(FATALERRTEST); exobj=ssltestlib.o; $(BUILD_CMD)
|
||||
|
||||
$(X509TIMETEST)$(EXE_EXT): $(X509TIMETEST).o
|
||||
@target=$(X509TIMETEST) $(BUILD_CMD)
|
||||
|
||||
$(SSLV2CONFTEST)$(EXE_EXT): $(SSLV2CONFTEST).o
|
||||
@target=$(SSLV2CONFTEST) $(BUILD_CMD)
|
||||
|
||||
@@ -1012,3 +1019,15 @@ wp_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
|
||||
wp_test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
|
||||
wp_test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
|
||||
wp_test.o: ../include/openssl/whrlpool.h wp_test.c
|
||||
x509_time_test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
|
||||
x509_time_test.o: ../include/openssl/buffer.h ../include/openssl/crypto.h
|
||||
x509_time_test.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
|
||||
x509_time_test.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
|
||||
x509_time_test.o: ../include/openssl/evp.h ../include/openssl/lhash.h
|
||||
x509_time_test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
|
||||
x509_time_test.o: ../include/openssl/opensslconf.h
|
||||
x509_time_test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
|
||||
x509_time_test.o: ../include/openssl/pkcs7.h ../include/openssl/safestack.h
|
||||
x509_time_test.o: ../include/openssl/sha.h ../include/openssl/stack.h
|
||||
x509_time_test.o: ../include/openssl/symhacks.h ../include/openssl/x509.h
|
||||
x509_time_test.o: ../include/openssl/x509_vfy.h testutil.h x509_time_test.c
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# project.
|
||||
#
|
||||
# ====================================================================
|
||||
# Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
||||
# Copyright (c) 2008-2018 The OpenSSL Project. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@@ -100,6 +100,13 @@ my $no_ec2m;
|
||||
my $no_ecdh;
|
||||
my $ossl8 = `$ossl_path version -v` =~ /0\.9\.8/;
|
||||
|
||||
system ("$ossl_path no-cms > $null_path");
|
||||
if ($? == 0)
|
||||
{
|
||||
print STDERR "CMS disabled. skipping...\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
system ("$ossl_path no-ec > $null_path");
|
||||
if ($? == 0)
|
||||
{
|
||||
|
||||
12
test/recipes/60-test_x509_time.t
Normal file
12
test/recipes/60-test_x509_time.t
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
use OpenSSL::Test::Simple;
|
||||
|
||||
simple_test("test_x509_time", "x509_time_test");
|
||||
18
test/testssl
18
test/testssl
@@ -172,14 +172,18 @@ for protocol in TLSv1.2 SSLv3; do
|
||||
test_cipher $cipher $protocol
|
||||
done
|
||||
echo "testing connection with weak DH, expecting failure"
|
||||
if [ $protocol = "SSLv3" ] ; then
|
||||
$ssltest -cipher EDH -dhe512 -ssl3
|
||||
if [ $protocol = "SSLv3" ] && ../util/shlib_wrap.sh ../apps/openssl no-ssl3; then
|
||||
echo "skipping weak DH test for disabled protocol"
|
||||
else
|
||||
$ssltest -cipher EDH -dhe512
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "FAIL: connection with weak DH succeeded"
|
||||
exit 1
|
||||
if [ $protocol = "SSLv3" ] ; then
|
||||
$ssltest -cipher EDH -dhe512 -ssl3
|
||||
else
|
||||
$ssltest -cipher EDH -dhe512
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "FAIL: connection with weak DH succeeded"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if ../util/shlib_wrap.sh ../apps/openssl no-ec; then
|
||||
|
||||
212
test/x509_time_test.c
Normal file
212
test/x509_time_test.c
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* Tests for X509 time functions */
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/x509.h>
|
||||
#include "testutil.h"
|
||||
#include "e_os.h"
|
||||
|
||||
typedef struct {
|
||||
const char *data;
|
||||
int type;
|
||||
time_t cmp_time;
|
||||
/* -1 if asn1_time <= cmp_time, 1 if asn1_time > cmp_time, 0 if error. */
|
||||
int expected;
|
||||
} TESTDATA;
|
||||
|
||||
static TESTDATA x509_cmp_tests[] = {
|
||||
{
|
||||
"20170217180154Z", V_ASN1_GENERALIZEDTIME,
|
||||
/* The same in seconds since epoch. */
|
||||
1487354514, -1,
|
||||
},
|
||||
{
|
||||
"20170217180154Z", V_ASN1_GENERALIZEDTIME,
|
||||
/* One second more. */
|
||||
1487354515, -1,
|
||||
},
|
||||
{
|
||||
"20170217180154Z", V_ASN1_GENERALIZEDTIME,
|
||||
/* One second less. */
|
||||
1487354513, 1,
|
||||
},
|
||||
/* Same as UTC time. */
|
||||
{
|
||||
"170217180154Z", V_ASN1_UTCTIME,
|
||||
/* The same in seconds since epoch. */
|
||||
1487354514, -1,
|
||||
},
|
||||
{
|
||||
"170217180154Z", V_ASN1_UTCTIME,
|
||||
/* One second more. */
|
||||
1487354515, -1,
|
||||
},
|
||||
{
|
||||
"170217180154Z", V_ASN1_UTCTIME,
|
||||
/* One second less. */
|
||||
1487354513, 1,
|
||||
},
|
||||
/* UTCTime from the 20th century. */
|
||||
{
|
||||
"990217180154Z", V_ASN1_UTCTIME,
|
||||
/* The same in seconds since epoch. */
|
||||
919274514, -1,
|
||||
},
|
||||
{
|
||||
"990217180154Z", V_ASN1_UTCTIME,
|
||||
/* One second more. */
|
||||
919274515, -1,
|
||||
},
|
||||
{
|
||||
"990217180154Z", V_ASN1_UTCTIME,
|
||||
/* One second less. */
|
||||
919274513, 1,
|
||||
},
|
||||
/* Various invalid formats. */
|
||||
{
|
||||
/* No trailing Z. */
|
||||
"20170217180154", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* No trailing Z, UTCTime. */
|
||||
"170217180154", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* No seconds. */
|
||||
"201702171801Z", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* No seconds, UTCTime. */
|
||||
"1702171801Z", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Fractional seconds. */
|
||||
"20170217180154.001Z", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Fractional seconds, UTCTime. */
|
||||
"170217180154.001Z", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Timezone offset. */
|
||||
"20170217180154+0100", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Timezone offset, UTCTime. */
|
||||
"170217180154+0100", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Extra digits. */
|
||||
"2017021718015400Z", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Extra digits, UTCTime. */
|
||||
"17021718015400Z", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Non-digits. */
|
||||
"2017021718015aZ", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Non-digits, UTCTime. */
|
||||
"17021718015aZ", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Trailing garbage. */
|
||||
"20170217180154Zlongtrailinggarbage", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Trailing garbage, UTCTime. */
|
||||
"170217180154Zlongtrailinggarbage", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Swapped type. */
|
||||
"20170217180154Z", V_ASN1_UTCTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Swapped type. */
|
||||
"170217180154Z", V_ASN1_GENERALIZEDTIME, 0, 0,
|
||||
},
|
||||
{
|
||||
/* Bad type. */
|
||||
"20170217180154Z", V_ASN1_OCTET_STRING, 0, 0,
|
||||
},
|
||||
};
|
||||
|
||||
static int test_x509_cmp_time(int idx)
|
||||
{
|
||||
ASN1_TIME t;
|
||||
int result;
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
t.type = x509_cmp_tests[idx].type;
|
||||
t.data = (unsigned char*)(x509_cmp_tests[idx].data);
|
||||
t.length = strlen(x509_cmp_tests[idx].data);
|
||||
|
||||
result = X509_cmp_time(&t, &x509_cmp_tests[idx].cmp_time);
|
||||
if (result != x509_cmp_tests[idx].expected) {
|
||||
fprintf(stderr, "test_x509_cmp_time(%d) failed: expected %d, got %d\n",
|
||||
idx, x509_cmp_tests[idx].expected, result);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_x509_cmp_time_current()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
/* Pick a day earlier and later, relative to any system clock. */
|
||||
ASN1_TIME *asn1_before = NULL, *asn1_after = NULL;
|
||||
int cmp_result, failed = 0;
|
||||
|
||||
asn1_before = ASN1_TIME_adj(NULL, now, -1, 0);
|
||||
asn1_after = ASN1_TIME_adj(NULL, now, 1, 0);
|
||||
|
||||
cmp_result = X509_cmp_time(asn1_before, NULL);
|
||||
if (cmp_result != -1) {
|
||||
fprintf(stderr, "test_x509_cmp_time_current failed: expected -1, got %d\n",
|
||||
cmp_result);
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
cmp_result = X509_cmp_time(asn1_after, NULL);
|
||||
if (cmp_result != 1) {
|
||||
fprintf(stderr, "test_x509_cmp_time_current failed: expected 1, got %d\n",
|
||||
cmp_result);
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
ASN1_TIME_free(asn1_before);
|
||||
ASN1_TIME_free(asn1_after);
|
||||
|
||||
return failed == 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned int idx;
|
||||
|
||||
if (!test_x509_cmp_time_current())
|
||||
ret = 1;
|
||||
|
||||
for (idx=0 ; idx < sizeof(x509_cmp_tests)/sizeof(x509_cmp_tests[0]) ; ++idx) {
|
||||
if (!test_x509_cmp_time(idx))
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
printf("PASS\n");
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user