diff --git a/CHANGES b/CHANGES index e2e61bb7..657f0cfb 100644 --- a/CHANGES +++ b/CHANGES @@ -7,7 +7,27 @@ https://github.com/openssl/openssl/commits/ and pick the appropriate release branch. - Changes between 1.1.0i and 1.1.1 [xx XXX xxxx] + Changes between 1.1.1 and 1.1.2 [xx XXX xxxx] + + *) AES-XTS mode now enforces that its two keys are different to mitigate + the attacked described in "Efficient Instantiations of Tweakable + Blockciphers and Refinements to Modes OCB and PMAC" by Phillip Rogaway. + Details of this attack can be obtained from: + http://web.cs.ucdavis.edu/%7Erogaway/papers/offsets.pdf + [Paul Dale] + + Changes between 1.1.0i and 1.1.1 [11 Sep 2018] + + *) Add a new ClientHello callback. Provides a callback interface that gives + the application the ability to adjust the nascent SSL object at the + earliest stage of ClientHello processing, immediately after extensions have + been collected but before they have been processed. In particular, this + callback can adjust the supported TLS versions in response to the contents + of the ClientHello + [Benjamin Kaduk] + + *) Add SM2 base algorithm support. + [Jack Lloyd] *) s390x assembly pack: add (improved) hardware-support for the following cryptographic primitives: sha3, shake, aes-gcm, aes-ccm, aes-ctr, aes-ofb, diff --git a/NEWS b/NEWS index 9ac74561..3179b1dd 100644 --- a/NEWS +++ b/NEWS @@ -5,22 +5,57 @@ This file gives a brief overview of the major changes between each OpenSSL release. For more details please read the CHANGES file. - Major changes between OpenSSL 1.1.0i and OpenSSL 1.1.1 [in pre-release] + Major changes between OpenSSL 1.1.1 and OpenSSL 1.1.2 [under development] - o Support for TLSv1.3 added + o + + Major changes between OpenSSL 1.1.0i and OpenSSL 1.1.1 [11 Sep 2018] + + o Support for TLSv1.3 added (see https://wiki.openssl.org/index.php/TLS1.3 + for further important information). The TLSv1.3 implementation includes: + o Fully compliant implementation of RFC8446 (TLSv1.3) on by default + o Early data (0-RTT) + o Post-handshake authentication and key update + o Middlebox Compatibility Mode + o TLSv1.3 PSKs + o Support for all five RFC8446 ciphersuites + o RSA-PSS signature algorithms (backported to TLSv1.2) + o Configurable session ticket support + o Stateless server support + o Rewrite of the packet construction code for "safer" packet handling + o Rewrite of the extension handling code + o Complete rewrite of the OpenSSL random number generator to introduce the + following capabilities + o The default RAND method now utilizes an AES-CTR DRBG according to + NIST standard SP 800-90Ar1. + o Support for multiple DRBG instances with seed chaining. + o There is a public and private DRBG instance. + o The DRBG instances are fork-safe. + o Keep all global DRBG instances on the secure heap if it is enabled. + o The public and private DRBG instance are per thread for lock free + operation + o Support for various new cryptographic algorithms including: + o SHA3 + o SHA512/224 and SHA512/256 + o EdDSA (both Ed25519 and Ed448) including X509 and TLS support + o X448 (adding to the existing X25519 support in 1.1.0) + o Multi-prime RSA + o SM2 + o SM3 + o SM4 + o SipHash + o ARIA (including TLS support) + o Significant Side-Channel attack security improvements + o Add a new ClientHello callback to provide the ability to adjust the SSL + object at an early stage. + o Add 'Maximum Fragment Length' TLS extension negotiation and support + o A new STORE module, which implements a uniform and URI based reader of + stores that can contain keys, certificates, CRLs and numerous other + objects. o Move the display of configuration data to configdata.pm. o Allow GNU style "make variables" to be used with Configure. - o Add a STORE module (OSSL_STORE) o Claim the namespaces OSSL and OPENSSL, represented as symbol prefixes - o Add multi-prime RSA (RFC 8017) support - o Add SM3 implemented according to GB/T 32905-2016 - o Add SM4 implemented according to GB/T 32907-2016. - o Add 'Maximum Fragment Length' TLS extension negotiation and support - o Add ARIA support - o Add SHA3 o Rewrite of devcrypto engine - o Add support for SipHash - o Grand redesign of the OpenSSL random generator Major changes between OpenSSL 1.1.0h and OpenSSL 1.1.0i [under development] diff --git a/README b/README index 6075f166..6818807a 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ - OpenSSL 1.1.1-pre10-dev + OpenSSL 1.1.2-dev Copyright (c) 1998-2018 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson diff --git a/apps/speed.c b/apps/speed.c index c859c862..27b4d50a 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -298,7 +298,7 @@ static int opt_found(const char *name, unsigned int *result, typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, - OPT_ELAPSED, OPT_EVP, OPT_DECRYPT, OPT_ENGINE, OPT_MULTI, + OPT_ELAPSED, OPT_EVP, OPT_HMAC, OPT_DECRYPT, OPT_ENGINE, OPT_MULTI, OPT_MR, OPT_MB, OPT_MISALIGN, OPT_ASYNCJOBS, OPT_R_ENUM, OPT_PRIMES, OPT_SECONDS, OPT_BYTES, OPT_AEAD } OPTION_CHOICE; @@ -308,6 +308,7 @@ const OPTIONS speed_options[] = { {OPT_HELP_STR, 1, '-', "Valid options are:\n"}, {"help", OPT_HELP, '-', "Display this summary"}, {"evp", OPT_EVP, 's', "Use EVP-named cipher or digest"}, + {"hmac", OPT_HMAC, 's', "HMAC using EVP-named digest"}, {"decrypt", OPT_DECRYPT, '-', "Time decryption instead of encryption (only EVP)"}, {"aead", OPT_AEAD, '-', @@ -369,6 +370,8 @@ const OPTIONS speed_options[] = { #define D_IGE_256_AES 28 #define D_GHASH 29 #define D_RAND 30 +#define D_EVP_HMAC 31 + /* name of algorithms to test */ static const char *names[] = { "md2", "mdc2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", "rc4", @@ -378,7 +381,7 @@ static const char *names[] = { "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", "evp", "sha256", "sha512", "whirlpool", "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash", - "rand" + "rand", "hmac" }; #define ALGOR_NUM OSSL_NELEM(names) @@ -600,6 +603,7 @@ typedef struct loopargs_st { unsigned char *buf2_malloc; unsigned char *key; unsigned int siglen; + size_t sigsize; #ifndef OPENSSL_NO_RSA RSA *rsa_key[RSA_NUM]; #endif @@ -1031,6 +1035,26 @@ static int EVP_Digest_loop(void *args) return count; } +static const EVP_MD *evp_hmac_md = NULL; +static char *evp_hmac_name = NULL; +static int EVP_HMAC_loop(void *args) +{ + loopargs_t *tempargs = *(loopargs_t **) args; + unsigned char *buf = tempargs->buf; + unsigned char no_key[32]; + int count; +#ifndef SIGALRM + int nb_iter = save_count * 4 * lengths[0] / lengths[testnum]; +#endif + + for (count = 0; COND(nb_iter); count++) { + if (HMAC(evp_hmac_md, no_key, sizeof(no_key), buf, lengths[testnum], + NULL, NULL) == NULL) + return -1; + } + return count; +} + #ifndef OPENSSL_NO_RSA static long rsa_c[RSA_NUM][2]; /* # RSA iteration test */ @@ -1185,11 +1209,11 @@ static int EdDSA_sign_loop(void *args) unsigned char *buf = tempargs->buf; EVP_MD_CTX **edctx = tempargs->eddsa_ctx; unsigned char *eddsasig = tempargs->buf2; - unsigned int *eddsasiglen = &tempargs->siglen; + size_t *eddsasigsize = &tempargs->sigsize; int ret, count; for (count = 0; COND(eddsa_c[testnum][0]); count++) { - ret = EVP_DigestSign(edctx[testnum], eddsasig, (size_t *)eddsasiglen, buf, 20); + ret = EVP_DigestSign(edctx[testnum], eddsasig, eddsasigsize, buf, 20); if (ret == 0) { BIO_printf(bio_err, "EdDSA sign failure\n"); ERR_print_errors(bio_err); @@ -1206,11 +1230,11 @@ static int EdDSA_verify_loop(void *args) unsigned char *buf = tempargs->buf; EVP_MD_CTX **edctx = tempargs->eddsa_ctx; unsigned char *eddsasig = tempargs->buf2; - unsigned int eddsasiglen = tempargs->siglen; + size_t eddsasigsize = tempargs->sigsize; int ret, count; for (count = 0; COND(eddsa_c[testnum][1]); count++) { - ret = EVP_DigestVerify(edctx[testnum], eddsasig, eddsasiglen, buf, 20); + ret = EVP_DigestVerify(edctx[testnum], eddsasig, eddsasigsize, buf, 20); if (ret != 1) { BIO_printf(bio_err, "EdDSA verify failure\n"); ERR_print_errors(bio_err); @@ -1525,7 +1549,7 @@ int speed_main(int argc, char **argv) const char *name; unsigned int nid; unsigned int bits; - unsigned int siglen; + size_t sigsize; } test_ed_curves[] = { /* EdDSA */ {"Ed25519", NID_ED25519, 253, 64}, @@ -1566,6 +1590,15 @@ int speed_main(int argc, char **argv) } doit[D_EVP] = 1; break; + case OPT_HMAC: + evp_hmac_md = EVP_get_digestbyname(opt_arg()); + if (evp_hmac_md == NULL) { + BIO_printf(bio_err, "%s: %s is an unknown digest\n", + prog, opt_arg()); + goto end; + } + doit[D_EVP_HMAC] = 1; + break; case OPT_DECRYPT: decrypt = 1; break; @@ -1804,9 +1837,9 @@ int speed_main(int argc, char **argv) e = setup_engine(engine_id, 0); /* No parameters; turn on everything. */ - if ((argc == 0) && !doit[D_EVP]) { + if (argc == 0 && !doit[D_EVP] && !doit[D_EVP_HMAC]) { for (i = 0; i < ALGOR_NUM; i++) - if (i != D_EVP) + if (i != D_EVP && i != D_EVP_HMAC) doit[i] = 1; #ifndef OPENSSL_NO_RSA for (i = 0; i < RSA_NUM; i++) @@ -2648,6 +2681,25 @@ int speed_main(int argc, char **argv) } } + if (doit[D_EVP_HMAC]) { + if (evp_hmac_md != NULL) { + const char *md_name = OBJ_nid2ln(EVP_MD_type(evp_hmac_md)); + evp_hmac_name = app_malloc(sizeof("HMAC()") + strlen(md_name), + "HMAC name"); + sprintf(evp_hmac_name, "HMAC(%s)", md_name); + names[D_EVP_HMAC] = evp_hmac_name; + + for (testnum = 0; testnum < size_num; testnum++) { + print_message(names[D_EVP_HMAC], save_count, lengths[testnum], + seconds.sym); + Time_F(START); + count = run_benchmark(async_jobs, EVP_HMAC_loop, loopargs); + d = Time_F(STOP); + print_result(D_EVP_HMAC, testnum, count, d); + } + } + } + for (i = 0; i < loopargs_len; i++) if (RAND_bytes(loopargs[i].buf, 36) <= 0) goto end; @@ -3101,9 +3153,9 @@ int speed_main(int argc, char **argv) } else { for (i = 0; i < loopargs_len; i++) { /* Perform EdDSA signature test */ - loopargs[i].siglen = test_ed_curves[testnum].siglen; + loopargs[i].sigsize = test_ed_curves[testnum].sigsize; st = EVP_DigestSign(loopargs[i].eddsa_ctx[testnum], - loopargs[i].buf2, (size_t *)&loopargs[i].siglen, + loopargs[i].buf2, &loopargs[i].sigsize, loopargs[i].buf, 20); if (st == 0) break; @@ -3133,7 +3185,7 @@ int speed_main(int argc, char **argv) /* Perform EdDSA verification test */ for (i = 0; i < loopargs_len; i++) { st = EVP_DigestVerify(loopargs[i].eddsa_ctx[testnum], - loopargs[i].buf2, loopargs[i].siglen, + loopargs[i].buf2, loopargs[i].sigsize, loopargs[i].buf, 20); if (st != 1) break; @@ -3346,6 +3398,7 @@ int speed_main(int argc, char **argv) OPENSSL_free(loopargs[i].secret_b); #endif } + OPENSSL_free(evp_hmac_name); if (async_jobs > 0) { for (i = 0; i < loopargs_len; i++) diff --git a/crypto/aes/asm/aes-parisc.pl b/crypto/aes/asm/aes-parisc.pl index 93ed09c3..e817c757 100644 --- a/crypto/aes/asm/aes-parisc.pl +++ b/crypto/aes/asm/aes-parisc.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2009-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 diff --git a/crypto/asn1/x_int64.c b/crypto/asn1/x_int64.c index f07ca3cf..0ee552cf 100644 --- a/crypto/asn1/x_int64.c +++ b/crypto/asn1/x_int64.c @@ -81,6 +81,16 @@ static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, return 0; cp = (char *)*pval; + + /* + * Strictly speaking, zero length is malformed. However, long_c2i + * (x_long.c) encodes 0 as a zero length INTEGER (wrongly, of course), + * so for the sake of backward compatibility, we still decode zero + * length INTEGERs as the number zero. + */ + if (len == 0) + goto long_compat; + if (!c2i_uint64_int(&utmp, &neg, &cont, len)) return 0; if ((it->size & INTxx_FLAG_SIGNED) == 0 && neg) { @@ -95,6 +105,8 @@ static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, if (neg) /* c2i_uint64_int() returns positive values */ utmp = 0 - utmp; + + long_compat: memcpy(cp, &utmp, sizeof(utmp)); return 1; } @@ -172,6 +184,16 @@ static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, return 0; cp = (char *)*pval; + + /* + * Strictly speaking, zero length is malformed. However, long_c2i + * (x_long.c) encodes 0 as a zero length INTEGER (wrongly, of course), + * so for the sake of backward compatibility, we still decode zero + * length INTEGERs as the number zero. + */ + if (len == 0) + goto long_compat; + if (!c2i_uint64_int(&utmp, &neg, &cont, len)) return 0; if ((it->size & INTxx_FLAG_SIGNED) == 0 && neg) { @@ -191,6 +213,8 @@ static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, return 0; } } + + long_compat: utmp2 = (uint32_t)utmp; memcpy(cp, &utmp2, sizeof(utmp2)); return 1; diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index 464a4446..70add10c 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/bn/bn_intern.c b/crypto/bn/bn_intern.c index faebdc8e..46bc9757 100644 --- a/crypto/bn/bn_intern.c +++ b/crypto/bn/bn_intern.c @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-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 diff --git a/crypto/bn/bn_lcl.h b/crypto/bn/bn_lcl.h index d74b5908..8a36db2e 100644 --- a/crypto/bn/bn_lcl.h +++ b/crypto/bn/bn_lcl.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/bn/bn_mod.c b/crypto/bn/bn_mod.c index ab847cb5..712fc8ac 100644 --- a/crypto/bn/bn_mod.c +++ b/crypto/bn/bn_mod.c @@ -1,5 +1,5 @@ /* - * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1998-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 diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c index bbbb84ac..5eda65cf 100644 --- a/crypto/bn/bn_mul.c +++ b/crypto/bn/bn_mul.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/bn/bn_nist.c b/crypto/bn/bn_nist.c index 4d71afda..dcdd321c 100644 --- a/crypto/bn/bn_nist.c +++ b/crypto/bn/bn_nist.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-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 diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index 8334b81f..0c0a590f 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c index a197cdc5..9eb8384f 100644 --- a/crypto/bn/bn_x931p.c +++ b/crypto/bn/bn_x931p.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-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 diff --git a/crypto/camellia/camellia.c b/crypto/camellia/camellia.c index 45f23252..c200b823 100644 --- a/crypto/camellia/camellia.c +++ b/crypto/camellia/camellia.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-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 diff --git a/crypto/cms/cms_lcl.h b/crypto/cms/cms_lcl.h index dd5a5852..916fcbfb 100644 --- a/crypto/cms/cms_lcl.h +++ b/crypto/cms/cms_lcl.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2008-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 diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index 1833b15e..07110d85 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-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 diff --git a/crypto/dllmain.c b/crypto/dllmain.c index c23b06b4..0838c55e 100644 --- a/crypto/dllmain.c +++ b/crypto/dllmain.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-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 diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c index 5237794d..ac1f65a5 100644 --- a/crypto/dsa/dsa_ossl.c +++ b/crypto/dsa/dsa_ossl.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c index d8e2781f..e9466b29 100644 --- a/crypto/dsa/dsa_sign.c +++ b/crypto/dsa/dsa_sign.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/ec/asm/ecp_nistz256-ppc64.pl b/crypto/ec/asm/ecp_nistz256-ppc64.pl index 116792f7..984c7f20 100755 --- a/crypto/ec/asm/ecp_nistz256-ppc64.pl +++ b/crypto/ec/asm/ecp_nistz256-ppc64.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2016-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 diff --git a/crypto/ec/asm/ecp_nistz256-sparcv9.pl b/crypto/ec/asm/ecp_nistz256-sparcv9.pl index 59df0f73..0a4def6e 100755 --- a/crypto/ec/asm/ecp_nistz256-sparcv9.pl +++ b/crypto/ec/asm/ecp_nistz256-sparcv9.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-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 diff --git a/crypto/ec/asm/ecp_nistz256-x86.pl b/crypto/ec/asm/ecp_nistz256-x86.pl index 8fdd76b8..0c6fc665 100755 --- a/crypto/ec/asm/ecp_nistz256-x86.pl +++ b/crypto/ec/asm/ecp_nistz256-x86.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-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 diff --git a/crypto/ec/ec2_oct.c b/crypto/ec/ec2_oct.c index d515dab8..0867f994 100644 --- a/crypto/ec/ec2_oct.c +++ b/crypto/ec/ec2_oct.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/crypto/ec/ec_cvt.c b/crypto/ec/ec_cvt.c index 7f8bc1c1..0ec346c1 100644 --- a/crypto/ec/ec_cvt.c +++ b/crypto/ec/ec_cvt.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/crypto/ec/ec_kmeth.c b/crypto/ec/ec_kmeth.c index decad65a..64a5d208 100644 --- a/crypto/ec/ec_kmeth.c +++ b/crypto/ec/ec_kmeth.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c index cde3090d..b538fadc 100644 --- a/crypto/ec/eck_prn.c +++ b/crypto/ec/eck_prn.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/crypto/ec/ecp_oct.c b/crypto/ec/ecp_oct.c index 2be3c865..7ade1b3d 100644 --- a/crypto/ec/ecp_oct.c +++ b/crypto/ec/ecp_oct.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c index 27c6df4f..9deaf5c6 100644 --- a/crypto/engine/eng_devcrypto.c +++ b/crypto/engine/eng_devcrypto.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * 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 diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h index 7c41da2f..b9548334 100644 --- a/crypto/engine/eng_int.h +++ b/crypto/engine/eng_int.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c index 0add3932..61d37a89 100644 --- a/crypto/evp/e_aes.c +++ b/crypto/evp/e_aes.c @@ -3410,10 +3410,30 @@ static int aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_AES_XTS_CTX *xctx = EVP_C_DATA(EVP_AES_XTS_CTX,ctx); - if (!xctx->xts.key1 || !xctx->xts.key2) + + if (xctx->xts.key1 == NULL + || xctx->xts.key2 == NULL + || out == NULL + || in == NULL + || len < AES_BLOCK_SIZE) return 0; - if (!out || !in || len < AES_BLOCK_SIZE) + + /* + * Verify that the two keys are different. + * + * This addresses the vulnerability described in Rogaway's September 2004 + * paper (http://web.cs.ucdavis.edu/~rogaway/papers/offsets.pdf): + * "Efficient Instantiations of Tweakable Blockciphers and Refinements + * to Modes OCB and PMAC". + * + * FIPS 140-2 IG A.9 XTS-AES Key Generation Requirements states that: + * "The check for Key_1 != Key_2 shall be done at any place BEFORE + * using the keys in the XTS-AES algorithm to process data with them." + */ + if (CRYPTO_memcmp(xctx->xts.key1, xctx->xts.key2, + EVP_CIPHER_CTX_key_length(ctx) / 2) == 0) return 0; + if (xctx->stream) (*xctx->stream) (in, out, len, xctx->xts.key1, xctx->xts.key2, diff --git a/crypto/evp/e_chacha20_poly1305.c b/crypto/evp/e_chacha20_poly1305.c index 6a9bccfe..c1917bb8 100644 --- a/crypto/evp/e_chacha20_poly1305.c +++ b/crypto/evp/e_chacha20_poly1305.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index f80fc064..5a88817b 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 diff --git a/crypto/evp/m_sha3.c b/crypto/evp/m_sha3.c index 729622b8..31379c0f 100644 --- a/crypto/evp/m_sha3.c +++ b/crypto/evp/m_sha3.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * 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 diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c index 0fc84f30..e851d7ab 100644 --- a/crypto/evp/p_seal.c +++ b/crypto/evp/p_seal.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/include/internal/aria.h b/crypto/include/internal/aria.h index e402b8ee..355abe53 100644 --- a/crypto/include/internal/aria.h +++ b/crypto/include/internal/aria.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/crypto/include/internal/bn_int.h b/crypto/include/internal/bn_int.h index 479f2589..cffe5cfc 100644 --- a/crypto/include/internal/bn_int.h +++ b/crypto/include/internal/bn_int.h @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-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 diff --git a/crypto/include/internal/chacha.h b/crypto/include/internal/chacha.h index 119361d4..67243f22 100644 --- a/crypto/include/internal/chacha.h +++ b/crypto/include/internal/chacha.h @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/crypto/include/internal/md32_common.h b/crypto/include/internal/md32_common.h index 2e9f893e..1124e9c2 100644 --- a/crypto/include/internal/md32_common.h +++ b/crypto/include/internal/md32_common.h @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 diff --git a/crypto/include/internal/siphash.h b/crypto/include/internal/siphash.h index e0868596..9573680f 100644 --- a/crypto/include/internal/siphash.h +++ b/crypto/include/internal/siphash.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * 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 @@ -18,7 +18,8 @@ typedef struct siphash_st SIPHASH; size_t SipHash_ctx_size(void); size_t SipHash_hash_size(SIPHASH *ctx); -int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int hash_size, +int SipHash_set_hash_size(SIPHASH *ctx, size_t hash_size); +int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int crounds, int drounds); void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen); int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen); diff --git a/crypto/include/internal/store_int.h b/crypto/include/internal/store_int.h index 0125aae0..6f31e019 100644 --- a/crypto/include/internal/store_int.h +++ b/crypto/include/internal/store_int.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * 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 diff --git a/crypto/include/internal/x509_int.h b/crypto/include/internal/x509_int.h index 1638de4c..b53c2b03 100644 --- a/crypto/include/internal/x509_int.h +++ b/crypto/include/internal/x509_int.h @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/crypto/lhash/lhash_lcl.h b/crypto/lhash/lhash_lcl.h index 8f792329..678224ac 100644 --- a/crypto/lhash/lhash_lcl.h +++ b/crypto/lhash/lhash_lcl.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/modes/asm/ghash-armv4.pl b/crypto/modes/asm/ghash-armv4.pl index 9d8c9883..dcc23f7d 100644 --- a/crypto/modes/asm/ghash-armv4.pl +++ b/crypto/modes/asm/ghash-armv4.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2010-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 diff --git a/crypto/modes/asm/ghash-parisc.pl b/crypto/modes/asm/ghash-parisc.pl index 654d9e9d..a614c99c 100644 --- a/crypto/modes/asm/ghash-parisc.pl +++ b/crypto/modes/asm/ghash-parisc.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2010-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 diff --git a/crypto/ocsp/ocsp_cl.c b/crypto/ocsp/ocsp_cl.c index 33ef9bbb..739ac018 100644 --- a/crypto/ocsp/ocsp_cl.c +++ b/crypto/ocsp/ocsp_cl.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-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 diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl index 0bde5ee7..f8380f2e 100755 --- a/crypto/perlasm/x86_64-xlate.pl +++ b/crypto/perlasm/x86_64-xlate.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2005-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 diff --git a/crypto/pkcs12/p12_asn.c b/crypto/pkcs12/p12_asn.c index 3ad86643..422dfc39 100644 --- a/crypto/pkcs12/p12_asn.c +++ b/crypto/pkcs12/p12_asn.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-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 diff --git a/crypto/pkcs12/p12_init.c b/crypto/pkcs12/p12_init.c index a78e183c..88db0f2d 100644 --- a/crypto/pkcs12/p12_init.c +++ b/crypto/pkcs12/p12_init.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 @@ -22,7 +22,8 @@ PKCS12 *PKCS12_init(int mode) PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); return NULL; } - ASN1_INTEGER_set(pkcs12->version, 3); + if (!ASN1_INTEGER_set(pkcs12->version, 3)) + goto err; pkcs12->authsafes->type = OBJ_nid2obj(mode); switch (mode) { case NID_pkcs7_data: diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 02e529c0..88d1d663 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 diff --git a/crypto/pkcs7/pk7_lib.c b/crypto/pkcs7/pk7_lib.c index ba4b5059..16b76431 100644 --- a/crypto/pkcs7/pk7_lib.c +++ b/crypto/pkcs7/pk7_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/poly1305/asm/poly1305-x86_64.pl b/crypto/poly1305/asm/poly1305-x86_64.pl index 88394b0a..342ad7f1 100755 --- a/crypto/poly1305/asm/poly1305-x86_64.pl +++ b/crypto/poly1305/asm/poly1305-x86_64.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2016-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 diff --git a/crypto/rc4/asm/rc4-parisc.pl b/crypto/rc4/asm/rc4-parisc.pl index b9927dad..4111f339 100644 --- a/crypto/rc4/asm/rc4-parisc.pl +++ b/crypto/rc4/asm/rc4-parisc.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2009-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 diff --git a/crypto/rsa/rsa_ossl.c b/crypto/rsa/rsa_ossl.c index e1e1c237..d581777e 100644 --- a/crypto/rsa/rsa_ossl.c +++ b/crypto/rsa/rsa_ossl.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/rsa/rsa_pk1.c b/crypto/rsa/rsa_pk1.c index a1134f1d..d07c0d6f 100644 --- a/crypto/rsa/rsa_pk1.c +++ b/crypto/rsa/rsa_pk1.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/rsa/rsa_pss.c b/crypto/rsa/rsa_pss.c index 26d5f36f..f7c575d0 100644 --- a/crypto/rsa/rsa_pss.c +++ b/crypto/rsa/rsa_pss.c @@ -244,7 +244,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, err: EVP_MD_CTX_free(ctx); - OPENSSL_clear_free(salt, sLen); + OPENSSL_clear_free(salt, (size_t)sLen); /* salt != NULL implies sLen > 0 */ return ret; diff --git a/crypto/rsa/rsa_ssl.c b/crypto/rsa/rsa_ssl.c index 97ae12df..286d0a42 100644 --- a/crypto/rsa/rsa_ssl.c +++ b/crypto/rsa/rsa_ssl.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-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 diff --git a/crypto/seed/seed_locl.h b/crypto/seed/seed_locl.h index 97c43ef6..ac2950d9 100644 --- a/crypto/seed/seed_locl.h +++ b/crypto/seed/seed_locl.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2007-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 diff --git a/crypto/sha/asm/keccak1600-s390x.pl b/crypto/sha/asm/keccak1600-s390x.pl index 58c44d8a..3bce19be 100755 --- a/crypto/sha/asm/keccak1600-s390x.pl +++ b/crypto/sha/asm/keccak1600-s390x.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. +# 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 diff --git a/crypto/sha/asm/sha1-parisc.pl b/crypto/sha/asm/sha1-parisc.pl index 88f4f2e4..b001be16 100644 --- a/crypto/sha/asm/sha1-parisc.pl +++ b/crypto/sha/asm/sha1-parisc.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2009-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 diff --git a/crypto/sha/asm/sha256-armv4.pl b/crypto/sha/asm/sha256-armv4.pl index 509aa2c5..edcfc312 100644 --- a/crypto/sha/asm/sha256-armv4.pl +++ b/crypto/sha/asm/sha256-armv4.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2007-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 diff --git a/crypto/sha/asm/sha512-armv4.pl b/crypto/sha/asm/sha512-armv4.pl index 872c27fb..0b4c5674 100644 --- a/crypto/sha/asm/sha512-armv4.pl +++ b/crypto/sha/asm/sha512-armv4.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2007-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 diff --git a/crypto/sha/asm/sha512-parisc.pl b/crypto/sha/asm/sha512-parisc.pl index d9933f0f..59eb320a 100755 --- a/crypto/sha/asm/sha512-parisc.pl +++ b/crypto/sha/asm/sha512-parisc.pl @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2009-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 diff --git a/crypto/siphash/siphash.c b/crypto/siphash/siphash.c index 72fd5198..ff84a29f 100644 --- a/crypto/siphash/siphash.c +++ b/crypto/siphash/siphash.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * 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 @@ -80,17 +80,32 @@ size_t SipHash_hash_size(SIPHASH *ctx) return ctx->hash_size; } +static size_t siphash_adjust_hash_size(size_t hash_size) +{ + if (hash_size == 0) + hash_size = SIPHASH_MAX_DIGEST_SIZE; + return hash_size; +} + +int SipHash_set_hash_size(SIPHASH *ctx, size_t hash_size) +{ + hash_size = siphash_adjust_hash_size(hash_size); + if (hash_size != SIPHASH_MIN_DIGEST_SIZE + && hash_size != SIPHASH_MAX_DIGEST_SIZE) + return 0; + + ctx->hash_size = hash_size; + return 1; +} + /* hash_size = crounds = drounds = 0 means SipHash24 with 16-byte output */ -int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int hash_size, int crounds, int drounds) +int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int crounds, int drounds) { uint64_t k0 = U8TO64_LE(k); uint64_t k1 = U8TO64_LE(k + 8); - if (hash_size == 0) - hash_size = SIPHASH_MAX_DIGEST_SIZE; - else if (hash_size != SIPHASH_MIN_DIGEST_SIZE && - hash_size != SIPHASH_MAX_DIGEST_SIZE) - return 0; + /* If the hash size wasn't set, i.e. is zero */ + ctx->hash_size = siphash_adjust_hash_size(ctx->hash_size); if (drounds == 0) drounds = SIPHASH_D_ROUNDS; @@ -99,7 +114,6 @@ int SipHash_Init(SIPHASH *ctx, const unsigned char *k, int hash_size, int cround ctx->crounds = crounds; ctx->drounds = drounds; - ctx->hash_size = hash_size; ctx->len = 0; ctx->total_inlen = 0; diff --git a/crypto/siphash/siphash_pmeth.c b/crypto/siphash/siphash_pmeth.c index a6352602..66e552fe 100644 --- a/crypto/siphash/siphash_pmeth.c +++ b/crypto/siphash/siphash_pmeth.c @@ -95,16 +95,13 @@ static int siphash_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) SIPHASH_PKEY_CTX *pctx = EVP_PKEY_CTX_get_data(ctx); const unsigned char* key; size_t len; - int hash_size; key = EVP_PKEY_get0_siphash(EVP_PKEY_CTX_get0_pkey(ctx), &len); if (key == NULL || len != SIPHASH_KEY_SIZE) return 0; EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT); EVP_MD_CTX_set_update_fn(mctx, int_update); - /* use default rounds (2,4) */ - hash_size = SipHash_hash_size(&pctx->ctx); - return SipHash_Init(&pctx->ctx, key, hash_size, 0, 0); + return SipHash_Init(&pctx->ctx, key, 0, 0); } static int siphash_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, EVP_MD_CTX *mctx) @@ -122,7 +119,6 @@ static int pkey_siphash_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) SIPHASH_PKEY_CTX *pctx = EVP_PKEY_CTX_get_data(ctx); const unsigned char *key; size_t len; - int hash_size; switch (type) { @@ -131,12 +127,7 @@ static int pkey_siphash_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) break; case EVP_PKEY_CTRL_SET_DIGEST_SIZE: - if (p1 != SIPHASH_MIN_DIGEST_SIZE && - p1 != SIPHASH_MAX_DIGEST_SIZE) { - return 0; - } - /* use default rounds (2,4) */ - return SipHash_Init(&pctx->ctx, ASN1_STRING_get0_data(&pctx->ktmp), p1, 0, 0); + return SipHash_set_hash_size(&pctx->ctx, p1); case EVP_PKEY_CTRL_SET_MAC_KEY: case EVP_PKEY_CTRL_DIGESTINIT: @@ -152,8 +143,8 @@ static int pkey_siphash_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) !ASN1_OCTET_STRING_set(&pctx->ktmp, key, len)) return 0; /* use default rounds (2,4) */ - hash_size = SipHash_hash_size(&pctx->ctx); - return SipHash_Init(&pctx->ctx, ASN1_STRING_get0_data(&pctx->ktmp), hash_size, 0, 0); + return SipHash_Init(&pctx->ctx, ASN1_STRING_get0_data(&pctx->ktmp), + 0, 0); default: return -2; @@ -167,6 +158,12 @@ static int pkey_siphash_ctrl_str(EVP_PKEY_CTX *ctx, { if (value == NULL) return 0; + if (strcmp(type, "digestsize") == 0) { + size_t hash_size = atoi(value); + + return pkey_siphash_ctrl(ctx, EVP_PKEY_CTRL_SET_DIGEST_SIZE, hash_size, + NULL); + } if (strcmp(type, "key") == 0) return EVP_PKEY_CTX_str2ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, value); if (strcmp(type, "hexkey") == 0) diff --git a/crypto/sm2/sm2_pmeth.c b/crypto/sm2/sm2_pmeth.c index 3e420658..d187699c 100644 --- a/crypto/sm2/sm2_pmeth.c +++ b/crypto/sm2/sm2_pmeth.c @@ -259,6 +259,7 @@ static int pkey_sm2_digest_custom(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) SM2_PKEY_CTX *smctx = ctx->data; EC_KEY *ec = ctx->pkey->pkey.ec; const EVP_MD *md = EVP_MD_CTX_md(mctx); + int mdlen = EVP_MD_size(md); if (!smctx->id_set) { /* @@ -270,11 +271,16 @@ static int pkey_sm2_digest_custom(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) return 0; } + if (mdlen < 0) { + SM2err(SM2_F_PKEY_SM2_DIGEST_CUSTOM, SM2_R_INVALID_DIGEST); + return 0; + } + /* get hashed prefix 'z' of tbs message */ if (!sm2_compute_z_digest(z, md, smctx->id, smctx->id_len, ec)) return 0; - return EVP_DigestUpdate(mctx, z, EVP_MD_size(md)); + return EVP_DigestUpdate(mctx, z, (size_t)mdlen); } const EVP_PKEY_METHOD sm2_pkey_meth = { diff --git a/crypto/uid.c b/crypto/uid.c index b2bfee32..f7ae2610 100644 --- a/crypto/uid.c +++ b/crypto/uid.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-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 diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c index d2b0a8af..d749af4d 100644 --- a/crypto/x509/x509_trs.c +++ b/crypto/x509/x509_trs.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index e11e51b6..97c1cbc2 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 diff --git a/crypto/x509v3/v3_tlsf.c b/crypto/x509v3/v3_tlsf.c index 61c16381..7fd6ef17 100644 --- a/crypto/x509v3/v3_tlsf.c +++ b/crypto/x509v3/v3_tlsf.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/doc/man1/crl.pod b/doc/man1/crl.pod index 29f46001..58f2bf62 100644 --- a/doc/man1/crl.pod +++ b/doc/man1/crl.pod @@ -133,7 +133,7 @@ L, L, L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/dsa.pod b/doc/man1/dsa.pod index a4dcc561..fb6cbf12 100644 --- a/doc/man1/dsa.pod +++ b/doc/man1/dsa.pod @@ -172,7 +172,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/gendsa.pod b/doc/man1/gendsa.pod index 1cbd3f47..b2580b4f 100644 --- a/doc/man1/gendsa.pod +++ b/doc/man1/gendsa.pod @@ -91,7 +91,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/genrsa.pod b/doc/man1/genrsa.pod index 638debaa..a9c994ff 100644 --- a/doc/man1/genrsa.pod +++ b/doc/man1/genrsa.pod @@ -118,7 +118,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/passwd.pod b/doc/man1/passwd.pod index bdfba2a0..c5760fe7 100644 --- a/doc/man1/passwd.pod +++ b/doc/man1/passwd.pod @@ -122,7 +122,7 @@ This can be used with a subsequent B<-rand> flag. =head1 COPYRIGHT -Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/pkcs8.pod b/doc/man1/pkcs8.pod index 65101150..9c923b87 100644 --- a/doc/man1/pkcs8.pod +++ b/doc/man1/pkcs8.pod @@ -309,7 +309,7 @@ The B<-iter> option was added to OpenSSL 1.1.0. =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/req.pod b/doc/man1/req.pod index 51f3ec44..113cd9b6 100644 --- a/doc/man1/req.pod +++ b/doc/man1/req.pod @@ -687,7 +687,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/rsa.pod b/doc/man1/rsa.pod index 0280d07d..14a8fb1e 100644 --- a/doc/man1/rsa.pod +++ b/doc/man1/rsa.pod @@ -210,7 +210,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/sess_id.pod b/doc/man1/sess_id.pod index 99aa8582..1f7a1e86 100644 --- a/doc/man1/sess_id.pod +++ b/doc/man1/sess_id.pod @@ -156,7 +156,7 @@ L, L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/speed.pod b/doc/man1/speed.pod index 523da0d3..16dc839e 100644 --- a/doc/man1/speed.pod +++ b/doc/man1/speed.pod @@ -12,6 +12,7 @@ B [B<-engine id>] [B<-elapsed>] [B<-evp algo>] +[B<-hmac algo>] [B<-decrypt>] [B<-rand file...>] [B<-writerand file>] @@ -55,6 +56,10 @@ If B is an AEAD cipher, then you can pass <-aead> to benchmark a TLS-like sequence. And if B is a multi-buffer capable cipher, e.g. aes-128-cbc-hmac-sha1, then B<-mb> will time multi-buffer operation. +=item B<-hmac digest> + +Time the HMAC algorithm using the specified message digest. + =item B<-decrypt> Time the decryption instead of encryption. Affects only the EVP testing. diff --git a/doc/man1/spkac.pod b/doc/man1/spkac.pod index 9ad03c12..655f1358 100644 --- a/doc/man1/spkac.pod +++ b/doc/man1/spkac.pod @@ -145,7 +145,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man1/ts.pod b/doc/man1/ts.pod index 3ec6e0d9..eeccaf67 100644 --- a/doc/man1/ts.pod +++ b/doc/man1/ts.pod @@ -664,7 +664,7 @@ L =head1 COPYRIGHT -Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2006-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 diff --git a/doc/man3/ASN1_INTEGER_get_int64.pod b/doc/man3/ASN1_INTEGER_get_int64.pod index 7ed1cca8..d0a6a3c8 100644 --- a/doc/man3/ASN1_INTEGER_get_int64.pod +++ b/doc/man3/ASN1_INTEGER_get_int64.pod @@ -123,7 +123,7 @@ were added to OpenSSL 1.1.0. =head1 COPYRIGHT -Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-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 diff --git a/doc/man3/BIO_s_file.pod b/doc/man3/BIO_s_file.pod index 3829112e..23cdc9b6 100644 --- a/doc/man3/BIO_s_file.pod +++ b/doc/man3/BIO_s_file.pod @@ -158,7 +158,7 @@ L, L =head1 COPYRIGHT -Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man3/BN_bn2bin.pod b/doc/man3/BN_bn2bin.pod index 5da1ffd1..b3cbc8cb 100644 --- a/doc/man3/BN_bn2bin.pod +++ b/doc/man3/BN_bn2bin.pod @@ -106,7 +106,7 @@ L =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man3/BN_generate_prime.pod b/doc/man3/BN_generate_prime.pod index ed17d3d3..b5058418 100644 --- a/doc/man3/BN_generate_prime.pod +++ b/doc/man3/BN_generate_prime.pod @@ -202,7 +202,7 @@ and BN_GENCB_get_arg() were added in OpenSSL 1.1.0 =head1 COPYRIGHT -Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man3/EC_GROUP_new.pod b/doc/man3/EC_GROUP_new.pod index 2a722cea..1eee4949 100644 --- a/doc/man3/EC_GROUP_new.pod +++ b/doc/man3/EC_GROUP_new.pod @@ -134,7 +134,7 @@ L, L =head1 COPYRIGHT -Copyright 2013-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2013-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 diff --git a/doc/man3/EVP_PKEY_get_default_digest_nid.pod b/doc/man3/EVP_PKEY_get_default_digest_nid.pod index 6113115a..da766770 100644 --- a/doc/man3/EVP_PKEY_get_default_digest_nid.pod +++ b/doc/man3/EVP_PKEY_get_default_digest_nid.pod @@ -41,7 +41,7 @@ This function was first added to OpenSSL 1.0.0. =head1 COPYRIGHT -Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2006-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 diff --git a/doc/man3/OCSP_resp_find_status.pod b/doc/man3/OCSP_resp_find_status.pod index 079e3a61..35f7d35e 100644 --- a/doc/man3/OCSP_resp_find_status.pod +++ b/doc/man3/OCSP_resp_find_status.pod @@ -189,7 +189,7 @@ L =head1 COPYRIGHT -Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-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 diff --git a/doc/man3/SSL_CTX_new.pod b/doc/man3/SSL_CTX_new.pod index 29be37b8..d0783415 100644 --- a/doc/man3/SSL_CTX_new.pod +++ b/doc/man3/SSL_CTX_new.pod @@ -209,7 +209,7 @@ L, L, L =head1 COPYRIGHT -Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man3/SSL_CTX_set0_CA_list.pod b/doc/man3/SSL_CTX_set0_CA_list.pod index 958d735e..618bd73e 100644 --- a/doc/man3/SSL_CTX_set0_CA_list.pod +++ b/doc/man3/SSL_CTX_set0_CA_list.pod @@ -82,7 +82,7 @@ L =head1 COPYRIGHT -Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. +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 diff --git a/doc/man3/SSL_CTX_set_mode.pod b/doc/man3/SSL_CTX_set_mode.pod index e6de1660..8f8edcf0 100644 --- a/doc/man3/SSL_CTX_set_mode.pod +++ b/doc/man3/SSL_CTX_set_mode.pod @@ -128,7 +128,7 @@ SSL_MODE_ASYNC was first added to OpenSSL 1.1.0. =head1 COPYRIGHT -Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2001-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 diff --git a/doc/man3/SSL_CTX_set_read_ahead.pod b/doc/man3/SSL_CTX_set_read_ahead.pod index f2731a0d..137e251b 100644 --- a/doc/man3/SSL_CTX_set_read_ahead.pod +++ b/doc/man3/SSL_CTX_set_read_ahead.pod @@ -64,7 +64,7 @@ L, L =head1 COPYRIGHT -Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-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 diff --git a/doc/man3/SSL_SESSION_get_protocol_version.pod b/doc/man3/SSL_SESSION_get_protocol_version.pod index 5d6bb32f..84c9ac17 100644 --- a/doc/man3/SSL_SESSION_get_protocol_version.pod +++ b/doc/man3/SSL_SESSION_get_protocol_version.pod @@ -46,7 +46,7 @@ SSL_SESSION_set_protocol_version() was first added to OpenSSL 1.1.1. =head1 COPYRIGHT -Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2001-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 diff --git a/doc/man3/SSL_check_chain.pod b/doc/man3/SSL_check_chain.pod index dd9db40c..4de36cc7 100644 --- a/doc/man3/SSL_check_chain.pod +++ b/doc/man3/SSL_check_chain.pod @@ -84,7 +84,7 @@ L =head1 COPYRIGHT -Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-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 diff --git a/doc/man3/SSL_get_peer_signature_nid.pod b/doc/man3/SSL_get_peer_signature_nid.pod index ac81b27f..ce6ab61f 100644 --- a/doc/man3/SSL_get_peer_signature_nid.pod +++ b/doc/man3/SSL_get_peer_signature_nid.pod @@ -37,7 +37,7 @@ L, L, =head1 COPYRIGHT -Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. +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 diff --git a/doc/man3/SSL_get_shared_sigalgs.pod b/doc/man3/SSL_get_shared_sigalgs.pod index 9de3f094..668a2a58 100644 --- a/doc/man3/SSL_get_shared_sigalgs.pod +++ b/doc/man3/SSL_get_shared_sigalgs.pod @@ -78,7 +78,7 @@ L =head1 COPYRIGHT -Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2015-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 diff --git a/doc/man3/SSL_in_init.pod b/doc/man3/SSL_in_init.pod index d8467a97..0760f7ec 100644 --- a/doc/man3/SSL_in_init.pod +++ b/doc/man3/SSL_in_init.pod @@ -100,7 +100,7 @@ L =head1 COPYRIGHT -Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. +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 diff --git a/doc/man3/SSL_read.pod b/doc/man3/SSL_read.pod index b1b20020..e671b8eb 100644 --- a/doc/man3/SSL_read.pod +++ b/doc/man3/SSL_read.pod @@ -142,7 +142,7 @@ L, L =head1 COPYRIGHT -Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man3/SSL_write.pod b/doc/man3/SSL_write.pod index d5284428..4dffd1fe 100644 --- a/doc/man3/SSL_write.pod +++ b/doc/man3/SSL_write.pod @@ -118,7 +118,7 @@ L, L =head1 COPYRIGHT -Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-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 diff --git a/doc/man3/X509_digest.pod b/doc/man3/X509_digest.pod index 36b89a66..9322c37d 100644 --- a/doc/man3/X509_digest.pod +++ b/doc/man3/X509_digest.pod @@ -57,7 +57,7 @@ L =head1 COPYRIGHT -Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. +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 diff --git a/engines/e_capi.c b/engines/e_capi.c index a7658922..37202b81 100644 --- a/engines/e_capi.c +++ b/engines/e_capi.c @@ -917,6 +917,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from, unsigned char *tmpbuf; CAPI_KEY *capi_key; CAPI_CTX *ctx; + DWORD flags = 0; DWORD dlen; if (flen <= 0) @@ -932,12 +933,23 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from, return -1; } - if (padding != RSA_PKCS1_PADDING) { - char errstr[10]; - BIO_snprintf(errstr, 10, "%d", padding); - CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, CAPI_R_UNSUPPORTED_PADDING); - ERR_add_error_data(2, "padding=", errstr); - return -1; + switch (padding) { + case RSA_PKCS1_PADDING: + /* Nothing to do */ + break; +#ifdef CRYPT_DECRYPT_RSA_NO_PADDING_CHECK + case RSA_NO_PADDING: + flags = CRYPT_DECRYPT_RSA_NO_PADDING_CHECK; + break; +#endif + default: + { + char errstr[10]; + BIO_snprintf(errstr, 10, "%d", padding); + CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, CAPI_R_UNSUPPORTED_PADDING); + ERR_add_error_data(2, "padding=", errstr); + return -1; + } } /* Create temp reverse order version of input */ @@ -950,14 +962,16 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from, /* Finally decrypt it */ dlen = flen; - if (!CryptDecrypt(capi_key->key, 0, TRUE, 0, tmpbuf, &dlen)) { + if (!CryptDecrypt(capi_key->key, 0, TRUE, flags, tmpbuf, &dlen)) { CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, CAPI_R_DECRYPT_ERROR); capi_addlasterror(); + OPENSSL_cleanse(tmpbuf, dlen); OPENSSL_free(tmpbuf); return -1; } else { memcpy(to, tmpbuf, (flen = (int)dlen)); } + OPENSSL_cleanse(tmpbuf, flen); OPENSSL_free(tmpbuf); return flen; diff --git a/engines/e_padlock.c b/engines/e_padlock.c index 43944abc..f6b1f169 100644 --- a/engines/e_padlock.c +++ b/engines/e_padlock.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2004-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 diff --git a/external/perl/transfer/Text/Template.pm b/external/perl/transfer/Text/Template.pm index fa2acc3f..b21f8753 100644 --- a/external/perl/transfer/Text/Template.pm +++ b/external/perl/transfer/Text/Template.pm @@ -1,4 +1,4 @@ -# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2016-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 diff --git a/fuzz/client.c b/fuzz/client.c index a262209c..7ce609ca 100644 --- a/fuzz/client.c +++ b/fuzz/client.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL licenses, (the "License"); * you may not use this file except in compliance with the License. diff --git a/fuzz/driver.c b/fuzz/driver.c index 928e0e14..54d67de2 100644 --- a/fuzz/driver.c +++ b/fuzz/driver.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL licenses, (the "License"); * you may not use this file except in compliance with the License. diff --git a/fuzz/server.c b/fuzz/server.c index db8c8b99..2d392ac8 100644 --- a/fuzz/server.c +++ b/fuzz/server.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL licenses, (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/internal/conf.h b/include/internal/conf.h index 23a9c3b4..dc1e7250 100644 --- a/include/internal/conf.h +++ b/include/internal/conf.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-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 diff --git a/include/internal/dso.h b/include/internal/dso.h index 3e67d505..eb5f7d53 100644 --- a/include/internal/dso.h +++ b/include/internal/dso.h @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-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 diff --git a/include/internal/o_dir.h b/include/internal/o_dir.h index f8926877..e7b55e0c 100644 --- a/include/internal/o_dir.h +++ b/include/internal/o_dir.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2004-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 diff --git a/include/openssl/opensslv.h b/include/openssl/opensslv.h index b866670e..f22601ad 100644 --- a/include/openssl/opensslv.h +++ b/include/openssl/opensslv.h @@ -39,8 +39,8 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x1010100aL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1-pre10-dev xx XXX xxxx" +# define OPENSSL_VERSION_NUMBER 0x10102000L +# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.2-dev xx XXX xxxx" /*- * The macros below are to be used for shared library (.so, .dll, ...) diff --git a/include/openssl/x509.h b/include/openssl/x509.h index 3a03562e..39ca0ba5 100644 --- a/include/openssl/x509.h +++ b/include/openssl/x509.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index fd32a640..860360b8 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/test/asn1_decode_test.c b/test/asn1_decode_test.c new file mode 100644 index 00000000..369023d5 --- /dev/null +++ b/test/asn1_decode_test.c @@ -0,0 +1,173 @@ +/* + * 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 + */ + +#include +#include + +#include +#include +#include "internal/numbers.h" +#include "testutil.h" + +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wunused-function" +#endif +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wunused-function" +#endif + +/* Badly coded ASN.1 INTEGER zero wrapped in a sequence */ +static unsigned char t_invalid_zero[] = { + 0x30, 0x02, /* SEQUENCE tag + length */ + 0x02, 0x00 /* INTEGER tag + length */ +}; + +#if OPENSSL_API_COMPAT < 0x10200000L +/* LONG case ************************************************************* */ + +typedef struct { + long test_long; +} ASN1_LONG_DATA; + +ASN1_SEQUENCE(ASN1_LONG_DATA) = { + ASN1_EMBED(ASN1_LONG_DATA, test_long, LONG), +} static_ASN1_SEQUENCE_END(ASN1_LONG_DATA) + +IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_LONG_DATA) +IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_LONG_DATA) + +static int test_long(void) +{ + const unsigned char *p = t_invalid_zero; + ASN1_LONG_DATA *dectst = + d2i_ASN1_LONG_DATA(NULL, &p, sizeof(t_invalid_zero)); + + if (dectst == NULL) + return 0; /* Fail */ + + ASN1_LONG_DATA_free(dectst); + return 1; +} +#endif + +/* INT32 case ************************************************************* */ + +typedef struct { + int32_t test_int32; +} ASN1_INT32_DATA; + +ASN1_SEQUENCE(ASN1_INT32_DATA) = { + ASN1_EMBED(ASN1_INT32_DATA, test_int32, INT32), +} static_ASN1_SEQUENCE_END(ASN1_INT32_DATA) + +IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT32_DATA) +IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT32_DATA) + +static int test_int32(void) +{ + const unsigned char *p = t_invalid_zero; + ASN1_INT32_DATA *dectst = + d2i_ASN1_INT32_DATA(NULL, &p, sizeof(t_invalid_zero)); + + if (dectst == NULL) + return 0; /* Fail */ + + ASN1_INT32_DATA_free(dectst); + return 1; +} + +/* UINT32 case ************************************************************* */ + +typedef struct { + uint32_t test_uint32; +} ASN1_UINT32_DATA; + +ASN1_SEQUENCE(ASN1_UINT32_DATA) = { + ASN1_EMBED(ASN1_UINT32_DATA, test_uint32, UINT32), +} static_ASN1_SEQUENCE_END(ASN1_UINT32_DATA) + +IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT32_DATA) +IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT32_DATA) + +static int test_uint32(void) +{ + const unsigned char *p = t_invalid_zero; + ASN1_UINT32_DATA *dectst = + d2i_ASN1_UINT32_DATA(NULL, &p, sizeof(t_invalid_zero)); + + if (dectst == NULL) + return 0; /* Fail */ + + ASN1_UINT32_DATA_free(dectst); + return 1; +} + +/* INT64 case ************************************************************* */ + +typedef struct { + int64_t test_int64; +} ASN1_INT64_DATA; + +ASN1_SEQUENCE(ASN1_INT64_DATA) = { + ASN1_EMBED(ASN1_INT64_DATA, test_int64, INT64), +} static_ASN1_SEQUENCE_END(ASN1_INT64_DATA) + +IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_INT64_DATA) +IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_INT64_DATA) + +static int test_int64(void) +{ + const unsigned char *p = t_invalid_zero; + ASN1_INT64_DATA *dectst = + d2i_ASN1_INT64_DATA(NULL, &p, sizeof(t_invalid_zero)); + + if (dectst == NULL) + return 0; /* Fail */ + + ASN1_INT64_DATA_free(dectst); + return 1; +} + +/* UINT64 case ************************************************************* */ + +typedef struct { + uint64_t test_uint64; +} ASN1_UINT64_DATA; + +ASN1_SEQUENCE(ASN1_UINT64_DATA) = { + ASN1_EMBED(ASN1_UINT64_DATA, test_uint64, UINT64), +} static_ASN1_SEQUENCE_END(ASN1_UINT64_DATA) + +IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(ASN1_UINT64_DATA) +IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(ASN1_UINT64_DATA) + +static int test_uint64(void) +{ + const unsigned char *p = t_invalid_zero; + ASN1_UINT64_DATA *dectst = + d2i_ASN1_UINT64_DATA(NULL, &p, sizeof(t_invalid_zero)); + + if (dectst == NULL) + return 0; /* Fail */ + + ASN1_UINT64_DATA_free(dectst); + return 1; +} + +int setup_tests(void) +{ +#if OPENSSL_API_COMPAT < 0x10200000L + ADD_TEST(test_long); +#endif + ADD_TEST(test_int32); + ADD_TEST(test_uint32); + ADD_TEST(test_int64); + ADD_TEST(test_uint64); + return 1; +} diff --git a/test/asn1_internal_test.c b/test/asn1_internal_test.c index 38313d58..63278040 100644 --- a/test/asn1_internal_test.c +++ b/test/asn1_internal_test.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-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 diff --git a/test/build.info b/test/build.info index 2c02ecc0..08657c80 100644 --- a/test/build.info +++ b/test/build.info @@ -44,7 +44,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN bio_callback_test \ bioprinttest sslapitest dtlstest sslcorrupttest bio_enc_test \ pkey_meth_test pkey_meth_kdf_test uitest cipherbytes_test \ - asn1_encode_test asn1_string_table_test \ + asn1_encode_test asn1_decode_test asn1_string_table_test \ x509_time_test x509_dup_cert_test x509_check_cert_pkey_test \ recordlentest drbgtest sslbuffertest \ recordlentest drbgtest drbg_cavs_test sslbuffertest \ @@ -410,6 +410,10 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN INCLUDE[asn1_encode_test]=../include DEPEND[asn1_encode_test]=../libcrypto libtestutil.a + SOURCE[asn1_decode_test]=asn1_decode_test.c + INCLUDE[asn1_decode_test]=../include + DEPEND[asn1_decode_test]=../libcrypto libtestutil.a + SOURCE[asn1_string_table_test]=asn1_string_table_test.c INCLUDE[asn1_string_table_test]=../include DEPEND[asn1_string_table_test]=../libcrypto libtestutil.a diff --git a/test/dhtest.c b/test/dhtest.c index 956d081f..5b2fd679 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -26,10 +26,10 @@ static int cb(int p, int n, BN_GENCB *arg); static int dh_test(void) { - DH *dh; - BIGNUM *p, *q, *g; + DH *dh = NULL; + BIGNUM *p = NULL, *q = NULL, *g = NULL; const BIGNUM *p2, *q2, *g2; - BIGNUM *priv_key; + BIGNUM *priv_key = NULL; const BIGNUM *pub_key2, *priv_key2; BN_GENCB *_cb = NULL; DH *a = NULL; @@ -49,7 +49,7 @@ static int dh_test(void) || !TEST_ptr(q = BN_new()) || !TEST_ptr(g = BN_new()) || !TEST_ptr(priv_key = BN_new())) - goto err; + goto err1; /* * I) basic tests @@ -60,40 +60,40 @@ static int dh_test(void) || !TEST_true(BN_set_word(q, 2039L)) || !TEST_true(BN_set_word(g, 3L)) || !TEST_true(DH_set0_pqg(dh, p, q, g))) - goto err; + goto err1; /* test the combined getter for p, q, and g */ DH_get0_pqg(dh, &p2, &q2, &g2); if (!TEST_ptr_eq(p2, p) || !TEST_ptr_eq(q2, q) || !TEST_ptr_eq(g2, g)) - goto err; + goto err2; /* test the simple getters for p, q, and g */ if (!TEST_ptr_eq(DH_get0_p(dh), p2) || !TEST_ptr_eq(DH_get0_q(dh), q2) || !TEST_ptr_eq(DH_get0_g(dh), g2)) - goto err; + goto err2; /* set the private key only*/ if (!TEST_true(BN_set_word(priv_key, 1234L)) || !TEST_true(DH_set0_key(dh, NULL, priv_key))) - goto err; + goto err2; /* test the combined getter for pub_key and priv_key */ DH_get0_key(dh, &pub_key2, &priv_key2); if (!TEST_ptr_eq(pub_key2, NULL) || !TEST_ptr_eq(priv_key2, priv_key)) - goto err; + goto err3; /* test the simple getters for pub_key and priv_key */ if (!TEST_ptr_eq(DH_get0_pub_key(dh), pub_key2) || !TEST_ptr_eq(DH_get0_priv_key(dh), priv_key2)) - goto err; + goto err3; /* now generate a key pair ... */ if (!DH_generate_key(dh)) - goto err; + goto err3; /* ... and check whether the private key was reused: */ @@ -101,14 +101,14 @@ static int dh_test(void) DH_get0_key(dh, &pub_key2, &priv_key2); if (!TEST_ptr(pub_key2) || !TEST_ptr_eq(priv_key2, priv_key)) - goto err; + goto err3; /* test it the simple getters for pub_key and priv_key */ if (!TEST_ptr_eq(DH_get0_pub_key(dh), pub_key2) || !TEST_ptr_eq(DH_get0_priv_key(dh), priv_key2)) - goto err; + goto err3; - /* check whether the public key was calculated correclty */ + /* check whether the public key was calculated correctly */ TEST_uint_eq(BN_get_word(pub_key2), 3331L); /* @@ -117,32 +117,32 @@ static int dh_test(void) /* generate a DH group ... */ if (!TEST_ptr(_cb = BN_GENCB_new())) - goto err; + goto err3; BN_GENCB_set(_cb, &cb, NULL); if (!TEST_ptr(a = DH_new()) || !TEST_true(DH_generate_parameters_ex(a, 64, DH_GENERATOR_5, _cb))) - goto err; + goto err3; /* ... and check whether it is valid */ if (!DH_check(a, &i)) - goto err; + goto err3; if (!TEST_false(i & DH_CHECK_P_NOT_PRIME) || !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME) || !TEST_false(i & DH_UNABLE_TO_CHECK_GENERATOR) || !TEST_false(i & DH_NOT_SUITABLE_GENERATOR)) - goto err; + goto err3; DH_get0_pqg(a, &ap, NULL, &ag); /* now create another copy of the DH group for the peer */ if (!TEST_ptr(b = DH_new())) - goto err; + goto err3; if (!TEST_ptr(bp = BN_dup(ap)) || !TEST_ptr(bg = BN_dup(ag)) || !TEST_true(DH_set0_pqg(b, bp, NULL, bg))) - goto err; + goto err3; bp = bg = NULL; /* @@ -150,43 +150,53 @@ static int dh_test(void) */ if (!DH_generate_key(a)) - goto err; + goto err3; DH_get0_key(a, &apub_key, NULL); if (!DH_generate_key(b)) - goto err; + goto err3; DH_get0_key(b, &bpub_key, &bpriv_key); /* Also test with a private-key-only copy of |b|. */ if (!TEST_ptr(c = DHparams_dup(b)) || !TEST_ptr(cpriv_key = BN_dup(bpriv_key)) || !TEST_true(DH_set0_key(c, NULL, cpriv_key))) - goto err; + goto err3; cpriv_key = NULL; alen = DH_size(a); if (!TEST_ptr(abuf = OPENSSL_malloc(alen)) || !TEST_true((aout = DH_compute_key(abuf, bpub_key, a)) != -1)) - goto err; + goto err3; blen = DH_size(b); if (!TEST_ptr(bbuf = OPENSSL_malloc(blen)) || !TEST_true((bout = DH_compute_key(bbuf, apub_key, b)) != -1)) - goto err; + goto err3; clen = DH_size(c); if (!TEST_ptr(cbuf = OPENSSL_malloc(clen)) || !TEST_true((cout = DH_compute_key(cbuf, apub_key, c)) != -1)) - goto err; + goto err3; if (!TEST_true(aout >= 4) || !TEST_mem_eq(abuf, aout, bbuf, bout) || !TEST_mem_eq(abuf, aout, cbuf, cout)) - goto err; + goto err3; ret = 1; + goto success; - err: + err1: + /* an error occurred before p,q,g were assigned to dh */ + BN_free(p); + BN_free(q); + BN_free(g); + err2: + /* an error occured before priv_key was assigned to dh */ + BN_free(priv_key); + err3: + success: OPENSSL_free(abuf); OPENSSL_free(bbuf); OPENSSL_free(cbuf); diff --git a/test/ecstresstest.c b/test/ecstresstest.c index fce64e6b..4f05d237 100644 --- a/test/ecstresstest.c +++ b/test/ecstresstest.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL licenses, (the "License"); * you may not use this file except in compliance with the License. diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index f0b0040e..7b847eed 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -855,27 +855,32 @@ static int test_EVP_PKEY_check(int i) p = input; - if (type == 0 && - (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len)) - || !TEST_ptr_eq(p, input + input_len) - || !TEST_int_eq(EVP_PKEY_id(pkey), expected_id))) - goto done; - + switch (type) { + case 0: + if (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len)) + || !TEST_ptr_eq(p, input + input_len) + || !TEST_int_eq(EVP_PKEY_id(pkey), expected_id)) + goto done; + break; #ifndef OPENSSL_NO_EC - if (type == 1 && - (!TEST_ptr(pubkey = BIO_new_mem_buf(input, input_len)) - || !TEST_ptr(eckey = d2i_EC_PUBKEY_bio(pubkey, NULL)) - || !TEST_ptr(pkey = EVP_PKEY_new()) - || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))) - goto done; - - if (type == 2 && - (!TEST_ptr(eckey = d2i_ECParameters(NULL, &p, input_len)) - || !TEST_ptr_eq(p, input + input_len) - || !TEST_ptr(pkey = EVP_PKEY_new()) - || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))) - goto done; + case 1: + if (!TEST_ptr(pubkey = BIO_new_mem_buf(input, input_len)) + || !TEST_ptr(eckey = d2i_EC_PUBKEY_bio(pubkey, NULL)) + || !TEST_ptr(pkey = EVP_PKEY_new()) + || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey))) + goto done; + break; + case 2: + if (!TEST_ptr(eckey = d2i_ECParameters(NULL, &p, input_len)) + || !TEST_ptr_eq(p, input + input_len) + || !TEST_ptr(pkey = EVP_PKEY_new()) + || !TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey))) + goto done; + break; #endif + default: + return 0; + } if (!TEST_ptr(ctx = EVP_PKEY_CTX_new(pkey, NULL))) goto done; diff --git a/test/evp_test.c b/test/evp_test.c index 5391563a..98301e65 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -73,6 +73,8 @@ static KEY_LIST *public_keys; static int find_key(EVP_PKEY **ppk, const char *name, KEY_LIST *lst); static int parse_bin(const char *value, unsigned char **buf, size_t *buflen); +static int pkey_test_ctrl(EVP_TEST *t, EVP_PKEY_CTX *pctx, + const char *value); /* * Compare two memory regions for equality, returning zero if they differ. @@ -843,6 +845,8 @@ typedef struct mac_data_st { /* Expected output */ unsigned char *output; size_t output_len; + /* Collection of controls */ + STACK_OF(OPENSSL_STRING) *controls; } MAC_DATA; static int mac_test_init(EVP_TEST *t, const char *alg) @@ -878,14 +882,22 @@ static int mac_test_init(EVP_TEST *t, const char *alg) mdat = OPENSSL_zalloc(sizeof(*mdat)); mdat->type = type; + mdat->controls = sk_OPENSSL_STRING_new_null(); t->data = mdat; return 1; } +/* Because OPENSSL_free is a macro, it can't be passed as a function pointer */ +static void openssl_free(char *m) +{ + OPENSSL_free(m); +} + static void mac_test_cleanup(EVP_TEST *t) { MAC_DATA *mdat = t->data; + sk_OPENSSL_STRING_pop_free(mdat->controls, openssl_free); OPENSSL_free(mdat->alg); OPENSSL_free(mdat->key); OPENSSL_free(mdat->input); @@ -909,6 +921,9 @@ static int mac_test_parse(EVP_TEST *t, return parse_bin(value, &mdata->input, &mdata->input_len); if (strcmp(keyword, "Output") == 0) return parse_bin(value, &mdata->output, &mdata->output_len); + if (strcmp(keyword, "Ctrl") == 0) + return sk_OPENSSL_STRING_push(mdata->controls, + OPENSSL_strdup(value)) != 0; return 0; } @@ -921,6 +936,7 @@ static int mac_test_run(EVP_TEST *t) const EVP_MD *md = NULL; unsigned char *got = NULL; size_t got_len; + int i; #ifdef OPENSSL_NO_DES if (expected->alg != NULL && strstr(expected->alg, "DES") != NULL) { @@ -955,7 +971,12 @@ static int mac_test_run(EVP_TEST *t) t->err = "DIGESTSIGNINIT_ERROR"; goto err; } - + for (i = 0; i < sk_OPENSSL_STRING_num(expected->controls); i++) + if (!pkey_test_ctrl(t, pctx, + sk_OPENSSL_STRING_value(expected->controls, i))) { + t->err = "EVPPKEYCTXCTRL_ERROR"; + goto err; + } if (!EVP_DigestSignUpdate(mctx, expected->input, expected->input_len)) { t->err = "DIGESTSIGNUPDATE_ERROR"; goto err; diff --git a/test/pemtest.c b/test/pemtest.c index 7f40ea37..3203d976 100644 --- a/test/pemtest.c +++ b/test/pemtest.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * 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 diff --git a/test/recipes/04-test_asn1_decode.t b/test/recipes/04-test_asn1_decode.t new file mode 100644 index 00000000..4a12b765 --- /dev/null +++ b/test/recipes/04-test_asn1_decode.t @@ -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_asn1_decode", "asn1_decode_test"); diff --git a/test/recipes/15-test_dsa.t b/test/recipes/15-test_dsa.t index c8f61cca..6ef06af1 100644 --- a/test/recipes/15-test_dsa.t +++ b/test/recipes/15-test_dsa.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-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 diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t index b6d23354..17a98dc9 100644 --- a/test/recipes/25-test_req.t +++ b/test/recipes/25-test_req.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-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 diff --git a/test/recipes/30-test_evp.t b/test/recipes/30-test_evp.t index d8e11e25..da0eadad 100644 --- a/test/recipes/30-test_evp.t +++ b/test/recipes/30-test_evp.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2015-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 diff --git a/test/recipes/30-test_evp_data/evpciph.txt b/test/recipes/30-test_evp_data/evpciph.txt index 422d8b35..d1086b72 100644 --- a/test/recipes/30-test_evp_data/evpciph.txt +++ b/test/recipes/30-test_evp_data/evpciph.txt @@ -1,5 +1,5 @@ # -# Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2001-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 @@ -1184,6 +1184,7 @@ Key = 0000000000000000000000000000000000000000000000000000000000000000 IV = 00000000000000000000000000000000 Plaintext = 0000000000000000000000000000000000000000000000000000000000000000 Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e +Result = CIPHERUPDATE_ERROR Cipher = aes-128-xts Key = 1111111111111111111111111111111122222222222222222222222222222222 diff --git a/test/recipes/30-test_evp_data/evpmac.txt b/test/recipes/30-test_evp_data/evpmac.txt index 9de8be1a..6864070b 100644 --- a/test/recipes/30-test_evp_data/evpmac.txt +++ b/test/recipes/30-test_evp_data/evpmac.txt @@ -1,5 +1,5 @@ # -# Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2001-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 @@ -128,6 +128,38 @@ Key = 000102030405060708090A0B0C0D0E0F Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E Output = 5150d1772f50834a503e069a973fbd7c +# SIPHASH - default values: 2,4 rounds, explicit 8-byte mac + +MAC = SipHash +Ctrl = digestsize:8 +Key = 000102030405060708090A0B0C0D0E0F +Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E +Output = B96AB0B9D449A78A + +# SIPHASH - default values: 2,4 rounds, explicit 16-byte mac + +MAC = SipHash +Ctrl = digestsize:16 +Key = 000102030405060708090A0B0C0D0E0F +Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E +Output = 5150d1772f50834a503e069a973fbd7c + +# SIPHASH - default values: 2,4 rounds, explicit 16-byte mac (set as 0) + +MAC = SipHash +Ctrl = digestsize:0 +Key = 000102030405060708090A0B0C0D0E0F +Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E +Output = 5150d1772f50834a503e069a973fbd7c + +# SIPHASH - default values: 2,4 rounds, explicit 13-byte mac (invalid size) + +MAC = SipHash +Ctrl = digestsize:13 +Key = 000102030405060708090A0B0C0D0E0F +Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E +Output = 5150d1772f50834a503e069a973fbd7c + Title = HMAC tests (from RFC2104 and others) MAC = HMAC diff --git a/test/recipes/70-test_servername.t b/test/recipes/70-test_servername.t index e6448aa8..2eff92aa 100644 --- a/test/recipes/70-test_servername.t +++ b/test/recipes/70-test_servername.t @@ -1,5 +1,5 @@ #! /usr/bin/env perl -# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. # Copyright 2017 BaishanCloud. All rights reserved. # # Licensed under the OpenSSL license (the "License"). You may not use diff --git a/test/sanitytest.c b/test/sanitytest.c index 0aaf3f45..204c01c2 100644 --- a/test/sanitytest.c +++ b/test/sanitytest.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/test/secmemtest.c b/test/secmemtest.c index 2795abb5..37c4b8f9 100644 --- a/test/secmemtest.c +++ b/test/secmemtest.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-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 diff --git a/test/servername_test.c b/test/servername_test.c index 6272baec..1a73bf00 100644 --- a/test/servername_test.c +++ b/test/servername_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright 2017 BaishanCloud. All rights reserved. * * Licensed under the OpenSSL license (the "License"). You may not use diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index 573c15d2..dfdce48d 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -196,7 +196,8 @@ static int test_siphash(int idx) for (i = 0; i < inlen; i++) in[i] = (unsigned char)i; - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, inlen); if (!TEST_true(SipHash_Final(&siphash, out, expectedlen)) @@ -204,7 +205,8 @@ static int test_siphash(int idx) return 0; if (inlen > 16) { - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, 1); SipHash_Update(&siphash, in+1, inlen-1); @@ -220,7 +222,8 @@ static int test_siphash(int idx) if (inlen > 32) { size_t half = inlen / 2; - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, half); SipHash_Update(&siphash, in+half, inlen-half); @@ -233,7 +236,8 @@ static int test_siphash(int idx) } for (half = 16; half < inlen; half += 16) { - if (!TEST_true(SipHash_Init(&siphash, key, expectedlen, 0, 0))) + if (!TEST_true(SipHash_set_hash_size(&siphash, expectedlen)) + || !TEST_true(SipHash_Init(&siphash, key, 0, 0))) return 0; SipHash_Update(&siphash, in, half); SipHash_Update(&siphash, in+half, inlen-half); @@ -258,19 +262,22 @@ static int test_siphash_basic(void) unsigned char output[SIPHASH_MAX_DIGEST_SIZE]; /* Use invalid hash size */ - return TEST_int_eq(SipHash_Init(&siphash, key, 4, 0, 0), 0) + return TEST_int_eq(SipHash_set_hash_size(&siphash, 4), 0) /* Use hash size = 8 */ - && TEST_true(SipHash_Init(&siphash, key, 8, 0, 0)) + && TEST_true(SipHash_set_hash_size(&siphash, 8)) + && TEST_true(SipHash_Init(&siphash, key, 0, 0)) && TEST_true(SipHash_Final(&siphash, output, 8)) && TEST_int_eq(SipHash_Final(&siphash, output, 16), 0) /* Use hash size = 16 */ - && TEST_true(SipHash_Init(&siphash, key, 16, 0, 0)) + && TEST_true(SipHash_set_hash_size(&siphash, 16)) + && TEST_true(SipHash_Init(&siphash, key, 0, 0)) && TEST_int_eq(SipHash_Final(&siphash, output, 8), 0) && TEST_true(SipHash_Final(&siphash, output, 16)) /* Use hash size = 0 (default = 16) */ - && TEST_true(SipHash_Init(&siphash, key, 0, 0, 0)) + && TEST_true(SipHash_set_hash_size(&siphash, 0)) + && TEST_true(SipHash_Init(&siphash, key, 0, 0)) && TEST_int_eq(SipHash_Final(&siphash, output, 8), 0) && TEST_true(SipHash_Final(&siphash, output, 16)); } diff --git a/test/testutil/driver.c b/test/testutil/driver.c index 09907347..6e9914c4 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-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 diff --git a/util/perl/TLSProxy/ServerHello.pm b/util/perl/TLSProxy/ServerHello.pm index 232c778b..84f2faab 100644 --- a/util/perl/TLSProxy/ServerHello.pm +++ b/util/perl/TLSProxy/ServerHello.pm @@ -1,4 +1,4 @@ -# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2016-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 diff --git a/util/perl/with_fallback.pm b/util/perl/with_fallback.pm index fc5638dd..24236503 100644 --- a/util/perl/with_fallback.pm +++ b/util/perl/with_fallback.pm @@ -1,4 +1,4 @@ -# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright 2016-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