From matt at openssl.org Thu Oct 1 10:21:29 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 01 Oct 2015 10:21:29 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1443694889.518093.28325.nullmailer@dev.openssl.org> The branch master has been updated via 3aabc1dd1c969e60bdea8f827d6645ff04c56b67 (commit) from 721c2ac0f427da7ac3c96c8996c8d4b7aeaa9912 (commit) - Log ----------------------------------------------------------------- commit 3aabc1dd1c969e60bdea8f827d6645ff04c56b67 Author: Dmitry Belyavskiy Date: Wed Sep 30 22:42:57 2015 +0300 Custom cipher constants Add some custom ctrls for Engine specific use. Reviewed-by: Tim Hudson Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: include/openssl/evp.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/openssl/evp.h b/include/openssl/evp.h index c60d178..02a6f98 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -427,6 +427,18 @@ struct evp_cipher_st { # define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b # define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c +/* For engine-specific control values */ +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM0 0x1000 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM1 0x1001 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM2 0x1002 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM3 0x1003 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM4 0x1004 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM5 0x1005 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM6 0x1006 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM7 0x1007 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM8 0x1008 +# define EVP_CTRL_ENGINE_CIPHER_CUSTOM9 0x1009 + /* RFC 5246 defines additional data to be 13 bytes in length */ # define EVP_AEAD_TLS1_AAD_LEN 13 From matt at openssl.org Thu Oct 1 12:54:14 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 01 Oct 2015 12:54:14 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1443704054.565128.18960.nullmailer@dev.openssl.org> The branch master has been updated via 57e4e926da904677be06d29c4c756303be8293b0 (commit) from 3aabc1dd1c969e60bdea8f827d6645ff04c56b67 (commit) - Log ----------------------------------------------------------------- commit 57e4e926da904677be06d29c4c756303be8293b0 Author: Matt Caswell Date: Thu Oct 1 13:51:31 2015 +0100 Revert "Custom cipher constants" This reverts commit 3aabc1dd1c969e60bdea8f827d6645ff04c56b67. Reviewed-by: Stephen Henson ----------------------------------------------------------------------- Summary of changes: include/openssl/evp.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 02a6f98..c60d178 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -427,18 +427,6 @@ struct evp_cipher_st { # define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b # define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c -/* For engine-specific control values */ -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM0 0x1000 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM1 0x1001 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM2 0x1002 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM3 0x1003 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM4 0x1004 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM5 0x1005 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM6 0x1006 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM7 0x1007 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM8 0x1008 -# define EVP_CTRL_ENGINE_CIPHER_CUSTOM9 0x1009 - /* RFC 5246 defines additional data to be 13 bytes in length */ # define EVP_AEAD_TLS1_AAD_LEN 13 From steve at openssl.org Fri Oct 2 13:08:21 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Fri, 02 Oct 2015 13:08:21 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1443791301.273518.30066.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 978c8aa8b79692d193437d28e2485ec5ffa9d6cc (commit) from 72ac982306be9c9ad5f355dba725ab3d0716879e (commit) - Log ----------------------------------------------------------------- commit 978c8aa8b79692d193437d28e2485ec5ffa9d6cc Author: Dr. Stephen Henson Date: Mon Sep 28 14:14:10 2015 +0100 Link in applink with fips_premain_dso PR#4042 Reviewed-by: Tim Hudson (cherry picked from commit d62c64b947ae96463a331de005165c57966d2149) ----------------------------------------------------------------------- Summary of changes: util/pl/VC-32.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index b597998..e5abb97 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -342,15 +342,17 @@ sub do_link_rule local($ret,$_); $file =~ s/\//$o/g if $o ne '/'; $n=&bname($target); - $ret.="$target: $files $dep_libs\n"; + $ret.="$target: $files $dep_libs"; if ($standalone == 1) { + $ret.=" \$(OBJ_D)${o}applink.obj\n"; $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t"; - $ret.= "\$(EX_LIBS) " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild); + $ret.= "\$(EX_LIBS) \$(OBJ_D)${o}applink.obj " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild); $ret.="$files $libs\n<<\n"; } elsif ($standalone == 2) { + $ret.="\n"; $ret.="\tSET FIPS_LINK=\$(LINK)\n"; $ret.="\tSET FIPS_CC=\$(CC)\n"; $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n"; @@ -363,6 +365,7 @@ sub do_link_rule } else { + $ret.="\n"; $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n"; $ret.="\t\$(APP_EX_OBJ) $files $libs\n<<\n"; } From rsalz at openssl.org Fri Oct 2 17:19:00 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 02 Oct 2015 17:19:00 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1443806340.288404.13424.nullmailer@dev.openssl.org> The branch master has been updated via 31c90887bde9d215de74bf985b244cde01bf4a67 (commit) from 4acfb10ce3070f11e871ae4b0fe6549de044dda8 (commit) - Log ----------------------------------------------------------------- commit 31c90887bde9d215de74bf985b244cde01bf4a67 Author: Rich Salz Date: Fri Oct 2 13:18:54 2015 -0400 Founders in emphasis ----------------------------------------------------------------------- Summary of changes: community/team.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/community/team.html b/community/team.html index 672e19c..50de030 100644 --- a/community/team.html +++ b/community/team.html @@ -38,7 +38,7 @@ - Mark J. Cox + Mark J. Cox mark at openssl.org UK - Dr. Stephen Henson + Dr. Stephen Henson steve at openssl.org UK - Ben Laurie/ + Ben Laurie/ ben at openssl.org UK 0833F510E18C1C32 - Names in bold are founding members of the OpenSSL projects. + Names in emphasis are founding members of the OpenSSL projects.

 

In addition, we gratefully acknowledge the contributions of the - following alumni: Ralf S. Engelschall, + following alumni: Ralf S. Engelschall, Nils Larsch, Holger Reif, and Paul C. Sutton. We also respectfully remember Ulf Möller who is no longer with us. From rsalz at openssl.org Fri Oct 2 17:19:49 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 02 Oct 2015 17:19:49 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1443806389.697593.13829.nullmailer@dev.openssl.org> The branch master has been updated via 864413760070cc458f6987c6e7e1b9aef7a867c2 (commit) from 31c90887bde9d215de74bf985b244cde01bf4a67 (commit) - Log ----------------------------------------------------------------- commit 864413760070cc458f6987c6e7e1b9aef7a867c2 Author: Rich Salz Date: Fri Oct 2 13:19:46 2015 -0400 fix typo on Ben's name ----------------------------------------------------------------------- Summary of changes: community/team.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community/team.html b/community/team.html index 50de030..fd9c256 100644 --- a/community/team.html +++ b/community/team.html @@ -84,7 +84,7 @@ - Ben Laurie/ + Ben Laurie ben at openssl.org UK The branch master has been updated via ae0c77a9cfe1b81963bf6beab37b96af5a4d807b (commit) from 864413760070cc458f6987c6e7e1b9aef7a867c2 (commit) - Log ----------------------------------------------------------------- commit ae0c77a9cfe1b81963bf6beab37b96af5a4d807b Author: Rich Salz Date: Fri Oct 2 13:23:46 2015 -0400 It's italics, not emphasis; add spacing ----------------------------------------------------------------------- Summary of changes: community/team.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/community/team.html b/community/team.html index fd9c256..c3d3d64 100644 --- a/community/team.html +++ b/community/team.html @@ -93,7 +93,8 @@ Steve Marquess - marquess at openssl.org + marquess at openssl.org   US CE1AE41903B0216376DCC2357E5776CE7D86D554 @@ -147,7 +148,7 @@ href="http://pool.sks-keyservers.net:11371/pks/lookup?op=get&search=0x1B3DF808C221D2A5ED74172F0833F510E18C1C32">0833F510E18C1C32 - Names in emphasis are founding members of the OpenSSL projects. + Names in italics are founding members of the OpenSSL projects.

 

From rsalz at openssl.org Fri Oct 2 18:22:14 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 02 Oct 2015 18:22:14 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1443810134.610793.31748.nullmailer@dev.openssl.org> The branch master has been updated via 9982cbbbf65473418661f5aa1f05e7ef88ada801 (commit) from 57e4e926da904677be06d29c4c756303be8293b0 (commit) - Log ----------------------------------------------------------------- commit 9982cbbbf65473418661f5aa1f05e7ef88ada801 Author: Rich Salz Date: Wed Sep 30 14:32:49 2015 -0400 Remove BIO_s_file_internal macro. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: crypto/x509/by_file.c | 4 ++-- include/openssl/bio.h | 1 - ssl/ssl_cert.c | 4 ++-- ssl/ssl_conf.c | 2 +- ssl/ssl_rsa.c | 16 ++++++++-------- ssl/ssl_txt.c | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c index 7983b15..8a156c7 100644 --- a/crypto/x509/by_file.c +++ b/crypto/x509/by_file.c @@ -129,7 +129,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) if (file == NULL) return (1); - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509err(X509_F_X509_LOAD_CERT_FILE, ERR_R_SYS_LIB); @@ -186,7 +186,7 @@ int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) if (file == NULL) return (1); - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509err(X509_F_X509_LOAD_CRL_FILE, ERR_R_SYS_LIB); diff --git a/include/openssl/bio.h b/include/openssl/bio.h index 0577bd8..f0fbc5b 100644 --- a/include/openssl/bio.h +++ b/include/openssl/bio.h @@ -635,7 +635,6 @@ int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, BIO_METHOD *BIO_s_file(void); BIO *BIO_new_file(const char *filename, const char *mode); -# define BIO_s_file_internal BIO_s_file # ifndef OPENSSL_NO_STDIO BIO *BIO_new_fp(FILE *stream, int close_flag); # endif diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index fb8a9f9..7571095 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -689,7 +689,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file) sk = sk_X509_NAME_new(xname_cmp); - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if ((sk == NULL) || (in == NULL)) { SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE, ERR_R_MALLOC_FAILURE); @@ -756,7 +756,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, oldcmp = sk_X509_NAME_set_cmp_func(stack, xname_cmp); - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK, diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c index 0a4625c..9c252fa 100644 --- a/ssl/ssl_conf.c +++ b/ssl/ssl_conf.c @@ -486,7 +486,7 @@ static int cmd_DHParameters(SSL_CONF_CTX *cctx, const char *value) DH *dh = NULL; BIO *in = NULL; if (cctx->ctx || cctx->ssl) { - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (!in) goto end; if (BIO_read_filename(in, value) <= 0) diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c index 9a3e0ec..9e172b5 100644 --- a/ssl/ssl_rsa.c +++ b/ssl/ssl_rsa.c @@ -90,7 +90,7 @@ int SSL_use_certificate_file(SSL *ssl, const char *file, int type) int ret = 0; X509 *x = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB); goto end; @@ -227,7 +227,7 @@ int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) BIO *in; RSA *rsa = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; @@ -299,7 +299,7 @@ int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type) BIO *in; EVP_PKEY *pkey = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; @@ -430,7 +430,7 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) int ret = 0; X509 *x = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB); goto end; @@ -512,7 +512,7 @@ int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) BIO *in; RSA *rsa = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; @@ -581,7 +581,7 @@ int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) BIO *in; EVP_PKEY *pkey = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, ERR_R_BUF_LIB); goto end; @@ -648,7 +648,7 @@ static int use_certificate_chain_file(SSL_CTX *ctx, SSL *ssl, const char *file) ERR_clear_error(); /* clear error stack for * SSL_CTX_use_certificate() */ - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if (in == NULL) { SSLerr(SSL_F_USE_CERTIFICATE_CHAIN_FILE, ERR_R_BUF_LIB); goto end; @@ -930,7 +930,7 @@ int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file) goto end; } - bin = BIO_new(BIO_s_file_internal()); + bin = BIO_new(BIO_s_file()); if (bin == NULL) { SSLerr(SSL_F_SSL_CTX_USE_SERVERINFO_FILE, ERR_R_BUF_LIB); goto end; diff --git a/ssl/ssl_txt.c b/ssl/ssl_txt.c index 0f506f0..d9d6f39 100644 --- a/ssl/ssl_txt.c +++ b/ssl/ssl_txt.c @@ -92,7 +92,7 @@ int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) BIO *b; int ret; - if ((b = BIO_new(BIO_s_file_internal())) == NULL) { + if ((b = BIO_new(BIO_s_file())) == NULL) { SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB); return (0); } From kurt at openssl.org Sat Oct 3 11:28:30 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Sat, 03 Oct 2015 11:28:30 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1443871710.660670.26207.nullmailer@dev.openssl.org> The branch master has been updated via 605236f6a8fe0743af2f63d93239a74c69dae137 (commit) from 9982cbbbf65473418661f5aa1f05e7ef88ada801 (commit) - Log ----------------------------------------------------------------- commit 605236f6a8fe0743af2f63d93239a74c69dae137 Author: Kurt Roeckx Date: Tue Sep 29 19:59:48 2015 +0200 Fix more d2i cases to properly update the input pointer Thanks to David Benjamin for pointing them out. Reviewed-by: Steve Henson MR #1198 ----------------------------------------------------------------------- Summary of changes: crypto/asn1/d2i_pr.c | 8 +++++--- crypto/x509/x_x509.c | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c index 90ec2f4..1b6f8eb 100644 --- a/crypto/asn1/d2i_pr.c +++ b/crypto/asn1/d2i_pr.c @@ -104,7 +104,8 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, EVP_PKEY_free(ret); ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); - + if (ret == NULL) + goto err; } else { ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB); goto err; @@ -160,8 +161,9 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, } ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); - if (ret != NULL) - *pp = p; + if (ret == NULL) + return NULL; + *pp = p; if (a) { *a = ret; } diff --git a/crypto/x509/x_x509.c b/crypto/x509/x_x509.c index 028c75a..92d4fa3 100644 --- a/crypto/x509/x_x509.c +++ b/crypto/x509/x_x509.c @@ -184,9 +184,7 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) return NULL; /* update length */ length -= q - *pp; - if (!length) - return ret; - if (!d2i_X509_CERT_AUX(&ret->aux, &q, length)) + if (length > 0 && !d2i_X509_CERT_AUX(&ret->aux, &q, length)) goto err; *pp = q; return ret; From kurt at openssl.org Sat Oct 3 11:36:09 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Sat, 03 Oct 2015 11:36:09 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1443872169.375772.27596.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via 6b247c181726e7dd3744570b850c0cef60776c55 (commit) from d62c64b947ae96463a331de005165c57966d2149 (commit) - Log ----------------------------------------------------------------- commit 6b247c181726e7dd3744570b850c0cef60776c55 Author: Kurt Roeckx Date: Tue Sep 29 19:59:48 2015 +0200 Fix more d2i cases to properly update the input pointer Thanks to David Benjamin for pointing them out. Reviewed-by: Steve Henson MR #1198 (cherry picked from commit 605236f6a8fe0743af2f63d93239a74c69dae137) ----------------------------------------------------------------------- Summary of changes: crypto/asn1/d2i_pr.c | 8 +++++--- crypto/asn1/x_x509.c | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c index 314f4e3..d21829a 100644 --- a/crypto/asn1/d2i_pr.c +++ b/crypto/asn1/d2i_pr.c @@ -104,7 +104,8 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, EVP_PKEY_free(ret); ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); - + if (ret == NULL) + goto err; } else { ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB); goto err; @@ -160,8 +161,9 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, } ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); - if (ret != NULL) - *pp = p; + if (ret == NULL) + return NULL; + *pp = p; if (a) { *a = ret; } diff --git a/crypto/asn1/x_x509.c b/crypto/asn1/x_x509.c index 63c15e8..e2cac83 100644 --- a/crypto/asn1/x_x509.c +++ b/crypto/asn1/x_x509.c @@ -186,9 +186,7 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) return NULL; /* update length */ length -= q - *pp; - if (!length) - return ret; - if (!d2i_X509_CERT_AUX(&ret->aux, &q, length)) + if (length > 0 && !d2i_X509_CERT_AUX(&ret->aux, &q, length)) goto err; *pp = q; return ret; From kurt at openssl.org Sat Oct 3 12:04:37 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Sat, 03 Oct 2015 12:04:37 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1443873877.986768.30934.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 67d42531744e56d11212ee000e4559cf95ac57a7 (commit) from 978c8aa8b79692d193437d28e2485ec5ffa9d6cc (commit) - Log ----------------------------------------------------------------- commit 67d42531744e56d11212ee000e4559cf95ac57a7 Author: Kurt Roeckx Date: Tue Sep 29 19:59:48 2015 +0200 Fix more d2i cases to properly update the input pointer Thanks to David Benjamin for pointing them out. Reviewed-by: Steve Henson MR #1198 (cherry picked from commit 605236f6a8fe0743af2f63d93239a74c69dae137) ----------------------------------------------------------------------- Summary of changes: crypto/asn1/d2i_pr.c | 8 +++++--- crypto/asn1/x_x509.c | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c index 314f4e3..d21829a 100644 --- a/crypto/asn1/d2i_pr.c +++ b/crypto/asn1/d2i_pr.c @@ -104,7 +104,8 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, EVP_PKEY_free(ret); ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); - + if (ret == NULL) + goto err; } else { ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB); goto err; @@ -160,8 +161,9 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, } ret = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); - if (ret != NULL) - *pp = p; + if (ret == NULL) + return NULL; + *pp = p; if (a) { *a = ret; } diff --git a/crypto/asn1/x_x509.c b/crypto/asn1/x_x509.c index 916e51f..bcd9166 100644 --- a/crypto/asn1/x_x509.c +++ b/crypto/asn1/x_x509.c @@ -186,9 +186,7 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) return NULL; /* update length */ length -= q - *pp; - if (!length) - return ret; - if (!d2i_X509_CERT_AUX(&ret->aux, &q, length)) + if (length > 0 && !d2i_X509_CERT_AUX(&ret->aux, &q, length)) goto err; *pp = q; return ret; From steve at openssl.org Mon Oct 5 02:34:11 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Mon, 05 Oct 2015 02:34:11 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444012451.490201.5070.nullmailer@dev.openssl.org> The branch master has been updated via f93ad22f6adb00e722c130e792799467f3927b56 (commit) from 605236f6a8fe0743af2f63d93239a74c69dae137 (commit) - Log ----------------------------------------------------------------- commit f93ad22f6adb00e722c130e792799467f3927b56 Author: Dr. Stephen Henson Date: Sat Oct 3 17:15:15 2015 +0100 Free up ASN.1 structures at top level only. When a decoding error in ASN.1 occurs only free up the partial structure at the top level. This simplifies embedded handling and fixes freeing up of structures when presented with malformed input. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: crypto/asn1/asn1_err.c | 2 +- crypto/asn1/tasn_dec.c | 68 +++++++++++++++++++++++++++++--------------------- include/openssl/asn1.h | 2 +- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/crypto/asn1/asn1_err.c b/crypto/asn1/asn1_err.c index 0d1cf0c..73dd53f 100644 --- a/crypto/asn1/asn1_err.c +++ b/crypto/asn1/asn1_err.c @@ -103,7 +103,7 @@ static ERR_STRING_DATA ASN1_str_functs[] = { {ERR_FUNC(ASN1_F_ASN1_INTEGER_TO_BN), "ASN1_INTEGER_to_BN"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_D2I_FP), "ASN1_item_d2i_fp"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_DUP), "ASN1_item_dup"}, - {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_D2I), "ASN1_ITEM_EX_D2I"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_EMBED_D2I), "asn1_item_embed_d2i"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_EMBED_NEW), "ASN1_ITEM_EMBED_NEW"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_BIO), "ASN1_item_i2d_bio"}, {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_FP), "ASN1_item_i2d_fp"}, diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c index 939ee20..94445bd 100644 --- a/crypto/asn1/tasn_dec.c +++ b/crypto/asn1/tasn_dec.c @@ -66,6 +66,10 @@ #include #include "asn1_locl.h" +static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, + long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx); + static int asn1_check_eoc(const unsigned char **in, long len); static int asn1_find_end(const unsigned char **in, long len, char inf); @@ -151,14 +155,25 @@ ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval, return NULL; } +int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, + const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx) +{ + int rv; + rv = asn1_item_embed_d2i(pval, in, len, it, tag, aclass, opt, ctx); + if (rv <= 0) + ASN1_item_ex_free(pval, it); + return rv; +} + /* * Decode an item, taking care of IMPLICIT tagging, if any. If 'opt' set and * tag mismatch return -1 to handle OPTIONAL */ -int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, - int tag, int aclass, char opt, ASN1_TLC *ctx) +static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in, + long len, const ASN1_ITEM *it, + int tag, int aclass, char opt, ASN1_TLC *ctx) { const ASN1_TEMPLATE *tt, *errtt = NULL; const ASN1_EXTERN_FUNCS *ef; @@ -189,7 +204,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, * template in the template itself. */ if ((tag != -1) || opt) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE); goto err; } @@ -205,7 +220,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL, &p, len, -1, 0, 1, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -214,7 +229,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* If OPTIONAL, assume this is OK */ if (opt) return -1; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MSTRING_NOT_UNIVERSAL); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MSTRING_NOT_UNIVERSAL); goto err; } /* Check tag matches bit map */ @@ -222,7 +237,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* If OPTIONAL, assume this is OK */ if (opt) return -1; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MSTRING_WRONG_TAG); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MSTRING_WRONG_TAG); goto err; } return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx); @@ -245,7 +260,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, asn1_set_choice_selector(pval, -1, it); } } else if (!ASN1_item_ex_new(pval, it)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } /* CHOICE type, try each possibility in turn */ @@ -264,7 +279,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, break; /* Otherwise must be an ASN1 parsing error */ errtt = tt; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -276,7 +291,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ASN1_item_ex_free(pval, it); return -1; } - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_NO_MATCHING_CHOICE_TYPE); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_NO_MATCHING_CHOICE_TYPE); goto err; } @@ -300,7 +315,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst, &p, len, tag, aclass, opt, ctx); if (!ret) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } else if (ret == -1) return -1; @@ -312,12 +327,12 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, else seq_nolen = seq_eoc; if (!cst) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_SEQUENCE_NOT_CONSTRUCTED); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_SEQUENCE_NOT_CONSTRUCTED); goto err; } if (!*pval && !ASN1_item_ex_new(pval, it)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ERR_R_NESTED_ASN1_ERROR); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; } @@ -349,7 +364,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, q = p; if (asn1_check_eoc(&p, len)) { if (!seq_eoc) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_UNEXPECTED_EOC); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_UNEXPECTED_EOC); goto err; } len -= p - q; @@ -388,12 +403,12 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, /* Check for EOC if expecting one */ if (seq_eoc && !asn1_check_eoc(&p, len)) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_MISSING_EOC); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MISSING_EOC); goto err; } /* Check all data read */ if (!seq_nolen && len) { - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_SEQUENCE_LENGTH_MISMATCH); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_SEQUENCE_LENGTH_MISMATCH); goto err; } @@ -413,7 +428,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, asn1_template_free(pseqval, seqtt); } else { errtt = seqtt; - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_FIELD_MISSING); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_FIELD_MISSING); goto err; } } @@ -429,9 +444,8 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, return 0; } auxerr: - ASN1err(ASN1_F_ASN1_ITEM_EX_D2I, ASN1_R_AUX_ERROR); + ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_AUX_ERROR); err: - ASN1_item_ex_free(pval, it); if (errtt) ERR_add_error_data(4, "Field=", errtt->field_name, ", Type=", it->sname); @@ -513,7 +527,6 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val, return 1; err: - asn1_template_free(val, tt); return 0; } @@ -601,8 +614,8 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val, break; } skfield = NULL; - if (!ASN1_item_ex_d2i(&skfield, &p, len, - ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) { + if (!asn1_item_embed_d2i(&skfield, &p, len, + ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; @@ -619,9 +632,9 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val, } } else if (flags & ASN1_TFLG_IMPTAG) { /* IMPLICIT tagging */ - ret = ASN1_item_ex_d2i(val, &p, len, - ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt, - ctx); + ret = asn1_item_embed_d2i(val, &p, len, + ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt, + ctx); if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; @@ -629,8 +642,8 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val, return -1; } else { /* Nothing special */ - ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), - -1, 0, opt, ctx); + ret = asn1_item_embed_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), + -1, 0, opt, ctx); if (!ret) { ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_NESTED_ASN1_ERROR); goto err; @@ -642,7 +655,6 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val, return 1; err: - asn1_template_free(val, tt); return 0; } diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h index 3a67d61..2405bd6 100644 --- a/include/openssl/asn1.h +++ b/include/openssl/asn1.h @@ -942,7 +942,7 @@ void ERR_load_ASN1_strings(void); # define ASN1_F_ASN1_INTEGER_TO_BN 119 # define ASN1_F_ASN1_ITEM_D2I_FP 206 # define ASN1_F_ASN1_ITEM_DUP 191 -# define ASN1_F_ASN1_ITEM_EX_D2I 120 +# define ASN1_F_ASN1_ITEM_EMBED_D2I 120 # define ASN1_F_ASN1_ITEM_EMBED_NEW 121 # define ASN1_F_ASN1_ITEM_I2D_BIO 192 # define ASN1_F_ASN1_ITEM_I2D_FP 193 From appro at openssl.org Mon Oct 5 07:26:53 2015 From: appro at openssl.org (Andy Polyakov) Date: Mon, 05 Oct 2015 07:26:53 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444030013.393171.4839.nullmailer@dev.openssl.org> The branch master has been updated via 5f0580ccf126a4834a406423e15da5b8a8bdf993 (commit) via 21ff9ac815f363a4fc9c8dc80ca09f0a5b2f02ef (commit) via 45f1351821a44f4ba7b5c6485277ba7729b6ec4a (commit) via b13fdc4860b5e1bf615b113950788a138e68ae7f (commit) from f93ad22f6adb00e722c130e792799467f3927b56 (commit) - Log ----------------------------------------------------------------- commit 5f0580ccf126a4834a406423e15da5b8a8bdf993 Author: Andy Polyakov Date: Wed Sep 30 10:36:21 2015 +0200 Harmonize pointer printing and size_t-fy casts. Reviewed-by: Richard Levitte commit 21ff9ac815f363a4fc9c8dc80ca09f0a5b2f02ef Author: Andy Polyakov Date: Wed Sep 30 10:28:14 2015 +0200 bio/bss_log.c: harmonize format string to silence -Wformat. Reviewed-by: Richard Levitte commit 45f1351821a44f4ba7b5c6485277ba7729b6ec4a Author: Andy Polyakov Date: Wed Sep 30 10:27:19 2015 +0200 Address Windows warnings in apps/. Reviewed-by: Richard Levitte commit b13fdc4860b5e1bf615b113950788a138e68ae7f Author: Andy Polyakov Date: Wed Sep 30 10:15:03 2015 +0200 Explicitly cast INVALID_SOCKET to (int) to address warnings on Windows. Even though SOCKET is effectively declared as (void *) on Windows, it's not actually a pointer, but an index within per-process table of kernel objects. The table size is actually limited and its upper limit is far below upper limit for signed 32-bit integer. This is what makes cast in question possible. Reviewed-by: Richard Levitte Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: apps/opt.c | 3 +-- apps/s_socket.c | 12 ++++++------ apps/s_time.c | 23 ----------------------- crypto/bio/b_print.c | 2 +- crypto/bio/b_sock.c | 20 ++++++++++---------- crypto/bio/bss_acpt.c | 12 ++++++------ crypto/bio/bss_conn.c | 8 ++++---- crypto/bio/bss_log.c | 2 +- crypto/mem_dbg.c | 8 ++++---- crypto/thr_id.c | 2 +- e_os.h | 4 +++- 11 files changed, 37 insertions(+), 59 deletions(-) diff --git a/apps/opt.c b/apps/opt.c index c7dcc43..90a9d84 100644 --- a/apps/opt.c +++ b/apps/opt.c @@ -80,8 +80,7 @@ static char prog[40]; #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_NETWARE) char *opt_progname(const char *argv0) { - int i; - int n; + size_t i, n; const char *p; char *q; diff --git a/apps/s_socket.c b/apps/s_socket.c index c1faffc..9d1f04a 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -266,7 +266,7 @@ static int init_client_ip(int *sock, const unsigned char ip[4], int port, else /* ( type == SOCK_DGRAM) */ s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (s == INVALID_SOCKET) { + if (s == (int)INVALID_SOCKET) { perror("socket"); return (0); } @@ -303,7 +303,7 @@ int init_client_unix(int *sock, const char *server) return (0); s = socket(AF_UNIX, SOCK_STREAM, 0); - if (s == INVALID_SOCKET) { + if (s == (int)INVALID_SOCKET) { perror("socket"); return (0); } @@ -428,7 +428,7 @@ static int init_server_long(int *sock, int port, char *ip, int type) else /* type == SOCK_DGRAM */ s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (s == INVALID_SOCKET) + if (s == (int)INVALID_SOCKET) goto err; # if defined SOL_SOCKET && defined SO_REUSEADDR { @@ -472,7 +472,7 @@ static int init_server_unix(int *sock, const char *path) return (0); s = socket(AF_UNIX, SOCK_STREAM, 0); - if (s == INVALID_SOCKET) + if (s == (int)INVALID_SOCKET) goto err; memset(&server, 0, sizeof(server)); @@ -527,7 +527,7 @@ static int do_accept(int acc_sock, int *sock, char **host) * can either go for (int *) or (void *). */ ret = accept(acc_sock, (struct sockaddr *)&from, (void *)&len); - if (ret == INVALID_SOCKET) { + if (ret == (int)INVALID_SOCKET) { # if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK)) int i; i = WSAGetLastError(); @@ -589,7 +589,7 @@ static int do_accept_unix(int acc_sock, int *sock) redoit: ret = accept(acc_sock, NULL, NULL); - if (ret == INVALID_SOCKET) { + if (ret == (int)INVALID_SOCKET) { if (errno == EINTR) { /* * check_timeout(); diff --git a/apps/s_time.c b/apps/s_time.c index 91d28c2..6514fb2 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -73,10 +73,6 @@ #include #include "s_apps.h" #include -#ifdef WIN32_STUFF -# include "winmain.h" -# include "wintext.h" -#endif #if !defined(OPENSSL_SYS_MSDOS) # include OPENSSL_UNISTD #endif @@ -166,9 +162,6 @@ int s_time_main(int argc, char **argv) 0, ver; long bytes_read = 0, finishtime = 0; OPTION_CHOICE o; -#ifdef OPENSSL_SYS_WIN32 - int exitNow = 0; /* Set when it's time to exit main */ -#endif meth = TLS_client_method(); verify_depth = 0; @@ -281,14 +274,6 @@ int s_time_main(int argc, char **argv) for (;;) { if (finishtime < (long)time(NULL)) break; -#ifdef WIN32_STUFF - - if (flushWinMsgs(0) == -1) - goto end; - - if (waitingToDie || exitNow) /* we're dead */ - goto end; -#endif if ((scon = doConnection(NULL, host, ctx)) == NULL) goto end; @@ -378,14 +363,6 @@ int s_time_main(int argc, char **argv) if (finishtime < (long)time(NULL)) break; -#ifdef WIN32_STUFF - if (flushWinMsgs(0) == -1) - goto end; - - if (waitingToDie || exitNow) /* we're dead */ - goto end; -#endif - if ((doConnection(scon, host, ctx)) == NULL) goto end; diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c index 06cadc8..f49ebee 100644 --- a/crypto/bio/b_print.c +++ b/crypto/bio/b_print.c @@ -370,7 +370,7 @@ _dopr(char **sbuffer, flags, min, max); break; case 'p': - value = (long)va_arg(args, void *); + value = (size_t)va_arg(args, void *); fmtint(sbuffer, buffer, &currlen, maxlen, value, 16, min, max, flags | DP_F_NUM); break; diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index 48e4036..e536eda 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -391,7 +391,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) struct sockaddr_in6 sa_in6; # endif } server, client; - int s = INVALID_SOCKET, cs, addrlen; + int s = (int)INVALID_SOCKET, cs, addrlen; unsigned char ip[4]; unsigned short port; char *str = NULL, *e; @@ -400,10 +400,10 @@ int BIO_get_accept_socket(char *host, int bind_mode) int err_num; if (BIO_sock_init() != 1) - return (INVALID_SOCKET); + return ((int)INVALID_SOCKET); if ((str = BUF_strdup(host)) == NULL) - return (INVALID_SOCKET); + return ((int)INVALID_SOCKET); h = p = NULL; h = str; @@ -503,7 +503,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) again: s = socket(server.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL); - if (s == INVALID_SOCKET) { + if (s == (int)INVALID_SOCKET) { SYSerr(SYS_F_SOCKET, get_last_socket_error()); ERR_add_error_data(3, "port='", host, "'"); BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET); @@ -545,11 +545,11 @@ int BIO_get_accept_socket(char *host, int bind_mode) goto err; } cs = socket(client.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL); - if (cs != INVALID_SOCKET) { + if (cs != (int)INVALID_SOCKET) { int ii; ii = connect(cs, &client.sa, addrlen); closesocket(cs); - if (ii == INVALID_SOCKET) { + if (ii == (int)INVALID_SOCKET) { bind_mode = BIO_BIND_REUSEADDR; closesocket(s); goto again; @@ -573,16 +573,16 @@ int BIO_get_accept_socket(char *host, int bind_mode) ret = 1; err: OPENSSL_free(str); - if ((ret == 0) && (s != INVALID_SOCKET)) { + if ((ret == 0) && (s != (int)INVALID_SOCKET)) { closesocket(s); - s = INVALID_SOCKET; + s = (int)INVALID_SOCKET; } return (s); } int BIO_accept(int sock, char **addr) { - int ret = INVALID_SOCKET; + int ret = (int)INVALID_SOCKET; unsigned long l; unsigned short port; char *p; @@ -631,7 +631,7 @@ int BIO_accept(int sock, char **addr) sa.len.i = (int)sa.len.s; /* use sa.len.i from this point */ } - if (ret == INVALID_SOCKET) { + if (ret == (int)INVALID_SOCKET) { if (BIO_sock_should_retry(ret)) return -2; SYSerr(SYS_F_ACCEPT, get_last_socket_error()); diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index eba6e25..c549c87 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -123,7 +123,7 @@ static int acpt_new(BIO *bi) BIO_ACCEPT *ba; bi->init = 0; - bi->num = INVALID_SOCKET; + bi->num = (int)INVALID_SOCKET; bi->flags = 0; if ((ba = BIO_ACCEPT_new()) == NULL) return (0); @@ -139,7 +139,7 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void) if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) return (NULL); - ret->accept_sock = INVALID_SOCKET; + ret->accept_sock = (int)INVALID_SOCKET; ret->bind_mode = BIO_BIND_NORMAL; return (ret); } @@ -160,11 +160,11 @@ static void acpt_close_socket(BIO *bio) BIO_ACCEPT *c; c = (BIO_ACCEPT *)bio->ptr; - if (c->accept_sock != INVALID_SOCKET) { + if (c->accept_sock != (int)INVALID_SOCKET) { shutdown(c->accept_sock, 2); closesocket(c->accept_sock); - c->accept_sock = INVALID_SOCKET; - bio->num = INVALID_SOCKET; + c->accept_sock = (int)INVALID_SOCKET; + bio->num = (int)INVALID_SOCKET; } } @@ -200,7 +200,7 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) return (-1); } s = BIO_get_accept_socket(c->param_addr, c->bind_mode); - if (s == INVALID_SOCKET) + if (s == (int)INVALID_SOCKET) return (-1); if (c->accept_nbio) { diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c index 0733a29..49b0f69 100644 --- a/crypto/bio/bss_conn.c +++ b/crypto/bio/bss_conn.c @@ -189,7 +189,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c) c->state = BIO_CONN_S_CREATE_SOCKET; ret = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (ret == INVALID_SOCKET) { + if (ret == (int)INVALID_SOCKET) { SYSerr(SYS_F_SOCKET, get_last_socket_error()); ERR_add_error_data(4, "host=", c->param_hostname, ":", c->param_port); @@ -313,7 +313,7 @@ BIO_METHOD *BIO_s_connect(void) static int conn_new(BIO *bi) { bi->init = 0; - bi->num = INVALID_SOCKET; + bi->num = (int)INVALID_SOCKET; bi->flags = 0; if ((bi->ptr = (char *)BIO_CONNECT_new()) == NULL) return (0); @@ -326,12 +326,12 @@ static void conn_close_socket(BIO *bio) BIO_CONNECT *c; c = (BIO_CONNECT *)bio->ptr; - if (bio->num != INVALID_SOCKET) { + if (bio->num != (int)INVALID_SOCKET) { /* Only do a shutdown if things were established */ if (c->state == BIO_CONN_S_OK) shutdown(bio->num, 2); closesocket(bio->num); - bio->num = INVALID_SOCKET; + bio->num = (int)INVALID_SOCKET; } } diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c index f59ec7c..a86ea29 100644 --- a/crypto/bio/bss_log.c +++ b/crypto/bio/bss_log.c @@ -322,7 +322,7 @@ static void xsyslog(BIO *bp, int priority, const char *string) break; } - sprintf(pidbuf, "[%u] ", GetCurrentProcessId()); + sprintf(pidbuf, "[%lu] ", GetCurrentProcessId()); lpszStrings[0] = pidbuf; lpszStrings[1] = string; diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 10cc893..2cd1169 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -321,9 +321,9 @@ static IMPLEMENT_LHASH_COMP_FN(mem, MEM) static unsigned long mem_hash(const MEM *a) { - unsigned long ret; + size_t ret; - ret = (unsigned long)a->addr; + ret = (size_t)a->addr; ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251; return (ret); @@ -661,8 +661,8 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l) bufp += strlen(bufp); } - BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n", - m->num, (unsigned long)m->addr); + BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%p\n", + m->num, m->addr); bufp += strlen(bufp); BIO_puts(l->bio, buf); diff --git a/crypto/thr_id.c b/crypto/thr_id.c index c391fc4..51088e4 100644 --- a/crypto/thr_id.c +++ b/crypto/thr_id.c @@ -146,7 +146,7 @@ void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr) /* * 'ptr' can be embedded in 'val' without loss of uniqueness */ - id->val = (unsigned long)id->ptr; + id->val = (size_t)id->ptr; return; } /* diff --git a/e_os.h b/e_os.h index 8c4223b..6aa0f73 100644 --- a/e_os.h +++ b/e_os.h @@ -477,7 +477,9 @@ struct servent *PASCAL getservbyname(const char *, const char *); /* * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because * the value constitutes an index in per-process table of limited size - * and not a real pointer. + * and not a real pointer. And we also depend on fact that all processors + * Windows run on happen to be two's-complement, which allows to + * interchange INVALID_SOCKET and -1. */ # define socket(d,t,p) ((int)socket(d,t,p)) # define accept(s,f,l) ((int)accept(s,f,l)) From levitte at openssl.org Mon Oct 5 09:08:58 2015 From: levitte at openssl.org (Richard Levitte) Date: Mon, 05 Oct 2015 09:08:58 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444036138.161090.25032.nullmailer@dev.openssl.org> The branch master has been updated via 2ff00bdbc4aad268e07df82541ff4a16b1f91fe8 (commit) via 46f4d2bef6c11e024c29b78a835b433c472ed3cf (commit) from 5f0580ccf126a4834a406423e15da5b8a8bdf993 (commit) - Log ----------------------------------------------------------------- commit 2ff00bdbc4aad268e07df82541ff4a16b1f91fe8 Author: Richard Levitte Date: Sun Oct 4 21:16:28 2015 +0200 make depend Reviewed-by: Ben Laurie commit 46f4d2bef6c11e024c29b78a835b433c472ed3cf Author: Richard Levitte Date: Sun Oct 4 21:12:03 2015 +0200 Fix make depend for things being built in subdirectories Some makedepend mechanisms remove all directory information in the target, so a dependency can looks like this: ssl3_record.o: record/ssl3_record.c However, that doesn't quite suit us, our Makefile has us build record/ssl3_record.o rather than ssl3_record.o. To clear this up, a change to util/clean-depend.pl takes care of this case by looking up the original file in the dependencies and restoring the directory information from it. Reviewed-by: Ben Laurie ----------------------------------------------------------------------- Summary of changes: ssl/Makefile | 227 ++++++++++++++++++++++++++------------------------- util/clean-depend.pl | 28 +++++-- 2 files changed, 141 insertions(+), 114 deletions(-) diff --git a/ssl/Makefile b/ssl/Makefile index b8ae9c3..7953da4 100644 --- a/ssl/Makefile +++ b/ssl/Makefile @@ -256,71 +256,124 @@ d1_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h d1_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h d1_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h d1_srvr.c d1_srvr.o: packet_locl.h record/record.h ssl_locl.h -dtls1_bitmap.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -dtls1_bitmap.o: ../include/openssl/bn.h ../include/openssl/buffer.h -dtls1_bitmap.o: ../include/openssl/comp.h ../include/openssl/crypto.h -dtls1_bitmap.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -dtls1_bitmap.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -dtls1_bitmap.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -dtls1_bitmap.o: ../include/openssl/err.h ../include/openssl/evp.h -dtls1_bitmap.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -dtls1_bitmap.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -dtls1_bitmap.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -dtls1_bitmap.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -dtls1_bitmap.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -dtls1_bitmap.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h -dtls1_bitmap.o: ../include/openssl/safestack.h ../include/openssl/sha.h -dtls1_bitmap.o: ../include/openssl/srtp.h ../include/openssl/ssl.h -dtls1_bitmap.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h -dtls1_bitmap.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -dtls1_bitmap.o: ../include/openssl/tls1.h ../include/openssl/x509.h -dtls1_bitmap.o: ../include/openssl/x509_vfy.h dtls1_bitmap.c -dtls1_bitmap.o: record/../packet_locl.h record/../record/record.h -dtls1_bitmap.o: record/../ssl_locl.h record/dtls1_bitmap.c record/record_locl.h -rec_layer_d1.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -rec_layer_d1.o: ../include/openssl/bn.h ../include/openssl/buffer.h -rec_layer_d1.o: ../include/openssl/comp.h ../include/openssl/crypto.h -rec_layer_d1.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -rec_layer_d1.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -rec_layer_d1.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -rec_layer_d1.o: ../include/openssl/err.h ../include/openssl/evp.h -rec_layer_d1.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -rec_layer_d1.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -rec_layer_d1.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -rec_layer_d1.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -rec_layer_d1.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -rec_layer_d1.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -rec_layer_d1.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -rec_layer_d1.o: ../include/openssl/sha.h ../include/openssl/srtp.h -rec_layer_d1.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -rec_layer_d1.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -rec_layer_d1.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -rec_layer_d1.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -rec_layer_d1.o: rec_layer_d1.c record/../packet_locl.h -rec_layer_d1.o: record/../record/record.h record/../ssl_locl.h -rec_layer_d1.o: record/rec_layer_d1.c record/record_locl.h -rec_layer_s3.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -rec_layer_s3.o: ../include/openssl/bn.h ../include/openssl/buffer.h -rec_layer_s3.o: ../include/openssl/comp.h ../include/openssl/crypto.h -rec_layer_s3.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -rec_layer_s3.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -rec_layer_s3.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -rec_layer_s3.o: ../include/openssl/err.h ../include/openssl/evp.h -rec_layer_s3.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -rec_layer_s3.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -rec_layer_s3.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -rec_layer_s3.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -rec_layer_s3.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -rec_layer_s3.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -rec_layer_s3.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -rec_layer_s3.o: ../include/openssl/sha.h ../include/openssl/srtp.h -rec_layer_s3.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -rec_layer_s3.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -rec_layer_s3.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -rec_layer_s3.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -rec_layer_s3.o: rec_layer_s3.c record/../packet_locl.h -rec_layer_s3.o: record/../record/record.h record/../ssl_locl.h -rec_layer_s3.o: record/rec_layer_s3.c record/record_locl.h +record/dtls1_bitmap.o: ../e_os.h ../include/openssl/asn1.h +record/dtls1_bitmap.o: ../include/openssl/bio.h ../include/openssl/bn.h +record/dtls1_bitmap.o: ../include/openssl/buffer.h ../include/openssl/comp.h +record/dtls1_bitmap.o: ../include/openssl/crypto.h ../include/openssl/dsa.h +record/dtls1_bitmap.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +record/dtls1_bitmap.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +record/dtls1_bitmap.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +record/dtls1_bitmap.o: ../include/openssl/evp.h ../include/openssl/hmac.h +record/dtls1_bitmap.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h +record/dtls1_bitmap.o: ../include/openssl/objects.h +record/dtls1_bitmap.o: ../include/openssl/opensslconf.h +record/dtls1_bitmap.o: ../include/openssl/opensslv.h +record/dtls1_bitmap.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +record/dtls1_bitmap.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +record/dtls1_bitmap.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h +record/dtls1_bitmap.o: ../include/openssl/safestack.h ../include/openssl/sha.h +record/dtls1_bitmap.o: ../include/openssl/srtp.h ../include/openssl/ssl.h +record/dtls1_bitmap.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h +record/dtls1_bitmap.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +record/dtls1_bitmap.o: ../include/openssl/tls1.h ../include/openssl/x509.h +record/dtls1_bitmap.o: ../include/openssl/x509_vfy.h record/../packet_locl.h +record/dtls1_bitmap.o: record/../record/record.h record/../ssl_locl.h +record/dtls1_bitmap.o: record/dtls1_bitmap.c record/record_locl.h +record/rec_layer_d1.o: ../e_os.h ../include/openssl/asn1.h +record/rec_layer_d1.o: ../include/openssl/bio.h ../include/openssl/bn.h +record/rec_layer_d1.o: ../include/openssl/buffer.h ../include/openssl/comp.h +record/rec_layer_d1.o: ../include/openssl/crypto.h ../include/openssl/dsa.h +record/rec_layer_d1.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +record/rec_layer_d1.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +record/rec_layer_d1.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +record/rec_layer_d1.o: ../include/openssl/evp.h ../include/openssl/hmac.h +record/rec_layer_d1.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h +record/rec_layer_d1.o: ../include/openssl/objects.h +record/rec_layer_d1.o: ../include/openssl/opensslconf.h +record/rec_layer_d1.o: ../include/openssl/opensslv.h +record/rec_layer_d1.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +record/rec_layer_d1.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +record/rec_layer_d1.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +record/rec_layer_d1.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +record/rec_layer_d1.o: ../include/openssl/sha.h ../include/openssl/srtp.h +record/rec_layer_d1.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +record/rec_layer_d1.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +record/rec_layer_d1.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +record/rec_layer_d1.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +record/rec_layer_d1.o: record/../packet_locl.h record/../record/record.h +record/rec_layer_d1.o: record/../ssl_locl.h record/rec_layer_d1.c +record/rec_layer_d1.o: record/record_locl.h +record/rec_layer_s3.o: ../e_os.h ../include/openssl/asn1.h +record/rec_layer_s3.o: ../include/openssl/bio.h ../include/openssl/bn.h +record/rec_layer_s3.o: ../include/openssl/buffer.h ../include/openssl/comp.h +record/rec_layer_s3.o: ../include/openssl/crypto.h ../include/openssl/dsa.h +record/rec_layer_s3.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +record/rec_layer_s3.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +record/rec_layer_s3.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +record/rec_layer_s3.o: ../include/openssl/evp.h ../include/openssl/hmac.h +record/rec_layer_s3.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h +record/rec_layer_s3.o: ../include/openssl/objects.h +record/rec_layer_s3.o: ../include/openssl/opensslconf.h +record/rec_layer_s3.o: ../include/openssl/opensslv.h +record/rec_layer_s3.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +record/rec_layer_s3.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +record/rec_layer_s3.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +record/rec_layer_s3.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +record/rec_layer_s3.o: ../include/openssl/sha.h ../include/openssl/srtp.h +record/rec_layer_s3.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +record/rec_layer_s3.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +record/rec_layer_s3.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +record/rec_layer_s3.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +record/rec_layer_s3.o: record/../packet_locl.h record/../record/record.h +record/rec_layer_s3.o: record/../ssl_locl.h record/rec_layer_s3.c +record/rec_layer_s3.o: record/record_locl.h +record/ssl3_buffer.o: ../e_os.h ../include/openssl/asn1.h +record/ssl3_buffer.o: ../include/openssl/bio.h ../include/openssl/bn.h +record/ssl3_buffer.o: ../include/openssl/buffer.h ../include/openssl/comp.h +record/ssl3_buffer.o: ../include/openssl/crypto.h ../include/openssl/dsa.h +record/ssl3_buffer.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +record/ssl3_buffer.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +record/ssl3_buffer.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +record/ssl3_buffer.o: ../include/openssl/evp.h ../include/openssl/hmac.h +record/ssl3_buffer.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h +record/ssl3_buffer.o: ../include/openssl/objects.h +record/ssl3_buffer.o: ../include/openssl/opensslconf.h +record/ssl3_buffer.o: ../include/openssl/opensslv.h +record/ssl3_buffer.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +record/ssl3_buffer.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +record/ssl3_buffer.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h +record/ssl3_buffer.o: ../include/openssl/safestack.h ../include/openssl/sha.h +record/ssl3_buffer.o: ../include/openssl/srtp.h ../include/openssl/ssl.h +record/ssl3_buffer.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h +record/ssl3_buffer.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +record/ssl3_buffer.o: ../include/openssl/tls1.h ../include/openssl/x509.h +record/ssl3_buffer.o: ../include/openssl/x509_vfy.h record/../packet_locl.h +record/ssl3_buffer.o: record/../record/record.h record/../ssl_locl.h +record/ssl3_buffer.o: record/record_locl.h record/ssl3_buffer.c +record/ssl3_record.o: ../e_os.h ../include/internal/constant_time_locl.h +record/ssl3_record.o: ../include/openssl/asn1.h ../include/openssl/bio.h +record/ssl3_record.o: ../include/openssl/bn.h ../include/openssl/buffer.h +record/ssl3_record.o: ../include/openssl/comp.h ../include/openssl/crypto.h +record/ssl3_record.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h +record/ssl3_record.o: ../include/openssl/e_os2.h ../include/openssl/ec.h +record/ssl3_record.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h +record/ssl3_record.o: ../include/openssl/err.h ../include/openssl/evp.h +record/ssl3_record.o: ../include/openssl/hmac.h ../include/openssl/lhash.h +record/ssl3_record.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +record/ssl3_record.o: ../include/openssl/opensslconf.h +record/ssl3_record.o: ../include/openssl/opensslv.h +record/ssl3_record.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +record/ssl3_record.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +record/ssl3_record.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +record/ssl3_record.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +record/ssl3_record.o: ../include/openssl/sha.h ../include/openssl/srtp.h +record/ssl3_record.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +record/ssl3_record.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +record/ssl3_record.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +record/ssl3_record.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +record/ssl3_record.o: record/../packet_locl.h record/../record/record.h +record/ssl3_record.o: record/../ssl_locl.h record/record_locl.h +record/ssl3_record.o: record/ssl3_record.c s3_both.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h s3_both.o: ../include/openssl/bn.h ../include/openssl/buffer.h s3_both.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -467,50 +520,6 @@ s3_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h s3_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h s3_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h s3_srvr.o: packet_locl.h record/record.h s3_srvr.c ssl_locl.h -ssl3_buffer.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -ssl3_buffer.o: ../include/openssl/bn.h ../include/openssl/buffer.h -ssl3_buffer.o: ../include/openssl/comp.h ../include/openssl/crypto.h -ssl3_buffer.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -ssl3_buffer.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -ssl3_buffer.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -ssl3_buffer.o: ../include/openssl/err.h ../include/openssl/evp.h -ssl3_buffer.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -ssl3_buffer.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -ssl3_buffer.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -ssl3_buffer.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -ssl3_buffer.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -ssl3_buffer.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h -ssl3_buffer.o: ../include/openssl/safestack.h ../include/openssl/sha.h -ssl3_buffer.o: ../include/openssl/srtp.h ../include/openssl/ssl.h -ssl3_buffer.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h -ssl3_buffer.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -ssl3_buffer.o: ../include/openssl/tls1.h ../include/openssl/x509.h -ssl3_buffer.o: ../include/openssl/x509_vfy.h record/../packet_locl.h -ssl3_buffer.o: record/../record/record.h record/../ssl_locl.h -ssl3_buffer.o: record/record_locl.h record/ssl3_buffer.c ssl3_buffer.c -ssl3_record.o: ../e_os.h ../include/internal/constant_time_locl.h -ssl3_record.o: ../include/openssl/asn1.h ../include/openssl/bio.h -ssl3_record.o: ../include/openssl/bn.h ../include/openssl/buffer.h -ssl3_record.o: ../include/openssl/comp.h ../include/openssl/crypto.h -ssl3_record.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -ssl3_record.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -ssl3_record.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -ssl3_record.o: ../include/openssl/err.h ../include/openssl/evp.h -ssl3_record.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -ssl3_record.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -ssl3_record.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -ssl3_record.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -ssl3_record.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -ssl3_record.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -ssl3_record.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -ssl3_record.o: ../include/openssl/sha.h ../include/openssl/srtp.h -ssl3_record.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -ssl3_record.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -ssl3_record.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -ssl3_record.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -ssl3_record.o: record/../packet_locl.h record/../record/record.h -ssl3_record.o: record/../ssl_locl.h record/record_locl.h record/ssl3_record.c -ssl3_record.o: ssl3_record.c ssl_algs.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_algs.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_algs.o: ../include/openssl/comp.h ../include/openssl/crypto.h diff --git a/util/clean-depend.pl b/util/clean-depend.pl index 04d86b6..30197b7 100755 --- a/util/clean-depend.pl +++ b/util/clean-depend.pl @@ -11,22 +11,40 @@ while() { my %files; +# Fetch all the dependency output first my $thisfile=""; while() { my ($dummy, $file,$deps)=/^((.*):)? (.*)$/; - my $origfile=""; $thisfile=$file if defined $file; next if !defined $deps; - $origfile=$thisfile; - $origfile=~s/\.o$/.c/; my @deps=split ' ',$deps; - @deps=grep(!/^\//, at deps); @deps=grep(!/^\\$/, at deps); - @deps=grep(!/^$origfile$/, at deps); push @{$files{$thisfile}}, at deps; } my $file; + +# Time to clean out possible system directories and normalise quirks +# from different makedepend methods +foreach $file (sort keys %files) { + # This gets around a quirk with gcc, which removes all directory + # information from the original file + my $tmpfile=$file; + $tmpfile=~s/\.o$/.c/; + (my $origfile)=grep(/(^|\/)${tmpfile}$/,@{$files{$file}}); + my $newfile=$origfile; + $newfile=~s/\.c$/.o/; + if ($newfile ne $file) { + $files{$newfile} = $files{$file}; + delete $files{$file}; + $file = $newfile; + } + + @{$files{$file}} = + grep(!/^\//, + grep(!/^$origfile$/, @{$files{$file}})); +} + foreach $file (sort keys %files) { my $len=0; my $dep; From emilia at openssl.org Mon Oct 5 17:07:08 2015 From: emilia at openssl.org (Emilia Kasper) Date: Mon, 05 Oct 2015 17:07:08 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444064828.361976.7659.nullmailer@dev.openssl.org> The branch master has been updated via 67202973cf55eaac021706c183377b8040cf0c20 (commit) via bf0fc41266f17311c5db1e0541d3dd12eb27deb6 (commit) via 38a3cbfbf728da0282c7e4ba29502740d853b1e6 (commit) via b3e2272c59a5720467045e2ae62940fdb708ce76 (commit) from 2ff00bdbc4aad268e07df82541ff4a16b1f91fe8 (commit) - Log ----------------------------------------------------------------- commit 67202973cf55eaac021706c183377b8040cf0c20 Author: Emilia Kasper Date: Thu Oct 1 13:54:11 2015 +0200 Add PACKET_copy_all Reviewed-by: Matt Caswell commit bf0fc41266f17311c5db1e0541d3dd12eb27deb6 Author: Emilia Kasper Date: Thu Oct 1 13:00:39 2015 +0200 ssl_sess.c: grab a copy of the session ID The user callback takes a non-const pointer, so don't pass PACKET data to it directly; rather, grab a local copy. Reviewed-by: Matt Caswell commit 38a3cbfbf728da0282c7e4ba29502740d853b1e6 Author: Emilia Kasper Date: Thu Oct 1 12:53:08 2015 +0200 PACKETize and clean up ssl_bytes_to_cipher_list. Fix alerts. Reviewed-by: Matt Caswell commit b3e2272c59a5720467045e2ae62940fdb708ce76 Author: Emilia Kasper Date: Wed Sep 30 15:33:12 2015 +0200 ssl3_get_client_hello: rearrange logic Move all packet parsing to the beginning of the method. This limits the SSLv2 compatibility soup to the parsing, and makes the rest of the processing uniform. This is also needed for simpler EMS support: EMS servers need to do an early scan for EMS to make resumption decisions. This'll be easier when the entire ClientHello is parsed in the beginning. As a side effect, 1) PACKETize ssl_get_prev_session and tls1_process_ticket; and 2) Delete dead code for SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG. Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: include/openssl/ssl.h | 1 + ssl/packet_locl.h | 27 ++- ssl/s3_srvr.c | 536 ++++++++++++++++++++++---------------------------- ssl/ssl_locl.h | 8 +- ssl/ssl_sess.c | 35 ++-- ssl/t1_lib.c | 49 ++--- test/packettest.c | 37 +++- 7 files changed, 341 insertions(+), 352 deletions(-) diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 8fa9363..4b21d0f 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -359,6 +359,7 @@ typedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type, /* Allow initial connection to servers that don't support RI */ # define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004L /* Removed from OpenSSL 0.9.8q and 1.0.0c */ +/* Dead forever, see CVE-2010-4180. */ # define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x0L # define SSL_OP_TLSEXT_PADDING 0x00000010L # define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x00000020L diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index 88cd202..e73eb3d 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -117,6 +117,13 @@ static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf, size_t len) return 1; } +/* Initialize a PACKET to hold zero bytes. */ +static inline void PACKET_null_init(PACKET *pkt) +{ + pkt->curr = NULL; + pkt->remaining = 0; +} + /* * Peek ahead and initialize |subpkt| with the next |len| bytes read from |pkt|. * Data is not copied: the |subpkt| packet will share its underlying buffer with @@ -294,7 +301,7 @@ __owur static inline int PACKET_get_4(PACKET *pkt, unsigned long *data) * underlying buffer gets freed */ __owur static inline int PACKET_peek_bytes(const PACKET *pkt, unsigned char **data, - size_t len) + size_t len) { if (PACKET_remaining(pkt) < len) return 0; @@ -349,6 +356,24 @@ __owur static inline int PACKET_copy_bytes(PACKET *pkt, unsigned char *data, } /* + * Copy packet data to |dest|, and set |len| to the number of copied bytes. + * If the packet has more than |dest_len| bytes, nothing is copied. + * Returns 1 if the packet data fits in |dest_len| bytes, 0 otherwise. + * Does not forward PACKET position (because it is typically the last thing + * done with a given PACKET). + */ +__owur static inline int PACKET_copy_all(const PACKET *pkt, unsigned char *dest, + size_t dest_len, size_t *len) { + if (PACKET_remaining(pkt) > dest_len) { + *len = 0; + return 0; + } + *len = pkt->remaining; + memcpy(dest, pkt->curr, pkt->remaining); + return 1; +} + +/* * Copy |pkt| bytes to a newly allocated buffer and store a pointer to the * result in |*data|, and the length in |len|. * If |*data| is not NULL, the old data is OPENSSL_free'd. diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index f771bd9..82162d8 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -164,8 +164,10 @@ #include #include -static STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, - int num, STACK_OF(SSL_CIPHER) **skp, int sslv2format); +static STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, + PACKET *cipher_suites, + STACK_OF(SSL_CIPHER) **skp, + int sslv2format, int *al); #ifndef OPENSSL_NO_SRP @@ -847,7 +849,9 @@ int ssl3_get_client_hello(SSL *s) #endif STACK_OF(SSL_CIPHER) *ciphers = NULL; int protverr = 1; - PACKET pkt, cipher_suite, compression; + /* |cookie| will only be initialized for DTLS. */ + PACKET pkt, session_id, cipher_suites, compression, extensions, cookie; + int is_v2_record; if (s->state == SSL3_ST_SR_CLNT_HELLO_C && !s->first_packet) goto retry_cert; @@ -877,8 +881,10 @@ int ssl3_get_client_hello(SSL *s) goto f_err; } + is_v2_record = RECORD_LAYER_is_sslv2_record(&s->rlayer); + /* First lets get s->client_version set correctly */ - if (RECORD_LAYER_is_sslv2_record(&s->rlayer)) { + if (is_v2_record) { unsigned int version; unsigned int mt; /*- @@ -1004,13 +1010,15 @@ int ssl3_get_client_hello(SSL *s) goto f_err; } - if (RECORD_LAYER_is_sslv2_record(&s->rlayer)) { + /* Parse the message and load client random. */ + if (is_v2_record) { /* * Handle an SSLv2 backwards compatible ClientHello * Note, this is only for SSLv3+ using the backward compatible format. * Real SSLv2 is not supported, and is rejected above. */ unsigned int cipher_len, session_id_len, challenge_len; + PACKET challenge; if (!PACKET_get_net_2(&pkt, &cipher_len) || !PACKET_get_net_2(&pkt, &session_id_len) @@ -1020,309 +1028,241 @@ int ssl3_get_client_hello(SSL *s) goto f_err; } - if (cipher_len == 0) { - /* we need at least one cipher */ - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_SPECIFIED); - goto f_err; - } - - if (!PACKET_get_sub_packet(&pkt, &cipher_suite, cipher_len)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH); - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - - if (ssl_bytes_to_cipher_list(s, PACKET_data(&cipher_suite), - cipher_len, &(ciphers), 1) == NULL) { - goto err; - } - - /* - * Ignore any session id. We don't allow resumption in a backwards - * compatible ClientHello - */ - if (!PACKET_forward(&pkt, session_id_len)) { + if (!PACKET_get_sub_packet(&pkt, &cipher_suites, cipher_len) + || !PACKET_get_sub_packet(&pkt, &session_id, session_id_len) + || !PACKET_get_sub_packet(&pkt, &challenge, challenge_len) + /* No extensions. */ + || PACKET_remaining(&pkt) != 0) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH); al = SSL_AD_DECODE_ERROR; goto f_err; } - s->hit = 0; - - if (!ssl_get_new_session(s, 1)) - goto err; /* Load the client random */ - i = challenge_len > SSL3_RANDOM_SIZE ? SSL3_RANDOM_SIZE : challenge_len; + challenge_len = challenge_len > SSL3_RANDOM_SIZE ? SSL3_RANDOM_SIZE : + challenge_len; memset(s->s3->client_random, 0, SSL3_RANDOM_SIZE); - if (!PACKET_peek_copy_bytes(&pkt, - s->s3->client_random + SSL3_RANDOM_SIZE - i, - i) - || !PACKET_forward(&pkt, challenge_len) - || PACKET_remaining(&pkt) != 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH); - al = SSL_AD_DECODE_ERROR; + if (!PACKET_copy_bytes(&challenge, + s->s3->client_random + SSL3_RANDOM_SIZE - + challenge_len, challenge_len)) { + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + al = SSL_AD_INTERNAL_ERROR; goto f_err; } + + PACKET_null_init(&compression); + PACKET_null_init(&extensions); + /* We're never DTLS here but just play safe and initialize. */ + PACKET_null_init(&cookie); } else { - /* If we get here we've got SSLv3+ in an SSLv3+ record */ - PACKET session_id; - unsigned int cookie_len; - /* load the client random and get the session-id */ + /* Regular ClientHello. */ if (!PACKET_copy_bytes(&pkt, s->s3->client_random, SSL3_RANDOM_SIZE) - || !PACKET_get_length_prefixed_1(&pkt, &session_id)) { + || !PACKET_get_length_prefixed_1(&pkt, &session_id)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } - /* - * If we require cookies and this ClientHello doesn't contain one, just - * return since we do not want to allocate any memory yet. So check - * cookie length... - */ - if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { - - if (!PACKET_peek_1(&pkt, &cookie_len)) { + if (SSL_IS_DTLS(s)) { + if (!PACKET_get_length_prefixed_1(&pkt, &cookie)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } - - if (cookie_len == 0) + /* + * If we require cookies and this ClientHello doesn't contain one, + * just return since we do not want to allocate any memory yet. + * So check cookie length... + */ + if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { + if (PACKET_remaining(&cookie) == 0) return 1; + } } - s->hit = 0; + if (!PACKET_get_length_prefixed_2(&pkt, &cipher_suites) + || !PACKET_get_length_prefixed_1(&pkt, &compression)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + /* Could be empty. */ + extensions = pkt; + } + + s->hit = 0; + + /* + * We don't allow resumption in a backwards compatible ClientHello. + * TODO(openssl-team): in TLS1.1+, session_id MUST be empty. + * + * Versions before 0.9.7 always allow clients to resume sessions in + * renegotiation. 0.9.7 and later allow this by default, but optionally + * ignore resumption requests with flag + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather + * than a change to default behavior so that applications relying on + * this for security won't even compile against older library versions). + * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to + * request renegotiation but not a new session (s->new_session remains + * unset): for servers, this essentially just means that the + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be + * ignored. + */ + if (is_v2_record || + (s->new_session && + (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) { + if (!ssl_get_new_session(s, 1)) + goto err; + } else { + i = ssl_get_prev_session(s, &extensions, &session_id); /* - * Versions before 0.9.7 always allow clients to resume sessions in - * renegotiation. 0.9.7 and later allow this by default, but optionally - * ignore resumption requests with flag - * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather - * than a change to default behavior so that applications relying on - * this for security won't even compile against older library versions). - * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to - * request renegotiation but not a new session (s->new_session remains - * unset): for servers, this essentially just means that the - * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be - * ignored. + * Only resume if the session's version matches the negotiated + * version. + * RFC 5246 does not provide much useful advice on resumption + * with a different protocol version. It doesn't forbid it but + * the sanity of such behaviour would be questionable. + * In practice, clients do not accept a version mismatch and + * will abort the handshake with an error. */ - if ((s->new_session - && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) { - if (!ssl_get_new_session(s, 1)) - goto err; + if (i == 1 && s->version == s->session->ssl_version) { + /* previous session */ + s->hit = 1; + } else if (i == -1) { + goto err; } else { - /* - * TODO(openssl-team): ssl_get_prev_session passes a non-const - * 'unsigned char*' session id to a user callback. Grab a copy of - * the data? - */ - i = ssl_get_prev_session(s, &pkt, PACKET_data(&session_id), - PACKET_remaining(&session_id)); - /* - * Only resume if the session's version matches the negotiated - * version. - * RFC 5246 does not provide much useful advice on resumption - * with a different protocol version. It doesn't forbid it but - * the sanity of such behaviour would be questionable. - * In practice, clients do not accept a version mismatch and - * will abort the handshake with an error. - */ - if (i == 1 && s->version == s->session->ssl_version) { - /* previous session */ - s->hit = 1; - } else if (i == -1) + /* i == 0 */ + if (!ssl_get_new_session(s, 1)) goto err; - else { - /* i == 0 */ - if (!ssl_get_new_session(s, 1)) - goto err; - } } + } - if (SSL_IS_DTLS(s)) { - PACKET cookie; - if (!PACKET_get_length_prefixed_1(&pkt, &cookie)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - cookie_len = PACKET_remaining(&cookie); + if (SSL_IS_DTLS(s)) { + size_t cookie_len = PACKET_remaining(&cookie); + /* + * The ClientHello may contain a cookie even if the + * HelloVerify message has not been sent--make sure that it + * does not cause an overflow. + */ + if (cookie_len > sizeof(s->d1->rcvd_cookie)) { + /* too much data */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); + goto f_err; + } + + /* verify the cookie if appropriate option is set. */ + if ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) && cookie_len > 0) { + /* Get cookie */ /* - * The ClientHello may contain a cookie even if the - * HelloVerify message has not been sent--make sure that it - * does not cause an overflow. + * TODO(openssl-team): rcvd_cookie appears unused outside this + * function. Remove the field? */ - if (cookie_len > sizeof(s->d1->rcvd_cookie)) { - /* too much data */ - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); + if (!PACKET_copy_bytes(&cookie, s->d1->rcvd_cookie, cookie_len)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto f_err; } - /* verify the cookie if appropriate option is set. */ - if ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) - && cookie_len > 0) { - /* Get cookie */ - /* - * TODO(openssl-team): rcvd_cookie appears unused outside this - * function. Remove the field? - */ - if (!PACKET_copy_bytes(&cookie, s->d1->rcvd_cookie, cookie_len)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto f_err; - } - - if (s->ctx->app_verify_cookie_cb != NULL) { - if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie, - cookie_len) == 0) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_COOKIE_MISMATCH); - goto f_err; - } - /* else cookie verification succeeded */ - } - /* default verification */ - else if (memcmp(s->d1->rcvd_cookie, s->d1->cookie, - s->d1->cookie_len) != 0) { + if (s->ctx->app_verify_cookie_cb != NULL) { + if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie, + cookie_len) == 0) { al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); - goto f_err; - } - /* Set to -2 so if successful we return 2 */ - ret = -2; - } - if (s->method->version == DTLS_ANY_VERSION) { - /* Select version to use */ - if (s->client_version <= DTLS1_2_VERSION && - !(s->options & SSL_OP_NO_DTLSv1_2)) { - s->version = DTLS1_2_VERSION; - s->method = DTLSv1_2_server_method(); - } else if (tls1_suiteb(s)) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); - s->version = s->client_version; - al = SSL_AD_PROTOCOL_VERSION; - goto f_err; - } else if (s->client_version <= DTLS1_VERSION && - !(s->options & SSL_OP_NO_DTLSv1)) { - s->version = DTLS1_VERSION; - s->method = DTLSv1_server_method(); - } else { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_WRONG_VERSION_NUMBER); - s->version = s->client_version; - al = SSL_AD_PROTOCOL_VERSION; + SSL_R_COOKIE_MISMATCH); goto f_err; } - s->session->ssl_version = s->version; + /* else cookie verification succeeded */ } + /* default verification */ + else if (memcmp(s->d1->rcvd_cookie, s->d1->cookie, + s->d1->cookie_len) != 0) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); + goto f_err; + } + /* Set to -2 so if successful we return 2 */ + ret = -2; } - - if (!PACKET_get_length_prefixed_2(&pkt, &cipher_suite)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (PACKET_remaining(&cipher_suite) == 0) { - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_SPECIFIED); - goto f_err; + if (s->method->version == DTLS_ANY_VERSION) { + /* Select version to use */ + if (s->client_version <= DTLS1_2_VERSION && + !(s->options & SSL_OP_NO_DTLSv1_2)) { + s->version = DTLS1_2_VERSION; + s->method = DTLSv1_2_server_method(); + } else if (tls1_suiteb(s)) { + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, + SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); + s->version = s->client_version; + al = SSL_AD_PROTOCOL_VERSION; + goto f_err; + } else if (s->client_version <= DTLS1_VERSION && + !(s->options & SSL_OP_NO_DTLSv1)) { + s->version = DTLS1_VERSION; + s->method = DTLSv1_server_method(); + } else { + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, + SSL_R_WRONG_VERSION_NUMBER); + s->version = s->client_version; + al = SSL_AD_PROTOCOL_VERSION; + goto f_err; + } + s->session->ssl_version = s->version; } + } - if (ssl_bytes_to_cipher_list(s, PACKET_data(&cipher_suite), - PACKET_remaining(&cipher_suite), - &(ciphers), 0) == NULL) { - goto err; - } + if (ssl_bytes_to_cipher_list(s, &cipher_suites, &(ciphers), + is_v2_record, &al) == NULL) { + goto f_err; + } - /* If it is a hit, check that the cipher is in the list */ - if (s->hit) { - j = 0; - id = s->session->cipher->id; + /* If it is a hit, check that the cipher is in the list */ + if (s->hit) { + j = 0; + id = s->session->cipher->id; #ifdef CIPHER_DEBUG - fprintf(stderr, "client sent %d ciphers\n", - sk_SSL_CIPHER_num(ciphers)); + fprintf(stderr, "client sent %d ciphers\n", + sk_SSL_CIPHER_num(ciphers)); #endif - for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { - c = sk_SSL_CIPHER_value(ciphers, i); + for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { + c = sk_SSL_CIPHER_value(ciphers, i); #ifdef CIPHER_DEBUG - fprintf(stderr, "client [%2d of %2d]:%s\n", - i, sk_SSL_CIPHER_num(ciphers), SSL_CIPHER_get_name(c)); + fprintf(stderr, "client [%2d of %2d]:%s\n", + i, sk_SSL_CIPHER_num(ciphers), SSL_CIPHER_get_name(c)); #endif - if (c->id == id) { - j = 1; - break; - } - } - /* - * Disabled because it can be used in a ciphersuite downgrade - * attack: - * CVE-2010-4180. - */ -#if 0 - if (j == 0 && (s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) - && (sk_SSL_CIPHER_num(ciphers) == 1)) { - /* - * Special case as client bug workaround: the previously used - * cipher may not be in the current list, the client instead - * might be trying to continue using a cipher that before wasn't - * chosen due to server preferences. We'll have to reject the - * connection if the cipher is not enabled, though. - */ - c = sk_SSL_CIPHER_value(ciphers, 0); - if (sk_SSL_CIPHER_find(SSL_get_ciphers(s), c) >= 0) { - s->session->cipher = c; - j = 1; - } - } -#endif - if (j == 0) { - /* - * we need to have the cipher in the cipher list if we are asked - * to reuse it - */ - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_REQUIRED_CIPHER_MISSING); - goto f_err; + if (c->id == id) { + j = 1; + break; } } - - /* compression */ - if (!PACKET_get_length_prefixed_1(&pkt, &compression)) { - /* not enough data */ - al = SSL_AD_DECODE_ERROR; + if (j == 0) { /* - * TODO(openssl-team): - * SSL_R_LENGTH_TOO_SHORT and SSL_R_LENGTH_MISMATCH are used - * interchangeably. Pick one. + * we need to have the cipher in the cipher list if we are asked + * to reuse it */ - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, + SSL_R_REQUIRED_CIPHER_MISSING); goto f_err; } + } - complen = PACKET_remaining(&compression); - for (j = 0; j < complen; j++) { - if (PACKET_data(&compression)[j] == 0) - break; - } - - if (j >= complen) { - /* no compress */ - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED); - goto f_err; - } + complen = PACKET_remaining(&compression); + for (j = 0; j < complen; j++) { + if (PACKET_data(&compression)[j] == 0) + break; } + if (j >= complen) { + /* no compress */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED); + goto f_err; + } + /* TLS extensions */ if (s->version >= SSL3_VERSION) { - if (!ssl_parse_clienthello_tlsext(s, &pkt)) { + if (!ssl_parse_clienthello_tlsext(s, &extensions)) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT); goto err; } @@ -3505,32 +3445,40 @@ err: #define SSLV2_CIPHER_LEN 3 -STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, - int num, +STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, + PACKET *cipher_suites, STACK_OF(SSL_CIPHER) **skp, - int sslv2format) + int sslv2format, int *al + ) { const SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *sk; - int i, n; + int n; + /* 3 = SSLV2_CIPHER_LEN > TLS_CIPHER_LEN = 2. */ + unsigned char cipher[SSLV2_CIPHER_LEN]; - if (s->s3) - s->s3->send_connection_binding = 0; + s->s3->send_connection_binding = 0; - if(sslv2format) { - n = SSLV2_CIPHER_LEN; - } else { - n = TLS_CIPHER_LEN; + n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN; + + if (PACKET_remaining(cipher_suites) == 0) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED); + *al = SSL_AD_ILLEGAL_PARAMETER; + return NULL; } - if (n == 0 || (num % n) != 0) { + + if (PACKET_remaining(cipher_suites) % n != 0) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); - return (NULL); + *al = SSL_AD_DECODE_ERROR; + return NULL; } + if ((skp == NULL) || (*skp == NULL)) { sk = sk_SSL_CIPHER_new_null(); /* change perhaps later */ if(sk == NULL) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); + *al = SSL_AD_INTERNAL_ERROR; return NULL; } } else { @@ -3538,28 +3486,33 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, sk_SSL_CIPHER_zero(sk); } - OPENSSL_free(s->s3->tmp.ciphers_raw); - s->s3->tmp.ciphers_raw = BUF_memdup(p, num); - if (s->s3->tmp.ciphers_raw == NULL) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); + if (!PACKET_memdup(cipher_suites, &s->s3->tmp.ciphers_raw, + &s->s3->tmp.ciphers_rawlen)) { + *al = SSL_AD_INTERNAL_ERROR; goto err; } - s->s3->tmp.ciphers_rawlen = (size_t)num; - for (i = 0; i < num; i += n) { + while (PACKET_copy_bytes(cipher_suites, cipher, n)) { + /* + * We only support SSLv2 format ciphers in SSLv3+ using a + * SSLv2 backward compatible ClientHello. In this case the first + * byte is always 0 for SSLv3 compatible ciphers. Anything else + * is an SSLv2 cipher and we ignore it + */ + if (sslv2format && cipher[0] != '\0') + continue; + /* Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV */ - if (s->s3 && (n != 3 || !p[0]) && - (p[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && - (p[n - 1] == (SSL3_CK_SCSV & 0xff))) { + if ((cipher[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && + (cipher[n - 1] == (SSL3_CK_SCSV & 0xff))) { /* SCSV fatal if renegotiating */ if (s->renegotiate) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING); - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + *al = SSL_AD_HANDSHAKE_FAILURE; goto err; } s->s3->send_connection_binding = 1; - p += n; #ifdef OPENSSL_RI_DEBUG fprintf(stderr, "SCSV received by server\n"); #endif @@ -3567,9 +3520,8 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, } /* Check for TLS_FALLBACK_SCSV */ - if ((n != 3 || !p[0]) && - (p[n - 2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) && - (p[n - 1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) { + if ((cipher[n - 2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) && + (cipher[n - 1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) { /* * The SCSV indicates that the client previously tried a higher * version. Fail if the current version is an unexpected @@ -3578,37 +3530,27 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, if (!SSL_ctrl(s, SSL_CTRL_CHECK_PROTO_VERSION, 0, NULL)) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_INAPPROPRIATE_FALLBACK); - if (s->s3) - ssl3_send_alert(s, SSL3_AL_FATAL, - SSL_AD_INAPPROPRIATE_FALLBACK); + *al = SSL_AD_INAPPROPRIATE_FALLBACK; goto err; } - p += n; continue; } - if(sslv2format) { - /* - * We only support SSLv2 format ciphers in SSLv3+ using a - * SSLv2 backward compatible ClientHello. In this case the first - * byte is always 0 for SSLv3 compatible ciphers. Anything else - * is an SSLv2 cipher and we ignore it - */ - if(p[0] == 0) - c = ssl_get_cipher_by_char(s, &p[1]); - else - c = NULL; - } else { - c = ssl_get_cipher_by_char(s, p); - } - p += n; + /* For SSLv2-compat, ignore leading 0-byte. */ + c = ssl_get_cipher_by_char(s, sslv2format ? &cipher[1] : cipher); if (c != NULL) { if (!sk_SSL_CIPHER_push(sk, c)) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); + *al = SSL_AD_INTERNAL_ERROR; goto err; } } } + if (PACKET_remaining(cipher_suites) > 0) { + *al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_INTERNAL_ERROR); + goto err; + } if (skp != NULL) *skp = sk; @@ -3616,5 +3558,5 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, err: if ((skp == NULL) || (*skp == NULL)) sk_SSL_CIPHER_free(sk); - return (NULL); + return NULL; } diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 544c1ad..7c57509 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -1861,8 +1861,8 @@ __owur CERT *ssl_cert_dup(CERT *cert); void ssl_cert_clear_certs(CERT *c); void ssl_cert_free(CERT *c); __owur int ssl_get_new_session(SSL *s, int session); -__owur int ssl_get_prev_session(SSL *s, PACKET *pkt, unsigned char *session, - int len); +__owur int ssl_get_prev_session(SSL *s, const PACKET *ext, + const PACKET *session_id); __owur SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket); __owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id); @@ -2113,8 +2113,8 @@ __owur int tls1_process_heartbeat(SSL *s, unsigned char *p, unsigned int length) __owur int dtls1_process_heartbeat(SSL *s, unsigned char *p, unsigned int length); # endif -__owur int tls1_process_ticket(SSL *s, PACKET *pkt, unsigned char *session_id, - int len, SSL_SESSION **ret); +__owur int tls1_process_ticket(SSL *s, const PACKET *ext, + const PACKET *session_id, SSL_SESSION **ret); __owur int tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, const EVP_MD *md); diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 3774db4..7660292 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -513,11 +513,8 @@ int ssl_get_new_session(SSL *s, int session) * ssl_get_prev attempts to find an SSL_SESSION to be used to resume this * connection. It is only called by servers. * - * session_id: points at the session ID in the ClientHello. This code will - * read past the end of this in order to parse out the session ticket - * extension, if any. - * len: the length of the session ID. - * limit: a pointer to the first byte after the ClientHello. + * ext: ClientHello extensions (including length prefix) + * session_id: ClientHello session ID. * * Returns: * -1: error @@ -529,8 +526,7 @@ int ssl_get_new_session(SSL *s, int session) * - Both for new and resumed sessions, s->tlsext_ticket_expected is set to 1 * if the server should issue a new session ticket (to 0 otherwise). */ -int ssl_get_prev_session(SSL *s, PACKET *pkt, unsigned char *session_id, - int len) +int ssl_get_prev_session(SSL *s, const PACKET *ext, const PACKET *session_id) { /* This is used only by servers. */ @@ -538,15 +534,16 @@ int ssl_get_prev_session(SSL *s, PACKET *pkt, unsigned char *session_id, int fatal = 0; int try_session_cache = 1; int r; + size_t len = PACKET_remaining(session_id); - if (len < 0 || len > SSL_MAX_SSL_SESSION_ID_LENGTH) + if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) goto err; if (len == 0) try_session_cache = 0; /* sets s->tlsext_ticket_expected */ - r = tls1_process_ticket(s, pkt, session_id, len, &ret); + r = tls1_process_ticket(s, ext, session_id, &ret); switch (r) { case -1: /* Error during processing */ fatal = 1; @@ -567,11 +564,14 @@ int ssl_get_prev_session(SSL *s, PACKET *pkt, unsigned char *session_id, !(s->session_ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) { SSL_SESSION data; + size_t local_len; data.ssl_version = s->version; - data.session_id_length = len; - if (len == 0) - return 0; - memcpy(data.session_id, session_id, len); + if (!PACKET_copy_all(session_id, data.session_id, + sizeof(data.session_id), + &local_len)) { + goto err; + } + data.session_id_length = local_len; CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); ret = lh_SSL_SESSION_retrieve(s->session_ctx->sessions, &data); if (ret != NULL) { @@ -586,8 +586,15 @@ int ssl_get_prev_session(SSL *s, PACKET *pkt, unsigned char *session_id, if (try_session_cache && ret == NULL && s->session_ctx->get_session_cb != NULL) { int copy = 1; + /* The user callback takes a non-const pointer, so grab a local copy. */ + unsigned char *sid = NULL; + size_t sid_len; + if (!PACKET_memdup(session_id, &sid, &sid_len)) + goto err; + ret = s->session_ctx->get_session_cb(s, sid, sid_len, ©); + OPENSSL_free(sid); - if ((ret = s->session_ctx->get_session_cb(s, session_id, len, ©))) { + if (ret != NULL) { s->session_ctx->stats.sess_cb_hit++; /* diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 463f34e..aeae5b0 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -2901,11 +2901,8 @@ int ssl_parse_serverhello_tlsext(SSL *s, PACKET *pkt) * ClientHello, and other operations depend on the result, we need to handle * any TLS session ticket extension at the same time. * - * session_id: points at the session ID in the ClientHello. This code will - * read past the end of this in order to parse out the session ticket - * extension, if any. - * len: the length of the session ID. - * limit: a pointer to the first byte after the ClientHello. + * session_id: ClientHello session ID. + * ext: ClientHello extensions (including length prefix) * ret: (output) on return, if a ticket was decrypted, then this is set to * point to the resulting session. * @@ -2930,11 +2927,11 @@ int ssl_parse_serverhello_tlsext(SSL *s, PACKET *pkt) * s->ctx->tlsext_ticket_key_cb asked to renew the client's ticket. * Otherwise, s->tlsext_ticket_expected is set to 0. */ -int tls1_process_ticket(SSL *s, PACKET *pkt, unsigned char *session_id, - int len, SSL_SESSION **ret) +int tls1_process_ticket(SSL *s, const PACKET *ext, const PACKET *session_id, + SSL_SESSION **ret) { unsigned int i; - PACKET bookmark = *pkt; + PACKET local_ext = *ext; int retv = -1; *ret = NULL; @@ -2949,38 +2946,20 @@ int tls1_process_ticket(SSL *s, PACKET *pkt, unsigned char *session_id, if ((s->version <= SSL3_VERSION)) return 0; - /* Skip past DTLS cookie */ - if (SSL_IS_DTLS(s)) { - if (!PACKET_get_1(pkt, &i) - || !PACKET_forward(pkt, i)) { - retv = -1; - goto end; - } - } - /* Skip past cipher list and compression algorithm list */ - if (!PACKET_get_net_2(pkt, &i) - || !PACKET_forward(pkt, i) - || !PACKET_get_1(pkt, &i) - || !PACKET_forward(pkt, i)) { - retv = -1; - goto end; - } - - /* Now at start of extensions */ - if (!PACKET_get_net_2(pkt, &i)) { + if (!PACKET_get_net_2(&local_ext, &i)) { retv = 0; goto end; } - while (PACKET_remaining (pkt) >= 4) { + while (PACKET_remaining(&local_ext) >= 4) { unsigned int type, size; - if (!PACKET_get_net_2(pkt, &type) - || !PACKET_get_net_2(pkt, &size)) { + if (!PACKET_get_net_2(&local_ext, &type) + || !PACKET_get_net_2(&local_ext, &size)) { /* Shouldn't ever happen */ retv = -1; goto end; } - if (PACKET_remaining(pkt) < size) { + if (PACKET_remaining(&local_ext) < size) { retv = 0; goto end; } @@ -3007,12 +2986,13 @@ int tls1_process_ticket(SSL *s, PACKET *pkt, unsigned char *session_id, retv = 2; goto end; } - if (!PACKET_get_bytes(pkt, &etick, size)) { + if (!PACKET_get_bytes(&local_ext, &etick, size)) { /* Shouldn't ever happen */ retv = -1; goto end; } - r = tls_decrypt_ticket(s, etick, size, session_id, len, ret); + r = tls_decrypt_ticket(s, etick, size, PACKET_data(session_id), + PACKET_remaining(session_id), ret); switch (r) { case 2: /* ticket couldn't be decrypted */ s->tlsext_ticket_expected = 1; @@ -3031,7 +3011,7 @@ int tls1_process_ticket(SSL *s, PACKET *pkt, unsigned char *session_id, } goto end; } else { - if (!PACKET_forward(pkt, size)) { + if (!PACKET_forward(&local_ext, size)) { retv = -1; goto end; } @@ -3039,7 +3019,6 @@ int tls1_process_ticket(SSL *s, PACKET *pkt, unsigned char *session_id, } retv = 0; end: - *pkt = bookmark; return retv; } diff --git a/test/packettest.c b/test/packettest.c index 6ee2ab1..915b42b 100644 --- a/test/packettest.c +++ b/test/packettest.c @@ -240,6 +240,25 @@ static int test_PACKET_copy_bytes(unsigned char buf[BUF_LEN]) return 1; } +static int test_PACKET_copy_all(unsigned char buf[BUF_LEN]) +{ + unsigned char dup[BUF_LEN]; + PACKET pkt; + size_t len; + + if ( !PACKET_buf_init(&pkt, buf, BUF_LEN) + || !PACKET_copy_all(&pkt, dup, BUF_LEN, &len) + || len != BUF_LEN + || memcmp(buf, dup, BUF_LEN) != 0 + || PACKET_remaining(&pkt) != BUF_LEN + || PACKET_copy_all(&pkt, dup, BUF_LEN - 1, &len)) { + fprintf(stderr, "test_PACKET_copy_bytes() failed\n"); + return 0; + } + + return 1; +} + static int test_PACKET_memdup(unsigned char buf[BUF_LEN]) { unsigned char *data = NULL; @@ -314,7 +333,7 @@ static int test_PACKET_buf_init() unsigned char buf[BUF_LEN]; PACKET pkt; - /* Also tests PACKET_get_len() */ + /* Also tests PACKET_remaining() */ if ( !PACKET_buf_init(&pkt, buf, 4) || PACKET_remaining(&pkt) != 4 || !PACKET_buf_init(&pkt, buf, BUF_LEN) @@ -327,6 +346,20 @@ static int test_PACKET_buf_init() return 1; } +static int test_PACKET_null_init() +{ + PACKET pkt; + + PACKET_null_init(&pkt); + if ( PACKET_remaining(&pkt) != 0 + || PACKET_forward(&pkt, 1)) { + fprintf(stderr, "test_PACKET_null_init() failed\n"); + return 0; + } + + return 1; +} + static int test_PACKET_get_length_prefixed_1() { unsigned char buf[BUF_LEN]; @@ -417,6 +450,7 @@ int main(int argc, char **argv) i = 0; if ( !test_PACKET_buf_init() + || !test_PACKET_null_init() || !test_PACKET_remaining(buf) || !test_PACKET_get_1(buf) || !test_PACKET_get_4(buf) @@ -426,6 +460,7 @@ int main(int argc, char **argv) || !test_PACKET_get_sub_packet(buf) || !test_PACKET_get_bytes(buf) || !test_PACKET_copy_bytes(buf) + || !test_PACKET_copy_all(buf) || !test_PACKET_memdup(buf) || !test_PACKET_strndup() || !test_PACKET_forward(buf) From matt at openssl.org Mon Oct 5 18:59:05 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 05 Oct 2015 18:59:05 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444071545.958032.20132.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via f141376ae2892b59f2b1af94204f925832f8dc3a (commit) via e4840c88c516d959785fcd842d8658d3b7a6ae43 (commit) from 67d42531744e56d11212ee000e4559cf95ac57a7 (commit) - Log ----------------------------------------------------------------- commit f141376ae2892b59f2b1af94204f925832f8dc3a Author: Matt Caswell Date: Mon Oct 5 14:12:05 2015 +0100 Change functions to pass in a limit rather than calculate it Some extension handling functions were passing in a pointer to the start of the data, plus the length in order to calculate the end, rather than just passing in the end to start with. This change makes things a little more readable. Reviewed-by: Emilia K?sper Conflicts: ssl/s3_srvr.c ssl/ssl_locl.h ssl/t1_lib.c commit e4840c88c516d959785fcd842d8658d3b7a6ae43 Author: Alessandro Ghedini Date: Fri Oct 2 14:38:30 2015 +0200 Validate ClientHello extension field length RT#4069 Reviewed-by: Emilia K?sper Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: ssl/s3_srvr.c | 2 +- ssl/ssl_locl.h | 2 +- ssl/t1_lib.c | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 3a5f71d..208063c 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -1264,7 +1264,7 @@ int ssl3_get_client_hello(SSL *s) #ifndef OPENSSL_NO_TLSEXT /* TLS extensions */ if (s->version >= SSL3_VERSION) { - if (!ssl_parse_clienthello_tlsext(s, &p, d, n, &al)) { + if (!ssl_parse_clienthello_tlsext(s, &p, d + n, &al)) { /* 'al' set by ssl_parse_clienthello_tlsext */ SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT); goto f_err; diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index a7f3f8d..5edf7a8 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -1154,7 +1154,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit); int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **data, - unsigned char *d, int n, int *al); + unsigned char *limit, int *al); int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **data, unsigned char *d, int n, int *al); int ssl_prepare_clienthello_tlsext(SSL *s); diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index d70b93f..b1b8bb0 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -913,7 +913,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, * 10.8..10.8.3 (which don't work). */ static void ssl_check_for_safari(SSL *s, const unsigned char *data, - const unsigned char *d, int n) + const unsigned char *limit) { unsigned short type, size; static const unsigned char kSafariExtensionsBlock[] = { @@ -942,11 +942,11 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, 0x02, 0x03, /* SHA-1/ECDSA */ }; - if (data >= (d + n - 2)) + if (data >= (limit - 2)) return; data += 2; - if (data > (d + n - 4)) + if (data > (limit - 4)) return; n2s(data, type); n2s(data, size); @@ -954,7 +954,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, if (type != TLSEXT_TYPE_server_name) return; - if (data + size > d + n) + if (data + size > limit) return; data += size; @@ -962,7 +962,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, const size_t len1 = sizeof(kSafariExtensionsBlock); const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock); - if (data + len1 + len2 != d + n) + if (data + len1 + len2 != limit) return; if (memcmp(data, kSafariExtensionsBlock, len1) != 0) return; @@ -971,7 +971,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, } else { const size_t len = sizeof(kSafariExtensionsBlock); - if (data + len != d + n) + if (data + len != limit) return; if (memcmp(data, kSafariExtensionsBlock, len) != 0) return; @@ -981,8 +981,8 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, } # endif /* !OPENSSL_NO_EC */ -int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, - int n, int *al) +int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + unsigned char *limit, int *al) { unsigned short type; unsigned short size; @@ -1004,7 +1004,7 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, # ifndef OPENSSL_NO_EC if (s->options & SSL_OP_SAFARI_ECDHE_ECDSA_BUG) - ssl_check_for_safari(s, data, d, n); + ssl_check_for_safari(s, data, limit); # endif /* !OPENSSL_NO_EC */ # ifndef OPENSSL_NO_SRP @@ -1016,22 +1016,22 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, s->srtp_profile = NULL; - if (data == d + n) + if (data == limit) goto ri_check; - if (data > (d + n - 2)) + if (data > (limit - 2)) goto err; n2s(data, len); - if (data > (d + n - len)) + if (data + len != limit) goto err; - while (data <= (d + n - 4)) { + while (data <= (limit - 4)) { n2s(data, type); n2s(data, size); - if (data + size > (d + n)) + if (data + size > (limit)) goto err; # if 0 fprintf(stderr, "Received extension type %d size %d\n", type, size); @@ -1396,7 +1396,7 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, } /* Spurious data on the end */ - if (data != d + n) + if (data != limit) goto err; *p = data; From matt at openssl.org Mon Oct 5 18:59:19 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 05 Oct 2015 18:59:19 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444071559.218935.20375.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via 61dfe3a720b37efe97fa5de23ceadd17ce47518d (commit) via 184718baabed00fecbc89fdd84b44014fcd6c444 (commit) from 6b247c181726e7dd3744570b850c0cef60776c55 (commit) - Log ----------------------------------------------------------------- commit 61dfe3a720b37efe97fa5de23ceadd17ce47518d Author: Matt Caswell Date: Mon Oct 5 14:12:05 2015 +0100 Change functions to pass in a limit rather than calculate it Some extension handling functions were passing in a pointer to the start of the data, plus the length in order to calculate the end, rather than just passing in the end to start with. This change makes things a little more readable. Reviewed-by: Emilia K?sper commit 184718baabed00fecbc89fdd84b44014fcd6c444 Author: Alessandro Ghedini Date: Fri Oct 2 14:38:30 2015 +0200 Validate ClientHello extension field length RT#4069 Reviewed-by: Emilia K?sper Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: ssl/s3_srvr.c | 2 +- ssl/ssl_locl.h | 2 +- ssl/t1_lib.c | 36 ++++++++++++++++++------------------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index acd3b9e..a355fde 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -1231,7 +1231,7 @@ int ssl3_get_client_hello(SSL *s) #ifndef OPENSSL_NO_TLSEXT /* TLS extensions */ if (s->version >= SSL3_VERSION) { - if (!ssl_parse_clienthello_tlsext(s, &p, d, n)) { + if (!ssl_parse_clienthello_tlsext(s, &p, d + n)) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT); goto err; } diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 6c2c551..1caf83b 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -1366,7 +1366,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit, int *al); int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **data, - unsigned char *d, int n); + unsigned char *limit); int tls1_set_server_sigalgs(SSL *s); int ssl_check_clienthello_tlsext_late(SSL *s); int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **data, diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 210a5e8..ba09848 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1837,7 +1837,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, * 10.8..10.8.3 (which don't work). */ static void ssl_check_for_safari(SSL *s, const unsigned char *data, - const unsigned char *d, int n) + const unsigned char *limit) { unsigned short type, size; static const unsigned char kSafariExtensionsBlock[] = { @@ -1866,11 +1866,11 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, 0x02, 0x03, /* SHA-1/ECDSA */ }; - if (data >= (d + n - 2)) + if (data >= (limit - 2)) return; data += 2; - if (data > (d + n - 4)) + if (data > (limit - 4)) return; n2s(data, type); n2s(data, size); @@ -1878,7 +1878,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, if (type != TLSEXT_TYPE_server_name) return; - if (data + size > d + n) + if (data + size > limit) return; data += size; @@ -1886,7 +1886,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, const size_t len1 = sizeof(kSafariExtensionsBlock); const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock); - if (data + len1 + len2 != d + n) + if (data + len1 + len2 != limit) return; if (memcmp(data, kSafariExtensionsBlock, len1) != 0) return; @@ -1895,7 +1895,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, } else { const size_t len = sizeof(kSafariExtensionsBlock); - if (data + len != d + n) + if (data + len != limit) return; if (memcmp(data, kSafariExtensionsBlock, len) != 0) return; @@ -1974,7 +1974,7 @@ static int tls1_alpn_handle_client_hello(SSL *s, const unsigned char *data, } static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, - unsigned char *d, int n, int *al) + unsigned char *limit, int *al) { unsigned short type; unsigned short size; @@ -1999,7 +1999,7 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, # ifndef OPENSSL_NO_EC if (s->options & SSL_OP_SAFARI_ECDHE_ECDSA_BUG) - ssl_check_for_safari(s, data, d, n); + ssl_check_for_safari(s, data, limit); # endif /* !OPENSSL_NO_EC */ /* Clear any signature algorithms extension received */ @@ -2016,22 +2016,22 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, s->srtp_profile = NULL; - if (data == d + n) + if (data == limit) goto ri_check; - if (data > (d + n - 2)) + if (data > (limit - 2)) goto err; n2s(data, len); - if (data > (d + n - len)) + if (data + len != limit) goto err; - while (data <= (d + n - 4)) { + while (data <= (limit - 4)) { n2s(data, type); n2s(data, size); - if (data + size > (d + n)) + if (data + size > (limit)) goto err; # if 0 fprintf(stderr, "Received extension type %d size %d\n", type, size); @@ -2405,7 +2405,7 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, } /* Spurious data on the end */ - if (data != d + n) + if (data != limit) goto err; *p = data; @@ -2465,8 +2465,8 @@ static int ssl_scan_clienthello_custom_tlsext(SSL *s, return 1; } -int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, - int n) +int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, + unsigned char *limit) { int al = -1; unsigned char *ptmp = *p; @@ -2476,7 +2476,7 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, * switch the parent context using SSL_set_SSL_CTX and custom extensions * need to be handled by the new SSL_CTX structure. */ - if (ssl_scan_clienthello_tlsext(s, p, d, n, &al) <= 0) { + if (ssl_scan_clienthello_tlsext(s, p, limit, &al) <= 0) { ssl3_send_alert(s, SSL3_AL_FATAL, al); return 0; } @@ -2487,7 +2487,7 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, } custom_ext_init(&s->cert->srv_ext); - if (ssl_scan_clienthello_custom_tlsext(s, ptmp, d + n, &al) <= 0) { + if (ssl_scan_clienthello_custom_tlsext(s, ptmp, limit, &al) <= 0) { ssl3_send_alert(s, SSL3_AL_FATAL, al); return 0; } From matt at openssl.org Mon Oct 5 18:59:30 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 05 Oct 2015 18:59:30 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444071570.651637.20612.nullmailer@dev.openssl.org> The branch master has been updated via 52a48f9eed73503c691056b5832b3eb04b95ea00 (commit) from 67202973cf55eaac021706c183377b8040cf0c20 (commit) - Log ----------------------------------------------------------------- commit 52a48f9eed73503c691056b5832b3eb04b95ea00 Author: Alessandro Ghedini Date: Fri Oct 2 13:43:29 2015 +0200 Validate ClientHello extension field length RT#4069 Reviewed-by: Emilia K?sper Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: ssl/t1_lib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index aeae5b0..4975c10 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1927,6 +1927,9 @@ static int ssl_scan_clienthello_tlsext(SSL *s, PACKET *pkt, int *al) if (!PACKET_get_net_2(pkt, &len)) goto err; + if (PACKET_remaining(pkt) != len) + goto err; + while (PACKET_get_net_2(pkt, &type) && PACKET_get_net_2(pkt, &size)) { PACKET subpkt; From matt at openssl.org Mon Oct 5 20:57:43 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 05 Oct 2015 20:57:43 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444078663.103149.8313.nullmailer@dev.openssl.org> The branch master has been updated via 52ee3ed3a11024ab6e11c5705da6c3ba17cf7d98 (commit) from 52a48f9eed73503c691056b5832b3eb04b95ea00 (commit) - Log ----------------------------------------------------------------- commit 52ee3ed3a11024ab6e11c5705da6c3ba17cf7d98 Author: Dmitry Belyavskiy Date: Sun Oct 4 12:11:26 2015 +0300 New cipher and cipher modes standardized in Russia This change introduces short names and NIDs for Russian GOST ciphers according to GOST R 34.13-2015 Reviewed-by: Richard Levitte Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: crypto/objects/obj_dat.h | 33 ++++++++++++++++++++++++++++++--- crypto/objects/obj_mac.num | 9 +++++++++ crypto/objects/objects.txt | 11 +++++++++++ include/openssl/obj_mac.h | 27 +++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 6210784..9fd2059 100644 --- a/crypto/objects/obj_dat.h +++ b/crypto/objects/obj_dat.h @@ -62,9 +62,9 @@ * [including the GNU Public Licence.] */ -#define NUM_NID 1009 -#define NUM_SN 1002 -#define NUM_LN 1002 +#define NUM_NID 1018 +#define NUM_SN 1011 +#define NUM_LN 1011 #define NUM_OBJ 936 static const unsigned char lvalues[6604]={ @@ -2658,6 +2658,15 @@ static const ASN1_OBJECT nid_objs[NUM_NID]={ &(lvalues[6593]),0}, {"issuerSignTool","Signing Tool of Issuer",NID_issuerSignTool,5, &(lvalues[6598]),0}, +{"gost89-cbc","gost89-cbc",NID_gost89_cbc,0,NULL,0}, +{"gost89-ecb","gost89-ecb",NID_gost89_ecb,0,NULL,0}, +{"gost89-ctr","gost89-ctr",NID_gost89_ctr,0,NULL,0}, +{"grasshopper-ecb","grasshopper-ecb",NID_grasshopper_ecb,0,NULL,0}, +{"grasshopper-ctr","grasshopper-ctr",NID_grasshopper_ctr,0,NULL,0}, +{"grasshopper-ofb","grasshopper-ofb",NID_grasshopper_ofb,0,NULL,0}, +{"grasshopper-cbc","grasshopper-cbc",NID_grasshopper_cbc,0,NULL,0}, +{"grasshopper-cfb","grasshopper-cfb",NID_grasshopper_cfb,0,NULL,0}, +{"grasshopper-mac","grasshopper-mac",NID_grasshopper_mac,0,NULL,0}, }; static const unsigned int sn_objs[NUM_SN]={ @@ -3025,10 +3034,19 @@ static const unsigned int sn_objs[NUM_SN]={ 979, /* "gost2012_256" */ 980, /* "gost2012_512" */ 813, /* "gost89" */ +1009, /* "gost89-cbc" */ 814, /* "gost89-cnt" */ 975, /* "gost89-cnt-12" */ +1011, /* "gost89-ctr" */ +1010, /* "gost89-ecb" */ 812, /* "gost94" */ 850, /* "gost94cc" */ +1015, /* "grasshopper-cbc" */ +1016, /* "grasshopper-cfb" */ +1013, /* "grasshopper-ctr" */ +1012, /* "grasshopper-ecb" */ +1017, /* "grasshopper-mac" */ +1014, /* "grasshopper-ofb" */ 797, /* "hmacWithMD5" */ 163, /* "hmacWithSHA1" */ 798, /* "hmacWithSHA224" */ @@ -4053,8 +4071,17 @@ static const unsigned int ln_objs[NUM_LN]={ 601, /* "generic cryptogram" */ 99, /* "givenName" */ 976, /* "gost-mac-12" */ +1009, /* "gost89-cbc" */ 814, /* "gost89-cnt" */ 975, /* "gost89-cnt-12" */ +1011, /* "gost89-ctr" */ +1010, /* "gost89-ecb" */ +1015, /* "grasshopper-cbc" */ +1016, /* "grasshopper-cfb" */ +1013, /* "grasshopper-ctr" */ +1012, /* "grasshopper-ecb" */ +1017, /* "grasshopper-mac" */ +1014, /* "grasshopper-ofb" */ 855, /* "hmac" */ 780, /* "hmac-md5" */ 781, /* "hmac-sha1" */ diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index e813b62..ac8a1a2 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -1006,3 +1006,12 @@ OGRN 1005 SNILS 1006 subjectSignTool 1007 issuerSignTool 1008 +gost89_cbc 1009 +gost89_ecb 1010 +gost89_ctr 1011 +grasshopper_ecb 1012 +grasshopper_ctr 1013 +grasshopper_ofb 1014 +grasshopper_cbc 1015 +grasshopper_cfb 1016 +grasshopper_mac 1017 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index 06928c6..9f5f6c4 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -1171,6 +1171,9 @@ cryptopro 20 : gost94 : GOST R 34.10-94 cryptopro 21 : gost89 : GOST 28147-89 : gost89-cnt : gost89-cnt-12 + : gost89-cbc + : gost89-ecb + : gost89-ctr !Cname id-Gost28147-89-MAC cryptopro 22 : gost-mac : GOST 28147-89 MAC : gost-mac-12 @@ -1280,6 +1283,14 @@ member-body 643 100 3 : SNILS : SNILS member-body 643 100 111 : subjectSignTool : Signing Tool of Subject member-body 643 100 112 : issuerSignTool : Signing Tool of Issuer +#GOST R34.13-2015 Grasshopper "Kuznechik" + : grasshopper-ecb + : grasshopper-ctr + : grasshopper-ofb + : grasshopper-cbc + : grasshopper-cfb + : grasshopper-mac + # Definitions for Camellia cipher - CBC MODE 1 2 392 200011 61 1 1 1 2 : CAMELLIA-128-CBC : camellia-128-cbc diff --git a/include/openssl/obj_mac.h b/include/openssl/obj_mac.h index fdf5b62..4388f70 100644 --- a/include/openssl/obj_mac.h +++ b/include/openssl/obj_mac.h @@ -3735,6 +3735,15 @@ #define SN_gost89_cnt_12 "gost89-cnt-12" #define NID_gost89_cnt_12 975 +#define SN_gost89_cbc "gost89-cbc" +#define NID_gost89_cbc 1009 + +#define SN_gost89_ecb "gost89-ecb" +#define NID_gost89_ecb 1010 + +#define SN_gost89_ctr "gost89-ctr" +#define NID_gost89_ctr 1011 + #define SN_id_Gost28147_89_MAC "gost-mac" #define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC" #define NID_id_Gost28147_89_MAC 815 @@ -4053,6 +4062,24 @@ #define NID_issuerSignTool 1008 #define OBJ_issuerSignTool OBJ_member_body,643L,100L,112L +#define SN_grasshopper_ecb "grasshopper-ecb" +#define NID_grasshopper_ecb 1012 + +#define SN_grasshopper_ctr "grasshopper-ctr" +#define NID_grasshopper_ctr 1013 + +#define SN_grasshopper_ofb "grasshopper-ofb" +#define NID_grasshopper_ofb 1014 + +#define SN_grasshopper_cbc "grasshopper-cbc" +#define NID_grasshopper_cbc 1015 + +#define SN_grasshopper_cfb "grasshopper-cfb" +#define NID_grasshopper_cfb 1016 + +#define SN_grasshopper_mac "grasshopper-mac" +#define NID_grasshopper_mac 1017 + #define SN_camellia_128_cbc "CAMELLIA-128-CBC" #define LN_camellia_128_cbc "camellia-128-cbc" #define NID_camellia_128_cbc 751 From appro at openssl.org Tue Oct 6 07:45:02 2015 From: appro at openssl.org (Andy Polyakov) Date: Tue, 06 Oct 2015 07:45:02 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444117502.520018.861.nullmailer@dev.openssl.org> The branch master has been updated via f4bd5de54459cc5f873807c7ed1f1b04b6e8d7e3 (commit) from 52ee3ed3a11024ab6e11c5705da6c3ba17cf7d98 (commit) - Log ----------------------------------------------------------------- commit f4bd5de54459cc5f873807c7ed1f1b04b6e8d7e3 Author: Andy Polyakov Date: Mon Oct 5 15:23:37 2015 +0200 Address more Windows warnings illuminated by mingw. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: include/openssl/e_os2.h | 8 ++++++-- ssl/record/rec_layer_s3.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h index 6ef1f39..23602a5 100644 --- a/include/openssl/e_os2.h +++ b/include/openssl/e_os2.h @@ -262,8 +262,12 @@ extern "C" { # define OPENSSL_GLOBAL_REF(name) _shadow_##name # endif -# ifdef OPENSSL_SYS_MSDOS -# define ossl_ssize_t long +# ifdef _WIN32 +# ifdef _WIN64 +# define ossl_ssize_t __int64 +# else +# define ossl_ssize_t int +# endif # endif # if defined(__ultrix) && !defined(ssize_t) diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 6beb8ce..f5dd27a 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -293,7 +293,7 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) * s->packet_length bytes if extend == 1].) */ int i, len, left; - long align = 0; + size_t align = 0; unsigned char *pkt; SSL3_BUFFER *rb; @@ -307,8 +307,8 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) left = rb->left; #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 - align = (long)rb->buf + SSL3_RT_HEADER_LENGTH; - align = (-align) & (SSL3_ALIGN_PAYLOAD - 1); + align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH; + align = (0-align) & (SSL3_ALIGN_PAYLOAD - 1); #endif if (!extend) { @@ -673,7 +673,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, int i, mac_size, clear = 0; int prefix_len = 0; int eivlen; - long align = 0; + size_t align = 0; SSL3_RECORD *wr; SSL3_BUFFER *wb = &s->rlayer.wbuf; SSL_SESSION *sess; @@ -753,8 +753,8 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, * multiple of SSL3_ALIGN_PAYLOAD, so if we want to align the real * payload, then we can just pretent we simply have two headers. */ - align = (long)SSL3_BUFFER_get_buf(wb) + 2 * SSL3_RT_HEADER_LENGTH; - align = (-align) & (SSL3_ALIGN_PAYLOAD - 1); + align = (size_t)SSL3_BUFFER_get_buf(wb) + 2 * SSL3_RT_HEADER_LENGTH; + align = (0-align) & (SSL3_ALIGN_PAYLOAD - 1); #endif p = SSL3_BUFFER_get_buf(wb) + align; SSL3_BUFFER_set_offset(wb, align); @@ -762,8 +762,8 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, p = SSL3_BUFFER_get_buf(wb) + SSL3_BUFFER_get_offset(wb) + prefix_len; } else { #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 - align = (long)SSL3_BUFFER_get_buf(wb) + SSL3_RT_HEADER_LENGTH; - align = (-align) & (SSL3_ALIGN_PAYLOAD - 1); + align = (size_t)SSL3_BUFFER_get_buf(wb) + SSL3_RT_HEADER_LENGTH; + align = (0-align) & (SSL3_ALIGN_PAYLOAD - 1); #endif p = SSL3_BUFFER_get_buf(wb) + align; SSL3_BUFFER_set_offset(wb, align); From steve at openssl.org Tue Oct 6 14:15:33 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 06 Oct 2015 14:15:33 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444140933.862323.22681.nullmailer@dev.openssl.org> The branch master has been updated via e58c4d3cdde7a0a01df2884bfeec31a2b07be22d (commit) from f4bd5de54459cc5f873807c7ed1f1b04b6e8d7e3 (commit) - Log ----------------------------------------------------------------- commit e58c4d3cdde7a0a01df2884bfeec31a2b07be22d Author: Dr. Stephen Henson Date: Tue Oct 6 14:15:14 2015 +0100 Don't try and parse boolean type. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: apps/asn1pars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 89afd5b..574b03f 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -279,9 +279,9 @@ int asn1parse_main(int argc, char **argv) } typ = ASN1_TYPE_get(at); if ((typ == V_ASN1_OBJECT) + || (typ == V_ASN1_BOOLEAN) || (typ == V_ASN1_NULL)) { - BIO_printf(bio_err, "Can't parse %s type\n", - typ == V_ASN1_NULL ? "NULL" : "OBJECT"); + BIO_printf(bio_err, "Can't parse %s type\n", ASN1_tag2str(typ)); ERR_print_errors(bio_err); goto end; } From steve at openssl.org Tue Oct 6 14:19:18 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 06 Oct 2015 14:19:18 +0000 Subject: [openssl-commits] [openssl] OpenSSL_0_9_8-stable update Message-ID: <1444141158.125273.23968.nullmailer@dev.openssl.org> The branch OpenSSL_0_9_8-stable has been updated via cc21b51add2415cc63113b71b34bc1c7b588e67d (commit) from 89133ba26a1c9e0fa99dd2cc782fa504ea3a5137 (commit) - Log ----------------------------------------------------------------- commit cc21b51add2415cc63113b71b34bc1c7b588e67d Author: Dr. Stephen Henson Date: Tue Oct 6 14:15:14 2015 +0100 Don't try and parse boolean type. Reviewed-by: Rich Salz (cherry picked from commit e58c4d3cdde7a0a01df2884bfeec31a2b07be22d) ----------------------------------------------------------------------- Summary of changes: apps/asn1pars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 3c9da5c..e3751f4 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -313,9 +313,9 @@ int MAIN(int argc, char **argv) } typ = ASN1_TYPE_get(at); if ((typ == V_ASN1_OBJECT) + || (typ == V_ASN1_BOOLEAN) || (typ == V_ASN1_NULL)) { - BIO_printf(bio_err, "Can't parse %s type\n", - typ == V_ASN1_NULL ? "NULL" : "OBJECT"); + BIO_printf(bio_err, "Can't parse %s type\n", ASN1_tag2str(typ)); ERR_print_errors(bio_err); goto end; } From steve at openssl.org Tue Oct 6 14:19:18 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 06 Oct 2015 14:19:18 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_0-stable update Message-ID: <1444141158.215376.23991.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_0-stable has been updated via 54edf96459dbece958707c6a8e92e82ada1d1c59 (commit) from 63bd50533e42ca1823a92e4ed18485d6b3dea27d (commit) - Log ----------------------------------------------------------------- commit 54edf96459dbece958707c6a8e92e82ada1d1c59 Author: Dr. Stephen Henson Date: Tue Oct 6 14:15:14 2015 +0100 Don't try and parse boolean type. Reviewed-by: Rich Salz (cherry picked from commit e58c4d3cdde7a0a01df2884bfeec31a2b07be22d) ----------------------------------------------------------------------- Summary of changes: apps/asn1pars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 7a0f169..70824e6 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -313,9 +313,9 @@ int MAIN(int argc, char **argv) } typ = ASN1_TYPE_get(at); if ((typ == V_ASN1_OBJECT) + || (typ == V_ASN1_BOOLEAN) || (typ == V_ASN1_NULL)) { - BIO_printf(bio_err, "Can't parse %s type\n", - typ == V_ASN1_NULL ? "NULL" : "OBJECT"); + BIO_printf(bio_err, "Can't parse %s type\n", ASN1_tag2str(typ)); ERR_print_errors(bio_err); goto end; } From steve at openssl.org Tue Oct 6 14:19:18 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 06 Oct 2015 14:19:18 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444141158.333252.24012.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via a0ba92ccde949582e498cb42bced205ec1c95a3c (commit) from f141376ae2892b59f2b1af94204f925832f8dc3a (commit) - Log ----------------------------------------------------------------- commit a0ba92ccde949582e498cb42bced205ec1c95a3c Author: Dr. Stephen Henson Date: Tue Oct 6 14:15:14 2015 +0100 Don't try and parse boolean type. Reviewed-by: Rich Salz (cherry picked from commit e58c4d3cdde7a0a01df2884bfeec31a2b07be22d) ----------------------------------------------------------------------- Summary of changes: apps/asn1pars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 11b0787..0a6b990 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -313,9 +313,9 @@ int MAIN(int argc, char **argv) } typ = ASN1_TYPE_get(at); if ((typ == V_ASN1_OBJECT) + || (typ == V_ASN1_BOOLEAN) || (typ == V_ASN1_NULL)) { - BIO_printf(bio_err, "Can't parse %s type\n", - typ == V_ASN1_NULL ? "NULL" : "OBJECT"); + BIO_printf(bio_err, "Can't parse %s type\n", ASN1_tag2str(typ)); ERR_print_errors(bio_err); goto end; } From steve at openssl.org Tue Oct 6 14:19:18 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 06 Oct 2015 14:19:18 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444141158.457309.24033.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via cba874539596a3f6563c4b462793a99965bcf1e1 (commit) from 61dfe3a720b37efe97fa5de23ceadd17ce47518d (commit) - Log ----------------------------------------------------------------- commit cba874539596a3f6563c4b462793a99965bcf1e1 Author: Dr. Stephen Henson Date: Tue Oct 6 14:15:14 2015 +0100 Don't try and parse boolean type. Reviewed-by: Rich Salz (cherry picked from commit e58c4d3cdde7a0a01df2884bfeec31a2b07be22d) ----------------------------------------------------------------------- Summary of changes: apps/asn1pars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 11b0787..0a6b990 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -313,9 +313,9 @@ int MAIN(int argc, char **argv) } typ = ASN1_TYPE_get(at); if ((typ == V_ASN1_OBJECT) + || (typ == V_ASN1_BOOLEAN) || (typ == V_ASN1_NULL)) { - BIO_printf(bio_err, "Can't parse %s type\n", - typ == V_ASN1_NULL ? "NULL" : "OBJECT"); + BIO_printf(bio_err, "Can't parse %s type\n", ASN1_tag2str(typ)); ERR_print_errors(bio_err); goto end; } From emilia at openssl.org Tue Oct 6 16:04:33 2015 From: emilia at openssl.org (Emilia Kasper) Date: Tue, 06 Oct 2015 16:04:33 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444147473.720483.10056.nullmailer@dev.openssl.org> The branch master has been updated via 20218b58b51b55189ada91807459d6bd64f5c986 (commit) from e58c4d3cdde7a0a01df2884bfeec31a2b07be22d (commit) - Log ----------------------------------------------------------------- commit 20218b58b51b55189ada91807459d6bd64f5c986 Author: Emilia Kasper Date: Tue Oct 6 17:27:35 2015 +0200 SSLv2 compat ciphers: clarify comment Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: ssl/s3_srvr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 82162d8..5f05b9f 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -3494,10 +3494,9 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, while (PACKET_copy_bytes(cipher_suites, cipher, n)) { /* - * We only support SSLv2 format ciphers in SSLv3+ using a - * SSLv2 backward compatible ClientHello. In this case the first - * byte is always 0 for SSLv3 compatible ciphers. Anything else - * is an SSLv2 cipher and we ignore it + * SSLv3 ciphers wrapped in an SSLv2-compatible ClientHello have the + * first byte set to zero, while true SSLv2 ciphers have a non-zero + * first byte. We don't support any true SSLv2 ciphers, so skip them. */ if (sslv2format && cipher[0] != '\0') continue; From rsalz at openssl.org Tue Oct 6 16:31:00 2015 From: rsalz at openssl.org (Rich Salz) Date: Tue, 06 Oct 2015 16:31:00 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444149060.795979.13608.nullmailer@dev.openssl.org> The branch master has been updated via 2d2846237364671670c4b9a8415ea957887e1797 (commit) from 20218b58b51b55189ada91807459d6bd64f5c986 (commit) - Log ----------------------------------------------------------------- commit 2d2846237364671670c4b9a8415ea957887e1797 Author: Alessandro Ghedini Date: Tue Oct 6 12:23:42 2015 -0400 Fix travis builds on master -Allow mingw debug builds to fail on Travis CI -Fix Travis email notifications config -Rename a variable to avoid a bogus warning with old GCC error: declaration of ``dup'' shadows a global declaration [-Werror=shadow] -Disable pedantic ms-format warnings with mingw -Properly define const DH parameters -Restore --debug flag in Travis CI builds; -d would get incorrectly passed to ./Configure in mingw debug builds. Signed-off-by: Rich Salz Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: .travis.yml | 12 +++++++----- Configurations/10-main.conf | 4 ++-- crypto/bn/bn_dh.c | 3 ++- test/packettest.c | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3125363..34b4d9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ compiler: env: - CONFIG_OPTS="" - CONFIG_OPTS="shared" - - CONFIG_OPTS="-d --strict-warnings" + - CONFIG_OPTS="--debug --strict-warnings" matrix: exclude: @@ -26,6 +26,11 @@ matrix: compiler: i686-w64-mingw32-gcc - os: osx compiler: x86_64-w64-mingw32-gcc + allow_failures: + - compiler: i686-w64-mingw32-gcc + env: CONFIG_OPTS="--debug --strict-warnings" + - compiler: x86_64-w64-mingw32-gcc + env: CONFIG_OPTS="--debug --strict-warnings" before_script: - if [ "$CC" == i686-w64-mingw32-gcc ]; then @@ -43,8 +48,5 @@ script: - if [ -z "$CROSS_COMPILE" ]; then make test; fi notifications: - recipient: - - openssl-commits at openssl.org email: - on_success: change - on_failure: always + - openssl-commits at openssl.org diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 426fbfa..9ebd20f 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -1174,7 +1174,7 @@ "mingw" => { inherit_from => [ asm("x86_asm") ], cc => "gcc", - cflags => "-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -march=i486 -Wall", + cflags => "-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -march=i486 -Wall -Wno-pedantic-ms-format", debug_cflags => "-g -O0", release_clags => "-O3 -fomit-frame-pointer", thread_cflag => "-D_MT", @@ -1199,7 +1199,7 @@ # Applink is never engaged and can as well be omitted. inherit_from => [ asm("x86_64_asm") ], cc => "gcc", - cflags => "-mno-cygwin -DL_ENDIAN -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE", + cflags => "-mno-cygwin -DL_ENDIAN -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -Wno-pedantic-ms-format", debug_cflags => "-g -O0", release_clags => "-O3", thread_cflag => "-D_MT", diff --git a/crypto/bn/bn_dh.c b/crypto/bn/bn_dh.c index 34f9fb0..5572a2d 100644 --- a/crypto/bn/bn_dh.c +++ b/crypto/bn/bn_dh.c @@ -248,7 +248,8 @@ static const BN_ULONG dh2048_256_q[] = { /* Macro to make a BIGNUM from static data */ -# define make_dh_bn(x) const BIGNUM _bignum_##x = { (BN_ULONG *) x, \ +# define make_dh_bn(x) extern const BIGNUM _bignum_##x; \ + const BIGNUM _bignum_##x = { (BN_ULONG *) x, \ OSSL_NELEM(x),\ OSSL_NELEM(x),\ 0, BN_FLG_STATIC_DATA }; diff --git a/test/packettest.c b/test/packettest.c index 915b42b..edaa282 100644 --- a/test/packettest.c +++ b/test/packettest.c @@ -242,16 +242,16 @@ static int test_PACKET_copy_bytes(unsigned char buf[BUF_LEN]) static int test_PACKET_copy_all(unsigned char buf[BUF_LEN]) { - unsigned char dup[BUF_LEN]; + unsigned char tmp[BUF_LEN]; PACKET pkt; size_t len; if ( !PACKET_buf_init(&pkt, buf, BUF_LEN) - || !PACKET_copy_all(&pkt, dup, BUF_LEN, &len) + || !PACKET_copy_all(&pkt, tmp, BUF_LEN, &len) || len != BUF_LEN - || memcmp(buf, dup, BUF_LEN) != 0 + || memcmp(buf, tmp, BUF_LEN) != 0 || PACKET_remaining(&pkt) != BUF_LEN - || PACKET_copy_all(&pkt, dup, BUF_LEN - 1, &len)) { + || PACKET_copy_all(&pkt, tmp, BUF_LEN - 1, &len)) { fprintf(stderr, "test_PACKET_copy_bytes() failed\n"); return 0; } From builds at travis-ci.org Tue Oct 6 16:44:39 2015 From: builds at travis-ci.org (Travis CI) Date: Tue, 06 Oct 2015 16:44:39 +0000 Subject: [openssl-commits] Fixed: openssl/openssl#336 (master - 2d28462) In-Reply-To: Message-ID: <5613fa76ac5d0_31968aaa8143f@e7046b54-d142-4938-87d2-0684ca120405.mail> Build Update for openssl/openssl ------------------------------------- Build: #336 Status: Fixed Duration: 13 minutes and 9 seconds Commit: 2d28462 (master) Author: Alessandro Ghedini Message: Fix travis builds on master -Allow mingw debug builds to fail on Travis CI -Fix Travis email notifications config -Rename a variable to avoid a bogus warning with old GCC error: declaration of ``dup'' shadows a global declaration [-Werror=shadow] -Disable pedantic ms-format warnings with mingw -Properly define const DH parameters -Restore --debug flag in Travis CI builds; -d would get incorrectly passed to ./Configure in mingw debug builds. Signed-off-by: Rich Salz Reviewed-by: Matt Caswell View the changeset: https://github.com/openssl/openssl/compare/20218b58b51b...2d2846237364 View the full build log and details: https://travis-ci.org/openssl/openssl/builds/83927557 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at openssl.org Wed Oct 7 15:33:55 2015 From: matt at openssl.org (Matt Caswell) Date: Wed, 07 Oct 2015 15:33:55 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444232035.077687.7978.nullmailer@dev.openssl.org> The branch master has been updated via 68a166285102a7cf5dadee763243ae575c5cee77 (commit) from 2d2846237364671670c4b9a8415ea957887e1797 (commit) - Log ----------------------------------------------------------------- commit 68a166285102a7cf5dadee763243ae575c5cee77 Author: Matt Caswell Date: Wed Oct 7 15:20:47 2015 +0100 Don't advance PACKET in ssl_check_for_safari The function ssl_check_for_safari fingerprints the incoming extensions to see whether it is one of the broken versions of safari. However it was failing to reset the PACKET back to the same position it started in, hence causing some extensions to be skipped incorrectly. Reviewed-by: Emilia K?sper ----------------------------------------------------------------------- Summary of changes: ssl/t1_lib.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 4975c10..f18f502 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1815,10 +1815,11 @@ static int tls1_alpn_handle_client_hello(SSL *s, PACKET *pkt, int *al) * Sadly we cannot differentiate 10.6, 10.7 and 10.8.4 (which work), from * 10.8..10.8.3 (which don't work). */ -static void ssl_check_for_safari(SSL *s, PACKET *pkt) +static void ssl_check_for_safari(SSL *s, const PACKET *pkt) { unsigned int type, size; unsigned char *eblock1, *eblock2; + PACKET tmppkt; static const unsigned char kSafariExtensionsBlock[] = { 0x00, 0x0a, /* elliptic_curves extension */ @@ -1846,10 +1847,12 @@ static void ssl_check_for_safari(SSL *s, PACKET *pkt) 0x02, 0x03, /* SHA-1/ECDSA */ }; - if (!PACKET_forward(pkt, 2) - || !PACKET_get_net_2(pkt, &type) - || !PACKET_get_net_2(pkt, &size) - || !PACKET_forward(pkt, size)) + tmppkt = *pkt; + + if (!PACKET_forward(&tmppkt, 2) + || !PACKET_get_net_2(&tmppkt, &type) + || !PACKET_get_net_2(&tmppkt, &size) + || !PACKET_forward(&tmppkt, size)) return; if (type != TLSEXT_TYPE_server_name) @@ -1859,9 +1862,9 @@ static void ssl_check_for_safari(SSL *s, PACKET *pkt) const size_t len1 = sizeof(kSafariExtensionsBlock); const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock); - if (!PACKET_get_bytes(pkt, &eblock1, len1) - || !PACKET_get_bytes(pkt, &eblock2, len2) - || PACKET_remaining(pkt)) + if (!PACKET_get_bytes(&tmppkt, &eblock1, len1) + || !PACKET_get_bytes(&tmppkt, &eblock2, len2) + || PACKET_remaining(&tmppkt)) return; if (memcmp(eblock1, kSafariExtensionsBlock, len1) != 0) return; @@ -1870,8 +1873,8 @@ static void ssl_check_for_safari(SSL *s, PACKET *pkt) } else { const size_t len = sizeof(kSafariExtensionsBlock); - if (!PACKET_get_bytes(pkt, &eblock1, len) - || PACKET_remaining(pkt)) + if (!PACKET_get_bytes(&tmppkt, &eblock1, len) + || PACKET_remaining(&tmppkt)) return; if (memcmp(eblock1, kSafariExtensionsBlock, len) != 0) return; From kurt at openssl.org Wed Oct 7 17:00:09 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Wed, 07 Oct 2015 17:00:09 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444237209.913160.15768.nullmailer@dev.openssl.org> The branch master has been updated via 8314146ac57059f6d4095ef23e30ccdeb4699938 (commit) via c804d23d73bb2f3f6ffe29fbda4dd2fa151fa243 (commit) via 99c203337574d967c86ffbfa13f40ace51048485 (commit) via d6e92c0bd6c36fc68291e79ef5753fd7f0420695 (commit) via f92768e6f5259069bd21dbed2b98b3423c1dfca4 (commit) from 68a166285102a7cf5dadee763243ae575c5cee77 (commit) - Log ----------------------------------------------------------------- commit 8314146ac57059f6d4095ef23e30ccdeb4699938 Author: Pascal Cuoq Date: Wed May 6 10:15:28 2015 +0200 Don't check pointer we just freed, always set it to NULL. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 commit c804d23d73bb2f3f6ffe29fbda4dd2fa151fa243 Author: Pascal Cuoq Date: Tue May 5 11:20:39 2015 +0200 Move BN_CTX_start() call so the error case can always call BN_CTX_end(). Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 commit 99c203337574d967c86ffbfa13f40ace51048485 Author: Pascal Cuoq Date: Tue May 5 11:20:39 2015 +0200 Move BN_CTX_start() call so the error case can always call BN_CTX_end(). Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 commit d6e92c0bd6c36fc68291e79ef5753fd7f0420695 Author: Pascal Cuoq Date: Wed May 6 09:55:28 2015 +0200 Properly check return type of DH_compute_key() It returns -1 on error, not 0. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 commit f92768e6f5259069bd21dbed2b98b3423c1dfca4 Author: Pascal Cuoq Date: Wed May 6 11:31:27 2015 +0200 Set flags to 0 before calling BN_with_flags() BN_with_flags() will read the dest->flags to keep the BN_FLG_MALLOCED but overwrites everything else. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 ----------------------------------------------------------------------- Summary of changes: crypto/asn1/tasn_fre.c | 3 +-- crypto/bn/bn_gcd.c | 2 ++ crypto/dsa/dsa_gen.c | 3 ++- crypto/rsa/rsa_eay.c | 3 ++- test/dhtest.c | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c index e219e2c..bd955d9 100644 --- a/crypto/asn1/tasn_fre.c +++ b/crypto/asn1/tasn_fre.c @@ -249,6 +249,5 @@ void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) ASN1_STRING_free((ASN1_STRING *)*pval); break; } - if (*pval) - *pval = NULL; + *pval = NULL; } diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index 17c6cf5..0264319 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -599,6 +599,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, * BN_div_no_branch will be called eventually. */ pB = &local_B; + local_B.flags = 0; BN_with_flags(pB, B, BN_FLG_CONSTTIME); if (!BN_nnmod(B, pB, A, ctx)) goto err; @@ -626,6 +627,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, * BN_div_no_branch will be called eventually. */ pA = &local_A; + local_A.flags = 0; BN_with_flags(pA, A, BN_FLG_CONSTTIME); /* (D, M) := (A/B, A%B) ... */ diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 97110ef..056e500 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -145,10 +145,11 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, if ((ctx = BN_CTX_new()) == NULL) goto err; + BN_CTX_start(ctx); + if ((mont = BN_MONT_CTX_new()) == NULL) goto err; - BN_CTX_start(ctx); r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c index 511ecb8..837e915 100644 --- a/crypto/rsa/rsa_eay.c +++ b/crypto/rsa/rsa_eay.c @@ -717,6 +717,8 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) BIGNUM *dmp1, *dmq1, *c, *pr1; int ret = 0; + BN_CTX_start(ctx); + local_dmp1 = BN_new(); local_dmq1 = BN_new(); local_c = BN_new(); @@ -724,7 +726,6 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) if (!local_dmp1 || !local_dmq1 || !local_c || !local_r1) goto err; - BN_CTX_start(ctx); r1 = BN_CTX_get(ctx); m1 = BN_CTX_get(ctx); vrfy = BN_CTX_get(ctx); diff --git a/test/dhtest.c b/test/dhtest.c index 9ce92ee..896af85 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -515,9 +515,9 @@ static int run_rfc5114_tests(void) * Work out shared secrets using both sides and compare with expected * values. */ - if (!DH_compute_key(Z1, dhB->pub_key, dhA)) + if (DH_compute_key(Z1, dhB->pub_key, dhA) == -1) goto bad_err; - if (!DH_compute_key(Z2, dhA->pub_key, dhB)) + if (DH_compute_key(Z2, dhA->pub_key, dhB) == -1) goto bad_err; if (memcmp(Z1, td->Z, td->Z_len)) From kurt at openssl.org Wed Oct 7 18:40:32 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Wed, 07 Oct 2015 18:40:32 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444243232.197389.863.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via cc1cdc5df5e80883de20d6f59ecfc4505bbb3e52 (commit) via 738b8e6bc2331ae9230411d88b8a100614f80457 (commit) via 6481be7346baea1ce0dcfe0a1ff28b0f44e9ce31 (commit) from cba874539596a3f6563c4b462793a99965bcf1e1 (commit) - Log ----------------------------------------------------------------- commit cc1cdc5df5e80883de20d6f59ecfc4505bbb3e52 Author: Pascal Cuoq Date: Tue May 5 11:20:39 2015 +0200 Move BN_CTX_start() call so the error case can always call BN_CTX_end(). Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 (cherry picked from commit 99c203337574d967c86ffbfa13f40ace51048485) commit 738b8e6bc2331ae9230411d88b8a100614f80457 Author: Pascal Cuoq Date: Wed May 6 09:55:28 2015 +0200 Properly check return type of DH_compute_key() It returns -1 on error, not 0. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 (cherry picked from commit d6e92c0bd6c36fc68291e79ef5753fd7f0420695) commit 6481be7346baea1ce0dcfe0a1ff28b0f44e9ce31 Author: Pascal Cuoq Date: Wed May 6 11:31:27 2015 +0200 Set flags to 0 before calling BN_with_flags() BN_with_flags() will read the dest->flags to keep the BN_FLG_MALLOCED but overwrites everything else. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 (cherry picked from commit f92768e6f5259069bd21dbed2b98b3423c1dfca4) ----------------------------------------------------------------------- Summary of changes: crypto/bn/bn_gcd.c | 2 ++ crypto/dh/dhtest.c | 4 ++-- crypto/dsa/dsa_gen.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index 97c55ab..ce59fe7 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -583,6 +583,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, * BN_div_no_branch will be called eventually. */ pB = &local_B; + local_B.flags = 0; BN_with_flags(pB, B, BN_FLG_CONSTTIME); if (!BN_nnmod(B, pB, A, ctx)) goto err; @@ -610,6 +611,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, * BN_div_no_branch will be called eventually. */ pA = &local_A; + local_A.flags = 0; BN_with_flags(pA, A, BN_FLG_CONSTTIME); /* (D, M) := (A/B, A%B) ... */ diff --git a/crypto/dh/dhtest.c b/crypto/dh/dhtest.c index c9dd76b..6fe8ff4 100644 --- a/crypto/dh/dhtest.c +++ b/crypto/dh/dhtest.c @@ -533,9 +533,9 @@ static int run_rfc5114_tests(void) * Work out shared secrets using both sides and compare with expected * values. */ - if (!DH_compute_key(Z1, dhB->pub_key, dhA)) + if (DH_compute_key(Z1, dhB->pub_key, dhA) == -1) goto bad_err; - if (!DH_compute_key(Z2, dhA->pub_key, dhB)) + if (DH_compute_key(Z2, dhA->pub_key, dhB) == -1) goto bad_err; if (memcmp(Z1, td->Z, td->Z_len)) diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 9d3b59e..6bc86dd 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -179,10 +179,11 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, if ((ctx = BN_CTX_new()) == NULL) goto err; + BN_CTX_start(ctx); + if ((mont = BN_MONT_CTX_new()) == NULL) goto err; - BN_CTX_start(ctx); r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); From kurt at openssl.org Wed Oct 7 18:43:36 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Wed, 07 Oct 2015 18:43:36 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444243416.331840.2107.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 91dc4497dec6fcb1e0ecf61f257c9c13364328b4 (commit) via 11ca27c912888460a7a06b9308fd85170e1db194 (commit) from a0ba92ccde949582e498cb42bced205ec1c95a3c (commit) - Log ----------------------------------------------------------------- commit 91dc4497dec6fcb1e0ecf61f257c9c13364328b4 Author: Pascal Cuoq Date: Tue May 5 11:20:39 2015 +0200 Move BN_CTX_start() call so the error case can always call BN_CTX_end(). Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 (cherry picked from commit 99c203337574d967c86ffbfa13f40ace51048485) commit 11ca27c912888460a7a06b9308fd85170e1db194 Author: Pascal Cuoq Date: Wed May 6 11:31:27 2015 +0200 Set flags to 0 before calling BN_with_flags() BN_with_flags() will read the dest->flags to keep the BN_FLG_MALLOCED but overwrites everything else. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 (cherry picked from commit f92768e6f5259069bd21dbed2b98b3423c1dfca4) ----------------------------------------------------------------------- Summary of changes: crypto/bn/bn_gcd.c | 2 ++ crypto/dsa/dsa_gen.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index 97c55ab..ce59fe7 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -583,6 +583,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, * BN_div_no_branch will be called eventually. */ pB = &local_B; + local_B.flags = 0; BN_with_flags(pB, B, BN_FLG_CONSTTIME); if (!BN_nnmod(B, pB, A, ctx)) goto err; @@ -610,6 +611,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, * BN_div_no_branch will be called eventually. */ pA = &local_A; + local_A.flags = 0; BN_with_flags(pA, A, BN_FLG_CONSTTIME); /* (D, M) := (A/B, A%B) ... */ diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index defa499..0dada3d 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -177,10 +177,11 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, if ((ctx = BN_CTX_new()) == NULL) goto err; + BN_CTX_start(ctx); + if ((mont = BN_MONT_CTX_new()) == NULL) goto err; - BN_CTX_start(ctx); r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); From kurt at openssl.org Wed Oct 7 19:15:24 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Wed, 07 Oct 2015 19:15:24 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1444245324.831093.6434.nullmailer@dev.openssl.org> The branch master has been updated via 739777feb5ecc030dd7a8aa044ea34aa38fb5f8f (commit) from ae0c77a9cfe1b81963bf6beab37b96af5a4d807b (commit) - Log ----------------------------------------------------------------- commit 739777feb5ecc030dd7a8aa044ea34aa38fb5f8f Author: Kurt Roeckx Date: Wed Oct 7 21:14:45 2015 +0200 Update key with new expiration date ----------------------------------------------------------------------- Summary of changes: news/openssl-security.asc | 126 +++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/news/openssl-security.asc b/news/openssl-security.asc index 952edbc..da6e23b 100755 --- a/news/openssl-security.asc +++ b/news/openssl-security.asc @@ -12,55 +12,55 @@ Ce9tWq6oK+o1MEc1Ejb1/kn9CeCloKlF8HkzhFLpqqkZ//3j73/6kuK45UVg5PbO 5HCnafDroN5wF9jMVxFhmDOOdXyIeYkBVF6swwIlyq8VlYSjYWGAUtIb3rOiUNWc zYY6spdAN6VtKTMnXTm608yH118p+UOB5rJuKBqk3tMaiIjoyOcya4ImenX85rfK eCOVNtdOC/0N8McfO0eFc6fZxcy7ykZ1a7FLyqQDexpZM7OLoM5SXObX1QARAQAB -tDRPcGVuU1NMIHNlY3VyaXR5IHRlYW0gPG9wZW5zc2wtc2VjdXJpdHlAb3BlbnNz -bC5vcmc+iQI9BBMBCgAnBQJUpdpWAhsDBQkB4TOABQsJCAcDBRUKCQgLBRYCAwEA -Ah4BAheAAAoJENiU4s6LPXn1j/UP/1iYmFLO4JDERSQ2qXDDryFnxM14hV8hnt8a -fh1NrjraYNOKo9S/2vvPv97FsNrzau7jCNAMUOyvWw/fNwur2jW5H44G7M8slaAg -DSfEEkKrG/mc+cC9VQfnGkOrgvfuOnPQ54uH0RRgRvjBO9rOzu4SKjXs4y5+gsVE -06mYY9fqCJK4opxImR3zZMhNPvbpHj44i9yZ4RPm0uQ1W7yJAD2P43ATG9MoFezw -eMtNL04jBIyd7p+edXTT49QTc8LkDGLpHxEecCYPkZGyEMbsm2ee2T5J1iSjiFkW -2+oY/6vZjg0CeUA8mR1ghtyfMc2gfHT7UHZ0TYBZ2eL8g0qzGAQwsFaOot/O2ljk -m5X5PrmnUx8FyBjyqRcScQOslPXPygFxhGZj8EYEaSNrDRaGPASGesNO6LabkkFl -1hIXM8ZCYhJlhiBGL5H0BTEohW2qYaHVgnklBUi/QqDTktt/hAcMHjA7+lXaXy7v -Y7KH3AvHpASd/jxLEL2oBUG3bKrfrb5su76OCbmOnKiIp0TeoT2gvQBRRKzsLelX -ypr5vbh9hYd6wjhruvIE1lesyS23di4E36IdZPYLMs0X9IWwsxSTyr9//MO9SOOc -fYA5IVbhxDYOFy4XucKcGVC1wpeYsCSKVtqPpzndSedX0Tc+gJ1LhphF/xlW/Oa9 -nuRHzeoFiQIcBBABCgAGBQJUpdtpAAoJECBkxTZBwl5dockP/0m9chPxSxSCac34 -wMcOdRs160JpETjnpdOxw22np/g1XawIZOxTBA3cpATfmod15fx/qjTJcVWx2RzZ -j4YdPr5JMzGLDnDDjS75Vj5kIfoHyvHVnybIVA4kjgWR4MU9fPV9xiF6uIjOhB7P -qqjb4C/B1+t+IY1uTSHpIIJJz06outCj5l6u3s1qLO234i0TzaZMF77y9YXgPbUf -yoRU/Kmpqx+teYFlsj1I1Rt3TyfKsS5FoYkgUM/7Gk00lRZqb9cpFRsJ0Ir8oGrG -MpcypAndtf2KT3HFmRP1wpxqiSedA13QMnTuH8UmEaM2fQWjba2+RrGFdd1eKzSa -NiaiwDFdl/dkkBSCIINgYJ+A22uywqpkmsfj4cPZ3Jt+Fh28h+4EeKM+Ozz0oKkE -yOlJE6xSCCu3u5+L3vkzIfqHVH8pizug+w1U2naQ5sNQYH/Ef3z4xjPhatBd4soE -IXJAIPymyfRoCqZNcm9mf4pJcOXdZ2I1VkMPYVrCog/CQ6Cyh0VWgggeNB1D1TEJ -jzI4csX/94QNBuLQafKb6O7HaU7b8w6rdff0XiLDUQeOEdJk5FEVvayb86crTpzl -sKWsPlbtq+rNUuxGWp8q5Hx7qxzZyEFe3phUSO/iCIlwkEqhPIkJGZ6eNxp8K3Ia -Lmr6z6lu6JMJuKHGcwX4Wam24+0vtCdPcGVuU1NMIHRlYW0gPG9wZW5zc2wtdGVh -bUBvcGVuc3NsLm9yZz6JAj0EEwEKACcFAlQv6Z8CGwMFCQHhM4AFCwkIBwMFFQoJ -CAsFFgIDAQACHgECF4AACgkQ2JTizos9efV70xAAlXY8dfsZRKMbVyv7YOPaC38X -L1ySNUqoMy0lBS8L8Sac5vrim3B1X8Ztxlli0kgIEbpDidT8sP8hxvQZa+rnObmp -aBXpBudBgT/FrpwKt0kAcfxnoLGo1ZrSS4MJPwgYAyg2VY6O5gzJG+AnxoeT6NpG -8KmgVsFr8QpLFJOI20fOoCCsNMWsQk5uWKifoYNnFsYwdaKJnzfYFqC3lQCcU12W -F0Eeo/+gSK309+Dq3ujoTgKAElOvVom3c+RIFRHTwnCgucrJFAgcavZiEEd9QGPg -3LsZ7HpmE6nwzPOwnxqM8qLtvUvzXJPH6j87iuk7ojPVBPAyHU2ITaANj8IyVi4l -iRzvNohypWCbV+MUyrkI/Ko+TrQ/XmDRfQKSfFbt9UBH1g+/iBfUVdLPNKD0gyXw -y04nTNdgyB5V3zjCfQ1UEZ5TESDXfjBP+5TGzF5IMlvAYa3dyGYpHuMTGjCno8R/ -d9vVxlOaQSWcbB5uNUHLj6Fpvoxvz1InfrarFXIh4jbZg0ewI3sbuUmjh0PhX0fR -r9HiEAhpRjUfdidWbuOa7+BMXyLOoifNpxv4Q8gm+eu/kxYjayRHNv+0DX1nKM2s -LdODoMf5BYIULLksavUlrmZ7GpJtBgEO4dhSDDp6VYw24NNSG8orV2V4Fleegdes -D8tAA1Bl6Chb64m28sKJAhwEEAEKAAYFAlSl23AACgkQIGTFNkHCXl3/qw/7BatG -hw4B4dKJsw2Ds3fBcOl4m8q5+TxIILZaz4ko63tLBoXzs04f3UF+5DKb0H/lo1Pp -3WYQL+KL0sVcZ3KDNXWLTpvz0qND88Ek85c0PusIrqcvD24bUlFkNyeToniPj+59 -LGbmxSg6FdQ9w+a72QwcE1hPxSYgnC8b5U1jlmteFKGYAI8vy5OkQG/t9JhS6yi9 -TTVAE+jT9tDbkmWaJo+B3+VReO0dRnH799vGk23GxXEf1ncA4SO6BFKve/eewB3b -uf4dbPnI6V3BS2Bcdo21bmECeqddAeIGAxWC5kvwZwHvjrkOJq+5jsRvB+PYUPhd -Atr6nNroWn+t/hFgfYd85arqLWj+Ln156tNFzULEgOIZcC2DnkW+a/cFa0GOqIyN -H3lysLuE0dzin6EE6upae/u2KYMeGqaOs6KdyH1bu/zUg0bxX0n2GyBBxCAKTeD7 -qpv/OMdNSZRQckTDYzAd+BguzQ3F9I8tVXWp53G4mZWVXK4kU78Gj4nvM6FMBEXo -wtvBNhx+xRY2n0mA0x36IbERcKLE7nCxhdiUqEZGixDbZOj1TTxMd97TC6FIWGQL -Vu46R0HJsulpljUBeEcMNM7hNC7dLlpSujZiOydJaHxio2uO5vOYetkrl7hA+MDm -02BteFshlUYlsOhCoM0qOTvW+t5OLY0yBrsEYCW5Ag0EVC/pnwEQAMB3s+8dq5T8 +tCdPcGVuU1NMIHRlYW0gPG9wZW5zc2wtdGVhbUBvcGVuc3NsLm9yZz6JAhwEEAEK +AAYFAlSl23AACgkQIGTFNkHCXl3/qw/7BatGhw4B4dKJsw2Ds3fBcOl4m8q5+TxI +ILZaz4ko63tLBoXzs04f3UF+5DKb0H/lo1Pp3WYQL+KL0sVcZ3KDNXWLTpvz0qND +88Ek85c0PusIrqcvD24bUlFkNyeToniPj+59LGbmxSg6FdQ9w+a72QwcE1hPxSYg +nC8b5U1jlmteFKGYAI8vy5OkQG/t9JhS6yi9TTVAE+jT9tDbkmWaJo+B3+VReO0d +RnH799vGk23GxXEf1ncA4SO6BFKve/eewB3buf4dbPnI6V3BS2Bcdo21bmECeqdd +AeIGAxWC5kvwZwHvjrkOJq+5jsRvB+PYUPhdAtr6nNroWn+t/hFgfYd85arqLWj+ +Ln156tNFzULEgOIZcC2DnkW+a/cFa0GOqIyNH3lysLuE0dzin6EE6upae/u2KYMe +GqaOs6KdyH1bu/zUg0bxX0n2GyBBxCAKTeD7qpv/OMdNSZRQckTDYzAd+BguzQ3F +9I8tVXWp53G4mZWVXK4kU78Gj4nvM6FMBEXowtvBNhx+xRY2n0mA0x36IbERcKLE +7nCxhdiUqEZGixDbZOj1TTxMd97TC6FIWGQLVu46R0HJsulpljUBeEcMNM7hNC7d +LlpSujZiOydJaHxio2uO5vOYetkrl7hA+MDm02BteFshlUYlsOhCoM0qOTvW+t5O +LY0yBrsEYCWJAj0EEwEKACcCGwMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AFAlYV +a4oFCQPGtVoACgkQ2JTizos9efUTaxAApjTpeJDK+RGPxoBwFF5CzBrPEoxXssXE +sbqqyh0rBbwTNEPwXDCBP9d7vcmXWVkCJYb3UhlakjDZO9S7DvAg6y2VKUFKCOx4 +J9B+YfrnAncQ6vvm6USjkzpgZi2/Bk1u4p/zkjKdHveLUH4mddiGxf3oIU8btEyD +3yAKVMbb4Pvzwu47Pvz+l7BWDR/zePIcQfY5udacsZlATpoBpfgO6O75wSaJ3Qu+ +iWxemysvF1yBCB2i32JUjq0CwHcy20LY216kMLSV/lSMA+aEALoSGfnwYi/fzLXk +N/km/v3DXlqXw2qRzC1pKu4qFqPDYAcDEUV27CROQxlmm5C3zE0vCM+dcOtaRHdB +Q+qpW2L/UZmGCLRxhO97ZzHghuACMRrQwiCg5mKW+X/2ESbGLsIakrWjRL5yvLs0 +2SgTMdXJqsa4Q8iRMx68GmhyFRQQdVOyldiR+yZeS544L3MHESzApB/+AL1dPXFM +bnFwemUhrIJHFLn2WP4AANfl6j/SkF/6UE8kiuz1NII9jh/9sPm5fKIUPRAfqRmZ +qkuPEZbgQSSHPtnAQ3kr3IfG/HQfPl6c7VrsoQQizcLrbMXJIJzxCvX0uWhmGQap +g37BGcM30GoaUQVD3sbVyC66lLavVWXAgTzXVuJGwhLH+eo5MgAqzA8H2qLLxfpt +365B/iLEZQy0NE9wZW5TU0wgc2VjdXJpdHkgdGVhbSA8b3BlbnNzbC1zZWN1cml0 +eUBvcGVuc3NsLm9yZz6JAhwEEAEKAAYFAlSl22kACgkQIGTFNkHCXl2hyQ//Sb1y +E/FLFIJpzfjAxw51GzXrQmkROOel07HDbaen+DVdrAhk7FMEDdykBN+ah3Xl/H+q +NMlxVbHZHNmPhh0+vkkzMYsOcMONLvlWPmQh+gfK8dWfJshUDiSOBZHgxT189X3G +IXq4iM6EHs+qqNvgL8HX634hjW5NIekggknPTqi60KPmXq7ezWos7bfiLRPNpkwX +vvL1heA9tR/KhFT8qamrH615gWWyPUjVG3dPJ8qxLkWhiSBQz/saTTSVFmpv1ykV +GwnQivygasYylzKkCd21/YpPccWZE/XCnGqJJ50DXdAydO4fxSYRozZ9BaNtrb5G +sYV13V4rNJo2JqLAMV2X92SQFIIgg2Bgn4Dba7LCqmSax+Phw9ncm34WHbyH7gR4 +oz47PPSgqQTI6UkTrFIIK7e7n4ve+TMh+odUfymLO6D7DVTadpDmw1Bgf8R/fPjG +M+Fq0F3iygQhckAg/KbJ9GgKpk1yb2Z/iklw5d1nYjVWQw9hWsKiD8JDoLKHRVaC +CB40HUPVMQmPMjhyxf/3hA0G4tBp8pvo7sdpTtvzDqt19/ReIsNRB44R0mTkURW9 +rJvzpytOnOWwpaw+Vu2r6s1S7EZanyrkfHurHNnIQV7emFRI7+IIiXCQSqE8iQkZ +np43GnwrchouavrPqW7okwm4ocZzBfhZqbbj7S+JAj0EEwEKACcCGwMFCwkIBwMF +FQoJCAsFFgIDAQACHgECF4AFAlYVa4MFCQPGtVoACgkQ2JTizos9efXWBg//VY7A +ASQldw9810c4B1FmwRjMNuKzwWMt6URk0VCpCy8dRFdvwIEg+8Pceak3uT56vIVg +zrG8o9pIj0o/90fLhIxu23HszWayTkgtbgPxrYhOnTIBAVL4eCIG+sJTAGkd106p +pZFdCoaaf2NTiSNMb+j10VTaD/FwXyoZP16lwUyi3UjzBFsZqQsclmVIy/6axYfD +foZ0+a8SsDgdpJpmVXgYWfJERwuHxiRSxppXq6khvkpqYIFURH5iev6us4Y8tGIW +VOfoAxPvvIRgTB2hbTczr63phnaX4vJTOc8sF/R9ZJGdScvLHdKlYimXpaRf7Kn/ +15cp+OsJSAvlGgheYB2X50JccgbNeXZMsWQ5PLHOZDXVGAEdy8pAoz78tcUinWsV +foXxiKsbouHZfuNsRjULKHOsp1Eiq5BAaEB7h2oNkES3SWs9hvcXWr3YdLTefUcy +tUB83yk6I/TDcAAzRU4VtaEU5L5VuG737/VNHcQLhE5crsIj5mb19cvPu935F0KK +QD6hpVuofNcPXrqhwLo/PGospTbo/hm5rABh59+7u86lkcsJeX0HdEe1tK2EqYTY +WEf7haAsdy7taLafPgKRORInWz8HM27Jnw4dEYgIVxxTs3/rsxWYytVizcCHZCcS +g7hszvF/7HShIFms0x7ew86fG5ePlMUNp0n/oWy5Ag0EVC/pnwEQAMB3s+8dq5T8 fW+b3OcGujEcbhyguc6D5shlNWsuCV3W7+izsVUe+0hD1YwD30C6zj2+CJrMxPQ/ BB3u3SbyHMDP5fKL7GQiA/n192hX2DuHxvQwnDNkHxYghtrFKOlXAyte2awA0fC+ e0o8lHa1Yd2ZZNqlDC23qJtLMJH8bX8CIr59KckNyv64bF+hVPIN3evnh1Ajn4A8 @@ -71,18 +71,18 @@ mY++fTsUPzSOvit0kqQfimziYx7QcJIagG92mvUmuf2PEfzvSi6iaIqMhaTaJq5q xOR0q430KakQktNPX53HflWL7YenDPYw1rEyQFxGqjaBY1X8NtuzZ0P4cahgsBFc 8HgYu2u3Ysd5wmvSTsOXld8Qsns1KIUOpzgWw56AJ6dxS3lK4QSUFwjzbZW9H0jJ 49eBMAaA+hCjv8c/4BFuZq9Gvsafn425Lx1V/3PFJlPu55V+7qWjeOkSzNctMlmC -qPQVetbZ/pHLAJO5IUO3SoTs5kl6bARzABEBAAGJAiUEGAEKAA8FAlQv6Z8CGwwF -CQHhM4AACgkQ2JTizos9efW9Gg/9GoPUHtq600MemwBQvgZdV1IMGTavvwnROhmr -DH+tmJnKchyEZ/SpfQWjEyj50WichcWaCQ0O4JNHL7cRXhJD8SbxwODQn6+6rdH2 -ilFCke+VDq3dKGbc4IM8YUHg3b6babXQkRTlUYsJ2oPCfNTjPFXXyLJvtdob1FPD -Xll42X+lcXx3P2seTf+lrGuPvg071ftDGFtnMom+DziC56wd3PqpGxyWuQycgtiX -YZEAs2rs7y028lVB3S/aRRtBll6NTdvAGoHaoSvnssqklID2lqoAhpvhO+wdgRrd -iHVUBJ9pzl1dUVZK8bU4R2Wx3SBK42dXeaWFnf3UqpiSMhyXwHZlCQNaQaMjFL8o -AJEWNakVlwejqoI+1kS0Am7iYV9L5bSUDvK9PDWKAJTUhQbOnO5lztumkmflbHg1 -6+ptT4VqpvB9mDdCdgOUB7spLKhTZkOVT9OG1ROxBQbIjt8PUUu2MbHw4XMx7pwk -YcYAu3tBaz9KDDMvvnYH9/V9o8b2qczQY98tIZaOVfjqK7smkMuNP82HXrpRTsfU -vW1i8TR4gH9RCO8ltNoAO6QXjCsCbeI+TTi8DqTYHcZD0cDmDBNojblubYS6mezo -dM1jIazlFqHFSBvzMbiSQ5BL5QZC3qd2B2DHxyuUDjvmJAVVPuIxu13yhrUC3SW2 -zWSthsI= -=08wY +qPQVetbZ/pHLAJO5IUO3SoTs5kl6bARzABEBAAGJAiUEGAEKAA8CGwwFAlYVa6cF +CQPGtYUACgkQ2JTizos9efUm0A/8D+84e0M5/HcmHzlWPaeRf5+0E8NQRdUX4NEU +2svbyfPXLw2r9/cYiBu1S5hmvhioOEvIXt1XGAUw1VfcFBIv2xLivW0etk3l0xlz +2MWZ5KWPyNmZcfvydRla+sAlo0TmZWPu4SeebMRznFB0ylAJIfQp3YCdTK8AUtfD +NNtIVlDU5cLuHUEx9BB3z1AiiZdqGy59htexwNfCB23nI+me10iFJf8PCv+Qe2jc +DTOpVimnJC8oGSw/b4rBBeMgFYg/E/AJ3MJgdmvdvg/zCBdArXETiU4V8XhWXb65 +E4Gw7oCU6Jn/aWSZYSEegArn/LR125qNwiv6kKNXO+6LwkixOZZp5WPlQf0f8mP6 +yJFnvPMbhfWQMPmPuEZTt8nT36Bn53fogkY8jo0SMK1tLyA7uVYOsCAyC1rN9NJG +DOu0+XFNhy1UKq1SIwBlLvWpnbxTsy/5kTg2XBHShmSFLzjQZzhSR8JsldH/dwDt +G/ddLu5J8WqzwR/K2NJ+kwyr6IQYuJoMSDlYIFu7mMTH54Cw0DPMDXvS+EIoD4Un +HfVyvRdOcvSjASoxiz1thbm1PCkgUch81EOkZ4uNK1gQZMVZ6sct+AsLOxsrRhAL +NfTGdYjweBAnrqo+mpomgIxRPSyc222MpAI59KUQ/RBLJdizSwdgxAHLO+qppMBb +3cLoiIs= +=0I7G -----END PGP PUBLIC KEY BLOCK----- From rsalz at openssl.org Wed Oct 7 20:42:53 2015 From: rsalz at openssl.org (Rich Salz) Date: Wed, 07 Oct 2015 20:42:53 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444250573.151833.16633.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via bb7b893d7c36803d8c5d4ca82a5a037c5fc111b9 (commit) from cc1cdc5df5e80883de20d6f59ecfc4505bbb3e52 (commit) - Log ----------------------------------------------------------------- commit bb7b893d7c36803d8c5d4ca82a5a037c5fc111b9 Author: Alessandro Ghedini Date: Wed Oct 7 16:40:37 2015 -0400 Fix travis 1.0.2 builds Disable -Wshadow error when building with GCC Add support for linu-x86_64-clang debug; this is needed for Travis CI. Disable linux-clang and mingw debug builds on Travis CI; not supported. Fix Travis email notifications config Signed-off-by: Rich Salz Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: .travis.yml | 12 ++++++++---- Configure | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3125363..b88eb3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,10 @@ matrix: compiler: i686-w64-mingw32-gcc - os: osx compiler: x86_64-w64-mingw32-gcc + - compiler: i686-w64-mingw32-gcc + env: CONFIG_OPTS="-d --strict-warnings" + - compiler: x86_64-w64-mingw32-gcc + env: CONFIG_OPTS="-d --strict-warnings" before_script: - if [ "$CC" == i686-w64-mingw32-gcc ]; then @@ -35,6 +39,9 @@ before_script: export CROSS_COMPILE=${CC%%gcc}; unset CC; ./Configure mingw64 $CONFIG_OPTS; else + if [ "$CC" == gcc ]; then + export CONFIG_OPTS="$CONFIG_OPTS -Wno-error=shadow"; + fi; ./config $CONFIG_OPTS; fi @@ -43,8 +50,5 @@ script: - if [ -z "$CROSS_COMPILE" ]; then make test; fi notifications: - recipient: - - openssl-commits at openssl.org email: - on_success: change - on_failure: always + - openssl-commits at openssl.org diff --git a/Configure b/Configure index d99eed7..81b263f 100755 --- a/Configure +++ b/Configure @@ -416,6 +416,7 @@ my %table=( "linux-ia64-icc","icc:-DL_ENDIAN -O2 -Wall::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-x86_64", "gcc:-m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux-x86_64-clang", "clang: -m64 -DL_ENDIAN -O3 -Wall -Wextra $clang_disabled_warnings -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", +"debug-linux-x86_64-clang", "clang: -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -g -Wall -Wextra $clang_disabled_warnings -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux-x86_64-icc", "icc:-DL_ENDIAN -O2::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux-x32", "gcc:-mx32 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-mx32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::x32", "linux64-s390x", "gcc:-m64 -DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", From builds at travis-ci.org Wed Oct 7 20:58:01 2015 From: builds at travis-ci.org (Travis CI) Date: Wed, 07 Oct 2015 20:58:01 +0000 Subject: [openssl-commits] Fixed: openssl/openssl#370 (OpenSSL_1_0_2-stable - bb7b893) In-Reply-To: Message-ID: <5615875774748_36ae036244237@c36adbbe-d6a1-4ffa-820e-cb49bc3397fe.mail> Build Update for openssl/openssl ------------------------------------- Build: #370 Status: Fixed Duration: 14 minutes and 38 seconds Commit: bb7b893 (OpenSSL_1_0_2-stable) Author: Alessandro Ghedini Message: Fix travis 1.0.2 builds Disable -Wshadow error when building with GCC Add support for linu-x86_64-clang debug; this is needed for Travis CI. Disable linux-clang and mingw debug builds on Travis CI; not supported. Fix Travis email notifications config Signed-off-by: Rich Salz Reviewed-by: Andy Polyakov View the changeset: https://github.com/openssl/openssl/compare/cc1cdc5df5e8...bb7b893d7c36 View the full build log and details: https://travis-ci.org/openssl/openssl/builds/84179207 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From levitte at openssl.org Thu Oct 8 10:40:06 2015 From: levitte at openssl.org (Richard Levitte) Date: Thu, 08 Oct 2015 10:40:06 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444300806.752474.24624.nullmailer@dev.openssl.org> The branch master has been updated via 5850cc75ea0c1581a9034390f1ca77cadc596238 (commit) from 8314146ac57059f6d4095ef23e30ccdeb4699938 (commit) - Log ----------------------------------------------------------------- commit 5850cc75ea0c1581a9034390f1ca77cadc596238 Author: Richard Levitte Date: Thu Oct 8 11:53:07 2015 +0200 When ENGINE_add finds that id or name is missing, actually return Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: crypto/engine/eng_list.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index 9e80eaf..54141f3 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -260,6 +260,7 @@ int ENGINE_add(ENGINE *e) } if ((e->id == NULL) || (e->name == NULL)) { ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_ID_OR_NAME_MISSING); + return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_add(e)) { From levitte at openssl.org Thu Oct 8 10:41:21 2015 From: levitte at openssl.org (Richard Levitte) Date: Thu, 08 Oct 2015 10:41:21 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444300881.163500.25624.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via b00424792f293b49e5e581aa36a9c826d1d2d508 (commit) from bb7b893d7c36803d8c5d4ca82a5a037c5fc111b9 (commit) - Log ----------------------------------------------------------------- commit b00424792f293b49e5e581aa36a9c826d1d2d508 Author: Richard Levitte Date: Thu Oct 8 11:53:07 2015 +0200 When ENGINE_add finds that id or name is missing, actually return Reviewed-by: Matt Caswell (cherry picked from commit 5850cc75ea0c1581a9034390f1ca77cadc596238) ----------------------------------------------------------------------- Summary of changes: crypto/engine/eng_list.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index 3384e31..83c95d5 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -260,6 +260,7 @@ int ENGINE_add(ENGINE *e) } if ((e->id == NULL) || (e->name == NULL)) { ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_ID_OR_NAME_MISSING); + return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_add(e)) { From levitte at openssl.org Thu Oct 8 10:41:24 2015 From: levitte at openssl.org (Richard Levitte) Date: Thu, 08 Oct 2015 10:41:24 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444300884.433705.25856.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 363c8fd572b19aa085dad8da6d7a5dd89930bf54 (commit) from 91dc4497dec6fcb1e0ecf61f257c9c13364328b4 (commit) - Log ----------------------------------------------------------------- commit 363c8fd572b19aa085dad8da6d7a5dd89930bf54 Author: Richard Levitte Date: Thu Oct 8 11:53:07 2015 +0200 When ENGINE_add finds that id or name is missing, actually return Reviewed-by: Matt Caswell (cherry picked from commit 5850cc75ea0c1581a9034390f1ca77cadc596238) ----------------------------------------------------------------------- Summary of changes: crypto/engine/eng_list.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index 3384e31..83c95d5 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -260,6 +260,7 @@ int ENGINE_add(ENGINE *e) } if ((e->id == NULL) || (e->name == NULL)) { ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_ID_OR_NAME_MISSING); + return 0; } CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); if (!engine_list_add(e)) { From matt at openssl.org Thu Oct 8 13:18:56 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 08 Oct 2015 13:18:56 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444310336.865286.18691.nullmailer@dev.openssl.org> The branch master has been updated via dffe51091f412dcbc18f6641132f0b4f0def6bce (commit) from 5850cc75ea0c1581a9034390f1ca77cadc596238 (commit) - Log ----------------------------------------------------------------- commit dffe51091f412dcbc18f6641132f0b4f0def6bce Author: Matt Caswell Date: Thu Oct 8 13:36:10 2015 +0100 Don't treat a bare OCTETSTRING as DigestInfo in int_rsa_verify The function int_rsa_verify is an internal function used for verifying an RSA signature. It takes an argument |dtype| which indicates the digest type that was used. Dependant on that digest type the processing of the signature data will vary. In particular if |dtype == NID_mdc2| and the signature data is a bare OCTETSTRING then it is treated differently to the default case where the signature data is treated as a DigestInfo (X509_SIG). Due to a missing "else" keyword the logic actually correctly processes the OCTETSTRING format signature first, and then attempts to continue and process it as DigestInfo. This will invariably fail because we already know that it is a bare OCTETSTRING. This failure doesn't actualy make a real difference because it ends up at the |err| label regardless and still returns a "success" result. This patch just cleans things up to make it look a bit more sane. RT#4076 Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: crypto/rsa/rsa_sign.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index ff70cd9..9f4649a 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -200,14 +200,13 @@ int int_rsa_verify(int dtype, const unsigned char *m, memcpy(rm, s + 2, 16); *prm_len = 16; ret = 1; - } else if (memcmp(m, s + 2, 16)) + } else if (memcmp(m, s + 2, 16)) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); - else + } else { ret = 1; - } - - /* Special case: SSL signature */ - if (dtype == NID_md5_sha1) { + } + } else if (dtype == NID_md5_sha1) { + /* Special case: SSL signature */ if ((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH)) RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); else From matt at openssl.org Thu Oct 8 13:19:12 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 08 Oct 2015 13:19:12 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444310352.373128.19540.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via 985abd1fd8aa24ef1bbf6adcf1923d07b35fa246 (commit) from b00424792f293b49e5e581aa36a9c826d1d2d508 (commit) - Log ----------------------------------------------------------------- commit 985abd1fd8aa24ef1bbf6adcf1923d07b35fa246 Author: Matt Caswell Date: Thu Oct 8 13:36:10 2015 +0100 Don't treat a bare OCTETSTRING as DigestInfo in int_rsa_verify The function int_rsa_verify is an internal function used for verifying an RSA signature. It takes an argument |dtype| which indicates the digest type that was used. Dependant on that digest type the processing of the signature data will vary. In particular if |dtype == NID_mdc2| and the signature data is a bare OCTETSTRING then it is treated differently to the default case where the signature data is treated as a DigestInfo (X509_SIG). Due to a missing "else" keyword the logic actually correctly processes the OCTETSTRING format signature first, and then attempts to continue and process it as DigestInfo. This will invariably fail because we already know that it is a bare OCTETSTRING. This failure doesn't actualy make a real difference because it ends up at the |err| label regardless and still returns a "success" result. This patch just cleans things up to make it look a bit more sane. RT#4076 Reviewed-by: Richard Levitte (cherry picked from commit dffe51091f412dcbc18f6641132f0b4f0def6bce) ----------------------------------------------------------------------- Summary of changes: crypto/rsa/rsa_sign.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index 19461c6..82ca832 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -218,14 +218,13 @@ int int_rsa_verify(int dtype, const unsigned char *m, memcpy(rm, s + 2, 16); *prm_len = 16; ret = 1; - } else if (memcmp(m, s + 2, 16)) + } else if (memcmp(m, s + 2, 16)) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); - else + } else { ret = 1; - } - - /* Special case: SSL signature */ - if (dtype == NID_md5_sha1) { + } + } else if (dtype == NID_md5_sha1) { + /* Special case: SSL signature */ if ((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH)) RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); else From matt at openssl.org Thu Oct 8 13:19:34 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 08 Oct 2015 13:19:34 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444310374.026776.19807.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via ec1f1255127c3987494978c9bf1c8f7ac9b093e4 (commit) from 363c8fd572b19aa085dad8da6d7a5dd89930bf54 (commit) - Log ----------------------------------------------------------------- commit ec1f1255127c3987494978c9bf1c8f7ac9b093e4 Author: Matt Caswell Date: Thu Oct 8 13:36:10 2015 +0100 Don't treat a bare OCTETSTRING as DigestInfo in int_rsa_verify The function int_rsa_verify is an internal function used for verifying an RSA signature. It takes an argument |dtype| which indicates the digest type that was used. Dependant on that digest type the processing of the signature data will vary. In particular if |dtype == NID_mdc2| and the signature data is a bare OCTETSTRING then it is treated differently to the default case where the signature data is treated as a DigestInfo (X509_SIG). Due to a missing "else" keyword the logic actually correctly processes the OCTETSTRING format signature first, and then attempts to continue and process it as DigestInfo. This will invariably fail because we already know that it is a bare OCTETSTRING. This failure doesn't actualy make a real difference because it ends up at the |err| label regardless and still returns a "success" result. This patch just cleans things up to make it look a bit more sane. RT#4076 Reviewed-by: Richard Levitte (cherry picked from commit dffe51091f412dcbc18f6641132f0b4f0def6bce) ----------------------------------------------------------------------- Summary of changes: crypto/rsa/rsa_sign.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index bc91da2..41c827f 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -218,14 +218,13 @@ int int_rsa_verify(int dtype, const unsigned char *m, memcpy(rm, s + 2, 16); *prm_len = 16; ret = 1; - } else if (memcmp(m, s + 2, 16)) + } else if (memcmp(m, s + 2, 16)) { RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); - else + } else { ret = 1; - } - - /* Special case: SSL signature */ - if (dtype == NID_md5_sha1) { + } + } else if (dtype == NID_md5_sha1) { + /* Special case: SSL signature */ if ((i != SSL_SIG_LENGTH) || memcmp(s, m, SSL_SIG_LENGTH)) RSAerr(RSA_F_INT_RSA_VERIFY, RSA_R_BAD_SIGNATURE); else From matt at openssl.org Thu Oct 8 14:43:24 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 08 Oct 2015 14:43:24 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444315404.894402.1929.nullmailer@dev.openssl.org> The branch master has been updated via 28dc5d1963c96db99e3fd48418552a5a0399480d (commit) from dffe51091f412dcbc18f6641132f0b4f0def6bce (commit) - Log ----------------------------------------------------------------- commit 28dc5d1963c96db99e3fd48418552a5a0399480d Author: Matt Caswell Date: Thu Oct 8 15:29:15 2015 +0100 Fix no-ripemd on Windows mkdef.pl was getting confused by: # ifdef OPENSSL_NO_RMD160 # error RIPEMD is disabled. # endif Changing RIPEMD to RMD160 solves it. Fix suggested by Steve Henson. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: include/openssl/ripemd.h | 2 +- util/libeay.num | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/openssl/ripemd.h b/include/openssl/ripemd.h index 9933078..97ad187 100644 --- a/include/openssl/ripemd.h +++ b/include/openssl/ripemd.h @@ -67,7 +67,7 @@ extern "C" { #endif # ifdef OPENSSL_NO_RMD160 -# error RIPEMD is disabled. +# error RMD160 is disabled. # endif # define RIPEMD160_LONG unsigned int diff --git a/util/libeay.num b/util/libeay.num index 1b7bb47..661575f 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -1016,11 +1016,11 @@ RSA_padding_check_none 1038 EXIST::FUNCTION:RSA bn_add_words 1039 NOEXIST::FUNCTION: d2i_Netscape_RSA_2 1040 NOEXIST::FUNCTION: CRYPTO_get_ex_new_index 1041 EXIST::FUNCTION: -RIPEMD160_Init 1042 EXIST::FUNCTION: -RIPEMD160_Update 1043 EXIST::FUNCTION: -RIPEMD160_Final 1044 EXIST::FUNCTION: -RIPEMD160 1045 EXIST::FUNCTION: -RIPEMD160_Transform 1046 EXIST::FUNCTION: +RIPEMD160_Init 1042 EXIST::FUNCTION:RMD160 +RIPEMD160_Update 1043 EXIST::FUNCTION:RMD160 +RIPEMD160_Final 1044 EXIST::FUNCTION:RMD160 +RIPEMD160 1045 EXIST::FUNCTION:RMD160 +RIPEMD160_Transform 1046 EXIST::FUNCTION:RMD160 RC5_32_set_key 1047 EXIST::FUNCTION:RC5 RC5_32_ecb_encrypt 1048 EXIST::FUNCTION:RC5 RC5_32_encrypt 1049 EXIST::FUNCTION:RC5 From emilia at openssl.org Thu Oct 8 14:46:23 2015 From: emilia at openssl.org (Emilia Kasper) Date: Thu, 08 Oct 2015 14:46:23 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444315583.501122.4720.nullmailer@dev.openssl.org> The branch master has been updated via 329428708d6836676f6a7078aa2e2a1db9a1addb (commit) from 28dc5d1963c96db99e3fd48418552a5a0399480d (commit) - Log ----------------------------------------------------------------- commit 329428708d6836676f6a7078aa2e2a1db9a1addb Author: Emilia Kasper Date: Fri Oct 2 14:40:30 2015 +0200 PACKET: simplify ServerKeyExchange parsing Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: include/openssl/ssl.h | 1 + ssl/packet_locl.h | 2 + ssl/s3_clnt.c | 289 ++++++++++++++++---------------------------------- ssl/ssl_err.c | 1 + 4 files changed, 97 insertions(+), 196 deletions(-) diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 4b21d0f..0727e7f 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -2115,6 +2115,7 @@ void ERR_load_SSL_strings(void); # define SSL_R_BAD_DH_PUB_KEY_VALUE 393 # define SSL_R_BAD_DH_P_LENGTH 110 # define SSL_R_BAD_DH_P_VALUE 395 +# define SSL_R_BAD_DH_VALUE 102 # define SSL_R_BAD_DIGEST_LENGTH 111 # define SSL_R_BAD_DSA_SIGNATURE 112 # define SSL_R_BAD_ECC_CERT 304 diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index e73eb3d..9354e6c 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -418,6 +418,8 @@ __owur static inline int PACKET_memdup(const PACKET *pkt, unsigned char **data, __owur static inline int PACKET_strndup(const PACKET *pkt, char **data) { OPENSSL_free(*data); + + /* This will succeed on an empty packet, unless pkt->curr == NULL. */ *data = BUF_strndup((const char*)pkt->curr, PACKET_remaining(pkt)); return (*data != NULL); } diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index a05be70..2df5afe 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -1434,7 +1434,6 @@ int ssl3_get_key_exchange(SSL *s) #endif EVP_MD_CTX md_ctx; int al, j, verify_ret, ok; - unsigned int i; long n, alg_k, alg_a; EVP_PKEY *pkey = NULL; const EVP_MD *md = NULL; @@ -1449,11 +1448,8 @@ int ssl3_get_key_exchange(SSL *s) BN_CTX *bn_ctx = NULL; EC_POINT *srvr_ecpoint = NULL; int curve_nid = 0; - unsigned int encoded_pt_len = 0; #endif - PACKET pkt, save_param_start; - unsigned char *data, *param; - size_t param_len; + PACKET pkt, save_param_start, signature; EVP_MD_CTX_init(&md_ctx); @@ -1512,9 +1508,9 @@ int ssl3_get_key_exchange(SSL *s) #ifndef OPENSSL_NO_PSK /* PSK ciphersuites are preceded by an identity hint */ if (alg_k & SSL_PSK) { - - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); + PACKET psk_identity_hint; + if (!PACKET_get_length_prefixed_2(&pkt, &psk_identity_hint)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } @@ -1524,33 +1520,16 @@ int ssl3_get_key_exchange(SSL *s) * a PSK identity hint can be as long as the maximum length of a PSK * identity. */ - if (i > PSK_MAX_IDENTITY_LEN) { + if (PACKET_remaining(&psk_identity_hint) > PSK_MAX_IDENTITY_LEN) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } - if (PACKET_remaining(&pkt) < i) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, - SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH); - goto f_err; - } - - OPENSSL_free(s->session->psk_identity_hint); - if (i != 0) { - unsigned char *hint = NULL; - if (!PACKET_get_bytes(&pkt, &hint, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - s->session->psk_identity_hint = BUF_strndup((char *)hint, i); - if (s->session->psk_identity_hint == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto f_err; - } - } else { - s->session->psk_identity_hint = NULL; + if (!PACKET_strndup(&psk_identity_hint, + &s->session->psk_identity_hint)) { + al = SSL_AD_INTERNAL_ERROR; + goto f_err; } } @@ -1560,62 +1539,27 @@ int ssl3_get_key_exchange(SSL *s) #endif /* !OPENSSL_NO_PSK */ #ifndef OPENSSL_NO_SRP if (alg_k & SSL_kSRP) { - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_N_LENGTH); - goto f_err; - } - - if ((s->srp_ctx.N = BN_bin2bn(data, i, NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); - goto err; - } - - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_G_LENGTH); + PACKET prime, generator, salt, server_pub; + if (!PACKET_get_length_prefixed_2(&pkt, &prime) + || !PACKET_get_length_prefixed_2(&pkt, &generator) + || !PACKET_get_length_prefixed_1(&pkt, &salt) + || !PACKET_get_length_prefixed_2(&pkt, &server_pub)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } - if ((s->srp_ctx.g = BN_bin2bn(data, i, NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); - goto err; - } - - if (!PACKET_get_1(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_S_LENGTH); - goto f_err; - } - - if ((s->srp_ctx.s = BN_bin2bn(data, i, NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); - goto err; - } - - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_B_LENGTH); - goto f_err; - } - - if ((s->srp_ctx.B = BN_bin2bn(data, i, NULL)) == NULL) { + if ((s->srp_ctx.N = + BN_bin2bn(PACKET_data(&prime), + PACKET_remaining(&prime), NULL)) == NULL + || (s->srp_ctx.g = + BN_bin2bn(PACKET_data(&generator), + PACKET_remaining(&generator), NULL)) == NULL + || (s->srp_ctx.s = + BN_bin2bn(PACKET_data(&salt), + PACKET_remaining(&salt), NULL)) == NULL + || (s->srp_ctx.B = + BN_bin2bn(PACKET_data(&server_pub), + PACKET_remaining(&server_pub), NULL)) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } @@ -1632,43 +1576,29 @@ int ssl3_get_key_exchange(SSL *s) #endif /* !OPENSSL_NO_SRP */ #ifndef OPENSSL_NO_RSA if (alg_k & SSL_kRSA) { + PACKET mod, exp; /* Temporary RSA keys only allowed in export ciphersuites */ if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } - if ((rsa = RSA_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto err; - } - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); + if (!PACKET_get_length_prefixed_2(&pkt, &mod) + || !PACKET_get_length_prefixed_2(&pkt, &exp)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_MODULUS_LENGTH); - goto f_err; - } - - if ((rsa->n = BN_bin2bn(data, i, rsa->n)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); + if ((rsa = RSA_new()) == NULL) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_E_LENGTH); - goto f_err; - } - - if ((rsa->e = BN_bin2bn(data, i, rsa->e)) == NULL) { + if ((rsa->n = BN_bin2bn(PACKET_data(&mod), PACKET_remaining(&mod), + rsa->n)) == NULL + || (rsa->e = BN_bin2bn(PACKET_data(&exp), PACKET_remaining(&exp), + rsa->e)) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } @@ -1695,68 +1625,33 @@ int ssl3_get_key_exchange(SSL *s) #endif #ifndef OPENSSL_NO_DH else if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) { - if ((dh = DH_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_DH_LIB); - goto err; - } - - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } + PACKET prime, generator, pub_key; - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_LENGTH); + if (!PACKET_get_length_prefixed_2(&pkt, &prime) + || !PACKET_get_length_prefixed_2(&pkt, &generator) + || !PACKET_get_length_prefixed_2(&pkt, &pub_key)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } - if ((dh->p = BN_bin2bn(data, i, NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); + if ((dh = DH_new()) == NULL) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } - if (BN_is_zero(dh->p)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_VALUE); - goto f_err; - } - - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_LENGTH); - goto f_err; - } - - if ((dh->g = BN_bin2bn(data, i, NULL)) == NULL) { + if ((dh->p = BN_bin2bn(PACKET_data(&prime), + PACKET_remaining(&prime), NULL)) == NULL + || (dh->g = BN_bin2bn(PACKET_data(&generator), + PACKET_remaining(&generator), NULL)) == NULL + || (dh->pub_key = + BN_bin2bn(PACKET_data(&pub_key), + PACKET_remaining(&pub_key), NULL)) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } - if (BN_is_zero(dh->g)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_VALUE); - goto f_err; - } - - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - - if (!PACKET_get_bytes(&pkt, &data, i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_PUB_KEY_LENGTH); - goto f_err; - } - - if ((dh->pub_key = BN_bin2bn(data, i, NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); - goto err; - } - - if (BN_is_zero(dh->pub_key)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_PUB_KEY_VALUE); + if (BN_is_zero(dh->p) || BN_is_zero(dh->g) || BN_is_zero(dh->pub_key)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_VALUE); goto f_err; } @@ -1778,6 +1673,8 @@ int ssl3_get_key_exchange(SSL *s) else if (alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) { EC_GROUP *ngroup; const EC_GROUP *group; + PACKET encoded_pt; + unsigned char *ecparams; if ((ecdh = EC_KEY_new()) == NULL) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); @@ -1786,15 +1683,10 @@ int ssl3_get_key_exchange(SSL *s) /* * Extract elliptic curve parameters and the server's ephemeral ECDH - * public key. Keep accumulating lengths of various components in - * param_len and make sure it never exceeds n. - */ - - /* - * XXX: For now we only support named (not generic) curves and the + * public key. For now we only support named (not generic) curves and * ECParameters in this case is just three bytes. */ - if (!PACKET_get_bytes(&pkt, &data, 3)) { + if (!PACKET_get_bytes(&pkt, &ecparams, 3)) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); goto f_err; } @@ -1802,12 +1694,12 @@ int ssl3_get_key_exchange(SSL *s) * Check curve is one of our preferences, if not server has sent an * invalid curve. ECParameters is 3 bytes. */ - if (!tls1_check_curve(s, data, 3)) { + if (!tls1_check_curve(s, ecparams, 3)) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_CURVE); goto f_err; } - if ((curve_nid = tls1_ec_curve_id2nid(*(data + 2))) == 0) { + if ((curve_nid = tls1_ec_curve_id2nid(*(ecparams + 2))) == 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS); @@ -1842,14 +1734,13 @@ int ssl3_get_key_exchange(SSL *s) goto err; } - if (!PACKET_get_1(&pkt, &encoded_pt_len)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); + if (!PACKET_get_length_prefixed_1(&pkt, &encoded_pt)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } - if (!PACKET_get_bytes(&pkt, &data, encoded_pt_len) || - (EC_POINT_oct2point(group, srvr_ecpoint, - data, encoded_pt_len, bn_ctx) == 0)) { + if (EC_POINT_oct2point(group, srvr_ecpoint, PACKET_data(&encoded_pt), + PACKET_remaining(&encoded_pt), bn_ctx) == 0) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_ECPOINT); goto f_err; } @@ -1883,21 +1774,29 @@ int ssl3_get_key_exchange(SSL *s) } #endif /* !OPENSSL_NO_EC */ - /* - * |pkt| now points to the beginning of the signature, so the difference - * equals the length of the parameters. - */ - param_len = PACKET_remaining(&save_param_start) - PACKET_remaining(&pkt); - /* if it was signed, check the signature */ if (pkey != NULL) { + PACKET params; + /* + * |pkt| now points to the beginning of the signature, so the difference + * equals the length of the parameters. + */ + if (!PACKET_get_sub_packet(&save_param_start, ¶ms, + PACKET_remaining(&save_param_start) - + PACKET_remaining(&pkt))) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + if (SSL_USE_SIGALGS(s)) { + unsigned char *sigalgs; int rv; - if (!PACKET_get_bytes(&pkt, &data, 2)) { + if (!PACKET_get_bytes(&pkt, &sigalgs, 2)) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); goto f_err; } - rv = tls12_check_peer_sigalg(&md, s, data, pkey); + rv = tls12_check_peer_sigalg(&md, s, sigalgs, pkey); if (rv == -1) goto err; else if (rv == 0) { @@ -1906,11 +1805,13 @@ int ssl3_get_key_exchange(SSL *s) #ifdef SSL_DEBUG fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); #endif - } else + } else { md = EVP_sha1(); + } - if (!PACKET_get_net_2(&pkt, &i)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); + if (!PACKET_get_length_prefixed_2(&pkt, &signature) + || PACKET_remaining(&pkt) != 0) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } j = EVP_PKEY_size(pkey); @@ -1922,19 +1823,11 @@ int ssl3_get_key_exchange(SSL *s) /* * Check signature length */ - if (i > (unsigned int)j - || !PACKET_get_bytes(&pkt, &data, i) - || PACKET_remaining(&pkt) != 0) { + if (PACKET_remaining(&signature) > (size_t)j) { /* wrong packet length */ SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_SIGNATURE_LENGTH); goto f_err; } - pkt = save_param_start; - if (!PACKET_get_bytes(&pkt, ¶m, param_len)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } #ifndef OPENSSL_NO_RSA if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { int num; @@ -1950,13 +1843,15 @@ int ssl3_get_key_exchange(SSL *s) SSL3_RANDOM_SIZE); EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, param, param_len); + EVP_DigestUpdate(&md_ctx, PACKET_data(¶ms), + PACKET_remaining(¶ms)); EVP_DigestFinal_ex(&md_ctx, q, &size); q += size; j += size; } verify_ret = - RSA_verify(NID_md5_sha1, md_buf, j, data, i, pkey->pkey.rsa); + RSA_verify(NID_md5_sha1, md_buf, j, PACKET_data(&signature), + PACKET_remaining(&signature), pkey->pkey.rsa); if (verify_ret < 0) { al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_DECRYPT); @@ -1976,8 +1871,10 @@ int ssl3_get_key_exchange(SSL *s) SSL3_RANDOM_SIZE); EVP_VerifyUpdate(&md_ctx, &(s->s3->server_random[0]), SSL3_RANDOM_SIZE); - EVP_VerifyUpdate(&md_ctx, param, param_len); - if (EVP_VerifyFinal(&md_ctx, data, (int)i, pkey) <= 0) { + EVP_VerifyUpdate(&md_ctx, PACKET_data(¶ms), + PACKET_remaining(¶ms)); + if (EVP_VerifyFinal(&md_ctx, PACKET_data(&signature), + PACKET_remaining(&signature), pkey) <= 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); diff --git a/ssl/ssl_err.c b/ssl/ssl_err.c index 447bac6..0b93db9 100644 --- a/ssl/ssl_err.c +++ b/ssl/ssl_err.c @@ -351,6 +351,7 @@ static ERR_STRING_DATA SSL_str_reasons[] = { {ERR_REASON(SSL_R_BAD_DH_PUB_KEY_VALUE), "bad dh pub key value"}, {ERR_REASON(SSL_R_BAD_DH_P_LENGTH), "bad dh p length"}, {ERR_REASON(SSL_R_BAD_DH_P_VALUE), "bad dh p value"}, + {ERR_REASON(SSL_R_BAD_DH_VALUE), "bad dh value"}, {ERR_REASON(SSL_R_BAD_DIGEST_LENGTH), "bad digest length"}, {ERR_REASON(SSL_R_BAD_DSA_SIGNATURE), "bad dsa signature"}, {ERR_REASON(SSL_R_BAD_ECC_CERT), "bad ecc cert"}, From stevem at openssl.org Thu Oct 8 19:09:33 2015 From: stevem at openssl.org (Steve Marquess) Date: Thu, 08 Oct 2015 19:09:33 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1444331373.189195.20936.nullmailer@dev.openssl.org> The branch master has been updated via 04aec9e4e49adb97b496b6e9bbd172bdab36cfe2 (commit) from 739777feb5ecc030dd7a8aa044ea34aa38fb5f8f (commit) - Log ----------------------------------------------------------------- commit 04aec9e4e49adb97b496b6e9bbd172bdab36cfe2 Author: Steve Marquess Date: Thu Oct 8 15:09:15 2015 -0400 Add ODF document ----------------------------------------------------------------------- Summary of changes: ...yPolicy-2.0.9.odt => SecurityPolicy-2.0.10.odt} | Bin 812096 -> 820246 bytes 1 file changed, 0 insertions(+), 0 deletions(-) copy docs/fips/{SecurityPolicy-2.0.9.odt => SecurityPolicy-2.0.10.odt} (91%) diff --git a/docs/fips/SecurityPolicy-2.0.9.odt b/docs/fips/SecurityPolicy-2.0.10.odt similarity index 91% copy from docs/fips/SecurityPolicy-2.0.9.odt copy to docs/fips/SecurityPolicy-2.0.10.odt index 8c285b0..12ce77e 100644 Binary files a/docs/fips/SecurityPolicy-2.0.9.odt and b/docs/fips/SecurityPolicy-2.0.10.odt differ From rsalz at openssl.org Fri Oct 9 03:32:13 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 09 Oct 2015 03:32:13 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444361533.821723.2527.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 978b5d709a6d7fc75665a837df2ad57fe9653dcf (commit) from ec1f1255127c3987494978c9bf1c8f7ac9b093e4 (commit) - Log ----------------------------------------------------------------- commit 978b5d709a6d7fc75665a837df2ad57fe9653dcf Author: Rich Salz Date: Thu Oct 8 23:31:29 2015 -0400 Fix travis build for 1.0.1 Add explicit linux-clang targets Add --strict-warnings support for clang Disable mingw debug builds Signed-off-by: Rich Salz Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: .travis.yml | 4 ++++ Configure | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3125363..397ac1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,10 @@ matrix: compiler: i686-w64-mingw32-gcc - os: osx compiler: x86_64-w64-mingw32-gcc + - compiler: i686-w64-mingw32-gcc + env: CONFIG_OPTS="-d --strict-warnings" + - compiler: x86_64-w64-mingw32-gcc + env: CONFIG_OPTS="-d --strict-warnings" before_script: - if [ "$CC" == i686-w64-mingw32-gcc ]; then diff --git a/Configure b/Configure index 60ec378..c9dedcd 100755 --- a/Configure +++ b/Configure @@ -105,6 +105,8 @@ my $usage="Usage: Configure [no- ...] [enable- ...] [experimenta my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DOPENSSL_NO_DEPRECATED"; +my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Qunused-arguments"; + my $strict_warnings = 0; my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL"; @@ -197,6 +199,7 @@ my %table=( "debug-linux-generic32","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -g -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-generic64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "debug-linux-x86_64","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -g -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", +"debug-linux-x86_64-clang","clang: -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -m64 -DL_ENDIAN -g -Wall -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "dist", "cc:-O::(unknown)::::::", # Basic configs that should work on any (32 and less bit) box @@ -361,6 +364,7 @@ my %table=( "linux-ia64-ecc","ecc:-DL_ENDIAN -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-ia64-icc","icc:-DL_ENDIAN -O2 -Wall -no_cpprt::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", "linux-x86_64", "gcc:-m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", +"linux-x86_64-clang","clang: -m64 -DL_ENDIAN -O3 -Wall -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", "linux64-s390x", "gcc:-m64 -DB_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", #### So called "highgprs" target for z/Architecture CPUs # "Highgprs" is kernel feature first implemented in Linux 2.6.32, see @@ -1574,12 +1578,21 @@ if ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/) if ($strict_warnings) { + my $ecc = $cc; + $ecc = "clang" if `$cc --version 2>&1` =~ /clang/; my $wopt; - die "ERROR --strict-warnings requires gcc" unless ($cc =~ /gcc$/); + die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc$/ or $ecc =~ /clang$/); foreach $wopt (split /\s+/, $gcc_devteam_warn) { $cflags .= " $wopt" unless ($cflags =~ /$wopt/) } + if ($ecc eq "clang") + { + foreach $wopt (split /\s+/, $clang_devteam_warn) + { + $cflags .= " $wopt" unless ($cflags =~ /$wopt/) + } + } } open(IN,' The branch master has been updated via 3149baf83cb703f060b1e6eeb440a45e010a626b (commit) from 329428708d6836676f6a7078aa2e2a1db9a1addb (commit) - Log ----------------------------------------------------------------- commit 3149baf83cb703f060b1e6eeb440a45e010a626b Author: Adam Eijdenberg Date: Tue Sep 15 09:13:48 2015 -0700 Initial commit for Certificate Transparency support Original authors: Rob Stradling Dr. Stephen Henson Reviewed-by: Emilia Kasper Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: Makefile.org | 2 +- crypto/ct/Makefile | 83 +++++++++++ crypto/{ecdh/ech_err.c => ct/ct_err.c} | 37 ++--- crypto/ct/ct_lib.c | 208 ++++++++++++++++++++++++++++ crypto/ct/ct_locl.h | 242 +++++++++++++++++++++++++++++++++ crypto/err/openssl.ec | 1 + crypto/x509v3/Makefile | 2 +- crypto/x509v3/v3_lib.c | 2 +- crypto/x509v3/v3_scts.c | 52 ++----- include/openssl/err.h | 2 + 10 files changed, 572 insertions(+), 59 deletions(-) create mode 100644 crypto/ct/Makefile copy crypto/{ecdh/ech_err.c => ct/ct_err.c} (73%) create mode 100644 crypto/ct/ct_lib.c create mode 100644 crypto/ct/ct_locl.h diff --git a/Makefile.org b/Makefile.org index b6bce44..3ecc5c5 100644 --- a/Makefile.org +++ b/Makefile.org @@ -143,7 +143,7 @@ SDIRS= \ bn ec rsa dsa ecdsa dh ecdh dso engine \ buffer bio stack lhash rand err \ evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui \ - cms pqueue ts jpake srp store cmac + cms pqueue ts jpake srp store cmac ct # keep in mind that the above list is adjusted by ./Configure # according to no-xxx arguments... diff --git a/crypto/ct/Makefile b/crypto/ct/Makefile new file mode 100644 index 0000000..ce3a6b1 --- /dev/null +++ b/crypto/ct/Makefile @@ -0,0 +1,83 @@ +# +# OpenSSL/crypto/ct/Makefile +# + +DIR= ct +TOP= ../.. +CC= cc +INCLUDES= -I.. -I$(TOP) -I../../include +CFLAG=-g +MAKEFILE= Makefile +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile + +LIB=$(TOP)/libcrypto.a +LIBSRC= ct_lib.c +LIBOBJ= ct_lib.o + +SRC= $(LIBSRC) + +HEADER= ct_lcl.h + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +test: + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) || echo Never mind. + @touch lib + +files: + $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO + +tags: + ctags $(SRC) + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +update: depend + +depend: + @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile... + $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +ct_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h +ct_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h +ct_lib.o: ../../include/openssl/comp.h ../../include/openssl/crypto.h +ct_lib.o: ../../include/openssl/dsa.h ../../include/openssl/dtls1.h +ct_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h +ct_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h +ct_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h +ct_lib.o: ../../include/openssl/hmac.h ../../include/openssl/lhash.h +ct_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h +ct_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +ct_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h +ct_lib.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h +ct_lib.o: ../../include/openssl/pqueue.h ../../include/openssl/rsa.h +ct_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +ct_lib.o: ../../include/openssl/srtp.h ../../include/openssl/ssl.h +ct_lib.o: ../../include/openssl/ssl2.h ../../include/openssl/ssl3.h +ct_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +ct_lib.o: ../../include/openssl/tls1.h ../../include/openssl/x509.h +ct_lib.o: ../../include/openssl/x509_vfy.h ../../ssl/packet_locl.h +ct_lib.o: ../../ssl/record/record.h ../../ssl/ssl_locl.h +ct_lib.o: ../include/internal/cryptlib.h ct_lib.c ct_locl.h diff --git a/crypto/ecdh/ech_err.c b/crypto/ct/ct_err.c similarity index 73% copy from crypto/ecdh/ech_err.c copy to crypto/ct/ct_err.c index 4781076..d2781c5 100644 --- a/crypto/ecdh/ech_err.c +++ b/crypto/ct/ct_err.c @@ -1,6 +1,6 @@ -/* crypto/ecdh/ech_err.c */ +/* crypto/ct/ct_err.c */ /* ==================================================================== - * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -61,36 +61,41 @@ #include #include -#include +#include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR -# define ERR_FUNC(func) ERR_PACK(ERR_LIB_ECDH,func,0) -# define ERR_REASON(reason) ERR_PACK(ERR_LIB_ECDH,0,reason) +# define ERR_FUNC(func) ERR_PACK(ERR_LIB_CT,func,0) +# define ERR_REASON(reason) ERR_PACK(ERR_LIB_CT,0,reason) -static ERR_STRING_DATA ECDH_str_functs[] = { - {ERR_FUNC(ECDH_F_ECDH_COMPUTE_KEY), "ECDH_compute_key"}, - {ERR_FUNC(ECDH_F_ECDH_DATA_NEW_METHOD), "ECDH_DATA_new_method"}, +static ERR_STRING_DATA CT_str_functs[] = { + {ERR_FUNC(CT_F_SCT_NEW), "SCT_new"}, + {ERR_FUNC(CT_F_SCT_SET0_LOG_ID), "SCT_set0_log_id"}, + {ERR_FUNC(CT_F_SCT_SET_LOG_ENTRY_TYPE), "SCT_set_log_entry_type"}, + {ERR_FUNC(CT_F_SCT_SET_SIGNATURE_NID), "SCT_set_signature_nid"}, + {ERR_FUNC(CT_F_SCT_SET_VERSION), "SCT_set_version"}, {0, NULL} }; -static ERR_STRING_DATA ECDH_str_reasons[] = { - {ERR_REASON(ECDH_R_KDF_FAILED), "KDF failed"}, - {ERR_REASON(ECDH_R_NO_PRIVATE_VALUE), "no private value"}, - {ERR_REASON(ECDH_R_POINT_ARITHMETIC_FAILURE), "point arithmetic failure"}, +static ERR_STRING_DATA CT_str_reasons[] = { + {ERR_REASON(CT_R_INVALID_LOG_ID_LENGTH), "invalid log id length"}, + {ERR_REASON(CT_R_UNRECOGNIZED_SIGNATURE_NID), + "unrecognized signature nid"}, + {ERR_REASON(CT_R_UNSUPPORTED_ENTRY_TYPE), "unsupported entry type"}, + {ERR_REASON(CT_R_UNSUPPORTED_VERSION), "unsupported version"}, {0, NULL} }; #endif -void ERR_load_ECDH_strings(void) +void ERR_load_CT_strings(void) { #ifndef OPENSSL_NO_ERR - if (ERR_func_error_string(ECDH_str_functs[0].error) == NULL) { - ERR_load_strings(0, ECDH_str_functs); - ERR_load_strings(0, ECDH_str_reasons); + if (ERR_func_error_string(CT_str_functs[0].error) == NULL) { + ERR_load_strings(0, CT_str_functs); + ERR_load_strings(0, CT_str_reasons); } #endif } diff --git a/crypto/ct/ct_lib.c b/crypto/ct/ct_lib.c new file mode 100644 index 0000000..7945745 --- /dev/null +++ b/crypto/ct/ct_lib.c @@ -0,0 +1,208 @@ +/* + * Written by Rob Stradling (rob at comodo.com) and Stephen Henson + * (steve at openssl.org) for the OpenSSL project 2014. + */ +/* ==================================================================== + * Copyright (c) 2014 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing at OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay at cryptsoft.com). This product includes software written by Tim + * Hudson (tjh at cryptsoft.com). + * + */ + +#ifndef OPENSSL_NO_CT + +# include +# include "internal/cryptlib.h" +# include "../ssl/ssl_locl.h" +# include "ct_locl.h" + +SCT *SCT_new(void) +{ + SCT *sct = OPENSSL_zalloc(sizeof(SCT)); + if (sct == NULL) { + CTerr(CT_F_SCT_NEW, ERR_R_MALLOC_FAILURE); + return NULL; + } + sct->entry_type = UNSET_ENTRY; + sct->version = UNSET_VERSION; + return sct; +} + +void SCT_free(SCT *sct) +{ + if (sct) { + OPENSSL_free(sct->log_id); + OPENSSL_free(sct->ext); + OPENSSL_free(sct->sig); + OPENSSL_free(sct->sct); + OPENSSL_free(sct); + } +} + +int SCT_set_version(SCT *sct, sct_version_t version) +{ + if (version != SCT_V1) { + CTerr(CT_F_SCT_SET_VERSION, CT_R_UNSUPPORTED_VERSION); + return 0; + } + sct->version = version; + return 1; +} + +int SCT_set_log_entry_type(SCT *sct, log_entry_type_t entry_type) +{ + if (entry_type != X509_ENTRY && entry_type != PRECERT_ENTRY) { + CTerr(CT_F_SCT_SET_LOG_ENTRY_TYPE, CT_R_UNSUPPORTED_ENTRY_TYPE); + return 0; + } + sct->entry_type = entry_type; + return 1; +} + +int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len) +{ + /* Currently only SHA-256 allowed so length must be SCT_V1_HASHLEN */ + if (log_id_len != SCT_V1_HASHLEN) { + CTerr(CT_F_SCT_SET0_LOG_ID, CT_R_INVALID_LOG_ID_LENGTH); + return 0; + } + OPENSSL_free(sct->log_id); + sct->log_id = log_id; + sct->log_id_len = log_id_len; + return 1; +} + +void SCT_set_timestamp(SCT *sct, uint64_t timestamp) +{ + sct->timestamp = timestamp; +} + +int SCT_set_signature_nid(SCT *sct, int nid) +{ + switch (nid) { + case NID_sha256WithRSAEncryption: + sct->hash_alg = TLSEXT_hash_sha256; + sct->sig_alg = TLSEXT_signature_rsa; + return 1; + case NID_ecdsa_with_SHA256: + sct->hash_alg = TLSEXT_hash_sha256; + sct->sig_alg = TLSEXT_signature_ecdsa; + return 1; + default: + CTerr(CT_F_SCT_SET_SIGNATURE_NID, CT_R_UNRECOGNIZED_SIGNATURE_NID); + return 0; + } +} + +void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len) +{ + OPENSSL_free(sct->ext); + sct->ext = ext; + sct->ext_len = ext_len; +} + +void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len) +{ + OPENSSL_free(sct->sig); + sct->sig = sig; + sct->sig_len = sig_len; +} + +sct_version_t SCT_get_version(const SCT *sct) +{ + return sct->version; +} + +log_entry_type_t SCT_get_log_entry_type(const SCT *sct) +{ + return sct->entry_type; +} + +size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id) +{ + *log_id = sct->log_id; + return sct->log_id_len; +} + +uint64_t SCT_get_timestamp(const SCT *sct) +{ + return sct->timestamp; +} + +int SCT_get_signature_nid(const SCT *sct) +{ + if (sct->version == SCT_V1) { + if (sct->hash_alg == TLSEXT_hash_sha256) { + switch (sct->sig_alg) { + case TLSEXT_signature_ecdsa: + return NID_ecdsa_with_SHA256; + case TLSEXT_signature_rsa: + return NID_sha256WithRSAEncryption; + default: + return NID_undef; + } + } + } + return NID_undef; +} + +size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext) +{ + *ext = sct->ext; + return sct->ext_len; +} + +size_t SCT_get0_signature(const SCT *sct, unsigned char **sig) +{ + *sig = sct->sig; + return sct->sig_len; +} + +#endif diff --git a/crypto/ct/ct_locl.h b/crypto/ct/ct_locl.h new file mode 100644 index 0000000..a616433 --- /dev/null +++ b/crypto/ct/ct_locl.h @@ -0,0 +1,242 @@ +/* crypto/ct/ct_locl.h */ +/* + * Written by Dr Stephen N Henson (steve at openssl.org) for the OpenSSL project + * 2015. + */ +/* ==================================================================== + * Copyright (c) 2015 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing at OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + */ +#ifndef HEADER_CT_LOCL_H +# define HEADER_CT_LOCL_H + +# ifdef __cplusplus +extern "C" { +# endif + +# ifndef OPENSSL_NO_CT + +/* All hashes are currently SHA256 */ +# define SCT_V1_HASHLEN 32 +/* Minimum RSA key size, from RFC6962 */ +# define SCT_MIN_RSA_BITS 2048 + +/* + * From RFC6962: opaque SerializedSCT<1..2^16-1>; struct { SerializedSCT + * sct_list <1..2^16-1>; } SignedCertificateTimestampList; + */ + +# define MAX_SCT_SIZE 65535 +# define MAX_SCT_LIST_SIZE MAX_SCT_SIZE + +typedef enum { + UNSET_ENTRY = -1, + X509_ENTRY = 0, + PRECERT_ENTRY = 1 +} log_entry_type_t; + +typedef enum { + UNSET_VERSION = -1, + SCT_V1 = 0 +} sct_version_t; + +typedef struct { + sct_version_t version; + /* If version is not SCT_V1 this contains the encoded SCT */ + unsigned char *sct; + size_t sct_len; + /* + * If version is SCT_V1 fields below contain components of the SCT. "logid", + * "ext" and "sig" point to buffers allocated with OPENSSL_malloc(). + */ + unsigned char *log_id; + size_t log_id_len; + + /* + * Note, we cannot distinguish between an unset timestamp, and one + * that is set to 0. However since CT didn't exist in 1970, no real + * SCT should ever be set as such. + */ + uint64_t timestamp; + unsigned char *ext; + size_t ext_len; + unsigned char hash_alg; + unsigned char sig_alg; + unsigned char *sig; + size_t sig_len; + /* Log entry type */ + log_entry_type_t entry_type; +} SCT; + +DECLARE_STACK_OF(SCT) + +/* + * Allocate new SCT. + * Caller is responsible for calling SCT_free when done. + */ +SCT *SCT_new(void); + +/* + * Free SCT and underlying datastructures. + */ +void SCT_free(SCT *sct); + +/* + * Set the version of an SCT. + * Returns 1 on success, 0 if the version is unrecognized. + */ +int SCT_set_version(SCT *sct, sct_version_t version); + +/* + * Set the log entry type of an SCT. + * Returns 1 on success. + */ +int SCT_set_log_entry_type(SCT *sct, log_entry_type_t entry_type); + +/* + * Set the log id of an SCT to point directly to the *logid specified. + * The SCT takes ownership of the specified pointer. + * Returns 1 on success. + */ +int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); + +/* + * Set the timestamp of an SCT. + */ +void SCT_set_timestamp(SCT *sct, uint64_t timestamp); + +/* + * Set the signature type of an SCT + * Currently NID_sha256WithRSAEncryption or NID_ecdsa_with_SHA256. + * Returns 1 on success. + */ +int SCT_set_signature_nid(SCT *sct, int nid); + +/* + * Set the extensions of an SCT to point directly to the *ext specified. + * The SCT takes ownership of the specified pointer. + */ +void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len); + +/* + * Set the signature of an SCT to point directly to the *sig specified. + * The SCT takes ownership of the specified pointer. + */ +void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len); + +/* + * Returns the version of the SCT. + */ +sct_version_t SCT_get_version(const SCT *sct); + +/* + * Returns the log entry type of the SCT. + */ +log_entry_type_t SCT_get_log_entry_type(const SCT *sct); + +/* + * Set *logid to point to the log id for the SCT. logid must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id); + +/* + * Returns the timestamp for the SCT. + */ +uint64_t SCT_get_timestamp(const SCT *sct); + +/* + * Return the nid for the signature used by the SCT. + * Currently NID_sha256WithRSAEncryption or NID_ecdsa_with_SHA256 (or NID_undef) + */ +int SCT_get_signature_nid(const SCT *sct); + +/* + * Set *ext to point to the extension data for the SCT. ext must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext); + +/* + * Set *sig to point to the signature for the SCT. sig must not be NULL. + * The SCT retains ownership of this pointer. + * Returns length of the data pointed to. + */ +size_t SCT_get0_signature(const SCT *sct, unsigned char **sig); + + +# endif + +/* BEGIN ERROR CODES */ +/* + * The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_CT_strings(void); + +/* Error codes for the CT functions. */ + +/* Function codes. */ +# define CT_F_SCT_NEW 100 +# define CT_F_SCT_SET0_LOG_ID 101 +# define CT_F_SCT_SET_LOG_ENTRY_TYPE 102 +# define CT_F_SCT_SET_SIGNATURE_NID 103 +# define CT_F_SCT_SET_VERSION 104 + +/* Reason codes. */ +# define CT_R_INVALID_LOG_ID_LENGTH 100 +# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 +# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 +# define CT_R_UNSUPPORTED_VERSION 103 + +#ifdef __cplusplus +} +#endif +#endif diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec index 8a10b80..08b0c0b 100644 --- a/crypto/err/openssl.ec +++ b/crypto/err/openssl.ec @@ -36,6 +36,7 @@ L HMAC include/openssl/hmac.h crypto/hmac/hmac_err.c L CMS include/openssl/cms.h crypto/cms/cms_err.c L JPAKE include/openssl/jpake.h crypto/jpake/jpake_err.c L FIPS include/openssl/fips.h crypto/fips_err.h +L CT crypto/ct/ct_locl.h crypto/ct/ct_err.c # additional header files to be scanned for function names L NONE crypto/x509/x509_vfy.h NONE diff --git a/crypto/x509v3/Makefile b/crypto/x509v3/Makefile index 5460af4..87fc083 100644 --- a/crypto/x509v3/Makefile +++ b/crypto/x509v3/Makefile @@ -523,7 +523,7 @@ v3_purp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h v3_purp.o: ../../include/openssl/x509v3.h ../include/internal/cryptlib.h v3_purp.o: ../include/internal/x509_int.h v3_purp.c -v3_scts.o: ../../e_os.h ../../include/openssl/asn1.h +v3_scts.o: ../../crypto/ct/ct_locl.h ../../e_os.h ../../include/openssl/asn1.h v3_scts.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h v3_scts.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h v3_scts.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index 5073575..8d42147 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c @@ -152,7 +152,7 @@ static const X509V3_EXT_METHOD *standard_exts[] = { &v3_idp, &v3_alt[2], &v3_freshest_crl, -#ifndef OPENSSL_NO_SCT +#ifndef OPENSSL_NO_CT &v3_ct_scts[0], &v3_ct_scts[1], #endif diff --git a/crypto/x509v3/v3_scts.c b/crypto/x509v3/v3_scts.c index b1505fe..6d3665c 100644 --- a/crypto/x509v3/v3_scts.c +++ b/crypto/x509v3/v3_scts.c @@ -61,8 +61,9 @@ #include #include #include "ext_dat.h" +#include "crypto/ct/ct_locl.h" -#ifndef OPENSSL_NO_SCT +#ifndef OPENSSL_NO_CT /* Signature and hash algorithms from RFC 5246 */ #define TLSEXT_hash_sha256 4 @@ -82,27 +83,6 @@ l|=((uint64_t)(*((c)++)))<< 8, \ l|=((uint64_t)(*((c)++)))) -typedef struct SCT_st { - /* The encoded SCT */ - unsigned char *sct; - unsigned short sctlen; - /* - * Components of the SCT. "logid", "ext" and "sig" point to addresses - * inside "sct". - */ - unsigned char version; - unsigned char *logid; - unsigned short logidlen; - uint64_t timestamp; - unsigned char *ext; - unsigned short extlen; - unsigned char hash_alg; - unsigned char sig_alg; - unsigned char *sig; - unsigned short siglen; -} SCT; - -DECLARE_STACK_OF(SCT) static void SCT_LIST_free(STACK_OF(SCT) *a); static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, @@ -162,14 +142,6 @@ static void timestamp_print(BIO *out, uint64_t timestamp) ASN1_GENERALIZEDTIME_free(gen); } -static void SCT_free(SCT *sct) -{ - if (!sct) - return; - OPENSSL_free(sct->sct); - OPENSSL_free(sct); -} - static void SCT_LIST_free(STACK_OF(SCT) *a) { sk_SCT_pop_free(a, SCT_free); @@ -219,7 +191,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, if (!sct->sct) goto err; memcpy(sct->sct, p, sctlen); - sct->sctlen = sctlen; + sct->sct_len = sctlen; p += sctlen; p2 = sct->sct; @@ -237,8 +209,8 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, goto err; sctlen -= 43; - sct->logid = p2; - sct->logidlen = 32; + sct->log_id = p2; + sct->log_id_len = 32; p2 += 32; n2l8(p2, sct->timestamp); @@ -247,7 +219,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, if (sctlen < fieldlen) goto err; sct->ext = p2; - sct->extlen = fieldlen; + sct->ext_len = fieldlen; p2 += fieldlen; sctlen -= fieldlen; @@ -267,7 +239,7 @@ static STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, if (sctlen != fieldlen) goto err; sct->sig = p2; - sct->siglen = fieldlen; + sct->sig_len = fieldlen; } } @@ -298,25 +270,25 @@ static int i2r_SCT_LIST(X509V3_EXT_METHOD *method, STACK_OF(SCT) *sct_list, BIO_printf(out, "v1(0)"); BIO_printf(out, "\n%*sLog ID : ", indent + 4, ""); - BIO_hex_string(out, indent + 16, 16, sct->logid, sct->logidlen); + BIO_hex_string(out, indent + 16, 16, sct->log_id, sct->log_id_len); BIO_printf(out, "\n%*sTimestamp : ", indent + 4, ""); timestamp_print(out, sct->timestamp); BIO_printf(out, "\n%*sExtensions: ", indent + 4, ""); - if (sct->extlen == 0) + if (sct->ext_len == 0) BIO_printf(out, "none"); else - BIO_hex_string(out, indent + 16, 16, sct->ext, sct->extlen); + BIO_hex_string(out, indent + 16, 16, sct->ext, sct->ext_len); BIO_printf(out, "\n%*sSignature : ", indent + 4, ""); tls12_signature_print(out, sct->hash_alg, sct->sig_alg); BIO_printf(out, "\n%*s ", indent + 4, ""); - BIO_hex_string(out, indent + 16, 16, sct->sig, sct->siglen); + BIO_hex_string(out, indent + 16, 16, sct->sig, sct->sig_len); } else { /* Unknown version */ BIO_printf(out, "unknown\n%*s", indent + 16, ""); - BIO_hex_string(out, indent + 16, 16, sct->sct, sct->sctlen); + BIO_hex_string(out, indent + 16, 16, sct->sct, sct->sct_len); } if (++i < sk_SCT_num(sct_list)) diff --git a/include/openssl/err.h b/include/openssl/err.h index e17706c..4c6d8d4 100644 --- a/include/openssl/err.h +++ b/include/openssl/err.h @@ -193,6 +193,7 @@ typedef struct err_state_st { # define ERR_LIB_TS 47 # define ERR_LIB_HMAC 48 # define ERR_LIB_JPAKE 49 +# define ERR_LIB_CT 50 # define ERR_LIB_USER 128 @@ -229,6 +230,7 @@ typedef struct err_state_st { # define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__) # define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__) # define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__) +# define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),__FILE__,__LINE__) /* * Borland C seems too stupid to be able to shift and do longs in the From matt at openssl.org Fri Oct 9 13:07:57 2015 From: matt at openssl.org (Matt Caswell) Date: Fri, 09 Oct 2015 13:07:57 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444396077.019734.7800.nullmailer@dev.openssl.org> The branch master has been updated via 0f0cfbe24c07376a67b12048686baa318db2cd95 (commit) from 3149baf83cb703f060b1e6eeb440a45e010a626b (commit) - Log ----------------------------------------------------------------- commit 0f0cfbe24c07376a67b12048686baa318db2cd95 Author: Matt Caswell Date: Fri Oct 9 12:10:16 2015 +0100 Fix Windows build Add the new ct directory to mkfiles.pl and fix the ct Makefile Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: crypto/ct/Makefile | 2 +- util/mkfiles.pl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/ct/Makefile b/crypto/ct/Makefile index ce3a6b1..fe2341d 100644 --- a/crypto/ct/Makefile +++ b/crypto/ct/Makefile @@ -20,7 +20,7 @@ LIBOBJ= ct_lib.o SRC= $(LIBSRC) -HEADER= ct_lcl.h +HEADER= ct_locl.h ALL= $(GENERAL) $(SRC) $(HEADER) diff --git a/util/mkfiles.pl b/util/mkfiles.pl index 268acad..68a9a6c 100755 --- a/util/mkfiles.pl +++ b/util/mkfiles.pl @@ -63,6 +63,7 @@ my @dirs = ( "crypto/whrlpool", "crypto/ts", "crypto/srp", +"crypto/ct", "ssl", "apps", "engines", From emilia at openssl.org Fri Oct 9 13:38:36 2015 From: emilia at openssl.org (Emilia Kasper) Date: Fri, 09 Oct 2015 13:38:36 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444397916.115779.12377.nullmailer@dev.openssl.org> The branch master has been updated via 310115448188415e270bb0bef958c7c130939838 (commit) from 0f0cfbe24c07376a67b12048686baa318db2cd95 (commit) - Log ----------------------------------------------------------------- commit 310115448188415e270bb0bef958c7c130939838 Author: Emilia Kasper Date: Tue Oct 6 17:20:32 2015 +0200 DTLS: remove unused cookie field Note that this commit constifies a user callback parameter and therefore will break compilation for applications using this callback. But unless they are abusing write access to the buffer, the fix is trivial. Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: apps/s_apps.h | 2 +- apps/s_cb.c | 2 +- include/openssl/ssl.h | 2 +- ssl/d1_lib.c | 6 +++--- ssl/packet_locl.h | 13 +++++++++++++ ssl/s3_srvr.c | 39 +++++++-------------------------------- ssl/ssl_locl.h | 3 +-- ssl/ssl_sess.c | 2 +- test/packettest.c | 20 ++++++++++++++++++++ 9 files changed, 48 insertions(+), 41 deletions(-) diff --git a/apps/s_apps.h b/apps/s_apps.h index c8069a0..55dc9f1 100644 --- a/apps/s_apps.h +++ b/apps/s_apps.h @@ -195,7 +195,7 @@ void tlsext_cb(SSL *s, int client_server, int type, unsigned char *data, int generate_cookie_callback(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len); -int verify_cookie_callback(SSL *ssl, unsigned char *cookie, +int verify_cookie_callback(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len); typedef struct ssl_excert_st SSL_EXCERT; diff --git a/apps/s_cb.c b/apps/s_cb.c index 643d91a..884b5e1 100644 --- a/apps/s_cb.c +++ b/apps/s_cb.c @@ -806,7 +806,7 @@ int generate_cookie_callback(SSL *ssl, unsigned char *cookie, return 1; } -int verify_cookie_callback(SSL *ssl, unsigned char *cookie, +int verify_cookie_callback(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len) { unsigned char *buffer, result[EVP_MAX_MD_SIZE]; diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 0727e7f..25ceca8 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -750,7 +750,7 @@ void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, *cookie_len)); void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*app_verify_cookie_cb) (SSL *ssl, - unsigned char + const unsigned char *cookie, unsigned int cookie_len)); diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index 4bdf90a..3a0a4cf 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -723,9 +723,9 @@ int dtls1_listen(SSL *s, struct sockaddr *client) /* This is fatal */ return -1; } - if (PACKET_remaining(&cookiepkt) > sizeof(s->d1->rcvd_cookie) - || s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookiepkt), - PACKET_remaining(&cookiepkt)) == 0) { + if (s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookiepkt), + PACKET_remaining(&cookiepkt)) == + 0) { /* * We treat invalid cookies in the same was as no cookie as * per RFC6347 diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index 9354e6c..778ec77 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -62,6 +62,7 @@ # include # include # include +# include # include "e_os.h" # ifdef __cplusplus @@ -125,6 +126,18 @@ static inline void PACKET_null_init(PACKET *pkt) } /* + * Returns 1 if the packet has length |num| and its contents equal the |num| + * bytes read from |ptr|. Returns 0 otherwise (lengths or contents not equal). + * If lengths are equal, performs the comparison in constant time. + */ +__owur static inline int PACKET_equal(const PACKET *pkt, const void *ptr, + size_t num) { + if (PACKET_remaining(pkt) != num) + return 0; + return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; +} + +/* * Peek ahead and initialize |subpkt| with the next |len| bytes read from |pkt|. * Data is not copied: the |subpkt| packet will share its underlying buffer with * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 5f05b9f..ca11c6e 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -1137,45 +1137,20 @@ int ssl3_get_client_hello(SSL *s) } if (SSL_IS_DTLS(s)) { - size_t cookie_len = PACKET_remaining(&cookie); - /* - * The ClientHello may contain a cookie even if the - * HelloVerify message has not been sent--make sure that it - * does not cause an overflow. - */ - if (cookie_len > sizeof(s->d1->rcvd_cookie)) { - /* too much data */ - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); - goto f_err; - } - - /* verify the cookie if appropriate option is set. */ - if ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) && cookie_len > 0) { - /* Get cookie */ - /* - * TODO(openssl-team): rcvd_cookie appears unused outside this - * function. Remove the field? - */ - if (!PACKET_copy_bytes(&cookie, s->d1->rcvd_cookie, cookie_len)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto f_err; - } - + /* Empty cookie was already handled above by returning early. */ + if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { if (s->ctx->app_verify_cookie_cb != NULL) { - if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie, - cookie_len) == 0) { + if (s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookie), + PACKET_remaining(&cookie)) == 0) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); goto f_err; + /* else cookie verification succeeded */ } - /* else cookie verification succeeded */ - } /* default verification */ - else if (memcmp(s->d1->rcvd_cookie, s->d1->cookie, - s->d1->cookie_len) != 0) { + } else if (!PACKET_equal(&cookie, s->d1->cookie, + s->d1->cookie_len)) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); goto f_err; diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 7c57509..ad6ae0e 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -798,7 +798,7 @@ struct ssl_ctx_st { unsigned int *cookie_len); /* verify cookie callback */ - int (*app_verify_cookie_cb) (SSL *ssl, unsigned char *cookie, + int (*app_verify_cookie_cb) (SSL *ssl, const unsigned char *cookie, unsigned int cookie_len); CRYPTO_EX_DATA ex_data; @@ -1421,7 +1421,6 @@ typedef struct hm_fragment_st { typedef struct dtls1_state_st { unsigned int send_cookie; unsigned char cookie[DTLS1_COOKIE_LENGTH]; - unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; unsigned int cookie_len; /* handshake message numbers */ diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 7660292..6f46b9f 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -1217,7 +1217,7 @@ void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, } void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, - int (*cb) (SSL *ssl, unsigned char *cookie, + int (*cb) (SSL *ssl, const unsigned char *cookie, unsigned int cookie_len)) { ctx->app_verify_cookie_cb = cb; diff --git a/test/packettest.c b/test/packettest.c index edaa282..ac360f59 100644 --- a/test/packettest.c +++ b/test/packettest.c @@ -360,6 +360,25 @@ static int test_PACKET_null_init() return 1; } +static int test_PACKET_equal(unsigned char buf[BUF_LEN]) +{ + PACKET pkt; + + if ( !PACKET_buf_init(&pkt, buf, 4) + || !PACKET_equal(&pkt, buf, 4) + || PACKET_equal(&pkt, buf + 1, 4) + || !PACKET_buf_init(&pkt, buf, BUF_LEN) + || !PACKET_equal(&pkt, buf, BUF_LEN) + || PACKET_equal(&pkt, buf, BUF_LEN - 1) + || PACKET_equal(&pkt, buf, BUF_LEN + 1) + || PACKET_equal(&pkt, buf, 0)) { + fprintf(stderr, "test_PACKET_equal() failed\n"); + return 0; + } + + return 1; +} + static int test_PACKET_get_length_prefixed_1() { unsigned char buf[BUF_LEN]; @@ -452,6 +471,7 @@ int main(int argc, char **argv) if ( !test_PACKET_buf_init() || !test_PACKET_null_init() || !test_PACKET_remaining(buf) + || !test_PACKET_equal(buf) || !test_PACKET_get_1(buf) || !test_PACKET_get_4(buf) || !test_PACKET_get_net_2(buf) From rsalz at openssl.org Fri Oct 9 21:06:37 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 09 Oct 2015 21:06:37 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444424797.687901.22012.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via bfc19297cddd5bc2192c02c7f8896d804b0456cb (commit) from 978b5d709a6d7fc75665a837df2ad57fe9653dcf (commit) - Log ----------------------------------------------------------------- commit bfc19297cddd5bc2192c02c7f8896d804b0456cb Author: Rich Salz Date: Fri Oct 9 14:14:34 2015 -0400 Avoid SHA1 weakness In X509_cmp, if cert digest is equal, look at DER of the signed part. This is what master and 1.0.2 already do. Reviewed-by: Dr. Stephen Henson ----------------------------------------------------------------------- Summary of changes: crypto/x509/x509_cmp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 3c5b717..5792e7f 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -179,11 +179,24 @@ unsigned long X509_subject_name_hash_old(X509 *x) */ int X509_cmp(const X509 *a, const X509 *b) { + int rv; + /* ensure hash is valid */ X509_check_purpose((X509 *)a, -1, 0); X509_check_purpose((X509 *)b, -1, 0); - return memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH); + rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH); + if (rv) + return rv; + /* Check for match against stored encoding too */ + if (!a->cert_info->enc.modified && !b->cert_info->enc.modified) { + rv = (int)(a->cert_info->enc.len - b->cert_info->enc.len); + if (rv) + return rv; + return memcmp(a->cert_info->enc.enc, b->cert_info->enc.enc, + a->cert_info->enc.len); + } + return rv; } #endif From steve at openssl.org Sat Oct 10 23:27:46 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sat, 10 Oct 2015 23:27:46 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444519666.799059.1398.nullmailer@dev.openssl.org> The branch master has been updated via c69ce9351336f5b4a8b33890756b3fd185528210 (commit) from 310115448188415e270bb0bef958c7c130939838 (commit) - Log ----------------------------------------------------------------- commit c69ce9351336f5b4a8b33890756b3fd185528210 Author: Dr. Stephen Henson Date: Sun Oct 11 00:06:56 2015 +0100 Typo. PR#4079 Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: crypto/evp/e_des3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 7156863..db36634 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -271,7 +271,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, # endif # ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &dat->ks1) - ! !DES_set_key_checked(&deskey[1], &dat->ks2)) + || DES_set_key_checked(&deskey[1], &dat->ks2)) return 0; # else DES_set_key_unchecked(&deskey[0], &dat->ks1); From steve at openssl.org Sat Oct 10 23:50:04 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sat, 10 Oct 2015 23:50:04 +0000 Subject: [openssl-commits] [openssl] OpenSSL_0_9_8-stable update Message-ID: <1444521004.347205.3578.nullmailer@dev.openssl.org> The branch OpenSSL_0_9_8-stable has been updated via 31172717e8324fbb01e1b3e65db6f5d48d7e352e (commit) from cc21b51add2415cc63113b71b34bc1c7b588e67d (commit) - Log ----------------------------------------------------------------- commit 31172717e8324fbb01e1b3e65db6f5d48d7e352e Author: Dr. Stephen Henson Date: Sun Oct 11 00:06:56 2015 +0100 Typo. PR#4079 Reviewed-by: Tim Hudson (cherry picked from commit c69ce9351336f5b4a8b33890756b3fd185528210) Conflicts: crypto/evp/e_des3.c ----------------------------------------------------------------------- Summary of changes: crypto/evp/e_des3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index b80348b..63b60b4 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -196,7 +196,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, DES_cblock *deskey = (DES_cblock *)key; # ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &data(ctx)->ks1) - ! !DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) + || DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) return 0; # else DES_set_key_unchecked(&deskey[0], &data(ctx)->ks1); From steve at openssl.org Sat Oct 10 23:50:04 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sat, 10 Oct 2015 23:50:04 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1444521004.522247.3621.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via b2593839da1e0c5af5fedf3fce3fd43c400199b4 (commit) from bfc19297cddd5bc2192c02c7f8896d804b0456cb (commit) - Log ----------------------------------------------------------------- commit b2593839da1e0c5af5fedf3fce3fd43c400199b4 Author: Dr. Stephen Henson Date: Sun Oct 11 00:06:56 2015 +0100 Typo. PR#4079 Reviewed-by: Tim Hudson (cherry picked from commit c69ce9351336f5b4a8b33890756b3fd185528210) Conflicts: crypto/evp/e_des3.c ----------------------------------------------------------------------- Summary of changes: crypto/evp/e_des3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 07a5aca..1272305 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -241,7 +241,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, DES_cblock *deskey = (DES_cblock *)key; # ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &data(ctx)->ks1) - ! !DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) + || DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) return 0; # else DES_set_key_unchecked(&deskey[0], &data(ctx)->ks1); From steve at openssl.org Sat Oct 10 23:50:04 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sat, 10 Oct 2015 23:50:04 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_0-stable update Message-ID: <1444521004.425809.3600.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_0-stable has been updated via d7ebdc2e98f7cc1df99fd7dd675bb6cfd6adb1ba (commit) from 54edf96459dbece958707c6a8e92e82ada1d1c59 (commit) - Log ----------------------------------------------------------------- commit d7ebdc2e98f7cc1df99fd7dd675bb6cfd6adb1ba Author: Dr. Stephen Henson Date: Sun Oct 11 00:06:56 2015 +0100 Typo. PR#4079 Reviewed-by: Tim Hudson (cherry picked from commit c69ce9351336f5b4a8b33890756b3fd185528210) Conflicts: crypto/evp/e_des3.c ----------------------------------------------------------------------- Summary of changes: crypto/evp/e_des3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 464168b..7485734 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -239,7 +239,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, DES_cblock *deskey = (DES_cblock *)key; # ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &data(ctx)->ks1) - ! !DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) + || DES_set_key_checked(&deskey[1], &data(ctx)->ks2)) return 0; # else DES_set_key_unchecked(&deskey[0], &data(ctx)->ks1); From steve at openssl.org Sat Oct 10 23:50:04 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sat, 10 Oct 2015 23:50:04 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444521004.624944.3642.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via 6868346585f38066de4610b516346a18a98a8427 (commit) from 985abd1fd8aa24ef1bbf6adcf1923d07b35fa246 (commit) - Log ----------------------------------------------------------------- commit 6868346585f38066de4610b516346a18a98a8427 Author: Dr. Stephen Henson Date: Sun Oct 11 00:06:56 2015 +0100 Typo. PR#4079 Reviewed-by: Tim Hudson (cherry picked from commit c69ce9351336f5b4a8b33890756b3fd185528210) ----------------------------------------------------------------------- Summary of changes: crypto/evp/e_des3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 96f272e..bf6c1d2 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -289,7 +289,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, # endif # ifdef EVP_CHECK_DES_KEY if (DES_set_key_checked(&deskey[0], &dat->ks1) - ! !DES_set_key_checked(&deskey[1], &dat->ks2)) + || DES_set_key_checked(&deskey[1], &dat->ks2)) return 0; # else DES_set_key_unchecked(&deskey[0], &dat->ks1); From steve at openssl.org Sun Oct 11 12:43:54 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sun, 11 Oct 2015 12:43:54 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444567434.773742.8594.nullmailer@dev.openssl.org> The branch master has been updated via 71a64af3312d4dfdff2597a979868d2bdd7e3642 (commit) via 9076bd25bfad9c661cad928331295bd5ec9b5af3 (commit) from c69ce9351336f5b4a8b33890756b3fd185528210 (commit) - Log ----------------------------------------------------------------- commit 71a64af3312d4dfdff2597a979868d2bdd7e3642 Author: Dr. Stephen Henson Date: Sat Sep 12 03:53:40 2015 +0100 Skip PSK tests for no-psk Reviewed-by: Matt Caswell commit 9076bd25bfad9c661cad928331295bd5ec9b5af3 Author: Dr. Stephen Henson Date: Fri Sep 11 17:08:11 2015 +0100 Make no-psk compile without warnings. PR#4035 Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: apps/s_server.c | 4 ---- ssl/s3_lib.c | 3 ++- ssl/ssl_cert.c | 4 ++-- test/recipes/80-test_ssl.t | 16 ++++++++++++---- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/s_server.c b/apps/s_server.c index f705393..aa43541 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -1316,10 +1316,6 @@ int s_server_main(int argc, char *argv[]) goto end; } break; -#else - case OPT_PSK_HINT: - case OPT_PSK: - break; #endif #ifndef OPENSSL_NO_SRP case OPT_SRPVFILE: diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 4b11e60..5e7b618 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -5228,8 +5228,9 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen, s->method->ssl3_enc->generate_master_secret(s, s->session->master_key, pms, pmslen); - +#ifndef OPENSSL_NO_PSK err: +#endif if (pms) { if (free_pms) OPENSSL_clear_free(pms, pmslen); diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 7571095..1caa3c8 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -333,13 +333,13 @@ CERT *ssl_cert_dup(CERT *cert) goto err; if (!custom_exts_copy(&ret->srv_ext, &cert->srv_ext)) goto err; - +#ifndef OPENSSL_NO_PSK if (cert->psk_identity_hint) { ret->psk_identity_hint = BUF_strdup(cert->psk_identity_hint); if (ret->psk_identity_hint == NULL) goto err; } - +#endif return (ret); err: diff --git a/test/recipes/80-test_ssl.t b/test/recipes/80-test_ssl.t index f84425d..6e5e22e 100644 --- a/test/recipes/80-test_ssl.t +++ b/test/recipes/80-test_ssl.t @@ -468,11 +468,19 @@ sub testssl { 'test tlsv1 with 1024bit RSA, 1024bit DHE, multiple handshakes'); } } - ok(run(test([@ssltest, "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])), - 'test tls1 with PSK'); + { + SKIP: { + skip "skipping PSK tests", 2 + if ($no_psk); + + ok(run(test([@ssltest, "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])), + 'test tls1 with PSK'); + + ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])), + 'test tls1 with PSK via BIO pair'); + } + } - ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])), - 'test tls1 with PSK via BIO pair'); }; subtest 'Next Protocol Negotiation Tests' => sub { From steve at openssl.org Sun Oct 11 19:38:17 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sun, 11 Oct 2015 19:38:17 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444592297.458453.27434.nullmailer@dev.openssl.org> The branch master has been updated via af170194a88d6127d447bea826845c23ca192727 (commit) via 47c9a1b5096be684c18335137284f0dfcefd12d6 (commit) via a332635ea0ec7dab14d550c2f151bb4ea8c64f78 (commit) via 44c734e95c4242af5ccfd7e5c4653eb196705cb9 (commit) from 71a64af3312d4dfdff2597a979868d2bdd7e3642 (commit) - Log ----------------------------------------------------------------- commit af170194a88d6127d447bea826845c23ca192727 Author: Dr. Stephen Henson Date: Wed Oct 7 14:42:34 2015 +0100 embed OCSP_CERTID Reviewed-by: Rich Salz commit 47c9a1b5096be684c18335137284f0dfcefd12d6 Author: Dr. Stephen Henson Date: Wed Oct 7 13:28:46 2015 +0100 embed support for ASN1_STRING Reviewed-by: Rich Salz commit a332635ea0ec7dab14d550c2f151bb4ea8c64f78 Author: Dr. Stephen Henson Date: Tue Oct 6 23:04:08 2015 +0100 Embed various OCSP fields. Reviewed-by: Rich Salz commit 44c734e95c4242af5ccfd7e5c4653eb196705cb9 Author: Dr. Stephen Henson Date: Tue Oct 6 22:53:48 2015 +0100 embed support for CHOICE type Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: crypto/asn1/asn1_lib.c | 3 ++- crypto/asn1/tasn_fre.c | 6 ++++-- crypto/asn1/tasn_new.c | 30 +++++++++++++++++++++--------- crypto/ocsp/ocsp_asn.c | 18 +++++++++--------- crypto/ocsp/ocsp_cl.c | 12 ++++++------ crypto/ocsp/ocsp_ext.c | 40 ++++++++++++++++++++-------------------- crypto/ocsp/ocsp_lcl.h | 18 +++++++++--------- crypto/ocsp/ocsp_lib.c | 17 ++++++++--------- crypto/ocsp/ocsp_prn.c | 18 +++++++++--------- crypto/ocsp/ocsp_srv.c | 22 +++++++++++----------- crypto/ocsp/ocsp_vfy.c | 20 ++++++++++---------- include/openssl/asn1.h | 2 ++ include/openssl/ocsp.h | 14 +++++++------- 13 files changed, 118 insertions(+), 102 deletions(-) diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index 3b36644..12248db 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -363,7 +363,8 @@ void ASN1_STRING_free(ASN1_STRING *a) return; if (!(a->flags & ASN1_STRING_FLAG_NDEF)) OPENSSL_free(a->data); - OPENSSL_free(a); + if (!(a->flags & ASN1_STRING_FLAG_EMBED)) + OPENSSL_free(a); } void ASN1_STRING_clear_free(ASN1_STRING *a) diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c index bd955d9..1e77885 100644 --- a/crypto/asn1/tasn_fre.c +++ b/crypto/asn1/tasn_fre.c @@ -125,8 +125,10 @@ static void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, } if (asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); - OPENSSL_free(*pval); - *pval = NULL; + if (embed == 0) { + OPENSSL_free(*pval); + *pval = NULL; + } break; case ASN1_ITYPE_EXTERN: diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index 294912c..33a8e97 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -67,7 +67,8 @@ static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); -static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, + int embed); static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); @@ -120,12 +121,12 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) if (it->templates) { if (!asn1_template_new(pval, it->templates)) goto memerr; - } else if (!asn1_primitive_new(pval, it)) + } else if (!asn1_primitive_new(pval, it, embed)) goto memerr; break; case ASN1_ITYPE_MSTRING: - if (!asn1_primitive_new(pval, it)) + if (!asn1_primitive_new(pval, it, embed)) goto memerr; break; @@ -142,9 +143,13 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) return 1; } } - *pval = OPENSSL_zalloc(it->size); - if (!*pval) - goto memerr; + if (embed) { + memset(*pval, 0, it->size); + } else { + *pval = OPENSSL_zalloc(it->size); + if (!*pval) + goto memerr; + } asn1_set_choice_selector(pval, -1, it); if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) goto auxerr; @@ -301,7 +306,8 @@ static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) * all the old functions. */ -static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) +static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, + int embed) { ASN1_TYPE *typ; ASN1_STRING *str; @@ -343,10 +349,16 @@ static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) break; default: - str = ASN1_STRING_type_new(utype); + if (embed) { + str = *(ASN1_STRING **)pval; + memset(str, 0, sizeof(*str)); + str->flags = ASN1_STRING_FLAG_EMBED; + } else { + str = ASN1_STRING_type_new(utype); + *pval = (ASN1_VALUE *)str; + } if (it->itype == ASN1_ITYPE_MSTRING && str) str->flags |= ASN1_STRING_FLAG_MSTRING; - *pval = (ASN1_VALUE *)str; break; } if (*pval) diff --git a/crypto/ocsp/ocsp_asn.c b/crypto/ocsp/ocsp_asn.c index c3362f0..00be995 100644 --- a/crypto/ocsp/ocsp_asn.c +++ b/crypto/ocsp/ocsp_asn.c @@ -62,7 +62,7 @@ #include "ocsp_lcl.h" ASN1_SEQUENCE(OCSP_SIGNATURE) = { - ASN1_SIMPLE(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR), + ASN1_EMBED(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR), ASN1_SIMPLE(OCSP_SIGNATURE, signature, ASN1_BIT_STRING), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SIGNATURE, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_SIGNATURE) @@ -70,10 +70,10 @@ ASN1_SEQUENCE(OCSP_SIGNATURE) = { IMPLEMENT_ASN1_FUNCTIONS(OCSP_SIGNATURE) ASN1_SEQUENCE(OCSP_CERTID) = { - ASN1_SIMPLE(OCSP_CERTID, hashAlgorithm, X509_ALGOR), - ASN1_SIMPLE(OCSP_CERTID, issuerNameHash, ASN1_OCTET_STRING), - ASN1_SIMPLE(OCSP_CERTID, issuerKeyHash, ASN1_OCTET_STRING), - ASN1_SIMPLE(OCSP_CERTID, serialNumber, ASN1_INTEGER) + ASN1_EMBED(OCSP_CERTID, hashAlgorithm, X509_ALGOR), + ASN1_EMBED(OCSP_CERTID, issuerNameHash, ASN1_OCTET_STRING), + ASN1_EMBED(OCSP_CERTID, issuerKeyHash, ASN1_OCTET_STRING), + ASN1_EMBED(OCSP_CERTID, serialNumber, ASN1_INTEGER) } ASN1_SEQUENCE_END(OCSP_CERTID) IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTID) @@ -95,7 +95,7 @@ ASN1_SEQUENCE(OCSP_REQINFO) = { IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQINFO) ASN1_SEQUENCE(OCSP_REQUEST) = { - ASN1_SIMPLE(OCSP_REQUEST, tbsRequest, OCSP_REQINFO), + ASN1_EMBED(OCSP_REQUEST, tbsRequest, OCSP_REQINFO), ASN1_EXP_OPT(OCSP_REQUEST, optionalSignature, OCSP_SIGNATURE, 0) } ASN1_SEQUENCE_END(OCSP_REQUEST) @@ -151,7 +151,7 @@ IMPLEMENT_ASN1_FUNCTIONS(OCSP_SINGLERESP) ASN1_SEQUENCE(OCSP_RESPDATA) = { ASN1_EXP_OPT(OCSP_RESPDATA, version, ASN1_INTEGER, 0), - ASN1_SIMPLE(OCSP_RESPDATA, responderId, OCSP_RESPID), + ASN1_EMBED(OCSP_RESPDATA, responderId, OCSP_RESPID), ASN1_SIMPLE(OCSP_RESPDATA, producedAt, ASN1_GENERALIZEDTIME), ASN1_SEQUENCE_OF(OCSP_RESPDATA, responses, OCSP_SINGLERESP), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_RESPDATA, responseExtensions, X509_EXTENSION, 1) @@ -160,8 +160,8 @@ ASN1_SEQUENCE(OCSP_RESPDATA) = { IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPDATA) ASN1_SEQUENCE(OCSP_BASICRESP) = { - ASN1_SIMPLE(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA), - ASN1_SIMPLE(OCSP_BASICRESP, signatureAlgorithm, X509_ALGOR), + ASN1_EMBED(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA), + ASN1_EMBED(OCSP_BASICRESP, signatureAlgorithm, X509_ALGOR), ASN1_SIMPLE(OCSP_BASICRESP, signature, ASN1_BIT_STRING), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_BASICRESP, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_BASICRESP) diff --git a/crypto/ocsp/ocsp_cl.c b/crypto/ocsp/ocsp_cl.c index 8143389..2b77146 100644 --- a/crypto/ocsp/ocsp_cl.c +++ b/crypto/ocsp/ocsp_cl.c @@ -93,7 +93,7 @@ OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid) goto err; OCSP_CERTID_free(one->reqCert); one->reqCert = cid; - if (req && !sk_OCSP_ONEREQ_push(req->tbsRequest->requestList, one)) + if (req && !sk_OCSP_ONEREQ_push(req->tbsRequest.requestList, one)) goto err; return one; err: @@ -115,8 +115,8 @@ int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm) return 0; } gen->type = GEN_DIRNAME; - GENERAL_NAME_free(req->tbsRequest->requestorName); - req->tbsRequest->requestorName = gen; + GENERAL_NAME_free(req->tbsRequest.requestorName); + req->tbsRequest.requestorName = gen; return 1; } @@ -230,7 +230,7 @@ int OCSP_resp_count(OCSP_BASICRESP *bs) { if (!bs) return -1; - return sk_OCSP_SINGLERESP_num(bs->tbsResponseData->responses); + return sk_OCSP_SINGLERESP_num(bs->tbsResponseData.responses); } /* Extract an OCSP_SINGLERESP response with a given index */ @@ -239,7 +239,7 @@ OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx) { if (!bs) return NULL; - return sk_OCSP_SINGLERESP_value(bs->tbsResponseData->responses, idx); + return sk_OCSP_SINGLERESP_value(bs->tbsResponseData.responses, idx); } /* Look single response matching a given certificate ID */ @@ -255,7 +255,7 @@ int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last) last = 0; else last++; - sresp = bs->tbsResponseData->responses; + sresp = bs->tbsResponseData.responses; for (i = last; i < sk_OCSP_SINGLERESP_num(sresp); i++) { single = sk_OCSP_SINGLERESP_value(sresp, i); if (!OCSP_id_cmp(id, single->certId)) diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c index 95c61e6..f9553f0 100644 --- a/crypto/ocsp/ocsp_ext.c +++ b/crypto/ocsp/ocsp_ext.c @@ -79,53 +79,53 @@ int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x) { - return (X509v3_get_ext_count(x->tbsRequest->requestExtensions)); + return (X509v3_get_ext_count(x->tbsRequest.requestExtensions)); } int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID - (x->tbsRequest->requestExtensions, nid, lastpos)); + (x->tbsRequest.requestExtensions, nid, lastpos)); } int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ - (x->tbsRequest->requestExtensions, obj, lastpos)); + (x->tbsRequest.requestExtensions, obj, lastpos)); } int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical - (x->tbsRequest->requestExtensions, crit, lastpos)); + (x->tbsRequest.requestExtensions, crit, lastpos)); } X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc) { - return (X509v3_get_ext(x->tbsRequest->requestExtensions, loc)); + return (X509v3_get_ext(x->tbsRequest.requestExtensions, loc)); } X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc) { - return (X509v3_delete_ext(x->tbsRequest->requestExtensions, loc)); + return (X509v3_delete_ext(x->tbsRequest.requestExtensions, loc)); } void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, int *idx) { - return X509V3_get_d2i(x->tbsRequest->requestExtensions, nid, crit, idx); + return X509V3_get_d2i(x->tbsRequest.requestExtensions, nid, crit, idx); } int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, unsigned long flags) { - return X509V3_add1_i2d(&x->tbsRequest->requestExtensions, nid, value, + return X509V3_add1_i2d(&x->tbsRequest.requestExtensions, nid, value, crit, flags); } int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc) { - return (X509v3_add_ext(&(x->tbsRequest->requestExtensions), ex, loc) != + return (X509v3_add_ext(&(x->tbsRequest.requestExtensions), ex, loc) != NULL); } @@ -183,56 +183,56 @@ int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc) int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x) { - return (X509v3_get_ext_count(x->tbsResponseData->responseExtensions)); + return (X509v3_get_ext_count(x->tbsResponseData.responseExtensions)); } int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID - (x->tbsResponseData->responseExtensions, nid, lastpos)); + (x->tbsResponseData.responseExtensions, nid, lastpos)); } int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ - (x->tbsResponseData->responseExtensions, obj, lastpos)); + (x->tbsResponseData.responseExtensions, obj, lastpos)); } int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical - (x->tbsResponseData->responseExtensions, crit, lastpos)); + (x->tbsResponseData.responseExtensions, crit, lastpos)); } X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc) { - return (X509v3_get_ext(x->tbsResponseData->responseExtensions, loc)); + return (X509v3_get_ext(x->tbsResponseData.responseExtensions, loc)); } X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc) { - return (X509v3_delete_ext(x->tbsResponseData->responseExtensions, loc)); + return (X509v3_delete_ext(x->tbsResponseData.responseExtensions, loc)); } void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, int *idx) { - return X509V3_get_d2i(x->tbsResponseData->responseExtensions, nid, crit, + return X509V3_get_d2i(x->tbsResponseData.responseExtensions, nid, crit, idx); } int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, int crit, unsigned long flags) { - return X509V3_add1_i2d(&x->tbsResponseData->responseExtensions, nid, + return X509V3_add1_i2d(&x->tbsResponseData.responseExtensions, nid, value, crit, flags); } int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc) { - return (X509v3_add_ext(&(x->tbsResponseData->responseExtensions), ex, loc) + return (X509v3_add_ext(&(x->tbsResponseData.responseExtensions), ex, loc) != NULL); } @@ -334,14 +334,14 @@ static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts, int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len) { - return ocsp_add1_nonce(&req->tbsRequest->requestExtensions, val, len); + return ocsp_add1_nonce(&req->tbsRequest.requestExtensions, val, len); } /* Same as above but for a response */ int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len) { - return ocsp_add1_nonce(&resp->tbsResponseData->responseExtensions, val, + return ocsp_add1_nonce(&resp->tbsResponseData.responseExtensions, val, len); } diff --git a/crypto/ocsp/ocsp_lcl.h b/crypto/ocsp/ocsp_lcl.h index 86fb0b9..c60d956 100644 --- a/crypto/ocsp/ocsp_lcl.h +++ b/crypto/ocsp/ocsp_lcl.h @@ -71,10 +71,10 @@ * serialNumber CertificateSerialNumber } */ struct ocsp_cert_id_st { - X509_ALGOR *hashAlgorithm; - ASN1_OCTET_STRING *issuerNameHash; - ASN1_OCTET_STRING *issuerKeyHash; - ASN1_INTEGER *serialNumber; + X509_ALGOR hashAlgorithm; + ASN1_OCTET_STRING issuerNameHash; + ASN1_OCTET_STRING issuerKeyHash; + ASN1_INTEGER serialNumber; }; /*- Request ::= SEQUENCE { @@ -105,7 +105,7 @@ struct ocsp_req_info_st { * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } */ struct ocsp_signature_st { - X509_ALGOR *signatureAlgorithm; + X509_ALGOR signatureAlgorithm; ASN1_BIT_STRING *signature; STACK_OF(X509) *certs; }; @@ -115,7 +115,7 @@ struct ocsp_signature_st { * optionalSignature [0] EXPLICIT Signature OPTIONAL } */ struct ocsp_request_st { - OCSP_REQINFO *tbsRequest; + OCSP_REQINFO tbsRequest; OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ }; @@ -211,7 +211,7 @@ struct ocsp_single_response_st { */ struct ocsp_response_data_st { ASN1_INTEGER *version; - OCSP_RESPID *responderId; + OCSP_RESPID responderId; ASN1_GENERALIZEDTIME *producedAt; STACK_OF(OCSP_SINGLERESP) *responses; STACK_OF(X509_EXTENSION) *responseExtensions; @@ -244,8 +244,8 @@ struct ocsp_response_data_st { * and CeloCom */ struct ocsp_basic_response_st { - OCSP_RESPDATA *tbsResponseData; - X509_ALGOR *signatureAlgorithm; + OCSP_RESPDATA tbsResponseData; + X509_ALGOR signatureAlgorithm; ASN1_BIT_STRING *signature; STACK_OF(X509) *certs; }; diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index aa0723c..0120194 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -109,7 +109,7 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, if ((cid = OCSP_CERTID_new()) == NULL) goto err; - alg = cid->hashAlgorithm; + alg = &cid->hashAlgorithm; ASN1_OBJECT_free(alg->algorithm); if ((nid = EVP_MD_type(dgst)) == NID_undef) { OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_UNKNOWN_NID); @@ -123,19 +123,18 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, if (!X509_NAME_digest(issuerName, dgst, md, &i)) goto digerr; - if (!(ASN1_OCTET_STRING_set(cid->issuerNameHash, md, i))) + if (!(ASN1_OCTET_STRING_set(&cid->issuerNameHash, md, i))) goto err; /* Calculate the issuerKey hash, excluding tag and length */ if (!EVP_Digest(issuerKey->data, issuerKey->length, md, &i, dgst, NULL)) goto err; - if (!(ASN1_OCTET_STRING_set(cid->issuerKeyHash, md, i))) + if (!(ASN1_OCTET_STRING_set(&cid->issuerKeyHash, md, i))) goto err; if (serialNumber) { - ASN1_INTEGER_free(cid->serialNumber); - if ((cid->serialNumber = ASN1_INTEGER_dup(serialNumber)) == NULL) + if (ASN1_STRING_copy(&cid->serialNumber, serialNumber) == 0) goto err; } return cid; @@ -149,13 +148,13 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b) { int ret; - ret = OBJ_cmp(a->hashAlgorithm->algorithm, b->hashAlgorithm->algorithm); + ret = OBJ_cmp(a->hashAlgorithm.algorithm, b->hashAlgorithm.algorithm); if (ret) return ret; - ret = ASN1_OCTET_STRING_cmp(a->issuerNameHash, b->issuerNameHash); + ret = ASN1_OCTET_STRING_cmp(&a->issuerNameHash, &b->issuerNameHash); if (ret) return ret; - return ASN1_OCTET_STRING_cmp(a->issuerKeyHash, b->issuerKeyHash); + return ASN1_OCTET_STRING_cmp(&a->issuerKeyHash, &b->issuerKeyHash); } int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b) @@ -164,7 +163,7 @@ int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b) ret = OCSP_id_issuer_cmp(a, b); if (ret) return ret; - return ASN1_INTEGER_cmp(a->serialNumber, b->serialNumber); + return ASN1_INTEGER_cmp(&a->serialNumber, &b->serialNumber); } /* diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c index b826292..70b6904 100644 --- a/crypto/ocsp/ocsp_prn.c +++ b/crypto/ocsp/ocsp_prn.c @@ -75,13 +75,13 @@ static int ocsp_certid_print(BIO *bp, OCSP_CERTID *a, int indent) BIO_printf(bp, "%*sCertificate ID:\n", indent, ""); indent += 2; BIO_printf(bp, "%*sHash Algorithm: ", indent, ""); - i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm); + i2a_ASN1_OBJECT(bp, a->hashAlgorithm.algorithm); BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, ""); - i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING); + i2a_ASN1_STRING(bp, &a->issuerNameHash, V_ASN1_OCTET_STRING); BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, ""); - i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING); + i2a_ASN1_STRING(bp, &a->issuerKeyHash, V_ASN1_OCTET_STRING); BIO_printf(bp, "\n%*sSerial Number: ", indent, ""); - i2a_ASN1_INTEGER(bp, a->serialNumber); + i2a_ASN1_INTEGER(bp, &a->serialNumber); BIO_printf(bp, "\n"); return 1; } @@ -144,7 +144,7 @@ int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *o, unsigned long flags) long l; OCSP_CERTID *cid = NULL; OCSP_ONEREQ *one = NULL; - OCSP_REQINFO *inf = o->tbsRequest; + OCSP_REQINFO *inf = &o->tbsRequest; OCSP_SIGNATURE *sig = o->optionalSignature; if (BIO_write(bp, "OCSP Request Data:\n", 19) <= 0) @@ -172,7 +172,7 @@ int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *o, unsigned long flags) inf->requestExtensions, flags, 4)) goto err; if (sig) { - X509_signature_print(bp, sig->signatureAlgorithm, sig->signature); + X509_signature_print(bp, &sig->signatureAlgorithm, sig->signature); for (i = 0; i < sk_X509_num(sig->certs); i++) { X509_print(bp, sk_X509_value(sig->certs, i)); PEM_write_bio_X509(bp, sk_X509_value(sig->certs, i)); @@ -216,14 +216,14 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags) i = ASN1_STRING_length(rb->response); if ((br = OCSP_response_get1_basic(o)) == NULL) goto err; - rd = br->tbsResponseData; + rd = &br->tbsResponseData; l = ASN1_INTEGER_get(rd->version); if (BIO_printf(bp, "\n Version: %lu (0x%lx)\n", l + 1, l) <= 0) goto err; if (BIO_puts(bp, " Responder Id: ") <= 0) goto err; - rid = rd->responderId; + rid = &rd->responderId; switch (rid->type) { case V_OCSP_RESPID_NAME: X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE); @@ -286,7 +286,7 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags) if (!X509V3_extensions_print(bp, "Response Extensions", rd->responseExtensions, flags, 4)) goto err; - if (X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0) + if (X509_signature_print(bp, &br->signatureAlgorithm, br->signature) <= 0) goto err; for (i = 0; i < sk_X509_num(br->certs); i++) { diff --git a/crypto/ocsp/ocsp_srv.c b/crypto/ocsp/ocsp_srv.c index 948eff9..8f196c8 100644 --- a/crypto/ocsp/ocsp_srv.c +++ b/crypto/ocsp/ocsp_srv.c @@ -74,12 +74,12 @@ int OCSP_request_onereq_count(OCSP_REQUEST *req) { - return sk_OCSP_ONEREQ_num(req->tbsRequest->requestList); + return sk_OCSP_ONEREQ_num(req->tbsRequest.requestList); } OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i) { - return sk_OCSP_ONEREQ_value(req->tbsRequest->requestList, i); + return sk_OCSP_ONEREQ_value(req->tbsRequest.requestList, i); } OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one) @@ -94,13 +94,13 @@ int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, if (!cid) return 0; if (pmd) - *pmd = cid->hashAlgorithm->algorithm; + *pmd = cid->hashAlgorithm.algorithm; if (piNameHash) - *piNameHash = cid->issuerNameHash; + *piNameHash = &cid->issuerNameHash; if (pikeyHash) - *pikeyHash = cid->issuerKeyHash; + *pikeyHash = &cid->issuerKeyHash; if (pserial) - *pserial = cid->serialNumber; + *pserial = &cid->serialNumber; return 1; } @@ -145,8 +145,8 @@ OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, OCSP_CERTSTATUS *cs; OCSP_REVOKEDINFO *ri; - if (rsp->tbsResponseData->responses == NULL - && (rsp->tbsResponseData->responses + if (rsp->tbsResponseData.responses == NULL + && (rsp->tbsResponseData.responses = sk_OCSP_SINGLERESP_new_null()) == NULL) goto err; @@ -195,7 +195,7 @@ OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, goto err; } - if (!(sk_OCSP_SINGLERESP_push(rsp->tbsResponseData->responses, single))) + if (!(sk_OCSP_SINGLERESP_push(rsp->tbsResponseData.responses, single))) goto err; return single; err: @@ -240,7 +240,7 @@ int OCSP_basic_sign(OCSP_BASICRESP *brsp, } } - rid = brsp->tbsResponseData->responderId; + rid = &brsp->tbsResponseData.responderId; if (flags & OCSP_RESPID_KEY) { unsigned char md[SHA_DIGEST_LENGTH]; X509_pubkey_digest(signer, EVP_sha1(), md, NULL); @@ -256,7 +256,7 @@ int OCSP_basic_sign(OCSP_BASICRESP *brsp, } if (!(flags & OCSP_NOTIME) && - !X509_gmtime_adj(brsp->tbsResponseData->producedAt, 0)) + !X509_gmtime_adj(brsp->tbsResponseData.producedAt, 0)) goto err; /* diff --git a/crypto/ocsp/ocsp_vfy.c b/crypto/ocsp/ocsp_vfy.c index 9dd3f3a..629ebf0 100644 --- a/crypto/ocsp/ocsp_vfy.c +++ b/crypto/ocsp/ocsp_vfy.c @@ -182,7 +182,7 @@ static int ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, unsigned long flags) { X509 *signer; - OCSP_RESPID *rid = bs->tbsResponseData->responderId; + OCSP_RESPID *rid = &bs->tbsResponseData.responderId; if ((signer = ocsp_find_signer_sk(certs, rid))) { *psigner = signer; return 2; @@ -231,7 +231,7 @@ static int ocsp_check_issuer(OCSP_BASICRESP *bs, STACK_OF(X509) *chain, X509 *signer, *sca; OCSP_CERTID *caid = NULL; int i; - sresp = bs->tbsResponseData->responses; + sresp = bs->tbsResponseData.responses; if (sk_X509_num(chain) <= 0) { OCSPerr(OCSP_F_OCSP_CHECK_ISSUER, OCSP_R_NO_CERTIFICATES_IN_CHAIN); @@ -292,8 +292,8 @@ static int ocsp_check_ids(STACK_OF(OCSP_SINGLERESP) *sresp, OCSP_CERTID **ret) /* Check to see if IDs match */ if (OCSP_id_issuer_cmp(cid, tmpid)) { /* If algoritm mismatch let caller deal with it */ - if (OBJ_cmp(tmpid->hashAlgorithm->algorithm, - cid->hashAlgorithm->algorithm)) + if (OBJ_cmp(tmpid->hashAlgorithm.algorithm, + cid->hashAlgorithm.algorithm)) return 2; /* Else mismatch */ return 0; @@ -314,7 +314,7 @@ static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid, X509_NAME *iname; int mdlen; unsigned char md[EVP_MAX_MD_SIZE]; - if ((dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm)) + if ((dgst = EVP_get_digestbyobj(cid->hashAlgorithm.algorithm)) == NULL) { OCSPerr(OCSP_F_OCSP_MATCH_ISSUERID, OCSP_R_UNKNOWN_MESSAGE_DIGEST); @@ -324,16 +324,16 @@ static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid, mdlen = EVP_MD_size(dgst); if (mdlen < 0) return -1; - if ((cid->issuerNameHash->length != mdlen) || - (cid->issuerKeyHash->length != mdlen)) + if ((cid->issuerNameHash.length != mdlen) || + (cid->issuerKeyHash.length != mdlen)) return 0; iname = X509_get_subject_name(cert); if (!X509_NAME_digest(iname, dgst, md, NULL)) return -1; - if (memcmp(md, cid->issuerNameHash->data, mdlen)) + if (memcmp(md, cid->issuerNameHash.data, mdlen)) return 0; X509_pubkey_digest(cert, dgst, md, NULL); - if (memcmp(md, cid->issuerKeyHash->data, mdlen)) + if (memcmp(md, cid->issuerKeyHash.data, mdlen)) return 0; return 1; @@ -380,7 +380,7 @@ int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED); return 0; } - gen = req->tbsRequest->requestorName; + gen = req->tbsRequest.requestorName; if (!gen || gen->type != GEN_DIRNAME) { OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE); diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h index 2405bd6..0768869 100644 --- a/include/openssl/asn1.h +++ b/include/openssl/asn1.h @@ -179,6 +179,8 @@ DECLARE_STACK_OF(X509_ALGOR) * type. */ # define ASN1_STRING_FLAG_MSTRING 0x040 +/* String is embedded and only content should be freed */ +# define ASN1_STRING_FLAG_EMBED 0x080 /* This is the base type that holds just about everything :-) */ struct asn1_string_st { int length; diff --git a/include/openssl/ocsp.h b/include/openssl/ocsp.h index ab45db4..79b4c37 100644 --- a/include/openssl/ocsp.h +++ b/include/openssl/ocsp.h @@ -186,19 +186,19 @@ typedef struct ocsp_service_locator_st OCSP_SERVICELOC; # define OCSP_REQUEST_sign(o,pkey,md) \ ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ - o->optionalSignature->signatureAlgorithm,NULL,\ - o->optionalSignature->signature,o->tbsRequest,pkey,md) + &o->optionalSignature->signatureAlgorithm,NULL,\ + o->optionalSignature->signature,&o->tbsRequest,pkey,md) # define OCSP_BASICRESP_sign(o,pkey,md,d) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\ - o->signature,o->tbsResponseData,pkey,md) + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),&o->signatureAlgorithm,NULL,\ + o->signature,&o->tbsResponseData,pkey,md) # define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ - a->optionalSignature->signatureAlgorithm,\ - a->optionalSignature->signature,a->tbsRequest,r) + &a->optionalSignature->signatureAlgorithm,\ + a->optionalSignature->signature,&a->tbsRequest,r) # define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ - a->signatureAlgorithm,a->signature,a->tbsResponseData,r) + &a->signatureAlgorithm,a->signature,&a->tbsResponseData,r) # define ASN1_BIT_STRING_digest(data,type,md,len) \ ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) From appro at openssl.org Mon Oct 12 10:08:39 2015 From: appro at openssl.org (Andy Polyakov) Date: Mon, 12 Oct 2015 10:08:39 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444644519.297530.8079.nullmailer@dev.openssl.org> The branch master has been updated via dc8980957ba12f49f7656429eda3a7b62c4cbb4c (commit) from af170194a88d6127d447bea826845c23ca192727 (commit) - Log ----------------------------------------------------------------- commit dc8980957ba12f49f7656429eda3a7b62c4cbb4c Author: Andy Polyakov Date: Wed Oct 7 09:35:12 2015 +0200 Configurations: move -Wno-pedantic-ms-format to .travis.yml. The option is not available in older toolchains and would cause breakage. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: .travis.yml | 4 ++-- Configurations/10-main.conf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 34b4d9d..c923119 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,10 +35,10 @@ matrix: before_script: - if [ "$CC" == i686-w64-mingw32-gcc ]; then export CROSS_COMPILE=${CC%%gcc}; unset CC; - ./Configure mingw $CONFIG_OPTS; + ./Configure mingw $CONFIG_OPTS -Wno-pedantic-ms-format; elif [ "$CC" == x86_64-w64-mingw32-gcc ]; then export CROSS_COMPILE=${CC%%gcc}; unset CC; - ./Configure mingw64 $CONFIG_OPTS; + ./Configure mingw64 $CONFIG_OPTS -Wno-pedantic-ms-format; else ./config $CONFIG_OPTS; fi diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 9ebd20f..426fbfa 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -1174,7 +1174,7 @@ "mingw" => { inherit_from => [ asm("x86_asm") ], cc => "gcc", - cflags => "-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -march=i486 -Wall -Wno-pedantic-ms-format", + cflags => "-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -march=i486 -Wall", debug_cflags => "-g -O0", release_clags => "-O3 -fomit-frame-pointer", thread_cflag => "-D_MT", @@ -1199,7 +1199,7 @@ # Applink is never engaged and can as well be omitted. inherit_from => [ asm("x86_64_asm") ], cc => "gcc", - cflags => "-mno-cygwin -DL_ENDIAN -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -Wno-pedantic-ms-format", + cflags => "-mno-cygwin -DL_ENDIAN -Wall -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE", debug_cflags => "-g -O0", release_clags => "-O3", thread_cflag => "-D_MT", From matt at openssl.org Mon Oct 12 11:47:44 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 12 Oct 2015 11:47:44 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444650464.399335.27290.nullmailer@dev.openssl.org> The branch master has been updated via d175e8a6c23ca212bf57ff78fdbca6942f3e0ef7 (commit) from dc8980957ba12f49f7656429eda3a7b62c4cbb4c (commit) - Log ----------------------------------------------------------------- commit d175e8a6c23ca212bf57ff78fdbca6942f3e0ef7 Author: Matt Caswell Date: Mon Oct 12 09:44:15 2015 +0100 Fix option name discrepancy There used to be options -macopt and -sigopt in <=1.0.2 for the dgst command line app. These were incorrectly spelled as -macop and -sigop in master. RT#4072 Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: apps/dgst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dgst.c b/apps/dgst.c index 99568f4..1e3a72c 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -109,8 +109,8 @@ OPTIONS dgst_options[] = { {"non-fips-allow", OPT_NON_FIPS_ALLOW, '-'}, {"hmac", OPT_HMAC, 's', "Create hashed MAC with key"}, {"mac", OPT_MAC, 's', "Create MAC (not neccessarily HMAC)"}, - {"sigop", OPT_SIGOPT, 's', "Signature parameter in n:v form"}, - {"macop", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"}, + {"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"}, + {"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"}, {"", OPT_DIGEST, '-', "Any supported digest"}, #ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, From ben at links.org Sun Oct 11 21:36:43 2015 From: ben at links.org (Ben Laurie) Date: Sun, 11 Oct 2015 21:36:43 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update In-Reply-To: <1444521004.624944.3642.nullmailer@dev.openssl.org> References: <1444521004.624944.3642.nullmailer@dev.openssl.org> Message-ID: How did that ever compile? Is EVP_CHECK_DES_KEY ever set? On Sat, 10 Oct 2015 at 16:50 Dr. Stephen Henson wrote: > The branch OpenSSL_1_0_2-stable has been updated > via 6868346585f38066de4610b516346a18a98a8427 (commit) > from 985abd1fd8aa24ef1bbf6adcf1923d07b35fa246 (commit) > > > - Log ----------------------------------------------------------------- > commit 6868346585f38066de4610b516346a18a98a8427 > Author: Dr. Stephen Henson > Date: Sun Oct 11 00:06:56 2015 +0100 > > Typo. > > PR#4079 > > Reviewed-by: Tim Hudson > (cherry picked from commit c69ce9351336f5b4a8b33890756b3fd185528210) > > ----------------------------------------------------------------------- > > Summary of changes: > crypto/evp/e_des3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c > index 96f272e..bf6c1d2 100644 > --- a/crypto/evp/e_des3.c > +++ b/crypto/evp/e_des3.c > @@ -289,7 +289,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const > unsigned char *key, > # endif > # ifdef EVP_CHECK_DES_KEY > if (DES_set_key_checked(&deskey[0], &dat->ks1) > - ! !DES_set_key_checked(&deskey[1], &dat->ks2)) > + || DES_set_key_checked(&deskey[1], &dat->ks2)) > return 0; > # else > DES_set_key_unchecked(&deskey[0], &dat->ks1); > _____ > openssl-commits mailing list > To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bkaduk at akamai.com Mon Oct 12 15:00:13 2015 From: bkaduk at akamai.com (Benjamin Kaduk) Date: Mon, 12 Oct 2015 10:00:13 -0500 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update In-Reply-To: References: <1444521004.624944.3642.nullmailer@dev.openssl.org> Message-ID: <561BCAFD.9020001@akamai.com> I would guess that no one has ever set EVP_CHECK_DES_KEY during the 11 years the code has been around (since commit 216659eb87485402a8e861a6de77233d1f5d7425), so maybe that code should just be removed. Sorry I didn't mention that in the ticket; I was in the middle of something else at the time but wanted to note the issue while it was in front of me. -Ben On 10/11/2015 04:36 PM, Ben Laurie wrote: > How did that ever compile? Is EVP_CHECK_DES_KEY ever set? > > On Sat, 10 Oct 2015 at 16:50 Dr. Stephen Henson > wrote: > > The branch OpenSSL_1_0_2-stable has been updated > via 6868346585f38066de4610b516346a18a98a8427 (commit) > from 985abd1fd8aa24ef1bbf6adcf1923d07b35fa246 (commit) > > > - Log > ----------------------------------------------------------------- > commit 6868346585f38066de4610b516346a18a98a8427 > Author: Dr. Stephen Henson > > Date: Sun Oct 11 00:06:56 2015 +0100 > > Typo. > > PR#4079 > > Reviewed-by: Tim Hudson > > (cherry picked from commit > c69ce9351336f5b4a8b33890756b3fd185528210) > > ----------------------------------------------------------------------- > > Summary of changes: > crypto/evp/e_des3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c > index 96f272e..bf6c1d2 100644 > --- a/crypto/evp/e_des3.c > +++ b/crypto/evp/e_des3.c > @@ -289,7 +289,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX > *ctx, const unsigned char *key, > # endif > # ifdef EVP_CHECK_DES_KEY > if (DES_set_key_checked(&deskey[0], &dat->ks1) > - ! !DES_set_key_checked(&deskey[1], &dat->ks2)) > + || DES_set_key_checked(&deskey[1], &dat->ks2)) > return 0; > # else > DES_set_key_unchecked(&deskey[0], &dat->ks1); > _____ > openssl-commits mailing list > To unsubscribe: > https://mta.openssl.org/mailman/listinfo/openssl-commits > > > > > _____ > openssl-commits mailing list > To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at openssl.org Mon Oct 12 21:33:36 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 12 Oct 2015 21:33:36 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444685616.625149.22445.nullmailer@dev.openssl.org> The branch master has been updated via a0a82324f965bbcc4faed4e1ee3fcaf81ea52166 (commit) from d175e8a6c23ca212bf57ff78fdbca6942f3e0ef7 (commit) - Log ----------------------------------------------------------------- commit a0a82324f965bbcc4faed4e1ee3fcaf81ea52166 Author: Matt Caswell Date: Mon Oct 12 12:40:15 2015 +0100 Centralise loading default apps config file Loading the config file after processing command line options can cause problems, e.g. where an engine provides new ciphers/digests these are not then recoginised on the command line. Move the default config file loading to before the command line option processing. Whilst we're doing this we might as well centralise this instead of doing it individually for each application. Finally if we do it before the OpenSSL_add_ssl_algorithms() call then ciphersuites provided by an engine (e.g. GOST) can be available to the apps. RT#4085 RT#4086 Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: apps/asn1pars.c | 3 --- apps/ca.c | 11 +++++++---- apps/ciphers.c | 3 --- apps/cms.c | 3 --- apps/crl.c | 3 --- apps/crl2p7.c | 3 --- apps/dgst.c | 3 --- apps/dhparam.c | 3 --- apps/dsa.c | 3 --- apps/dsaparam.c | 3 --- apps/ec.c | 3 --- apps/ecparam.c | 3 --- apps/enc.c | 3 --- apps/engine.c | 3 --- apps/gendsa.c | 3 --- apps/genpkey.c | 3 --- apps/genrsa.c | 3 --- apps/nseq.c | 3 --- apps/ocsp.c | 3 --- apps/openssl.c | 14 ++++++++++++-- apps/passwd.c | 3 --- apps/pkcs12.c | 3 --- apps/pkcs7.c | 3 --- apps/pkcs8.c | 3 --- apps/pkey.c | 3 --- apps/pkeyparam.c | 3 --- apps/pkeyutl.c | 3 --- apps/prime.c | 3 --- apps/rand.c | 3 --- apps/rsa.c | 4 ---- apps/rsautl.c | 3 --- apps/s_client.c | 3 --- apps/s_server.c | 3 --- apps/smime.c | 3 --- apps/speed.c | 3 --- apps/spkac.c | 2 -- apps/verify.c | 3 --- apps/x509.c | 3 --- 38 files changed, 19 insertions(+), 114 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index 574b03f..6f88a1d 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -186,9 +186,6 @@ int asn1parse_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (oidfile != NULL) { in = bio_open_default(oidfile, 'r', FORMAT_TEXT); if (in == NULL) diff --git a/apps/ca.c b/apps/ca.c index defbf00..586fbe4 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -484,10 +484,13 @@ end_of_options: argv = opt_rest(); BIO_printf(bio_err, "Using configuration from %s\n", configfile); - if ((conf = app_load_config(configfile)) == NULL) - goto end; - if (!app_load_modules(conf)) - goto end; + /* We already loaded the default config file */ + if (configfile != default_config_file) { + if ((conf = app_load_config(configfile)) == NULL) + goto end; + if (!app_load_modules(conf)) + goto end; + } /* Lets get the config section we are using */ if (section == NULL) { diff --git a/apps/ciphers.c b/apps/ciphers.c index a2ccf28..bf3c204 100644 --- a/apps/ciphers.c +++ b/apps/ciphers.c @@ -144,9 +144,6 @@ int ciphers_main(int argc, char **argv) else if (argc != 0) goto opthelp; - if (!app_load_modules(NULL)) - goto end; - ctx = SSL_CTX_new(meth); if (ctx == NULL) goto err; diff --git a/apps/cms.c b/apps/cms.c index 6ed9338..fef3403 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -684,9 +684,6 @@ int cms_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - if (need_rand) { app_RAND_load_file(NULL, (inrand != NULL)); if (inrand != NULL) diff --git a/apps/crl.c b/apps/crl.c index 253f7a5..b2a5d7f 100644 --- a/apps/crl.c +++ b/apps/crl.c @@ -232,9 +232,6 @@ int crl_main(int argc, char **argv) if (!nmflag_set) nmflag = XN_FLAG_ONELINE; - if (!app_load_modules(NULL)) - goto end; - x = load_crl(infile, informat); if (x == NULL) goto end; diff --git a/apps/crl2p7.c b/apps/crl2p7.c index 8cc1b62..930875a 100644 --- a/apps/crl2p7.c +++ b/apps/crl2p7.c @@ -148,9 +148,6 @@ int crl2pkcs7_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (!nocrl) { in = bio_open_default(infile, 'r', informat); if (in == NULL) diff --git a/apps/dgst.c b/apps/dgst.c index 1e3a72c..e62a8de 100644 --- a/apps/dgst.c +++ b/apps/dgst.c @@ -236,9 +236,6 @@ int dgst_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (do_verify && !sigfile) { BIO_printf(bio_err, "No signature to verify: use the -signature option\n"); diff --git a/apps/dhparam.c b/apps/dhparam.c index 334a129..17c0b5b 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -230,9 +230,6 @@ int dhparam_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (argv[0] && (!opt_int(argv[0], &num) || num <= 0)) goto end; diff --git a/apps/dsa.c b/apps/dsa.c index d829f98..9dcc75e 100644 --- a/apps/dsa.c +++ b/apps/dsa.c @@ -202,9 +202,6 @@ int dsa_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - BIO_printf(bio_err, "read DSA key\n"); { EVP_PKEY *pkey; diff --git a/apps/dsaparam.c b/apps/dsaparam.c index 1ba93e6..a0a3372 100644 --- a/apps/dsaparam.c +++ b/apps/dsaparam.c @@ -183,9 +183,6 @@ int dsaparam_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (argc == 1) { if (!opt_int(argv[0], &num)) goto end; diff --git a/apps/ec.c b/apps/ec.c index a30d3f0..3c38e61 100644 --- a/apps/ec.c +++ b/apps/ec.c @@ -202,9 +202,6 @@ int ec_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - in = bio_open_default(infile, 'r', informat); if (in == NULL) goto end; diff --git a/apps/ecparam.c b/apps/ecparam.c index 5a98f45..9d13447 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -220,9 +220,6 @@ int ecparam_main(int argc, char **argv) argv = opt_rest(); private = genkey ? 1 : 0; - if (!app_load_modules(NULL)) - goto end; - in = bio_open_default(infile, 'r', informat); if (in == NULL) goto end; diff --git a/apps/enc.c b/apps/enc.c index 5ffb1f0..b0c82d6 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -295,9 +295,6 @@ int enc_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) { BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog); goto end; diff --git a/apps/engine.c b/apps/engine.c index b1c1371..b4da23e 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -369,9 +369,6 @@ int engine_main(int argc, char **argv) } } - if (!app_load_modules(NULL)) - goto end; - for (i = 0; i < sk_OPENSSL_STRING_num(engines); i++) { const char *id = sk_OPENSSL_STRING_value(engines, i); if ((e = ENGINE_by_id(id)) != NULL) { diff --git a/apps/gendsa.c b/apps/gendsa.c index f1e1f54..5d5cb5e 100644 --- a/apps/gendsa.c +++ b/apps/gendsa.c @@ -144,9 +144,6 @@ int gendsa_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - in = bio_open_default(dsaparams, 'r', FORMAT_PEM); if (in == NULL) goto end2; diff --git a/apps/genpkey.c b/apps/genpkey.c index d809833..333cea9 100644 --- a/apps/genpkey.c +++ b/apps/genpkey.c @@ -181,9 +181,6 @@ int genpkey_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - out = bio_open_owner(outfile, outformat, private); if (out == NULL) goto end; diff --git a/apps/genrsa.c b/apps/genrsa.c index 54484b5..b0e5e19 100644 --- a/apps/genrsa.c +++ b/apps/genrsa.c @@ -169,9 +169,6 @@ int genrsa_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - out = bio_open_owner(outfile, FORMAT_PEM, private); if (out == NULL) goto end; diff --git a/apps/nseq.c b/apps/nseq.c index 06893c8..e8cf69d 100644 --- a/apps/nseq.c +++ b/apps/nseq.c @@ -109,9 +109,6 @@ int nseq_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - in = bio_open_default(infile, 'r', FORMAT_PEM); if (in == NULL) goto end; diff --git a/apps/ocsp.c b/apps/ocsp.c index 960b776..0f8ddcc 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -494,9 +494,6 @@ int ocsp_main(int argc, char **argv) if (!req && !reqin && !respin && !(port && ridx_filename)) goto opthelp; - if (!app_load_modules(NULL)) - goto end; - out = bio_open_default(outfile, 'w', FORMAT_TEXT); if (out == NULL) goto end; diff --git a/apps/openssl.c b/apps/openssl.c index 81a3762..565903f 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -166,7 +166,7 @@ BIO *bio_in = NULL; BIO *bio_out = NULL; BIO *bio_err = NULL; -static void apps_startup() +static int apps_startup() { #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); @@ -174,6 +174,13 @@ static void apps_startup() CRYPTO_malloc_init(); ERR_load_crypto_strings(); ERR_load_SSL_strings(); + + if (!app_load_modules(NULL)) { + ERR_print_errors(bio_err); + BIO_printf(bio_err, "Error loading default configuration\n"); + return 0; + } + OpenSSL_add_all_algorithms(); OpenSSL_add_ssl_algorithms(); OPENSSL_load_builtin_modules(); @@ -182,6 +189,7 @@ static void apps_startup() #ifndef OPENSSL_NO_ENGINE ENGINE_load_builtin_engines(); #endif + return 1; } static void apps_shutdown() @@ -328,7 +336,9 @@ int main(int argc, char *argv[]) #endif } - apps_startup(); + if (!apps_startup()) + goto end; + prog = prog_init(); pname = opt_progname(argv[0]); diff --git a/apps/passwd.c b/apps/passwd.c index 8988313..372e0e8 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -201,9 +201,6 @@ int passwd_main(int argc, char **argv) goto opthelp; # endif - if (!app_load_modules(NULL)) - goto end; - if (infile && in_stdin) { BIO_printf(bio_err, "%s: Can't combine -in and -stdin\n", prog); goto end; diff --git a/apps/pkcs12.c b/apps/pkcs12.c index e1f663a..11930e9 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -354,9 +354,6 @@ int pkcs12_main(int argc, char **argv) mpass = macpass; } - if (!app_load_modules(NULL)) - goto end; - if (export_cert || inrand) { app_RAND_load_file(NULL, (inrand != NULL)); if (inrand != NULL) diff --git a/apps/pkcs7.c b/apps/pkcs7.c index fff14dc..1ed0b01 100644 --- a/apps/pkcs7.c +++ b/apps/pkcs7.c @@ -193,9 +193,6 @@ int pkcs7_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - in = bio_open_default(infile, 'r', informat); if (in == NULL) goto end; diff --git a/apps/pkcs8.c b/apps/pkcs8.c index 765744f..3d7282e 100644 --- a/apps/pkcs8.c +++ b/apps/pkcs8.c @@ -233,9 +233,6 @@ int pkcs8_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - if ((pbe_nid == -1) && !cipher) pbe_nid = NID_pbeWithMD5AndDES_CBC; diff --git a/apps/pkey.c b/apps/pkey.c index d2a66eb..694cdd1 100644 --- a/apps/pkey.c +++ b/apps/pkey.c @@ -169,9 +169,6 @@ int pkey_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - out = bio_open_owner(outfile, outformat, private); if (out == NULL) goto end; diff --git a/apps/pkeyparam.c b/apps/pkeyparam.c index 215611e..abb40d1 100644 --- a/apps/pkeyparam.c +++ b/apps/pkeyparam.c @@ -118,9 +118,6 @@ int pkeyparam_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - in = bio_open_default(infile, 'r', FORMAT_PEM); if (in == NULL) goto end; diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index c3e1889..82ebdee 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -230,9 +230,6 @@ int pkeyutl_main(int argc, char **argv) if (ctx == NULL) goto opthelp; - if (!app_load_modules(NULL)) - goto end; - if (sigfile && (pkey_op != EVP_PKEY_OP_VERIFY)) { BIO_printf(bio_err, "%s: Signature file specified for non verify\n", prog); diff --git a/apps/prime.c b/apps/prime.c index 2ce4e94..b6c5ad5 100644 --- a/apps/prime.c +++ b/apps/prime.c @@ -109,9 +109,6 @@ int prime_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (argc == 0 && !generate) { BIO_printf(bio_err, "%s: No prime specified\n", prog); goto end; diff --git a/apps/rand.c b/apps/rand.c index 315e6be..150eef4 100644 --- a/apps/rand.c +++ b/apps/rand.c @@ -126,9 +126,6 @@ int rand_main(int argc, char **argv) if (sscanf(argv[0], "%d", &num) != 1 || num < 0) goto opthelp; - if (!app_load_modules(NULL)) - goto end; - app_RAND_load_file(NULL, (inrand != NULL)); if (inrand != NULL) BIO_printf(bio_err, "%ld semi-random bytes loaded\n", diff --git a/apps/rsa.c b/apps/rsa.c index f8a0dec..0640ba4 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -256,10 +256,6 @@ int rsa_main(int argc, char **argv) BIO_printf(bio_err, "Error getting passwords\n"); goto end; } - - if (!app_load_modules(NULL)) - goto end; - if (check && pubin) { BIO_printf(bio_err, "Only private keys can be checked\n"); goto end; diff --git a/apps/rsautl.c b/apps/rsautl.c index 84a1de1..5d6bdc0 100644 --- a/apps/rsautl.c +++ b/apps/rsautl.c @@ -214,9 +214,6 @@ int rsautl_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - /* FIXME: seed PRNG only if needed */ app_RAND_load_file(NULL, 0); diff --git a/apps/s_client.c b/apps/s_client.c index d76f921..9bad1b5 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -1063,9 +1063,6 @@ int s_client_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - if (proxystr) { if (connectstr == NULL) { BIO_printf(bio_err, "%s: -proxy requires use of -connect\n", prog); diff --git a/apps/s_server.c b/apps/s_server.c index aa43541..bfc8b1f 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -1475,9 +1475,6 @@ int s_server_main(int argc, char *argv[]) goto end; } - if (!app_load_modules(NULL)) - goto end; - if (s_key_file == NULL) s_key_file = s_cert_file; diff --git a/apps/smime.c b/apps/smime.c index db645d0..551a8fd 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -422,9 +422,6 @@ int smime_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - if (need_rand) { app_RAND_load_file(NULL, (inrand != NULL)); if (inrand != NULL) diff --git a/apps/speed.c b/apps/speed.c index 046c0b2..faa3e15 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -850,9 +850,6 @@ int speed_main(int argc, char **argv) argc = opt_num_rest(); argv = opt_rest(); - if (!app_load_modules(NULL)) - goto end; - /* Remaining arguments are algorithms. */ for ( ; *argv; argv++) { if (found(*argv, doit_choices, &i)) { diff --git a/apps/spkac.c b/apps/spkac.c index 180f80f..eaeb3c1 100644 --- a/apps/spkac.c +++ b/apps/spkac.c @@ -186,8 +186,6 @@ int spkac_main(int argc, char **argv) if ((conf = app_load_config(infile)) == NULL) goto end; - if (!app_load_modules(conf)) - goto end; spkstr = NCONF_get_string(conf, spksect, spkac); diff --git a/apps/verify.c b/apps/verify.c index 61f8cf7..bd4ed05 100644 --- a/apps/verify.c +++ b/apps/verify.c @@ -198,9 +198,6 @@ int verify_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL) goto end; X509_STORE_set_verify_cb(store, cb); diff --git a/apps/x509.c b/apps/x509.c index 9472b68..ff1e8cb 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -493,9 +493,6 @@ int x509_main(int argc, char **argv) if (!nmflag_set) nmflag = XN_FLAG_ONELINE; - if (!app_load_modules(NULL)) - goto end; - out = bio_open_default(outfile, 'w', outformat); if (out == NULL) goto end; From matt at openssl.org Mon Oct 12 21:44:22 2015 From: matt at openssl.org (Matt Caswell) Date: Mon, 12 Oct 2015 21:44:22 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444686262.190594.24848.nullmailer@dev.openssl.org> The branch master has been updated via 1dce6c3f9eef0da2866b82d816dc945883427060 (commit) from a0a82324f965bbcc4faed4e1ee3fcaf81ea52166 (commit) - Log ----------------------------------------------------------------- commit 1dce6c3f9eef0da2866b82d816dc945883427060 Author: Matt Caswell Date: Mon Oct 12 13:03:50 2015 +0100 Rename -set-serial command to req Previous OpenSSL versions used -set_serial, but master was using -set-serial - so rename it back to the old version. RT#4059 Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: apps/req.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/req.c b/apps/req.c index ce0fcbc..1dcf0f7 100644 --- a/apps/req.c +++ b/apps/req.c @@ -169,7 +169,7 @@ OPTIONS req_options[] = { {"multivalue-rdn", OPT_MULTIVALUE_RDN, '-', "Enable support for multivalued RDNs"}, {"days", OPT_DAYS, 'p', "Number of days cert is valid for"}, - {"set-serial", OPT_SET_SERIAL, 'p', "Serial number to use"}, + {"set_serial", OPT_SET_SERIAL, 'p', "Serial number to use"}, {"extensions", OPT_EXTENSIONS, 's', "Cert extension section (override value in config file)"}, {"reqexts", OPT_REQEXTS, 's', From appro at openssl.org Tue Oct 13 17:49:03 2015 From: appro at openssl.org (Andy Polyakov) Date: Tue, 13 Oct 2015 17:49:03 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444758543.443396.26403.nullmailer@dev.openssl.org> The branch master has been updated via 2d2a83543f757cf3a48a1a0e412aee183a6d539b (commit) via 82987e6119403661c45f781a8b6748941c15ade6 (commit) via 85833408b4fb6e109cb05bf8dbe9cdb6bd8f280d (commit) via 4ada8be2a6c538ee66a9a35a182052f359fc94b3 (commit) from 1dce6c3f9eef0da2866b82d816dc945883427060 (commit) - Log ----------------------------------------------------------------- commit 2d2a83543f757cf3a48a1a0e412aee183a6d539b Author: Andy Polyakov Date: Mon Oct 12 22:31:20 2015 +0200 testlib/OpenSSL/Test.pm: remove redundant 'cmd /c', MSWin32 Perl can take care of itself. Reviewed-by: Richard Levitte commit 82987e6119403661c45f781a8b6748941c15ade6 Author: Andy Polyakov Date: Mon Oct 12 22:26:14 2015 +0200 Harmonize do_rehash_rule with updated test/recipies/25-test_verify.t. Reviewed-by: Richard Levitte commit 85833408b4fb6e109cb05bf8dbe9cdb6bd8f280d Author: Andy Polyakov Date: Mon Oct 12 22:24:27 2015 +0200 Test suite: chomp->s/\R// to harmonize with mingw 'make test'. Reviewed-by: Richard Levitte commit 4ada8be2a6c538ee66a9a35a182052f359fc94b3 Author: Andy Polyakov Date: Mon Oct 12 22:16:07 2015 +0200 Test suite: minimal required to get mingw 'make test' work under Linux. (part by Alessandro Ghedini) Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: test/recipes/00-check_testexes.t | 6 +++--- test/recipes/10-test_bn.t | 2 +- test/recipes/20-test_enc.t | 2 +- test/recipes/25-test_req.t | 2 +- test/recipes/25-test_verify.t | 3 +++ test/recipes/70-test_sslextension.t | 2 +- test/recipes/70-test_sslsessiontick.t | 2 +- test/recipes/70-test_sslskewith0p.t | 2 +- test/recipes/70-test_sslvertol.t | 2 +- test/recipes/80-test_ssl.t | 2 +- test/recipes/tconversion.pl | 12 ++++++++++-- test/testlib/OpenSSL/Test.pm | 14 ++++++++++---- test/testlib/OpenSSL/Test/Utils.pm | 2 +- util/mk1mf.pl | 4 ++-- util/pl/VC-32.pl | 1 + util/pl/unix.pl | 3 ++- util/shlib_wrap.sh | 2 +- 17 files changed, 41 insertions(+), 22 deletions(-) diff --git a/test/recipes/00-check_testexes.t b/test/recipes/00-check_testexes.t index 3ab38c7..c086f7f 100644 --- a/test/recipes/00-check_testexes.t +++ b/test/recipes/00-check_testexes.t @@ -12,7 +12,7 @@ my $OpenSSL_ver = ""; my $Makefile = top_file("Makefile"); if (open(FH, $Makefile)) { $OpenSSL_ver = - (map { chomp; s/^VERSION=([^\s]*)\s*$//; $1 } grep { /^VERSION=/ } )[0]; + (map { s/\R//; s/^VERSION=([^\s]*)\s*$//; $1 } grep { /^VERSION=/ } )[0]; close FH; } @@ -24,14 +24,14 @@ plan skip_all => "because MINFO not found. If you want this test to run, please my $MINFO_ver = ""; while() { - chomp; + s/\R//; # chomp; if (/^VERSION=([^\s]*)\s*$/) { $MINFO_ver = $1; } last if /^RELATIVE_DIRECTORY=test$/; } while() { - chomp; + s/\R//; # chomp; last if /^EXE=/; } close FH; diff --git a/test/recipes/10-test_bn.t b/test/recipes/10-test_bn.t index 29b449f..a01d9bf 100644 --- a/test/recipes/10-test_bn.t +++ b/test/recipes/10-test_bn.t @@ -25,7 +25,7 @@ my $init = ok(run(test(["bntest"], stdout => $testresults)), 'initialize'); @lines = ; close DATA; } - chomp(@lines); + map { s/\R//; } @lines; # chomp(@lines); plan tests => scalar grep(/^print /, @lines); diff --git a/test/recipes/20-test_enc.t b/test/recipes/20-test_enc.t index bd5a436..836d979 100644 --- a/test/recipes/20-test_enc.t +++ b/test/recipes/20-test_enc.t @@ -21,7 +21,7 @@ my $test = catfile(".", "p"); my $cmd = "openssl"; my @ciphers = - map { chomp; s/^\s+//; s/\s+$//; split /\s+/ } + map { s/^\s+//; s/\s+$//; split /\s+/ } run(app([$cmd, "list", "-cipher-commands"]), capture => 1); plan tests => 1 + (scalar @ciphers)*2; diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t index 4f9de77..ce1f869 100644 --- a/test/recipes/25-test_req.t +++ b/test/recipes/25-test_req.t @@ -31,7 +31,7 @@ sub run_conversion { open DATA, "req-check.err"; SKIP: { plan skip_all => "skipping req conversion test for $reqfile" - if grep /Unknown Public Key/, map { chomp } ; + if grep /Unknown Public Key/, map { s/\R//; } ; tconversion("req", "testreq.pem", @openssl_args); } diff --git a/test/recipes/25-test_verify.t b/test/recipes/25-test_verify.t index 10897a1..7c0f091 100644 --- a/test/recipes/25-test_verify.t +++ b/test/recipes/25-test_verify.t @@ -8,6 +8,9 @@ use OpenSSL::Test qw/:DEFAULT top_dir top_file/; setup("test_verify"); +plan skip_all => "no rehash.time was found." + unless (-f top_file("rehash.time")); + plan tests => 1; note("Expect some failures and expired certificate"); diff --git a/test/recipes/70-test_sslextension.t b/test/recipes/70-test_sslextension.t index 4aa3f61..bd99b19 100755 --- a/test/recipes/70-test_sslextension.t +++ b/test/recipes/70-test_sslextension.t @@ -60,7 +60,7 @@ my $test_name = "test_sslextension"; setup($test_name); plan skip_all => "$test_name can only be performed with OpenSSL configured shared" - unless (map { chomp; s/^SHARED_LIBS=\s*//; $_ } + unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ } grep { /^SHARED_LIBS=/ } do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne ""; diff --git a/test/recipes/70-test_sslsessiontick.t b/test/recipes/70-test_sslsessiontick.t index a7a450a..9209fd7 100755 --- a/test/recipes/70-test_sslsessiontick.t +++ b/test/recipes/70-test_sslsessiontick.t @@ -61,7 +61,7 @@ my $test_name = "test_sslsessiontick"; setup($test_name); plan skip_all => "$test_name can only be performed with OpenSSL configured shared" - unless (map { chomp; s/^SHARED_LIBS=\s*//; $_ } + unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ } grep { /^SHARED_LIBS=/ } do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne ""; diff --git a/test/recipes/70-test_sslskewith0p.t b/test/recipes/70-test_sslskewith0p.t index d8d74b3..3f5e131 100755 --- a/test/recipes/70-test_sslskewith0p.t +++ b/test/recipes/70-test_sslskewith0p.t @@ -60,7 +60,7 @@ my $test_name = "test_sslskewith0p"; setup($test_name); plan skip_all => "$test_name can only be performed with OpenSSL configured shared" - unless (map { chomp; s/^SHARED_LIBS=\s*//; $_ } + unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ } grep { /^SHARED_LIBS=/ } do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne ""; diff --git a/test/recipes/70-test_sslvertol.t b/test/recipes/70-test_sslvertol.t index 9717f80..78c6410 100755 --- a/test/recipes/70-test_sslvertol.t +++ b/test/recipes/70-test_sslvertol.t @@ -60,7 +60,7 @@ my $test_name = "test_sslextension"; setup($test_name); plan skip_all => "$test_name can only be performed with OpenSSL configured shared" - unless (map { chomp; s/^SHARED_LIBS=\s*//; $_ } + unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ } grep { /^SHARED_LIBS=/ } do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne ""; diff --git a/test/recipes/80-test_ssl.t b/test/recipes/80-test_ssl.t index 6e5e22e..5f520de 100644 --- a/test/recipes/80-test_ssl.t +++ b/test/recipes/80-test_ssl.t @@ -414,7 +414,7 @@ sub testssl { map { split(/:/, $_) } run(app(["openssl", "ciphers", "${_}:$ciphers"]), capture => 1); - chomp @c; + map { s/\R//; } @c; # chomp @c; $protocolciphersuitcount += scalar @c; $_ => [ @c ] } @protocols; diff --git a/test/recipes/tconversion.pl b/test/recipes/tconversion.pl index 011dcbf..07e3406 100644 --- a/test/recipes/tconversion.pl +++ b/test/recipes/tconversion.pl @@ -68,14 +68,14 @@ sub tconversion { } if ($testtype ne "p7d") { - is(compare_text("$testtype-fff.p", "$testtype-f.p"), 0, + is(cmp_text("$testtype-fff.p", "$testtype-f.p"), 0, 'comparing orig to p'); } foreach my $to (@conversionforms) { next if $to eq "d"; foreach my $from (@conversionforms) { - is(compare_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0, + is(cmp_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0, "comparing $to to $from$to"); } } @@ -85,4 +85,12 @@ sub tconversion { unlink glob "$testtype-fff.*"; } +sub cmp_text { + return compare_text(@_, sub { + $_[0] =~ s/\R//g; + $_[1] =~ s/\R//g; + return $_[0] ne $_[1]; + }); +} + 1; diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm index c64d68d..06accb5 100644 --- a/test/testlib/OpenSSL/Test.pm +++ b/test/testlib/OpenSSL/Test.pm @@ -284,8 +284,6 @@ sub run { my $prefix = ""; if ( $^O eq "VMS" ) { # VMS $prefix = "pipe "; - } elsif ($^O eq "MSWin32") { # MSYS - $prefix = "cmd /c "; } my @r = (); @@ -357,7 +355,7 @@ operating system. =cut sub top_dir { - return __top_file(@_, ""); # This caters for operating systems that have + return __top_dir(@_); # This caters for operating systems that have # a very distinct syntax for directories. } @@ -577,6 +575,12 @@ sub __top_file { return catfile($directories{TOP}, at _,$f); } +sub __top_dir { + BAIL_OUT("Must run setup() first") if (! $test_name); + + return catdir($directories{TOP}, at _); +} + sub __test_file { BAIL_OUT("Must run setup() first") if (! $test_name); @@ -668,7 +672,9 @@ sub __fixup_cmd { my $prefix = __top_file("util", "shlib_wrap.sh")." "; my $ext = $ENV{"EXE_EXT"} || ""; - if ( $^O eq "VMS" ) { # VMS + if (defined($ENV{EXE_SHELL})) { + $prefix = "$ENV{EXE_SHELL} "; + } elsif ($^O eq "VMS" ) { # VMS $prefix = "mcr "; $ext = ".exe"; } elsif ($^O eq "MSWin32") { # Windows diff --git a/test/testlib/OpenSSL/Test/Utils.pm b/test/testlib/OpenSSL/Test/Utils.pm index fc9b533..5312c20 100644 --- a/test/testlib/OpenSSL/Test/Utils.pm +++ b/test/testlib/OpenSSL/Test/Utils.pm @@ -46,7 +46,7 @@ my $disabled_set = 0; sub check_disabled { #print STDERR "Running check_disabled\n"; foreach (run(app(["openssl", "list", "-disabled"]), capture => 1)) { - chomp; + s/\R//; # chomp; next if /:/; # skip header $disabled{lc $_} = 1; } diff --git a/util/mk1mf.pl b/util/mk1mf.pl index 9d8a47d..491a1bb 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -779,8 +779,8 @@ reallyclean: EOF -$rules .= &do_rehash_rule("rehash", "certs apps"); -$rules .= &do_test_rule("test", "rehash", "run_tests.pl"); +$rules .= &do_rehash_rule("rehash.time", "certs apps"); +$rules .= &do_test_rule("test", "rehash.time", "run_tests.pl"); my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; $platform_cpp_symbol =~ s/-/_/g; diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index a2d35c6..8cb4835 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -307,6 +307,7 @@ $target: $deps set OPENSSL=\$(BIN_D)${o}openssl.exe set OPENSSL_DEBUG_MEMORY=on \$(PERL) tools/c_rehash certs/demo + echo off > $target EOF return $ret } diff --git a/util/pl/unix.pl b/util/pl/unix.pl index 528d4d0..c1fa1ff 100644 --- a/util/pl/unix.pl +++ b/util/pl/unix.pl @@ -193,7 +193,8 @@ $target: $deps (OPENSSL="`pwd`/util/opensslwrap.sh"; \\ OPENSSL_DEBUG_MEMORY=on; \\ export OPENSSL OPENSSL_DEBUG_MEMORY; \\ - \$(PERL) tools/c_rehash certs/demo) + \$(PERL) tools/c_rehash certs/demo; \\ + touch $target) EOF return $ret } diff --git a/util/shlib_wrap.sh b/util/shlib_wrap.sh index 8775cb5..646b0fe 100755 --- a/util/shlib_wrap.sh +++ b/util/shlib_wrap.sh @@ -88,7 +88,7 @@ if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES fi -cmd="$1${EXE_EXT}" +cmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}" shift if [ $# -eq 0 ]; then exec "$cmd" # old sh, such as Tru64 4.x, fails to expand empty "$@" From rsalz at openssl.org Tue Oct 13 18:05:00 2015 From: rsalz at openssl.org (Rich Salz) Date: Tue, 13 Oct 2015 18:05:00 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444759500.138271.493.nullmailer@dev.openssl.org> The branch master has been updated via f386742cfb811a9d2c886240e90b1064511b9acf (commit) from 2d2a83543f757cf3a48a1a0e412aee183a6d539b (commit) - Log ----------------------------------------------------------------- commit f386742cfb811a9d2c886240e90b1064511b9acf Author: Alessandro Ghedini Date: Mon Oct 12 16:15:43 2015 -0400 GH429: Add clang to travis Signed-off-by: Rich Salz Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: .travis.yml | 17 ++++++++++++++--- Configure | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c923119..f27b4b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,13 @@ language: c addons: - apt_packages: - - binutils-mingw-w64 - - gcc-mingw-w64 + apt: + packages: + - gcc-5 + - binutils-mingw-w64 + - gcc-mingw-w64 + sources: + - ubuntu-toolchain-r-test os: - linux @@ -12,6 +16,7 @@ os: compiler: - clang - gcc + - gcc-5 - i686-w64-mingw32-gcc - x86_64-w64-mingw32-gcc @@ -21,8 +26,14 @@ env: - CONFIG_OPTS="--debug --strict-warnings" matrix: + include: + - os: linux + compiler: gcc-5 + env: CONFIG_OPTS="--debug --strict-warnings -fsanitize=address" exclude: - os: osx + compiler: gcc-5 + - os: osx compiler: i686-w64-mingw32-gcc - os: osx compiler: x86_64-w64-mingw32-gcc diff --git a/Configure b/Configure index b277957..06b2278 100755 --- a/Configure +++ b/Configure @@ -1640,7 +1640,7 @@ if ($strict_warnings) my $ecc = $cc; $ecc = "clang" if `$cc --version 2>&1` =~ /clang/; my $wopt; - die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc$/ or $ecc =~ /clang$/); + die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc(-\d(\.\d)*)?$/ or $ecc =~ /clang$/); foreach $wopt (split /\s+/, $gcc_devteam_warn) { $cflags .= " $wopt" unless ($cflags =~ /$wopt/) From rsalz at openssl.org Tue Oct 13 20:10:16 2015 From: rsalz at openssl.org (Rich Salz) Date: Tue, 13 Oct 2015 20:10:16 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444767016.248905.3863.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via bf9d61d1abfc4d36562aa799cd9dc59c7bb46e57 (commit) from 6868346585f38066de4610b516346a18a98a8427 (commit) - Log ----------------------------------------------------------------- commit bf9d61d1abfc4d36562aa799cd9dc59c7bb46e57 Author: Peter Mosmans Date: Tue May 27 23:26:11 2014 +0100 RT3346: Fix test_bn regexp for Windows using MSYS. (cherry picked from commit 028bac0670c167f154438742eb4d0fbed73df209) Signed-off-by: Rich Salz Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index 80aeccf..8cbb5ad 100644 --- a/test/Makefile +++ b/test/Makefile @@ -245,7 +245,7 @@ test_bn: $(BNTEST)$(EXE_EXT) $(EXPTEST)$(EXE_EXT) bctest @../util/shlib_wrap.sh ./$(BNTEST) >tmp.bntest @echo quit >>tmp.bntest @echo "running bc" - @) {if (/^test (.*)/) {print STDERR "\nverify $$1";} elsif (!/^0$$/) {die "\nFailed! bc: $$_";} else {print STDERR "."; $$i++;}} print STDERR "\n$$i tests passed\n"' + @) {if (/^test (.*)/) {print STDERR "\nverify $$1";} elsif (!/^0\r?$$/) {die "\nFailed! bc: $$_";} else {print STDERR "."; $$i++;}} print STDERR "\n$$i tests passed\n"' @echo 'test a^b%c implementations' ../util/shlib_wrap.sh ./$(EXPTEST) From rsalz at openssl.org Tue Oct 13 20:13:16 2015 From: rsalz at openssl.org (Rich Salz) Date: Tue, 13 Oct 2015 20:13:16 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444767196.928400.6975.nullmailer@dev.openssl.org> The branch master has been updated via 6220acf887546709bfd583dea4fccffc95da99fc (commit) from f386742cfb811a9d2c886240e90b1064511b9acf (commit) - Log ----------------------------------------------------------------- commit 6220acf887546709bfd583dea4fccffc95da99fc Author: Alessandro Ghedini Date: Tue Oct 6 20:27:50 2015 +0200 Add Clang 3.6 and additional GCC 5 builds to travis Follow-up to f386742. Signed-off-by: Rich Salz Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.travis.yml b/.travis.yml index f27b4b6..3deea54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,12 @@ language: c addons: apt: packages: + - clang-3.6 - gcc-5 - binutils-mingw-w64 - gcc-mingw-w64 sources: + - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test os: @@ -15,6 +17,7 @@ os: compiler: - clang + - clang-3.6 - gcc - gcc-5 - i686-w64-mingw32-gcc @@ -28,10 +31,21 @@ env: matrix: include: - os: linux + compiler: clang-3.6 + env: CONFIG_OPTS="-fsanitize=address" + - os: linux + compiler: clang-3.6 + env: CONFIG_OPTS="--debug --strict-warnings -fsanitize=address" + - os: linux + compiler: gcc-5 + env: CONFIG_OPTS="-fsanitize=address" + - os: linux compiler: gcc-5 env: CONFIG_OPTS="--debug --strict-warnings -fsanitize=address" exclude: - os: osx + compiler: clang-3.6 + - os: osx compiler: gcc-5 - os: osx compiler: i686-w64-mingw32-gcc From steve at openssl.org Tue Oct 13 22:01:05 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 13 Oct 2015 22:01:05 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444773665.576197.16713.nullmailer@dev.openssl.org> The branch master has been updated via 4ec36aff2a3c221b640dafa56ac838312e6724f4 (commit) from 6220acf887546709bfd583dea4fccffc95da99fc (commit) - Log ----------------------------------------------------------------- commit 4ec36aff2a3c221b640dafa56ac838312e6724f4 Author: Dr. Stephen Henson Date: Mon Oct 12 21:14:04 2015 +0100 RFC5753 compliance. RFC5753 requires that we omit parameters for AES key wrap and set them to NULL for 3DES wrap. OpenSSL decrypt uses the received algorithm parameters so can transparently handle either form. Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: crypto/evp/evp_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 5ee3dcb..319eede 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -70,7 +70,8 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) { switch (EVP_CIPHER_CTX_mode(c)) { case EVP_CIPH_WRAP_MODE: - ASN1_TYPE_set(type, V_ASN1_NULL, NULL); + if (EVP_CIPHER_CTX_nid(c) == NID_id_smime_alg_CMS3DESwrap) + ASN1_TYPE_set(type, V_ASN1_NULL, NULL); ret = 1; break; From steve at openssl.org Tue Oct 13 22:03:16 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Tue, 13 Oct 2015 22:03:16 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444773796.289989.18108.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via a20d9422cf7a516cd576be8f91fe90738459ef42 (commit) from bf9d61d1abfc4d36562aa799cd9dc59c7bb46e57 (commit) - Log ----------------------------------------------------------------- commit a20d9422cf7a516cd576be8f91fe90738459ef42 Author: Dr. Stephen Henson Date: Mon Oct 12 21:14:04 2015 +0100 RFC5753 compliance. RFC5753 requires that we omit parameters for AES key wrap and set them to NULL for 3DES wrap. OpenSSL decrypt uses the received algorithm parameters so can transparently handle either form. Reviewed-by: Andy Polyakov (cherry picked from commit 4ec36aff2a3c221b640dafa56ac838312e6724f4) ----------------------------------------------------------------------- Summary of changes: crypto/evp/evp_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index d2c9ae4..7e0bab9 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -74,7 +74,8 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) { switch (EVP_CIPHER_CTX_mode(c)) { case EVP_CIPH_WRAP_MODE: - ASN1_TYPE_set(type, V_ASN1_NULL, NULL); + if (EVP_CIPHER_CTX_nid(c) == NID_id_smime_alg_CMS3DESwrap) + ASN1_TYPE_set(type, V_ASN1_NULL, NULL); ret = 1; break; From emilia at openssl.org Wed Oct 14 15:11:02 2015 From: emilia at openssl.org (Emilia Kasper) Date: Wed, 14 Oct 2015 15:11:02 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444835462.793391.29921.nullmailer@dev.openssl.org> The branch master has been updated via 58dd1ce91aeafb513fa9fd09740e3151c2479314 (commit) from 4ec36aff2a3c221b640dafa56ac838312e6724f4 (commit) - Log ----------------------------------------------------------------- commit 58dd1ce91aeafb513fa9fd09740e3151c2479314 Author: Emilia Kasper Date: Fri Oct 9 20:00:53 2015 +0200 make depend: prefer clang over makedepend Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: Configure | 7 ++++--- util/domd | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Configure b/Configure index 06b2278..9ff6e70 100755 --- a/Configure +++ b/Configure @@ -1635,10 +1635,11 @@ if ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/) $shlib_minor=$2; } +my $ecc = $cc; +$ecc = "clang" if `$cc --version 2>&1` =~ /clang/; + if ($strict_warnings) { - my $ecc = $cc; - $ecc = "clang" if `$cc --version 2>&1` =~ /clang/; my $wopt; die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc(-\d(\.\d)*)?$/ or $ecc =~ /clang$/); foreach $wopt (split /\s+/, $gcc_devteam_warn) @@ -1703,7 +1704,7 @@ while () s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; - s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc" || ($cc eq 'cc' && $target =~ /darwin/); + s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang"; } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; diff --git a/util/domd b/util/domd index 552a352..f5be00d 100755 --- a/util/domd +++ b/util/domd @@ -12,7 +12,8 @@ fi if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi cp Makefile Makefile.save -if expr "$MAKEDEPEND" : '.*cc' > /dev/null; then +if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || + echo $MAKEDEPEND | grep -q "gcc"; then args="" while [ $# -gt 0 ]; do if [ "$1" != "--" ]; then args="$args $1"; fi From emilia at openssl.org Wed Oct 14 15:20:10 2015 From: emilia at openssl.org (Emilia Kasper) Date: Wed, 14 Oct 2015 15:20:10 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444836010.688305.3586.nullmailer@dev.openssl.org> The branch master has been updated via b84939cc96896a5a9a8f5181794e53dce9b5d229 (commit) from 58dd1ce91aeafb513fa9fd09740e3151c2479314 (commit) - Log ----------------------------------------------------------------- commit b84939cc96896a5a9a8f5181794e53dce9b5d229 Author: Emilia Kasper Date: Fri Oct 9 17:38:47 2015 +0200 ct_locl.h: fix some comments Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: crypto/ct/ct_locl.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crypto/ct/ct_locl.h b/crypto/ct/ct_locl.h index a616433..2d8e045 100644 --- a/crypto/ct/ct_locl.h +++ b/crypto/ct/ct_locl.h @@ -91,8 +91,9 @@ typedef struct { unsigned char *sct; size_t sct_len; /* - * If version is SCT_V1 fields below contain components of the SCT. "logid", - * "ext" and "sig" point to buffers allocated with OPENSSL_malloc(). + * If version is SCT_V1, fields below contain components of the SCT. + * "log_id", "ext" and "sig" point to buffers allocated with + * OPENSSL_malloc(). */ unsigned char *log_id; size_t log_id_len; @@ -139,7 +140,7 @@ int SCT_set_version(SCT *sct, sct_version_t version); int SCT_set_log_entry_type(SCT *sct, log_entry_type_t entry_type); /* - * Set the log id of an SCT to point directly to the *logid specified. + * Set the log id of an SCT to point directly to the *log_id specified. * The SCT takes ownership of the specified pointer. * Returns 1 on success. */ @@ -180,7 +181,7 @@ sct_version_t SCT_get_version(const SCT *sct); log_entry_type_t SCT_get_log_entry_type(const SCT *sct); /* - * Set *logid to point to the log id for the SCT. logid must not be NULL. + * Set *log_id to point to the log id for the SCT. log_id must not be NULL. * The SCT retains ownership of this pointer. * Returns length of the data pointed to. */ @@ -193,7 +194,8 @@ uint64_t SCT_get_timestamp(const SCT *sct); /* * Return the nid for the signature used by the SCT. - * Currently NID_sha256WithRSAEncryption or NID_ecdsa_with_SHA256 (or NID_undef) + * Currently NID_sha256WithRSAEncryption or NID_ecdsa_with_SHA256 + * (or NID_undef). */ int SCT_get_signature_nid(const SCT *sct); From emilia at openssl.org Wed Oct 14 16:46:19 2015 From: emilia at openssl.org (Emilia Kasper) Date: Wed, 14 Oct 2015 16:46:19 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444841179.986678.12253.nullmailer@dev.openssl.org> The branch master has been updated via 6f73d28c20459034bfd4090494be9fb1a479c8af (commit) from b84939cc96896a5a9a8f5181794e53dce9b5d229 (commit) - Log ----------------------------------------------------------------- commit 6f73d28c20459034bfd4090494be9fb1a479c8af Author: Emilia Kasper Date: Wed Oct 14 18:32:38 2015 +0200 Remove EVP_CHECK_DES_KEY Thanks to the OpenBSD community for bringing this to our attention. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: CHANGES | 2 ++ crypto/evp/e_des.c | 5 ----- crypto/evp/e_des3.c | 13 ------------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index ec55dc3..3d9c183 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ _______________ Changes between 1.0.2 and 1.1.0 [xx XXX xxxx] + *) Remove EVP_CHECK_DES_KEY, a compile-time option that never compiled. + [Emilia K?sper] *) Removed DES and RC4 ciphersuites from DEFAULT. Also removed RC2 although in 1.0.2 EXPORT was already removed and the only RC2 ciphersuite is also diff --git a/crypto/evp/e_des.c b/crypto/evp/e_des.c index 0506973..74e87e8 100644 --- a/crypto/evp/e_des.c +++ b/crypto/evp/e_des.c @@ -241,12 +241,7 @@ static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, } } # endif -# ifdef EVP_CHECK_DES_KEY - if (DES_set_key_checked(deskey, dat->ks.ks) != 0) - return 0; -# else DES_set_key_unchecked(deskey, ctx->cipher_data); -# endif return 1; } diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index db36634..c113a17 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -269,14 +269,8 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, } } # endif -# ifdef EVP_CHECK_DES_KEY - if (DES_set_key_checked(&deskey[0], &dat->ks1) - || DES_set_key_checked(&deskey[1], &dat->ks2)) - return 0; -# else DES_set_key_unchecked(&deskey[0], &dat->ks1); DES_set_key_unchecked(&deskey[1], &dat->ks2); -# endif memcpy(&dat->ks3, &dat->ks1, sizeof(dat->ks1)); return 1; } @@ -302,16 +296,9 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, } } # endif -# ifdef EVP_CHECK_DES_KEY - if (DES_set_key_checked(&deskey[0], &dat->ks1) - || DES_set_key_checked(&deskey[1], &dat->ks2) - || DES_set_key_checked(&deskey[2], &dat->ks3)) - return 0; -# else DES_set_key_unchecked(&deskey[0], &dat->ks1); DES_set_key_unchecked(&deskey[1], &dat->ks2); DES_set_key_unchecked(&deskey[2], &dat->ks3); -# endif return 1; } From emilia at openssl.org Wed Oct 14 17:11:40 2015 From: emilia at openssl.org (Emilia Kasper) Date: Wed, 14 Oct 2015 17:11:40 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444842700.582558.25455.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via c97c7f8d53dda12f4fda24fc7542281999df97f6 (commit) from a20d9422cf7a516cd576be8f91fe90738459ef42 (commit) - Log ----------------------------------------------------------------- commit c97c7f8d53dda12f4fda24fc7542281999df97f6 Author: Emilia Kasper Date: Fri Oct 9 20:00:53 2015 +0200 make depend: prefer clang over makedepend Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: Configure | 6 ++++-- util/domd | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Configure b/Configure index 81b263f..e374a69 100755 --- a/Configure +++ b/Configure @@ -1647,10 +1647,11 @@ if ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/) $shlib_minor=$2; } +my $ecc = $cc; +$ecc = "clang" if `$cc --version 2>&1` =~ /clang/; + if ($strict_warnings) { - my $ecc = $cc; - $ecc = "clang" if `$cc --version 2>&1` =~ /clang/; my $wopt; die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc$/ or $ecc =~ /clang$/); foreach $wopt (split /\s+/, $gcc_devteam_warn) @@ -1714,6 +1715,7 @@ while () s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc"; + s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang"; } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; diff --git a/util/domd b/util/domd index bab48cb..6a628c7 100755 --- a/util/domd +++ b/util/domd @@ -14,7 +14,8 @@ if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi cp Makefile Makefile.save # fake the presence of Kerberos touch $TOP/krb5.h -if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then +if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || + echo $MAKEDEPEND | grep -q "gcc"; then args="" while [ $# -gt 0 ]; do if [ "$1" != "--" ]; then args="$args $1"; fi From emilia at openssl.org Thu Oct 15 14:19:48 2015 From: emilia at openssl.org (Emilia Kasper) Date: Thu, 15 Oct 2015 14:19:48 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444918788.963979.19110.nullmailer@dev.openssl.org> The branch master has been updated via bbafa47b554fa2c89cf944951c170bbe21edf469 (commit) from 6f73d28c20459034bfd4090494be9fb1a479c8af (commit) - Log ----------------------------------------------------------------- commit bbafa47b554fa2c89cf944951c170bbe21edf469 Author: Emilia Kasper Date: Thu Oct 15 13:27:55 2015 +0200 Appease gcc's Wmaybe-uninitialized False positive: gcc (4.8) can't figure out the SSL_IS_DTLS logic. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: ssl/s3_srvr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index ca11c6e..7bf5828 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -883,6 +883,7 @@ int ssl3_get_client_hello(SSL *s) is_v2_record = RECORD_LAYER_is_sslv2_record(&s->rlayer); + PACKET_null_init(&cookie); /* First lets get s->client_version set correctly */ if (is_v2_record) { unsigned int version; @@ -1052,8 +1053,6 @@ int ssl3_get_client_hello(SSL *s) PACKET_null_init(&compression); PACKET_null_init(&extensions); - /* We're never DTLS here but just play safe and initialize. */ - PACKET_null_init(&cookie); } else { /* Regular ClientHello. */ if (!PACKET_copy_bytes(&pkt, s->s3->client_random, SSL3_RANDOM_SIZE) From emilia at openssl.org Thu Oct 15 14:21:04 2015 From: emilia at openssl.org (Emilia Kasper) Date: Thu, 15 Oct 2015 14:21:04 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444918864.817535.20106.nullmailer@dev.openssl.org> The branch master has been updated via f4f78ff7daf15f609a8bef1179d01cc982e37478 (commit) from bbafa47b554fa2c89cf944951c170bbe21edf469 (commit) - Log ----------------------------------------------------------------- commit f4f78ff7daf15f609a8bef1179d01cc982e37478 Author: Emilia Kasper Date: Thu Oct 15 12:53:35 2015 +0200 PACKET: fix __owur Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: ssl/packet_locl.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index 778ec77..507d64f 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -86,7 +86,7 @@ static inline void packet_forward(PACKET *pkt, size_t len) /* * Returns the number of bytes remaining to be read in the PACKET */ -__owur static inline size_t PACKET_remaining(const PACKET *pkt) +static inline size_t PACKET_remaining(const PACKET *pkt) { return pkt->remaining; } @@ -107,7 +107,8 @@ static inline unsigned char *PACKET_data(const PACKET *pkt) * copy of the data so |buf| must be present for the whole time that the PACKET * is being used. */ -static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf, size_t len) +__owur static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf, + size_t len) { /* Sanity check for negative values. */ if (buf + len < buf) @@ -148,9 +149,7 @@ __owur static inline int PACKET_peek_sub_packet(const PACKET *pkt, if (PACKET_remaining(pkt) < len) return 0; - PACKET_buf_init(subpkt, pkt->curr, len); - - return 1; + return PACKET_buf_init(subpkt, pkt->curr, len); } /* From steve at openssl.org Thu Oct 15 14:37:36 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Thu, 15 Oct 2015 14:37:36 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444919856.871755.31350.nullmailer@dev.openssl.org> The branch master has been updated via f51e5ed6b4b91d12228da873db72aa28109d1797 (commit) via 34a42e1489bf4f45bfad069eceba56315d4713be (commit) via 81e4943843773a04067703e0dc1668ec5d3b4cf1 (commit) via 4392479c08392feb4be2ecb9d1b5decc50e32df0 (commit) via 272d917deb0534a6a9b13e22ff16e4c95406d1ed (commit) via 4002da0f52828dc4a495f7ac163d9e77c2774f3e (commit) from f4f78ff7daf15f609a8bef1179d01cc982e37478 (commit) - Log ----------------------------------------------------------------- commit f51e5ed6b4b91d12228da873db72aa28109d1797 Author: Dr. Stephen Henson Date: Wed Aug 5 03:21:40 2015 +0100 Fix self signed handling. Don't mark a certificate as self signed if keyUsage is present and certificate signing not asserted. PR#3979 Reviewed-by: Matt Caswell commit 34a42e1489bf4f45bfad069eceba56315d4713be Author: Dr. Stephen Henson Date: Sun Oct 11 21:13:42 2015 +0100 embed CRL serial number and signature fields Reviewed-by: Rich Salz commit 81e4943843773a04067703e0dc1668ec5d3b4cf1 Author: Dr. Stephen Henson Date: Sun Oct 11 21:05:49 2015 +0100 embed certificate serial number and signature fields Reviewed-by: Rich Salz commit 4392479c08392feb4be2ecb9d1b5decc50e32df0 Author: Dr. Stephen Henson Date: Sun Oct 11 20:44:07 2015 +0100 embed value field of X509_EXTENSION Reviewed-by: Rich Salz commit 272d917deb0534a6a9b13e22ff16e4c95406d1ed Author: Dr. Stephen Henson Date: Sun Oct 11 21:20:19 2015 +0100 add CHANGES entry for embed Reviewed-by: Rich Salz commit 4002da0f52828dc4a495f7ac163d9e77c2774f3e Author: Dr. Stephen Henson Date: Sun Oct 11 23:25:08 2015 +0100 Handle embed flag in ASN1_STRING_copy(). Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: CHANGES | 21 +++++++++++++++++++++ crypto/asn1/asn1_lib.c | 4 +++- crypto/include/internal/x509_int.h | 8 ++++---- crypto/x509/t_x509.c | 2 +- crypto/x509/x509_cmp.c | 10 +++++----- crypto/x509/x509_lcl.h | 2 +- crypto/x509/x509_set.c | 15 +++++---------- crypto/x509/x509_v3.c | 4 ++-- crypto/x509/x509_vfy.c | 2 +- crypto/x509/x509cset.c | 17 ++++++----------- crypto/x509/x_all.c | 11 ++++++----- crypto/x509/x_crl.c | 14 +++++++------- crypto/x509/x_exten.c | 2 +- crypto/x509/x_x509.c | 6 +++--- crypto/x509v3/v3_purp.c | 19 ++++++++++--------- 15 files changed, 76 insertions(+), 61 deletions(-) diff --git a/CHANGES b/CHANGES index 3d9c183..cfbb7a7 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,27 @@ _______________ Changes between 1.0.2 and 1.1.0 [xx XXX xxxx] + + *) New ASN.1 embed macro. + + New ASN.1 macro ASN1_EMBED. This is the same as ASN1_SIMPLE except the + structure is not allocated: it is part of the parent. That is instead of + + FOO *x; + + it must be: + + FOO x; + + This reduces memory fragmentation and make it impossible to accidentally + set a mandatory field to NULL. + + This currently only works for some fields specifically a SEQUENCE, CHOICE, + or ASN1_STRING type which is part of a parent SEQUENCE. Since it is + equivalent to ASN1_SIMPLE it cannot be tagged, OPTIONAL, SET OF or + SEQUENCE OF. + [Steve Henson] + *) Remove EVP_CHECK_DES_KEY, a compile-time option that never compiled. [Emilia K?sper] diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index 12248db..ef9223c 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -284,7 +284,9 @@ int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) dst->type = str->type; if (!ASN1_STRING_set(dst, str->data, str->length)) return 0; - dst->flags = str->flags; + /* Copy flags but preserve embed value */ + dst->flags &= ASN1_STRING_FLAG_EMBED; + dst->flags |= str->flags & ~ASN1_STRING_FLAG_EMBED; return 1; } diff --git a/crypto/include/internal/x509_int.h b/crypto/include/internal/x509_int.h index 8fd0bcf..5997a21 100644 --- a/crypto/include/internal/x509_int.h +++ b/crypto/include/internal/x509_int.h @@ -121,7 +121,7 @@ struct X509_crl_info_st { struct X509_crl_st { X509_CRL_INFO crl; /* signed CRL data */ X509_ALGOR sig_alg; /* CRL signature algorithm */ - ASN1_BIT_STRING *signature; /* CRL signature */ + ASN1_BIT_STRING signature; /* CRL signature */ int references; int flags; /* @@ -145,7 +145,7 @@ struct X509_crl_st { }; struct x509_revoked_st { - ASN1_INTEGER *serialNumber; /* revoked entry serial number */ + ASN1_INTEGER serialNumber; /* revoked entry serial number */ ASN1_TIME *revocationDate; /* revocation date */ STACK_OF(X509_EXTENSION) *extensions; /* CRL entry extensions: optional */ /* decoded value of CRLissuer extension: set if indirect CRL */ @@ -176,7 +176,7 @@ struct x509_cert_aux_st { struct x509_cinf_st { ASN1_INTEGER *version; /* [ 0 ] default of v1 */ - ASN1_INTEGER *serialNumber; + ASN1_INTEGER serialNumber; X509_ALGOR signature; X509_NAME *issuer; X509_VAL validity; @@ -191,7 +191,7 @@ struct x509_cinf_st { struct x509_st { X509_CINF cert_info; X509_ALGOR sig_alg; - ASN1_BIT_STRING *signature; + ASN1_BIT_STRING signature; int valid; int references; char *name; diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c index 4cab108..5a73db1 100644 --- a/crypto/x509/t_x509.c +++ b/crypto/x509/t_x509.c @@ -238,7 +238,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, ci->extensions, cflag, 8); if (!(cflag & X509_FLAG_NO_SIGDUMP)) { - if (X509_signature_print(bp, &x->sig_alg, x->signature) <= 0) + if (X509_signature_print(bp, &x->sig_alg, &x->signature) <= 0) goto err; } if (!(cflag & X509_FLAG_NO_AUX)) { diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 1e469f9..4017545 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -72,7 +72,7 @@ int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) ai = &a->cert_info; bi = &b->cert_info; - i = ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber); + i = ASN1_INTEGER_cmp(&ai->serialNumber, &bi->serialNumber); if (i) return (i); return (X509_NAME_cmp(ai->issuer, bi->issuer)); @@ -94,8 +94,8 @@ unsigned long X509_issuer_and_serial_hash(X509 *a) goto err; OPENSSL_free(f); if (!EVP_DigestUpdate - (&ctx, (unsigned char *)a->cert_info.serialNumber->data, - (unsigned long)a->cert_info.serialNumber->length)) + (&ctx, (unsigned char *)a->cert_info.serialNumber.data, + (unsigned long)a->cert_info.serialNumber.length)) goto err; if (!EVP_DigestFinal_ex(&ctx, &(md[0]), NULL)) goto err; @@ -152,7 +152,7 @@ X509_NAME *X509_get_subject_name(X509 *a) ASN1_INTEGER *X509_get_serialNumber(X509 *a) { - return (a->cert_info.serialNumber); + return &a->cert_info.serialNumber; } unsigned long X509_subject_name_hash(X509 *x) @@ -278,7 +278,7 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, if (!sk) return NULL; - x.cert_info.serialNumber = serial; + x.cert_info.serialNumber = *serial; x.cert_info.issuer = name; for (i = 0; i < sk_X509_num(sk); i++) { diff --git a/crypto/x509/x509_lcl.h b/crypto/x509/x509_lcl.h index 71c8a2a..af04341 100644 --- a/crypto/x509/x509_lcl.h +++ b/crypto/x509/x509_lcl.h @@ -98,7 +98,7 @@ struct x509_attributes_st { struct X509_extension_st { ASN1_OBJECT *object; ASN1_BOOLEAN critical; - ASN1_OCTET_STRING *value; + ASN1_OCTET_STRING value; }; /* diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c index 7873edf..38ec0db 100644 --- a/crypto/x509/x509_set.c +++ b/crypto/x509/x509_set.c @@ -85,16 +85,11 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) ASN1_INTEGER *in; if (x == NULL) - return (0); - in = x->cert_info.serialNumber; - if (in != serial) { - in = ASN1_INTEGER_dup(serial); - if (in != NULL) { - ASN1_INTEGER_free(x->cert_info.serialNumber); - x->cert_info.serialNumber = in; - } - } - return (in != NULL); + return 0; + in = &x->cert_info.serialNumber; + if (in != serial) + return ASN1_STRING_copy(in, serial); + return 1; } int X509_set_issuer_name(X509 *x, X509_NAME *name) diff --git a/crypto/x509/x509_v3.c b/crypto/x509/x509_v3.c index 4e9c8f5..f192979 100644 --- a/crypto/x509/x509_v3.c +++ b/crypto/x509/x509_v3.c @@ -253,7 +253,7 @@ int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data) if (ex == NULL) return (0); - i = ASN1_OCTET_STRING_set(ex->value, data->data, data->length); + i = ASN1_OCTET_STRING_set(&ex->value, data->data, data->length); if (!i) return (0); return (1); @@ -270,7 +270,7 @@ ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ex) { if (ex == NULL) return (NULL); - return (ex->value); + return &ex->value; } int X509_EXTENSION_get_critical(X509_EXTENSION *ex) diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 9cecde7..1ae3675 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -2088,7 +2088,7 @@ X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, * Add only if not also in base. TODO: need something cleverer here * for some more complex CRLs covering multiple CAs. */ - if (!X509_CRL_get0_by_serial(base, &rvtmp, rvn->serialNumber)) { + if (!X509_CRL_get0_by_serial(base, &rvtmp, &rvn->serialNumber)) { rvtmp = X509_REVOKED_dup(rvn); if (!rvtmp) goto memerr; diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c index a779fd4..899d492 100644 --- a/crypto/x509/x509cset.c +++ b/crypto/x509/x509cset.c @@ -172,7 +172,7 @@ void X509_CRL_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, X509_CRL *crl) { if (psig != NULL) - *psig = crl->signature; + *psig = &crl->signature; if (palg != NULL) *palg = &crl->sig_alg; } @@ -206,7 +206,7 @@ int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) ASN1_INTEGER *X509_REVOKED_get0_serialNumber(X509_REVOKED *x) { - return x->serialNumber; + return &x->serialNumber; } int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) @@ -215,15 +215,10 @@ int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) if (x == NULL) return (0); - in = x->serialNumber; - if (in != serial) { - in = ASN1_INTEGER_dup(serial); - if (in != NULL) { - ASN1_INTEGER_free(x->serialNumber); - x->serialNumber = in; - } - } - return (in != NULL); + in = &x->serialNumber; + if (in != serial) + return ASN1_STRING_copy(in, serial); + return 1; } STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(X509_REVOKED *r) diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index 1db66f6..5c5f573 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -77,7 +77,7 @@ int X509_verify(X509 *a, EVP_PKEY *r) if (X509_ALGOR_cmp(&a->sig_alg, &a->cert_info.signature)) return 0; return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF), &a->sig_alg, - a->signature, &a->cert_info, r)); + &a->signature, &a->cert_info, r)); } int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) @@ -96,7 +96,8 @@ int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) { x->cert_info.enc.modified = 1; return (ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), &x->cert_info.signature, - &x->sig_alg, x->signature, &x->cert_info, pkey, md)); + &x->sig_alg, &x->signature, &x->cert_info, pkey, + md)); } int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) @@ -104,7 +105,7 @@ int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) x->cert_info.enc.modified = 1; return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CINF), &x->cert_info.signature, - &x->sig_alg, x->signature, &x->cert_info, ctx); + &x->sig_alg, &x->signature, &x->cert_info, ctx); } int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert) @@ -130,14 +131,14 @@ int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md) { x->crl.enc.modified = 1; return (ASN1_item_sign(ASN1_ITEM_rptr(X509_CRL_INFO), &x->crl.sig_alg, - &x->sig_alg, x->signature, &x->crl, pkey, md)); + &x->sig_alg, &x->signature, &x->crl, pkey, md)); } int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx) { x->crl.enc.modified = 1; return ASN1_item_sign_ctx(ASN1_ITEM_rptr(X509_CRL_INFO), - &x->crl.sig_alg, &x->sig_alg, x->signature, + &x->crl.sig_alg, &x->sig_alg, &x->signature, &x->crl, ctx); } diff --git a/crypto/x509/x_crl.c b/crypto/x509/x_crl.c index c8889d1..79fa5ca 100644 --- a/crypto/x509/x_crl.c +++ b/crypto/x509/x_crl.c @@ -69,7 +69,7 @@ static int X509_REVOKED_cmp(const X509_REVOKED *const *a, static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); ASN1_SEQUENCE(X509_REVOKED) = { - ASN1_SIMPLE(X509_REVOKED,serialNumber, ASN1_INTEGER), + ASN1_EMBED(X509_REVOKED,serialNumber, ASN1_INTEGER), ASN1_SIMPLE(X509_REVOKED,revocationDate, ASN1_TIME), ASN1_SEQUENCE_OF_OPT(X509_REVOKED,extensions, X509_EXTENSION) } ASN1_SEQUENCE_END(X509_REVOKED) @@ -333,7 +333,7 @@ static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) ASN1_SEQUENCE_ref(X509_CRL, crl_cb, CRYPTO_LOCK_X509_CRL) = { ASN1_EMBED(X509_CRL, crl, X509_CRL_INFO), ASN1_EMBED(X509_CRL, sig_alg, X509_ALGOR), - ASN1_SIMPLE(X509_CRL, signature, ASN1_BIT_STRING) + ASN1_EMBED(X509_CRL, signature, ASN1_BIT_STRING) } ASN1_SEQUENCE_END_ref(X509_CRL, X509_CRL) IMPLEMENT_ASN1_FUNCTIONS(X509_REVOKED) @@ -349,8 +349,8 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_CRL) static int X509_REVOKED_cmp(const X509_REVOKED *const *a, const X509_REVOKED *const *b) { - return (ASN1_STRING_cmp((ASN1_STRING *)(*a)->serialNumber, - (ASN1_STRING *)(*b)->serialNumber)); + return (ASN1_STRING_cmp((ASN1_STRING *)&(*a)->serialNumber, + (ASN1_STRING *)&(*b)->serialNumber)); } int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev) @@ -394,7 +394,7 @@ int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x) static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r) { return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO), - &crl->sig_alg, crl->signature, &crl->crl, r)); + &crl->sig_alg, &crl->signature, &crl->crl, r)); } static int crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm, @@ -430,7 +430,7 @@ static int def_crl_lookup(X509_CRL *crl, { X509_REVOKED rtmp, *rev; int idx; - rtmp.serialNumber = serial; + rtmp.serialNumber = *serial; /* * Sort revoked into serial number order if not already sorted. Do this * under a lock to avoid race condition. @@ -446,7 +446,7 @@ static int def_crl_lookup(X509_CRL *crl, /* Need to look for matching name */ for (; idx < sk_X509_REVOKED_num(crl->crl.revoked); idx++) { rev = sk_X509_REVOKED_value(crl->crl.revoked, idx); - if (ASN1_INTEGER_cmp(rev->serialNumber, serial)) + if (ASN1_INTEGER_cmp(&rev->serialNumber, serial)) return 0; if (crl_revoked_issuer_match(crl, issuer, rev)) { if (ret) diff --git a/crypto/x509/x_exten.c b/crypto/x509/x_exten.c index c0d4c96..c5b391f 100644 --- a/crypto/x509/x_exten.c +++ b/crypto/x509/x_exten.c @@ -66,7 +66,7 @@ ASN1_SEQUENCE(X509_EXTENSION) = { ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT), ASN1_OPT(X509_EXTENSION, critical, ASN1_BOOLEAN), - ASN1_SIMPLE(X509_EXTENSION, value, ASN1_OCTET_STRING) + ASN1_EMBED(X509_EXTENSION, value, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(X509_EXTENSION) ASN1_ITEM_TEMPLATE(X509_EXTENSIONS) = diff --git a/crypto/x509/x_x509.c b/crypto/x509/x_x509.c index 92d4fa3..ad2309c 100644 --- a/crypto/x509/x_x509.c +++ b/crypto/x509/x_x509.c @@ -66,7 +66,7 @@ ASN1_SEQUENCE_enc(X509_CINF, enc, 0) = { ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0), - ASN1_SIMPLE(X509_CINF, serialNumber, ASN1_INTEGER), + ASN1_EMBED(X509_CINF, serialNumber, ASN1_INTEGER), ASN1_EMBED(X509_CINF, signature, X509_ALGOR), ASN1_SIMPLE(X509_CINF, issuer, X509_NAME), ASN1_EMBED(X509_CINF, validity, X509_VAL), @@ -135,7 +135,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, ASN1_SEQUENCE_ref(X509, x509_cb, CRYPTO_LOCK_X509) = { ASN1_EMBED(X509, cert_info, X509_CINF), ASN1_EMBED(X509, sig_alg, X509_ALGOR), - ASN1_SIMPLE(X509, signature, ASN1_BIT_STRING) + ASN1_EMBED(X509, signature, ASN1_BIT_STRING) } ASN1_SEQUENCE_END_ref(X509, X509) IMPLEMENT_ASN1_FUNCTIONS(X509) @@ -215,7 +215,7 @@ int i2d_re_X509_tbs(X509 *x, unsigned char **pp) void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg, X509 *x) { if (psig) - *psig = x->signature; + *psig = &x->signature; if (palg) *palg = &x->sig_alg; } diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c index 43f3551..90b3abc 100644 --- a/crypto/x509v3/v3_purp.c +++ b/crypto/x509v3/v3_purp.c @@ -380,6 +380,14 @@ static void setup_crldp(X509 *x) setup_dp(x, sk_DIST_POINT_value(x->crldp, i)); } +#define V1_ROOT (EXFLAG_V1|EXFLAG_SS) +#define ku_reject(x, usage) \ + (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) +#define xku_reject(x, usage) \ + (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage))) +#define ns_reject(x, usage) \ + (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) + static void x509v3_cache_extensions(X509 *x) { BASIC_CONSTRAINTS *bs; @@ -497,7 +505,8 @@ static void x509v3_cache_extensions(X509 *x) if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) { x->ex_flags |= EXFLAG_SI; /* If SKID matches AKID also indicate self signed */ - if (X509_check_akid(x, x->akid) == X509_V_OK) + if (X509_check_akid(x, x->akid) == X509_V_OK && + !ku_reject(x, KU_KEY_CERT_SIGN)) x->ex_flags |= EXFLAG_SS; } x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); @@ -536,14 +545,6 @@ static void x509v3_cache_extensions(X509 *x) * 4 basicConstraints absent but keyUsage present and keyCertSign asserted. */ -#define V1_ROOT (EXFLAG_V1|EXFLAG_SS) -#define ku_reject(x, usage) \ - (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) -#define xku_reject(x, usage) \ - (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage))) -#define ns_reject(x, usage) \ - (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) - static int check_ca(const X509 *x) { /* keyUsage if present should allow cert signing */ From steve at openssl.org Thu Oct 15 14:39:14 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Thu, 15 Oct 2015 14:39:14 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1444919954.720714.885.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via e272f8ef8f63298466494adcd29512797ab1eece (commit) from c97c7f8d53dda12f4fda24fc7542281999df97f6 (commit) - Log ----------------------------------------------------------------- commit e272f8ef8f63298466494adcd29512797ab1eece Author: Dr. Stephen Henson Date: Wed Aug 5 03:21:40 2015 +0100 Fix self signed handling. Don't mark a certificate as self signed if keyUsage is present and certificate signing not asserted. PR#3979 Reviewed-by: Matt Caswell (cherry picked from commit f51e5ed6b4b91d12228da873db72aa28109d1797) ----------------------------------------------------------------------- Summary of changes: crypto/x509v3/v3_purp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c index 36b0d87..845be67 100644 --- a/crypto/x509v3/v3_purp.c +++ b/crypto/x509v3/v3_purp.c @@ -380,6 +380,14 @@ static void setup_crldp(X509 *x) setup_dp(x, sk_DIST_POINT_value(x->crldp, i)); } +#define V1_ROOT (EXFLAG_V1|EXFLAG_SS) +#define ku_reject(x, usage) \ + (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) +#define xku_reject(x, usage) \ + (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage))) +#define ns_reject(x, usage) \ + (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) + static void x509v3_cache_extensions(X509 *x) { BASIC_CONSTRAINTS *bs; @@ -499,7 +507,8 @@ static void x509v3_cache_extensions(X509 *x) if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) { x->ex_flags |= EXFLAG_SI; /* If SKID matches AKID also indicate self signed */ - if (X509_check_akid(x, x->akid) == X509_V_OK) + if (X509_check_akid(x, x->akid) == X509_V_OK && + !ku_reject(x, KU_KEY_CERT_SIGN)) x->ex_flags |= EXFLAG_SS; } x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); @@ -538,14 +547,6 @@ static void x509v3_cache_extensions(X509 *x) * 4 basicConstraints absent but keyUsage present and keyCertSign asserted. */ -#define V1_ROOT (EXFLAG_V1|EXFLAG_SS) -#define ku_reject(x, usage) \ - (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) -#define xku_reject(x, usage) \ - (((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage))) -#define ns_reject(x, usage) \ - (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) - static int check_ca(const X509 *x) { /* keyUsage if present should allow cert signing */ From matt at openssl.org Thu Oct 15 16:31:41 2015 From: matt at openssl.org (Matt Caswell) Date: Thu, 15 Oct 2015 16:31:41 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444926701.933169.17822.nullmailer@dev.openssl.org> The branch master has been updated via 8b7080b0b7f30669c0784d8aa73388f95bbd056b (commit) from f51e5ed6b4b91d12228da873db72aa28109d1797 (commit) - Log ----------------------------------------------------------------- commit 8b7080b0b7f30669c0784d8aa73388f95bbd056b Author: Matt Caswell Date: Tue Oct 13 15:02:47 2015 +0100 Remove Obsolete engines There are a number of engines in the OpenSSL source code which are now obsolete. The following engines have been removed: 4758cca, aep, atalla, cswift, nuron, sureware. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: CHANGES | 3 + crypto/engine/eng_all.c | 18 - doc/crypto/engine.pod | 6 - engines/Makefile | 31 +- engines/e_4758cca.c | 937 ---------------------------- engines/e_4758cca.ec | 1 - engines/e_4758cca_err.c | 153 ----- engines/e_4758cca_err.h | 98 --- engines/e_aep.c | 1182 ------------------------------------ engines/e_aep.ec | 1 - engines/e_aep_err.c | 159 ----- engines/e_aep_err.h | 106 ---- engines/e_atalla.c | 621 ------------------- engines/e_atalla.ec | 1 - engines/e_atalla_err.c | 145 ----- engines/e_atalla_err.h | 94 --- engines/e_cswift.c | 1081 --------------------------------- engines/e_cswift.ec | 1 - engines/e_cswift_err.c | 150 ----- engines/e_cswift_err.h | 99 --- engines/e_nuron.c | 435 ------------- engines/e_nuron.ec | 1 - engines/e_nuron_err.c | 142 ----- engines/e_nuron_err.h | 91 --- engines/e_sureware.c | 1074 -------------------------------- engines/e_sureware.ec | 1 - engines/e_sureware_err.c | 154 ----- engines/e_sureware_err.h | 104 ---- engines/makeengines.com | 3 +- engines/vendor_defns/aep.h | 235 ------- engines/vendor_defns/atalla.h | 44 -- engines/vendor_defns/cswift.h | 223 ------- engines/vendor_defns/hw_4758_cca.h | 150 ----- engines/vendor_defns/sureware.h | 250 -------- 34 files changed, 9 insertions(+), 7785 deletions(-) delete mode 100644 engines/e_4758cca.c delete mode 100644 engines/e_4758cca.ec delete mode 100644 engines/e_4758cca_err.c delete mode 100644 engines/e_4758cca_err.h delete mode 100644 engines/e_aep.c delete mode 100644 engines/e_aep.ec delete mode 100644 engines/e_aep_err.c delete mode 100644 engines/e_aep_err.h delete mode 100644 engines/e_atalla.c delete mode 100644 engines/e_atalla.ec delete mode 100644 engines/e_atalla_err.c delete mode 100644 engines/e_atalla_err.h delete mode 100644 engines/e_cswift.c delete mode 100644 engines/e_cswift.ec delete mode 100644 engines/e_cswift_err.c delete mode 100644 engines/e_cswift_err.h delete mode 100644 engines/e_nuron.c delete mode 100644 engines/e_nuron.ec delete mode 100644 engines/e_nuron_err.c delete mode 100644 engines/e_nuron_err.h delete mode 100644 engines/e_sureware.c delete mode 100644 engines/e_sureware.ec delete mode 100644 engines/e_sureware_err.c delete mode 100644 engines/e_sureware_err.h delete mode 100644 engines/vendor_defns/aep.h delete mode 100644 engines/vendor_defns/atalla.h delete mode 100644 engines/vendor_defns/cswift.h delete mode 100644 engines/vendor_defns/hw_4758_cca.h delete mode 100644 engines/vendor_defns/sureware.h diff --git a/CHANGES b/CHANGES index cfbb7a7..3408794 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Changes between 1.0.2 and 1.1.0 [xx XXX xxxx] + *) Removed obsolete engines: 4758cca, aep, atalla, cswift, nuron and sureware. + [Matt Caswell] + *) New ASN.1 embed macro. New ASN.1 macro ASN1_EMBED. This is the same as ASN1_SIMPLE except the diff --git a/crypto/engine/eng_all.c b/crypto/engine/eng_all.c index 5ab498e..5a36994 100644 --- a/crypto/engine/eng_all.c +++ b/crypto/engine/eng_all.c @@ -73,29 +73,11 @@ void ENGINE_load_builtin_engines(void) ENGINE_load_dynamic(); #ifndef OPENSSL_NO_STATIC_ENGINE # ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_4758_CCA - ENGINE_load_4758cca(); -# endif /*- * These engines have been disabled as they do not currently build -#ifndef OPENSSL_NO_HW_AEP - ENGINE_load_aep(); -#endif -#ifndef OPENSSL_NO_HW_ATALLA - ENGINE_load_atalla(); -#endif -#ifndef OPENSSL_NO_HW_CSWIFT - ENGINE_load_cswift(); -#endif #ifndef OPENSSL_NO_HW_NCIPHER ENGINE_load_chil(); #endif -#ifndef OPENSSL_NO_HW_NURON - ENGINE_load_nuron(); -#endif -#ifndef OPENSSL_NO_HW_SUREWARE - ENGINE_load_sureware(); -#endif #ifndef OPENSSL_NO_HW_UBSEC ENGINE_load_ubsec(); #endif diff --git a/doc/crypto/engine.pod b/doc/crypto/engine.pod index c1be658..9424a7c 100644 --- a/doc/crypto/engine.pod +++ b/doc/crypto/engine.pod @@ -24,14 +24,8 @@ engine - ENGINE cryptographic module support void ENGINE_load_openssl(void); void ENGINE_load_dynamic(void); #ifndef OPENSSL_NO_STATIC_ENGINE - void ENGINE_load_4758cca(void); - void ENGINE_load_aep(void); - void ENGINE_load_atalla(void); void ENGINE_load_chil(void); - void ENGINE_load_cswift(void); void ENGINE_load_gmp(void); - void ENGINE_load_nuron(void); - void ENGINE_load_sureware(void); void ENGINE_load_ubsec(void); #endif void ENGINE_load_cryptodev(void); diff --git a/engines/Makefile b/engines/Makefile index 3773e74..5cd2aa2 100644 --- a/engines/Makefile +++ b/engines/Makefile @@ -3,7 +3,7 @@ # #The following engines have been disabled as they currently do not build -# aep atalla cswift chil nuron sureware ubsec +# sureware ubsec DIR= engines TOP= .. @@ -31,13 +31,11 @@ AFLAGS= $(ASFLAGS) GENERAL=Makefile engines.com install.com engine_vector.mar LIB=$(TOP)/libcrypto.a -LIBNAMES= 4758cca gmp padlock capi -LIBSRC= e_4758cca.c \ - e_gmp.c \ +LIBNAMES= gmp padlock capi +LIBSRC= e_gmp.c \ e_padlock.c \ e_capi.c -LIBOBJ= e_4758cca.o \ - e_gmp.o \ +LIBOBJ= e_gmp.o \ e_padlock.o \ e_capi.o \ $(ENGINES_ASM_OBJ) @@ -48,11 +46,8 @@ TESTLIBOBJ= e_ossltest.o SRC= $(LIBSRC) -HEADER= e_4758cca_err.c e_4758cca_err.h \ - e_gmp_err.c e_gmp_err.h \ +HEADER= e_gmp_err.c e_gmp_err.h \ e_chil_err.c e_chil_err.h \ - e_nuron_err.c e_nuron_err.h \ - e_sureware_err.c e_sureware_err.h \ e_ubsec_err.c e_ubsec_err.h \ e_capi_err.c e_capi_err.h \ e_ossltest_err.c e_ossltest_err.h @@ -159,22 +154,6 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -e_4758cca.o: ../include/openssl/asn1.h ../include/openssl/bio.h -e_4758cca.o: ../include/openssl/bn.h ../include/openssl/buffer.h -e_4758cca.o: ../include/openssl/crypto.h ../include/openssl/dso.h -e_4758cca.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -e_4758cca.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -e_4758cca.o: ../include/openssl/engine.h ../include/openssl/err.h -e_4758cca.o: ../include/openssl/evp.h ../include/openssl/lhash.h -e_4758cca.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -e_4758cca.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -e_4758cca.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h -e_4758cca.o: ../include/openssl/rand.h ../include/openssl/rsa.h -e_4758cca.o: ../include/openssl/safestack.h ../include/openssl/sha.h -e_4758cca.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -e_4758cca.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -e_4758cca.o: e_4758cca.c e_4758cca_err.c e_4758cca_err.h -e_4758cca.o: vendor_defns/hw_4758_cca.h e_capi.o: ../include/openssl/asn1.h ../include/openssl/bio.h e_capi.o: ../include/openssl/buffer.h ../include/openssl/crypto.h e_capi.o: ../include/openssl/e_os2.h ../include/openssl/ec.h diff --git a/engines/e_4758cca.c b/engines/e_4758cca.c deleted file mode 100644 index 396f2c2..0000000 --- a/engines/e_4758cca.c +++ /dev/null @@ -1,937 +0,0 @@ -/* Author: Maurice Gittens */ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_RSA -# include -#endif -#include - -#ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_4758_CCA - -# ifdef FLAT_INC -# include "hw_4758_cca.h" -# else -# include "vendor_defns/hw_4758_cca.h" -# endif - -# include "e_4758cca_err.c" - -static int ibm_4758_cca_destroy(ENGINE *e); -static int ibm_4758_cca_init(ENGINE *e); -static int ibm_4758_cca_finish(ENGINE *e); -static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, - void (*f) (void)); - -/* rsa functions */ -/* -------------*/ -# ifndef OPENSSL_NO_RSA -static int cca_rsa_pub_enc(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -static int cca_rsa_priv_dec(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa); -static int cca_rsa_verify(int dtype, const unsigned char *m, - unsigned int m_len, const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa); - -/* utility functions */ -/* ---------------------*/ -static EVP_PKEY *ibm_4758_load_privkey(ENGINE *, const char *, - UI_METHOD *ui_method, - void *callback_data); -static EVP_PKEY *ibm_4758_load_pubkey(ENGINE *, const char *, - UI_METHOD *ui_method, - void *callback_data); - -static int getModulusAndExponent(const unsigned char *token, - long *exponentLength, - unsigned char *exponent, long *modulusLength, - long *modulusFieldLength, - unsigned char *modulus); -# endif - -/* RAND number functions */ -/* ---------------------*/ -static int cca_get_random_bytes(unsigned char *, int); -static int cca_random_status(void); - -# ifndef OPENSSL_NO_RSA -static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -# endif - -/* Function pointers for CCA verbs */ -/* -------------------------------*/ -# ifndef OPENSSL_NO_RSA -static F_KEYRECORDREAD keyRecordRead; -static F_DIGITALSIGNATUREGENERATE digitalSignatureGenerate; -static F_DIGITALSIGNATUREVERIFY digitalSignatureVerify; -static F_PUBLICKEYEXTRACT publicKeyExtract; -static F_PKAENCRYPT pkaEncrypt; -static F_PKADECRYPT pkaDecrypt; -# endif -static F_RANDOMNUMBERGENERATE randomNumberGenerate; - -/* static variables */ -/* ----------------*/ -static const char *CCA4758_LIB_NAME = NULL; -static const char *get_CCA4758_LIB_NAME(void) -{ - if (CCA4758_LIB_NAME) - return CCA4758_LIB_NAME; - return CCA_LIB_NAME; -} - -static void free_CCA4758_LIB_NAME(void) -{ - if (CCA4758_LIB_NAME) - OPENSSL_free((void *)CCA4758_LIB_NAME); - CCA4758_LIB_NAME = NULL; -} - -static long set_CCA4758_LIB_NAME(const char *name) -{ - free_CCA4758_LIB_NAME(); - return (((CCA4758_LIB_NAME = BUF_strdup(name)) != NULL) ? 1 : 0); -} - -# ifndef OPENSSL_NO_RSA -static const char *n_keyRecordRead = CSNDKRR; -static const char *n_digitalSignatureGenerate = CSNDDSG; -static const char *n_digitalSignatureVerify = CSNDDSV; -static const char *n_publicKeyExtract = CSNDPKX; -static const char *n_pkaEncrypt = CSNDPKE; -static const char *n_pkaDecrypt = CSNDPKD; -# endif -static const char *n_randomNumberGenerate = CSNBRNG; - -# ifndef OPENSSL_NO_RSA -static int hndidx = -1; -# endif -static DSO *dso = NULL; - -/* openssl engine initialization structures */ -/* ----------------------------------------*/ - -# define CCA4758_CMD_SO_PATH ENGINE_CMD_BASE -static const ENGINE_CMD_DEFN cca4758_cmd_defns[] = { - {CCA4758_CMD_SO_PATH, - "SO_PATH", - "Specifies the path to the '4758cca' shared library", - ENGINE_CMD_FLAG_STRING}, - {0, NULL, NULL, 0} -}; - -# ifndef OPENSSL_NO_RSA -static RSA_METHOD ibm_4758_cca_rsa = { - "IBM 4758 CCA RSA method", - cca_rsa_pub_enc, - NULL, - NULL, - cca_rsa_priv_dec, - NULL, /* rsa_mod_exp, */ - NULL, /* mod_exp_mont, */ - NULL, /* init */ - NULL, /* finish */ - RSA_FLAG_SIGN_VER, /* flags */ - NULL, /* app_data */ - cca_rsa_sign, /* rsa_sign */ - cca_rsa_verify, /* rsa_verify */ - NULL /* rsa_keygen */ -}; -# endif - -static RAND_METHOD ibm_4758_cca_rand = { - /* "IBM 4758 RAND method", */ - NULL, /* seed */ - cca_get_random_bytes, /* get random bytes from the card */ - NULL, /* cleanup */ - NULL, /* add */ - cca_get_random_bytes, /* pseudo rand */ - cca_random_status, /* status */ -}; - -static const char *engine_4758_cca_id = "4758cca"; -static const char *engine_4758_cca_name = - "IBM 4758 CCA hardware engine support"; -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -/* Compatibility hack, the dynamic library uses this form in the path */ -static const char *engine_4758_cca_id_alt = "4758_cca"; -# endif - -/* engine implementation */ -/* ---------------------*/ -static int bind_helper(ENGINE *e) -{ - if (!ENGINE_set_id(e, engine_4758_cca_id) || - !ENGINE_set_name(e, engine_4758_cca_name) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_RSA(e, &ibm_4758_cca_rsa) || -# endif - !ENGINE_set_RAND(e, &ibm_4758_cca_rand) || - !ENGINE_set_destroy_function(e, ibm_4758_cca_destroy) || - !ENGINE_set_init_function(e, ibm_4758_cca_init) || - !ENGINE_set_finish_function(e, ibm_4758_cca_finish) || - !ENGINE_set_ctrl_function(e, ibm_4758_cca_ctrl) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_load_privkey_function(e, ibm_4758_load_privkey) || - !ENGINE_set_load_pubkey_function(e, ibm_4758_load_pubkey) || -# endif - !ENGINE_set_cmd_defns(e, cca4758_cmd_defns)) - return 0; - /* Ensure the error handling is set up */ - ERR_load_CCA4758_strings(); - return 1; -} - -# ifdef OPENSSL_NO_DYNAMIC_ENGINE -static ENGINE *engine_4758_cca(void) -{ - ENGINE *ret = ENGINE_new(); - if (!ret) - return NULL; - if (!bind_helper(ret)) { - ENGINE_free(ret); - return NULL; - } - return ret; -} - -void ENGINE_load_4758cca(void) -{ - ENGINE *e_4758 = engine_4758_cca(); - if (!e_4758) - return; - ENGINE_add(e_4758); - ENGINE_free(e_4758); - ERR_clear_error(); -} -# endif - -static int ibm_4758_cca_destroy(ENGINE *e) -{ - ERR_unload_CCA4758_strings(); - free_CCA4758_LIB_NAME(); - return 1; -} - -static int ibm_4758_cca_init(ENGINE *e) -{ - if (dso) { - CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_ALREADY_LOADED); - goto err; - } - - dso = DSO_load(NULL, get_CCA4758_LIB_NAME(), NULL, 0); - if (!dso) { - CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE); - goto err; - } -#define BINDIT(t, name) (t)DSO_bind_func(dso, name) -# ifndef OPENSSL_NO_RSA - if ((keyRecordRead = BINDIT(F_KEYRECORDREAD, n_keyRecordRead)) == NULL - || (randomNumberGenerate = BINDIT(F_RANDOMNUMBERGENERATE, n_randomNumberGenerate)) == NULL - || (digitalSignatureGenerate = BINDIT(F_DIGITALSIGNATUREGENERATE, n_digitalSignatureGenerate)) == NULL - || (digitalSignatureVerify = BINDIT(F_DIGITALSIGNATUREVERIFY, n_digitalSignatureVerify)) == NULL - || (publicKeyExtract = BINDIT(F_PUBLICKEYEXTRACT, n_publicKeyExtract)) == NULL - || (pkaEncrypt = BINDIT(F_PKAENCRYPT, n_pkaEncrypt)) == NULL - || (pkaDecrypt = BINDIT(F_PKADECRYPT, n_pkaDecrypt)) == NULL) - { - CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE); - goto err; - } -# else - if ((randomNumberGenerate = BINDIT(F_RANDOMNUMBERGENERATE, n_randomNumberGenerate)) == NULL) { - CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE); - goto err; - } -# endif - -# ifndef OPENSSL_NO_RSA - hndidx = RSA_get_ex_new_index(0, "IBM 4758 CCA RSA key handle", - NULL, NULL, cca_ex_free); -# endif - - return 1; - err: - DSO_free(dso); - dso = NULL; - -# ifndef OPENSSL_NO_RSA - keyRecordRead = (F_KEYRECORDREAD) 0; - digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE) 0; - digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0; - publicKeyExtract = (F_PUBLICKEYEXTRACT)0; - pkaEncrypt = (F_PKAENCRYPT) 0; - pkaDecrypt = (F_PKADECRYPT) 0; -# endif - randomNumberGenerate = (F_RANDOMNUMBERGENERATE) 0; - return 0; -} - -static int ibm_4758_cca_finish(ENGINE *e) -{ - free_CCA4758_LIB_NAME(); - if (!dso) { - CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH, CCA4758_R_NOT_LOADED); - return 0; - } - if (!DSO_free(dso)) { - CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH, CCA4758_R_UNIT_FAILURE); - return 0; - } - dso = NULL; -# ifndef OPENSSL_NO_RSA - keyRecordRead = (F_KEYRECORDREAD) 0; - randomNumberGenerate = (F_RANDOMNUMBERGENERATE) 0; - digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE) 0; - digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0; - publicKeyExtract = (F_PUBLICKEYEXTRACT)0; - pkaEncrypt = (F_PKAENCRYPT) 0; - pkaDecrypt = (F_PKADECRYPT) 0; -# endif - randomNumberGenerate = (F_RANDOMNUMBERGENERATE) 0; - return 1; -} - -static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, - void (*f) (void)) -{ - int initialised = ((dso == NULL) ? 0 : 1); - switch (cmd) { - case CCA4758_CMD_SO_PATH: - if (p == NULL) { - CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL, - ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - if (initialised) { - CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL, CCA4758_R_ALREADY_LOADED); - return 0; - } - return set_CCA4758_LIB_NAME((const char *)p); - default: - break; - } - CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL, - CCA4758_R_COMMAND_NOT_IMPLEMENTED); - return 0; -} - -# ifndef OPENSSL_NO_RSA - -# define MAX_CCA_PKA_TOKEN_SIZE 2500 - -static EVP_PKEY *ibm_4758_load_privkey(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, - void *callback_data) -{ - RSA *rtmp = NULL; - EVP_PKEY *res = NULL; - unsigned char *keyToken = NULL; - unsigned char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE]; - long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE; - long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE; - long returnCode; - long reasonCode; - long exitDataLength = 0; - long ruleArrayLength = 0; - unsigned char exitData[8]; - unsigned char ruleArray[8]; - unsigned char keyLabel[64]; - unsigned long keyLabelLength = strlen(key_id); - unsigned char modulus[256]; - long modulusFieldLength = sizeof(modulus); - long modulusLength = 0; - unsigned char exponent[256]; - long exponentLength = sizeof(exponent); - - if (keyLabelLength > sizeof(keyLabel)) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PRIVKEY, - CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return NULL; - } - - memset(keyLabel, ' ', sizeof(keyLabel)); - memcpy(keyLabel, key_id, keyLabelLength); - - keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long)); - if (!keyToken) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PRIVKEY, ERR_R_MALLOC_FAILURE); - goto err; - } - - keyRecordRead(&returnCode, &reasonCode, &exitDataLength, - exitData, &ruleArrayLength, ruleArray, keyLabel, - &keyTokenLength, keyToken + sizeof(long)); - - if (returnCode) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PRIVKEY, - CCA4758_R_FAILED_LOADING_PRIVATE_KEY); - goto err; - } - - publicKeyExtract(&returnCode, &reasonCode, &exitDataLength, - exitData, &ruleArrayLength, ruleArray, &keyTokenLength, - keyToken + sizeof(long), &pubKeyTokenLength, - pubKeyToken); - - if (returnCode) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PRIVKEY, - CCA4758_R_FAILED_LOADING_PRIVATE_KEY); - goto err; - } - - if (!getModulusAndExponent(pubKeyToken, &exponentLength, - exponent, &modulusLength, &modulusFieldLength, - modulus)) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PRIVKEY, - CCA4758_R_FAILED_LOADING_PRIVATE_KEY); - goto err; - } - - (*(long *)keyToken) = keyTokenLength; - rtmp = RSA_new_method(e); - RSA_set_ex_data(rtmp, hndidx, (char *)keyToken); - - rtmp->e = BN_bin2bn(exponent, exponentLength, NULL); - rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL); - rtmp->flags |= RSA_FLAG_EXT_PKEY; - - res = EVP_PKEY_new(); - EVP_PKEY_assign_RSA(res, rtmp); - - return res; - err: - OPENSSL_free(keyToken); - return NULL; -} - -static EVP_PKEY *ibm_4758_load_pubkey(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, - void *callback_data) -{ - RSA *rtmp = NULL; - EVP_PKEY *res = NULL; - unsigned char *keyToken = NULL; - long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE; - long returnCode; - long reasonCode; - long exitDataLength = 0; - long ruleArrayLength = 0; - unsigned char exitData[8]; - unsigned char ruleArray[8]; - unsigned char keyLabel[64]; - unsigned long keyLabelLength = strlen(key_id); - unsigned char modulus[512]; - long modulusFieldLength = sizeof(modulus); - long modulusLength = 0; - unsigned char exponent[512]; - long exponentLength = sizeof(exponent); - - if (keyLabelLength > sizeof(keyLabel)) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY, - CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return NULL; - } - - memset(keyLabel, ' ', sizeof(keyLabel)); - memcpy(keyLabel, key_id, keyLabelLength); - - keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long)); - if (!keyToken) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY, ERR_R_MALLOC_FAILURE); - goto err; - } - - keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData, - &ruleArrayLength, ruleArray, keyLabel, &keyTokenLength, - keyToken + sizeof(long)); - - if (returnCode) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY, ERR_R_MALLOC_FAILURE); - goto err; - } - - if (!getModulusAndExponent(keyToken + sizeof(long), &exponentLength, - exponent, &modulusLength, &modulusFieldLength, - modulus)) { - CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY, - CCA4758_R_FAILED_LOADING_PUBLIC_KEY); - goto err; - } - - (*(long *)keyToken) = keyTokenLength; - rtmp = RSA_new_method(e); - RSA_set_ex_data(rtmp, hndidx, (char *)keyToken); - rtmp->e = BN_bin2bn(exponent, exponentLength, NULL); - rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL); - rtmp->flags |= RSA_FLAG_EXT_PKEY; - res = EVP_PKEY_new(); - EVP_PKEY_assign_RSA(res, rtmp); - - return res; - err: - OPENSSL_free(keyToken); - return NULL; -} - -static int cca_rsa_pub_enc(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding) -{ - long returnCode; - long reasonCode; - long lflen = flen; - long exitDataLength = 0; - unsigned char exitData[8]; - long ruleArrayLength = 1; - unsigned char ruleArray[8] = "PKCS-1.2"; - long dataStructureLength = 0; - unsigned char dataStructure[8]; - long outputLength = RSA_size(rsa); - long keyTokenLength; - unsigned char *keyToken = (unsigned char *)RSA_get_ex_data(rsa, hndidx); - - keyTokenLength = *(long *)keyToken; - keyToken += sizeof(long); - - pkaEncrypt(&returnCode, &reasonCode, &exitDataLength, exitData, - &ruleArrayLength, ruleArray, &lflen, (unsigned char *)from, - &dataStructureLength, dataStructure, &keyTokenLength, - keyToken, &outputLength, to); - - if (returnCode || reasonCode) - return -(returnCode << 16 | reasonCode); - return outputLength; -} - -static int cca_rsa_priv_dec(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding) -{ - long returnCode; - long reasonCode; - long lflen = flen; - long exitDataLength = 0; - unsigned char exitData[8]; - long ruleArrayLength = 1; - unsigned char ruleArray[8] = "PKCS-1.2"; - long dataStructureLength = 0; - unsigned char dataStructure[8]; - long outputLength = RSA_size(rsa); - long keyTokenLength; - unsigned char *keyToken = (unsigned char *)RSA_get_ex_data(rsa, hndidx); - - keyTokenLength = *(long *)keyToken; - keyToken += sizeof(long); - - pkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData, - &ruleArrayLength, ruleArray, &lflen, (unsigned char *)from, - &dataStructureLength, dataStructure, &keyTokenLength, - keyToken, &outputLength, to); - - return (returnCode | reasonCode) ? 0 : 1; -} - -# define SSL_SIG_LEN 36 - -static int cca_rsa_verify(int type, const unsigned char *m, - unsigned int m_len, const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa) -{ - long returnCode; - long reasonCode; - long lsiglen = siglen; - long exitDataLength = 0; - unsigned char exitData[8]; - long ruleArrayLength = 1; - unsigned char ruleArray[8] = "PKCS-1.1"; - long keyTokenLength; - unsigned char *keyToken = (unsigned char *)RSA_get_ex_data(rsa, hndidx); - long length = SSL_SIG_LEN; - long keyLength; - unsigned char *hashBuffer = NULL; - X509_SIG sig; - ASN1_TYPE parameter; - X509_ALGOR algorithm; - ASN1_OCTET_STRING digest; - - keyTokenLength = *(long *)keyToken; - keyToken += sizeof(long); - - if (type == NID_md5 || type == NID_sha1) { - sig.algor = &algorithm; - algorithm.algorithm = OBJ_nid2obj(type); - - if (!algorithm.algorithm) { - CCA4758err(CCA4758_F_CCA_RSA_VERIFY, - CCA4758_R_UNKNOWN_ALGORITHM_TYPE); - return 0; - } - - if (!OBJ_length(algorithm.algorithm)) { - CCA4758err(CCA4758_F_CCA_RSA_VERIFY, - CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD); - return 0; - } - - parameter.type = V_ASN1_NULL; - parameter.value.ptr = NULL; - algorithm.parameter = ¶meter; - - sig.digest = &digest; - sig.digest->data = (unsigned char *)m; - sig.digest->length = m_len; - - length = i2d_X509_SIG(&sig, NULL); - } - - keyLength = RSA_size(rsa); - - if (length - RSA_PKCS1_PADDING > keyLength) { - CCA4758err(CCA4758_F_CCA_RSA_VERIFY, - CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return 0; - } - - switch (type) { - case NID_md5_sha1: - if (m_len != SSL_SIG_LEN) { - CCA4758err(CCA4758_F_CCA_RSA_VERIFY, - CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return 0; - } - - hashBuffer = (unsigned char *)m; - length = m_len; - break; - case NID_md5: - { - unsigned char *ptr; - ptr = hashBuffer = OPENSSL_malloc((unsigned int)keyLength + 1); - if (!hashBuffer) { - CCA4758err(CCA4758_F_CCA_RSA_VERIFY, ERR_R_MALLOC_FAILURE); - return 0; - } - - i2d_X509_SIG(&sig, &ptr); - } - break; - case NID_sha1: - { - unsigned char *ptr; - ptr = hashBuffer = OPENSSL_malloc((unsigned int)keyLength + 1); - if (!hashBuffer) { - CCA4758err(CCA4758_F_CCA_RSA_VERIFY, ERR_R_MALLOC_FAILURE); - return 0; - } - i2d_X509_SIG(&sig, &ptr); - } - break; - default: - return 0; - } - - digitalSignatureVerify(&returnCode, &reasonCode, &exitDataLength, - exitData, &ruleArrayLength, ruleArray, - &keyTokenLength, keyToken, &length, hashBuffer, - &lsiglen, (unsigned char *)sigbuf); - - if (type == NID_sha1 || type == NID_md5) - OPENSSL_clear_free(hashBuffer, keyLength + 1); - - return ((returnCode || reasonCode) ? 0 : 1); -} - -# define SSL_SIG_LEN 36 - -static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa) -{ - long returnCode; - long reasonCode; - long exitDataLength = 0; - unsigned char exitData[8]; - long ruleArrayLength = 1; - unsigned char ruleArray[8] = "PKCS-1.1"; - long outputLength = 256; - long outputBitLength; - long keyTokenLength; - unsigned char *hashBuffer = NULL; - unsigned char *keyToken = (unsigned char *)RSA_get_ex_data(rsa, hndidx); - long length = SSL_SIG_LEN; - long keyLength; - X509_SIG sig; - ASN1_TYPE parameter; - X509_ALGOR algorithm; - ASN1_OCTET_STRING digest; - - keyTokenLength = *(long *)keyToken; - keyToken += sizeof(long); - - if (type == NID_md5 || type == NID_sha1) { - sig.algor = &algorithm; - algorithm.algorithm = OBJ_nid2obj(type); - - if (!algorithm.algorithm) { - CCA4758err(CCA4758_F_CCA_RSA_SIGN, - CCA4758_R_UNKNOWN_ALGORITHM_TYPE); - return 0; - } - - if (!OBJ_length(algorithm.algorithm)) { - CCA4758err(CCA4758_F_CCA_RSA_SIGN, - CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD); - return 0; - } - - parameter.type = V_ASN1_NULL; - parameter.value.ptr = NULL; - algorithm.parameter = ¶meter; - - sig.digest = &digest; - sig.digest->data = (unsigned char *)m; - sig.digest->length = m_len; - - length = i2d_X509_SIG(&sig, NULL); - } - - keyLength = RSA_size(rsa); - - if (length - RSA_PKCS1_PADDING > keyLength) { - CCA4758err(CCA4758_F_CCA_RSA_SIGN, - CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return 0; - } - - switch (type) { - case NID_md5_sha1: - if (m_len != SSL_SIG_LEN) { - CCA4758err(CCA4758_F_CCA_RSA_SIGN, - CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return 0; - } - hashBuffer = (unsigned char *)m; - length = m_len; - break; - case NID_md5: - { - unsigned char *ptr; - ptr = hashBuffer = OPENSSL_malloc((unsigned int)keyLength + 1); - if (!hashBuffer) { - CCA4758err(CCA4758_F_CCA_RSA_SIGN, ERR_R_MALLOC_FAILURE); - return 0; - } - i2d_X509_SIG(&sig, &ptr); - } - break; - case NID_sha1: - { - unsigned char *ptr; - ptr = hashBuffer = OPENSSL_malloc((unsigned int)keyLength + 1); - if (!hashBuffer) { - CCA4758err(CCA4758_F_CCA_RSA_SIGN, ERR_R_MALLOC_FAILURE); - return 0; - } - i2d_X509_SIG(&sig, &ptr); - } - break; - default: - return 0; - } - - digitalSignatureGenerate(&returnCode, &reasonCode, &exitDataLength, - exitData, &ruleArrayLength, ruleArray, - &keyTokenLength, keyToken, &length, hashBuffer, - &outputLength, &outputBitLength, sigret); - - if (type == NID_sha1 || type == NID_md5) - OPENSSL_clear_free(hashBuffer, keyLength + 1); - - *siglen = outputLength; - - return ((returnCode || reasonCode) ? 0 : 1); -} - -static int getModulusAndExponent(const unsigned char *token, - long *exponentLength, - unsigned char *exponent, long *modulusLength, - long *modulusFieldLength, - unsigned char *modulus) -{ - unsigned long len; - - if (*token++ != (char)0x1E) /* internal PKA token? */ - return 0; - - if (*token++) /* token version must be zero */ - return 0; - - len = *token++; - len = len << 8; - len |= (unsigned char)*token++; - - token += 4; /* skip reserved bytes */ - - if (*token++ == (char)0x04) { - if (*token++) /* token version must be zero */ - return 0; - - len = *token++; - len = len << 8; - len |= (unsigned char)*token++; - - token += 2; /* skip reserved section */ - - len = *token++; - len = len << 8; - len |= (unsigned char)*token++; - - *exponentLength = len; - - len = *token++; - len = len << 8; - len |= (unsigned char)*token++; - - *modulusLength = len; - - len = *token++; - len = len << 8; - len |= (unsigned char)*token++; - - *modulusFieldLength = len; - - memcpy(exponent, token, *exponentLength); - token += *exponentLength; - - memcpy(modulus, token, *modulusFieldLength); - return 1; - } - return 0; -} - -# endif /* OPENSSL_NO_RSA */ - -static int cca_random_status(void) -{ - return 1; -} - -static int cca_get_random_bytes(unsigned char *buf, int num) -{ - long ret_code; - long reason_code; - long exit_data_length; - unsigned char exit_data[4]; - unsigned char form[] = "RANDOM "; - unsigned char rand_buf[8]; - - while (num >= (int)sizeof(rand_buf)) { - randomNumberGenerate(&ret_code, &reason_code, &exit_data_length, - exit_data, form, rand_buf); - if (ret_code) - return 0; - num -= sizeof(rand_buf); - memcpy(buf, rand_buf, sizeof(rand_buf)); - buf += sizeof(rand_buf); - } - - if (num) { - randomNumberGenerate(&ret_code, &reason_code, NULL, NULL, - form, rand_buf); - if (ret_code) - return 0; - memcpy(buf, rand_buf, num); - } - - return 1; -} - -# ifndef OPENSSL_NO_RSA -static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx, - long argl, void *argp) -{ - OPENSSL_free(item); -} -# endif - -/* Goo to handle building as a dynamic engine */ -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -static int bind_fn(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, engine_4758_cca_id) != 0) && - (strcmp(id, engine_4758_cca_id_alt) != 0)) - return 0; - if (!bind_helper(e)) - return 0; - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() - IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) -# endif /* OPENSSL_NO_DYNAMIC_ENGINE */ -# endif /* !OPENSSL_NO_HW_4758_CCA */ -#endif /* !OPENSSL_NO_HW */ diff --git a/engines/e_4758cca.ec b/engines/e_4758cca.ec deleted file mode 100644 index f30ed02..0000000 --- a/engines/e_4758cca.ec +++ /dev/null @@ -1 +0,0 @@ -L CCA4758 e_4758cca_err.h e_4758cca_err.c diff --git a/engines/e_4758cca_err.c b/engines/e_4758cca_err.c deleted file mode 100644 index aed7199..0000000 --- a/engines/e_4758cca_err.c +++ /dev/null @@ -1,153 +0,0 @@ -/* e_4758cca_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -/* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. - */ - -#include -#include -#include "e_4758cca_err.h" - -/* BEGIN ERROR CODES */ -#ifndef OPENSSL_NO_ERR - -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - -static ERR_STRING_DATA CCA4758_str_functs[] = { - {ERR_FUNC(CCA4758_F_CCA_RSA_SIGN), "CCA_RSA_SIGN"}, - {ERR_FUNC(CCA4758_F_CCA_RSA_VERIFY), "CCA_RSA_VERIFY"}, - {ERR_FUNC(CCA4758_F_IBM_4758_CCA_CTRL), "IBM_4758_CCA_CTRL"}, - {ERR_FUNC(CCA4758_F_IBM_4758_CCA_FINISH), "IBM_4758_CCA_FINISH"}, - {ERR_FUNC(CCA4758_F_IBM_4758_CCA_INIT), "IBM_4758_CCA_INIT"}, - {ERR_FUNC(CCA4758_F_IBM_4758_LOAD_PRIVKEY), "IBM_4758_LOAD_PRIVKEY"}, - {ERR_FUNC(CCA4758_F_IBM_4758_LOAD_PUBKEY), "IBM_4758_LOAD_PUBKEY"}, - {0, NULL} -}; - -static ERR_STRING_DATA CCA4758_str_reasons[] = { - {ERR_REASON(CCA4758_R_ALREADY_LOADED), "already loaded"}, - {ERR_REASON(CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD), - "asn1 oid unknown for md"}, - {ERR_REASON(CCA4758_R_COMMAND_NOT_IMPLEMENTED), - "command not implemented"}, - {ERR_REASON(CCA4758_R_DSO_FAILURE), "dso failure"}, - {ERR_REASON(CCA4758_R_FAILED_LOADING_PRIVATE_KEY), - "failed loading private key"}, - {ERR_REASON(CCA4758_R_FAILED_LOADING_PUBLIC_KEY), - "failed loading public key"}, - {ERR_REASON(CCA4758_R_NOT_LOADED), "not loaded"}, - {ERR_REASON(CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL), - "size too large or too small"}, - {ERR_REASON(CCA4758_R_UNIT_FAILURE), "unit failure"}, - {ERR_REASON(CCA4758_R_UNKNOWN_ALGORITHM_TYPE), "unknown algorithm type"}, - {0, NULL} -}; - -#endif - -#ifdef CCA4758_LIB_NAME -static ERR_STRING_DATA CCA4758_lib_name[] = { - {0, CCA4758_LIB_NAME}, - {0, NULL} -}; -#endif - -static int CCA4758_lib_error_code = 0; -static int CCA4758_error_init = 1; - -static void ERR_load_CCA4758_strings(void) -{ - if (CCA4758_lib_error_code == 0) - CCA4758_lib_error_code = ERR_get_next_error_library(); - - if (CCA4758_error_init) { - CCA4758_error_init = 0; -#ifndef OPENSSL_NO_ERR - ERR_load_strings(CCA4758_lib_error_code, CCA4758_str_functs); - ERR_load_strings(CCA4758_lib_error_code, CCA4758_str_reasons); -#endif - -#ifdef CCA4758_LIB_NAME - CCA4758_lib_name->error = ERR_PACK(CCA4758_lib_error_code, 0, 0); - ERR_load_strings(0, CCA4758_lib_name); -#endif - } -} - -static void ERR_unload_CCA4758_strings(void) -{ - if (CCA4758_error_init == 0) { -#ifndef OPENSSL_NO_ERR - ERR_unload_strings(CCA4758_lib_error_code, CCA4758_str_functs); - ERR_unload_strings(CCA4758_lib_error_code, CCA4758_str_reasons); -#endif - -#ifdef CCA4758_LIB_NAME - ERR_unload_strings(0, CCA4758_lib_name); -#endif - CCA4758_error_init = 1; - } -} - -static void ERR_CCA4758_error(int function, int reason, char *file, int line) -{ - if (CCA4758_lib_error_code == 0) - CCA4758_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(CCA4758_lib_error_code, function, reason, file, line); -} diff --git a/engines/e_4758cca_err.h b/engines/e_4758cca_err.h deleted file mode 100644 index 2f29d96..0000000 --- a/engines/e_4758cca_err.h +++ /dev/null @@ -1,98 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#ifndef HEADER_CCA4758_ERR_H -# define HEADER_CCA4758_ERR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -static void ERR_load_CCA4758_strings(void); -static void ERR_unload_CCA4758_strings(void); -static void ERR_CCA4758_error(int function, int reason, char *file, int line); -# define CCA4758err(f,r) ERR_CCA4758_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the CCA4758 functions. */ - -/* Function codes. */ -# define CCA4758_F_CCA_RSA_SIGN 105 -# define CCA4758_F_CCA_RSA_VERIFY 106 -# define CCA4758_F_IBM_4758_CCA_CTRL 100 -# define CCA4758_F_IBM_4758_CCA_FINISH 101 -# define CCA4758_F_IBM_4758_CCA_INIT 102 -# define CCA4758_F_IBM_4758_LOAD_PRIVKEY 103 -# define CCA4758_F_IBM_4758_LOAD_PUBKEY 104 - -/* Reason codes. */ -# define CCA4758_R_ALREADY_LOADED 100 -# define CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD 101 -# define CCA4758_R_COMMAND_NOT_IMPLEMENTED 102 -# define CCA4758_R_DSO_FAILURE 103 -# define CCA4758_R_FAILED_LOADING_PRIVATE_KEY 104 -# define CCA4758_R_FAILED_LOADING_PUBLIC_KEY 105 -# define CCA4758_R_NOT_LOADED 106 -# define CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL 107 -# define CCA4758_R_UNIT_FAILURE 108 -# define CCA4758_R_UNKNOWN_ALGORITHM_TYPE 109 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/engines/e_aep.c b/engines/e_aep.c deleted file mode 100644 index abcdb15..0000000 --- a/engines/e_aep.c +++ /dev/null @@ -1,1182 +0,0 @@ -/* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#include -#include -#include - -#include -#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__) || defined(__MINGW32__) -# include -# include -#else -# include -typedef int pid_t; -#endif - -#if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) -# define getpid GetThreadID -extern int GetThreadID(void); -#elif defined(_WIN32) && !defined(__WATCOMC__) -# define getpid _getpid -#endif - -#include -#include -#include -#include -#ifndef OPENSSL_NO_RSA -# include -#endif -#ifndef OPENSSL_NO_DSA -# include -#endif -#ifndef OPENSSL_NO_DH -# include -#endif - -#ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_AEP -# ifdef FLAT_INC -# include "aep.h" -# else -# include "vendor_defns/aep.h" -# endif - -# define AEP_LIB_NAME "aep engine" -# define FAIL_TO_SW 0x10101010 - -# include "e_aep_err.c" - -static int aep_init(ENGINE *e); -static int aep_finish(ENGINE *e); -static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)); -static int aep_destroy(ENGINE *e); - -static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR hConnection); -static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection); -static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection); -static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use); - -/* BIGNUM stuff */ -# ifndef OPENSSL_NO_RSA -static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); - -static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *q, const BIGNUM *dmp1, - const BIGNUM *dmq1, const BIGNUM *iqmp, - BN_CTX *ctx); -# endif - -/* RSA stuff */ -# ifndef OPENSSL_NO_RSA -static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx); -# endif - -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -# ifndef OPENSSL_NO_RSA -static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -# endif - -/* DSA stuff */ -# ifndef OPENSSL_NO_DSA -static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, - BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont); - -static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -/* DH stuff */ -/* This function is aliased to mod_exp (with the DH and mont dropped). */ -# ifndef OPENSSL_NO_DH -static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -/* rand stuff */ -# ifdef AEPRAND -static int aep_rand(unsigned char *buf, int num); -static int aep_rand_status(void); -# endif - -/* Bignum conversion stuff */ -static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32 *BigNumSize); -static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize, - unsigned char *AEP_BigNum); -static AEP_RV ConvertAEPBigNum(void *ArbBigNum, AEP_U32 BigNumSize, - unsigned char *AEP_BigNum); - -/* The definitions for control commands specific to this engine */ -# define AEP_CMD_SO_PATH ENGINE_CMD_BASE -static const ENGINE_CMD_DEFN aep_cmd_defns[] = { - {AEP_CMD_SO_PATH, - "SO_PATH", - "Specifies the path to the 'aep' shared library", - ENGINE_CMD_FLAG_STRING}, - {0, NULL, NULL, 0} -}; - -# ifndef OPENSSL_NO_RSA -/* Our internal RSA_METHOD that we provide pointers to */ -static RSA_METHOD aep_rsa = { - "Aep RSA method", - NULL, /* rsa_pub_encrypt */ - NULL, /* rsa_pub_decrypt */ - NULL, /* rsa_priv_encrypt */ - NULL, /* rsa_priv_encrypt */ - aep_rsa_mod_exp, /* rsa_mod_exp */ - aep_mod_exp_mont, /* bn_mod_exp */ - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - NULL, /* rsa_sign */ - NULL, /* rsa_verify */ - NULL /* rsa_keygen */ -}; -# endif - -# ifndef OPENSSL_NO_DSA -/* Our internal DSA_METHOD that we provide pointers to */ -static DSA_METHOD aep_dsa = { - "Aep DSA method", - NULL, /* dsa_do_sign */ - NULL, /* dsa_sign_setup */ - NULL, /* dsa_do_verify */ - aep_dsa_mod_exp, /* dsa_mod_exp */ - aep_mod_exp_dsa, /* bn_mod_exp */ - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - NULL, /* dsa_paramgen */ - NULL /* dsa_keygen */ -}; -# endif - -# ifndef OPENSSL_NO_DH -/* Our internal DH_METHOD that we provide pointers to */ -static DH_METHOD aep_dh = { - "Aep DH method", - NULL, - NULL, - aep_mod_exp_dh, - NULL, - NULL, - 0, - NULL, - NULL -}; -# endif - -# ifdef AEPRAND -/* our internal RAND_method that we provide pointers to */ -static RAND_METHOD aep_random = { - /* - * "AEP RAND method", - */ - NULL, - aep_rand, - NULL, - NULL, - aep_rand, - aep_rand_status, -}; -# endif - -/* - * Define an array of structures to hold connections - */ -static AEP_CONNECTION_ENTRY aep_app_conn_table[MAX_PROCESS_CONNECTIONS]; - -/* - * Used to determine if this is a new process - */ -static pid_t recorded_pid = 0; - -# ifdef AEPRAND -static AEP_U8 rand_block[RAND_BLK_SIZE]; -static AEP_U32 rand_block_bytes = 0; -# endif - -/* Constants used when creating the ENGINE */ -static const char *engine_aep_id = "aep"; -static const char *engine_aep_name = "Aep hardware engine support"; - -static int max_key_len = 2176; - -/* - * This internal function is used by ENGINE_aep() and possibly by the - * "dynamic" ENGINE support too - */ -static int bind_aep(ENGINE *e) -{ -# ifndef OPENSSL_NO_RSA - const RSA_METHOD *meth1; -# endif -# ifndef OPENSSL_NO_DSA - const DSA_METHOD *meth2; -# endif -# ifndef OPENSSL_NO_DH - const DH_METHOD *meth3; -# endif - - if (!ENGINE_set_id(e, engine_aep_id) || - !ENGINE_set_name(e, engine_aep_name) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_RSA(e, &aep_rsa) || -# endif -# ifndef OPENSSL_NO_DSA - !ENGINE_set_DSA(e, &aep_dsa) || -# endif -# ifndef OPENSSL_NO_DH - !ENGINE_set_DH(e, &aep_dh) || -# endif -# ifdef AEPRAND - !ENGINE_set_RAND(e, &aep_random) || -# endif - !ENGINE_set_init_function(e, aep_init) || - !ENGINE_set_destroy_function(e, aep_destroy) || - !ENGINE_set_finish_function(e, aep_finish) || - !ENGINE_set_ctrl_function(e, aep_ctrl) || - !ENGINE_set_cmd_defns(e, aep_cmd_defns)) - return 0; - -# ifndef OPENSSL_NO_RSA - /* - * We know that the "PKCS1_SSLeay()" functions hook properly to the - * aep-specific mod_exp and mod_exp_crt so we use those functions. NB: We - * don't use ENGINE_openssl() or anything "more generic" because - * something like the RSAref code may not hook properly, and if you own - * one of these cards then you have the right to do RSA operations on it - * anyway! - */ - meth1 = RSA_PKCS1_SSLeay(); - aep_rsa.rsa_pub_enc = meth1->rsa_pub_enc; - aep_rsa.rsa_pub_dec = meth1->rsa_pub_dec; - aep_rsa.rsa_priv_enc = meth1->rsa_priv_enc; - aep_rsa.rsa_priv_dec = meth1->rsa_priv_dec; -# endif - -# ifndef OPENSSL_NO_DSA - /* - * Use the DSA_OpenSSL() method and just hook the mod_exp-ish bits. - */ - meth2 = DSA_OpenSSL(); - aep_dsa.dsa_do_sign = meth2->dsa_do_sign; - aep_dsa.dsa_sign_setup = meth2->dsa_sign_setup; - aep_dsa.dsa_do_verify = meth2->dsa_do_verify; - - aep_dsa = *DSA_get_default_method(); - aep_dsa.dsa_mod_exp = aep_dsa_mod_exp; - aep_dsa.bn_mod_exp = aep_mod_exp_dsa; -# endif - -# ifndef OPENSSL_NO_DH - /* Much the same for Diffie-Hellman */ - meth3 = DH_OpenSSL(); - aep_dh.generate_key = meth3->generate_key; - aep_dh.compute_key = meth3->compute_key; - aep_dh.bn_mod_exp = meth3->bn_mod_exp; -# endif - - /* Ensure the aep error handling is set up */ - ERR_load_AEPHK_strings(); - - return 1; -} - -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -static int bind_helper(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, engine_aep_id) != 0)) - return 0; - if (!bind_aep(e)) - return 0; - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() - IMPLEMENT_DYNAMIC_BIND_FN(bind_helper) -# else -static ENGINE *engine_aep(void) -{ - ENGINE *ret = ENGINE_new(); - if (!ret) - return NULL; - if (!bind_aep(ret)) { - ENGINE_free(ret); - return NULL; - } - return ret; -} - -void ENGINE_load_aep(void) -{ - /* Copied from eng_[openssl|dyn].c */ - ENGINE *toadd = engine_aep(); - if (!toadd) - return; - ENGINE_add(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -} -# endif - -/* - * This is a process-global DSO handle used for loading and unloading the Aep - * library. NB: This is only set (or unset) during an init() or finish() call - * (reference counts permitting) and they're operating with global locks, so - * this should be thread-safe implicitly. - */ -static DSO *aep_dso = NULL; - -/* - * These are the static string constants for the DSO file name and the - * function symbol names to bind to. - */ -static const char *AEP_LIBNAME = NULL; -static const char *get_AEP_LIBNAME(void) -{ - if (AEP_LIBNAME) - return AEP_LIBNAME; - return "aep"; -} - -static void free_AEP_LIBNAME(void) -{ - OPENSSL_free(AEP_LIBNAME); - AEP_LIBNAME = NULL; -} - -static long set_AEP_LIBNAME(const char *name) -{ - free_AEP_LIBNAME(); - return ((AEP_LIBNAME = BUF_strdup(name)) != NULL ? 1 : 0); -} - -static const char *AEP_F1 = "AEP_ModExp"; -static const char *AEP_F2 = "AEP_ModExpCrt"; -# ifdef AEPRAND -static const char *AEP_F3 = "AEP_GenRandom"; -# endif -static const char *AEP_F4 = "AEP_Finalize"; -static const char *AEP_F5 = "AEP_Initialize"; -static const char *AEP_F6 = "AEP_OpenConnection"; -static const char *AEP_F7 = "AEP_SetBNCallBacks"; -static const char *AEP_F8 = "AEP_CloseConnection"; - -/* - * These are the function pointers that are (un)set when the library has - * successfully (un)loaded. - */ -static t_AEP_OpenConnection *p_AEP_OpenConnection = NULL; -static t_AEP_CloseConnection *p_AEP_CloseConnection = NULL; -static t_AEP_ModExp *p_AEP_ModExp = NULL; -static t_AEP_ModExpCrt *p_AEP_ModExpCrt = NULL; -# ifdef AEPRAND -static t_AEP_GenRandom *p_AEP_GenRandom = NULL; -# endif -static t_AEP_Initialize *p_AEP_Initialize = NULL; -static t_AEP_Finalize *p_AEP_Finalize = NULL; -static t_AEP_SetBNCallBacks *p_AEP_SetBNCallBacks = NULL; - -/* (de)initialisation functions. */ -static int aep_init(ENGINE *e) -{ - t_AEP_ModExp *p1; - t_AEP_ModExpCrt *p2; -# ifdef AEPRAND - t_AEP_GenRandom *p3; -# endif - t_AEP_Finalize *p4; - t_AEP_Initialize *p5; - t_AEP_OpenConnection *p6; - t_AEP_SetBNCallBacks *p7; - t_AEP_CloseConnection *p8; - - int to_return = 0; - - if (aep_dso != NULL) { - AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_ALREADY_LOADED); - goto err; - } - /* Attempt to load libaep.so. */ - - aep_dso = DSO_load(NULL, get_AEP_LIBNAME(), NULL, 0); - if (aep_dso == NULL) { - AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_NOT_LOADED); - goto err; - } - -#define BINDIT(t, name) (t *)DSO_bind_func(aep_dso, name) - if ((p1 = BINDIT(t_AEP_ModExp, AEP_F1)) == NULL - || (p2 = BINDIT(t_AEP_ModExpCrt, AEP_F2)) == NULL -# ifdef AEPRAND - || (p3 = BINDIT(t_AEP_GenRandom, AEP_F3)) == NULL -# endif - || (p4 = BINDIT(t_AEP_Finalize, AEP_F4)) == NULL - || (p5 = BINDIT(t_AEP_Initialize, AEP_F5)) == NULL - || (p6 = BINDIT(t_AEP_OpenConnection, AEP_F6)) == NULL - || (p7 = BINDIT(t_AEP_SetBNCallBacks, AEP_F7)) == NULL - || (p8 = BINDIT(t_AEP_CloseConnection, AEP_F8)) == NULL) { - AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_NOT_LOADED); - goto err; - } - - /* Copy the pointers */ - - p_AEP_ModExp = p1; - p_AEP_ModExpCrt = p2; -# ifdef AEPRAND - p_AEP_GenRandom = p3; -# endif - p_AEP_Finalize = p4; - p_AEP_Initialize = p5; - p_AEP_OpenConnection = p6; - p_AEP_SetBNCallBacks = p7; - p_AEP_CloseConnection = p8; - - to_return = 1; - - return to_return; - - err: - - DSO_free(aep_dso); - aep_dso = NULL; - - p_AEP_OpenConnection = NULL; - p_AEP_ModExp = NULL; - p_AEP_ModExpCrt = NULL; -# ifdef AEPRAND - p_AEP_GenRandom = NULL; -# endif - p_AEP_Initialize = NULL; - p_AEP_Finalize = NULL; - p_AEP_SetBNCallBacks = NULL; - p_AEP_CloseConnection = NULL; - - return to_return; -} - -/* Destructor (complements the "ENGINE_aep()" constructor) */ -static int aep_destroy(ENGINE *e) -{ - free_AEP_LIBNAME(); - ERR_unload_AEPHK_strings(); - return 1; -} - -static int aep_finish(ENGINE *e) -{ - int to_return = 0, in_use; - AEP_RV rv; - - if (aep_dso == NULL) { - AEPHKerr(AEPHK_F_AEP_FINISH, AEPHK_R_NOT_LOADED); - goto err; - } - - rv = aep_close_all_connections(0, &in_use); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_FINISH, AEPHK_R_CLOSE_HANDLES_FAILED); - goto err; - } - if (in_use) { - AEPHKerr(AEPHK_F_AEP_FINISH, AEPHK_R_CONNECTIONS_IN_USE); - goto err; - } - - rv = p_AEP_Finalize(); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_FINISH, AEPHK_R_FINALIZE_FAILED); - goto err; - } - - if (!DSO_free(aep_dso)) { - AEPHKerr(AEPHK_F_AEP_FINISH, AEPHK_R_UNIT_FAILURE); - goto err; - } - - aep_dso = NULL; - p_AEP_CloseConnection = NULL; - p_AEP_OpenConnection = NULL; - p_AEP_ModExp = NULL; - p_AEP_ModExpCrt = NULL; -# ifdef AEPRAND - p_AEP_GenRandom = NULL; -# endif - p_AEP_Initialize = NULL; - p_AEP_Finalize = NULL; - p_AEP_SetBNCallBacks = NULL; - - to_return = 1; - err: - return to_return; -} - -static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) -{ - int initialised = ((aep_dso == NULL) ? 0 : 1); - switch (cmd) { - case AEP_CMD_SO_PATH: - if (p == NULL) { - AEPHKerr(AEPHK_F_AEP_CTRL, ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - if (initialised) { - AEPHKerr(AEPHK_F_AEP_CTRL, AEPHK_R_ALREADY_LOADED); - return 0; - } - return set_AEP_LIBNAME((const char *)p); - default: - break; - } - AEPHKerr(AEPHK_F_AEP_CTRL, AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED); - return 0; -} - -static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx) -{ - int to_return = 0; - int r_len = 0; - AEP_CONNECTION_HNDL hConnection; - AEP_RV rv; - - r_len = BN_num_bits(m); - - /* Perform in software if modulus is too large for hardware. */ - - if (r_len > max_key_len) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - return BN_mod_exp(r, a, p, m, ctx); - } - - /* - * Grab a connection from the pool - */ - rv = aep_get_connection(&hConnection); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_GET_HANDLE_FAILED); - return BN_mod_exp(r, a, p, m, ctx); - } - - /* - * To the card with the mod exp - */ - rv = p_AEP_ModExp(hConnection, (void *)a, (void *)p, (void *)m, (void *)r, - NULL); - - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_MOD_EXP_FAILED); - rv = aep_close_connection(hConnection); - return BN_mod_exp(r, a, p, m, ctx); - } - - /* - * Return the connection to the pool - */ - rv = aep_return_connection(hConnection); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_RETURN_CONNECTION_FAILED); - goto err; - } - - to_return = 1; - err: - return to_return; -} - -# ifndef OPENSSL_NO_RSA -static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *q, const BIGNUM *dmp1, - const BIGNUM *dmq1, const BIGNUM *iqmp, - BN_CTX *ctx) -{ - AEP_RV rv = AEP_R_OK; - AEP_CONNECTION_HNDL hConnection; - - /* - * Grab a connection from the pool - */ - rv = aep_get_connection(&hConnection); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT, AEPHK_R_GET_HANDLE_FAILED); - return FAIL_TO_SW; - } - - /* - * To the card with the mod exp - */ - rv = p_AEP_ModExpCrt(hConnection, (void *)a, (void *)p, (void *)q, - (void *)dmp1, (void *)dmq1, (void *)iqmp, (void *)r, - NULL); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT, AEPHK_R_MOD_EXP_CRT_FAILED); - rv = aep_close_connection(hConnection); - return FAIL_TO_SW; - } - - /* - * Return the connection to the pool - */ - rv = aep_return_connection(hConnection); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT, AEPHK_R_RETURN_CONNECTION_FAILED); - goto err; - } - - err: - return rv; -} -# endif - -# ifdef AEPRAND -static int aep_rand(unsigned char *buf, int len) -{ - AEP_RV rv = AEP_R_OK; - AEP_CONNECTION_HNDL hConnection; - - CRYPTO_w_lock(CRYPTO_LOCK_RAND); - - /* - * Can the request be serviced with what's already in the buffer? - */ - if (len <= rand_block_bytes) { - memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len); - rand_block_bytes -= len; - CRYPTO_w_unlock(CRYPTO_LOCK_RAND); - } else - /* - * If not the get another block of random bytes - */ - { - CRYPTO_w_unlock(CRYPTO_LOCK_RAND); - - rv = aep_get_connection(&hConnection); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_RAND, AEPHK_R_GET_HANDLE_FAILED); - goto err_nounlock; - } - - if (len > RAND_BLK_SIZE) { - rv = p_AEP_GenRandom(hConnection, len, 2, buf, NULL); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_RAND, AEPHK_R_GET_RANDOM_FAILED); - goto err_nounlock; - } - } else { - CRYPTO_w_lock(CRYPTO_LOCK_RAND); - - rv = p_AEP_GenRandom(hConnection, RAND_BLK_SIZE, 2, - &rand_block[0], NULL); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_RAND, AEPHK_R_GET_RANDOM_FAILED); - - goto err; - } - - rand_block_bytes = RAND_BLK_SIZE; - - memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len); - rand_block_bytes -= len; - - CRYPTO_w_unlock(CRYPTO_LOCK_RAND); - } - - rv = aep_return_connection(hConnection); - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_RAND, AEPHK_R_RETURN_CONNECTION_FAILED); - - goto err_nounlock; - } - } - - return 1; - err: - CRYPTO_w_unlock(CRYPTO_LOCK_RAND); - err_nounlock: - return 0; -} - -static int aep_rand_status(void) -{ - return 1; -} -# endif - -# ifndef OPENSSL_NO_RSA -static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) -{ - int to_return = 0; - AEP_RV rv = AEP_R_OK; - - if (!aep_dso) { - AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP, AEPHK_R_NOT_LOADED); - goto err; - } - - /* - * See if we have all the necessary bits for a crt - */ - if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp) { - rv = aep_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1, rsa->dmq1, - rsa->iqmp, ctx); - - if (rv == FAIL_TO_SW) { - const RSA_METHOD *meth = RSA_PKCS1_SSLeay(); - to_return = (*meth->rsa_mod_exp) (r0, I, rsa, ctx); - goto err; - } else if (rv != AEP_R_OK) - goto err; - } else { - if (!rsa->d || !rsa->n) { - AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP, AEPHK_R_MISSING_KEY_COMPONENTS); - goto err; - } - - rv = aep_mod_exp(r0, I, rsa->d, rsa->n, ctx); - if (rv != AEP_R_OK) - goto err; - - } - - to_return = 1; - - err: - return to_return; -} -# endif - -# ifndef OPENSSL_NO_DSA -static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, - BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont) -{ - BIGNUM t; - int to_return = 0; - BN_init(&t); - - /* let rr = a1 ^ p1 mod m */ - if (!aep_mod_exp(rr, a1, p1, m, ctx)) - goto end; - /* let t = a2 ^ p2 mod m */ - if (!aep_mod_exp(&t, a2, p2, m, ctx)) - goto end; - /* let rr = rr * t mod m */ - if (!BN_mod_mul(rr, rr, &t, m, ctx)) - goto end; - to_return = 1; - end: - BN_free(&t); - return to_return; -} - -static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return aep_mod_exp(r, a, p, m, ctx); -} -# endif - -# ifndef OPENSSL_NO_RSA -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - return aep_mod_exp(r, a, p, m, ctx); -} -# endif - -# ifndef OPENSSL_NO_DH -/* This function is aliased to mod_exp (with the dh and mont dropped). */ -static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return aep_mod_exp(r, a, p, m, ctx); -} -# endif - -static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection) -{ - int count; - AEP_RV rv = AEP_R_OK; - - /* - * Get the current process id - */ - pid_t curr_pid; - - CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - - curr_pid = getpid(); - - /* - * Check if this is the first time this is being called from the current - * process - */ - if (recorded_pid != curr_pid) { - /* - * Remember our pid so we can check if we're in a new process - */ - recorded_pid = curr_pid; - - /* - * Call Finalize to make sure we have not inherited some data from a - * parent process - */ - p_AEP_Finalize(); - - /* - * Initialise the AEP API - */ - rv = p_AEP_Initialize(NULL); - - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_GET_CONNECTION, AEPHK_R_INIT_FAILURE); - recorded_pid = 0; - goto end; - } - - /* - * Set the AEP big num call back functions - */ - rv = p_AEP_SetBNCallBacks(&GetBigNumSize, &MakeAEPBigNum, - &ConvertAEPBigNum); - - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_GET_CONNECTION, - AEPHK_R_SETBNCALLBACK_FAILURE); - recorded_pid = 0; - goto end; - } -# ifdef AEPRAND - /* - * Reset the rand byte count - */ - rand_block_bytes = 0; -# endif - - /* - * Init the structures - */ - for (count = 0; count < MAX_PROCESS_CONNECTIONS; count++) { - aep_app_conn_table[count].conn_state = NotConnected; - aep_app_conn_table[count].conn_hndl = 0; - } - - /* - * Open a connection - */ - rv = p_AEP_OpenConnection(phConnection); - - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_GET_CONNECTION, AEPHK_R_UNIT_FAILURE); - recorded_pid = 0; - goto end; - } - - aep_app_conn_table[0].conn_state = InUse; - aep_app_conn_table[0].conn_hndl = *phConnection; - goto end; - } - /* - * Check the existing connections to see if we can find a free one - */ - for (count = 0; count < MAX_PROCESS_CONNECTIONS; count++) { - if (aep_app_conn_table[count].conn_state == Connected) { - aep_app_conn_table[count].conn_state = InUse; - *phConnection = aep_app_conn_table[count].conn_hndl; - goto end; - } - } - /* - * If no connections available, we're going to have to try to open a new - * one - */ - for (count = 0; count < MAX_PROCESS_CONNECTIONS; count++) { - if (aep_app_conn_table[count].conn_state == NotConnected) { - /* - * Open a connection - */ - rv = p_AEP_OpenConnection(phConnection); - - if (rv != AEP_R_OK) { - AEPHKerr(AEPHK_F_AEP_GET_CONNECTION, AEPHK_R_UNIT_FAILURE); - goto end; - } - - aep_app_conn_table[count].conn_state = InUse; - aep_app_conn_table[count].conn_hndl = *phConnection; - goto end; - } - } - rv = AEP_R_GENERAL_ERROR; - end: - CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - return rv; -} - -static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection) -{ - int count; - - CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - - /* - * Find the connection item that matches this connection handle - */ - for (count = 0; count < MAX_PROCESS_CONNECTIONS; count++) { - if (aep_app_conn_table[count].conn_hndl == hConnection) { - aep_app_conn_table[count].conn_state = Connected; - break; - } - } - - CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - - return AEP_R_OK; -} - -static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection) -{ - int count; - AEP_RV rv = AEP_R_OK; - - CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - - /* - * Find the connection item that matches this connection handle - */ - for (count = 0; count < MAX_PROCESS_CONNECTIONS; count++) { - if (aep_app_conn_table[count].conn_hndl == hConnection) { - rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl); - if (rv != AEP_R_OK) - goto end; - aep_app_conn_table[count].conn_state = NotConnected; - aep_app_conn_table[count].conn_hndl = 0; - break; - } - } - - end: - CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - return rv; -} - -static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use) -{ - int count; - AEP_RV rv = AEP_R_OK; - - *in_use = 0; - if (use_engine_lock) - CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - for (count = 0; count < MAX_PROCESS_CONNECTIONS; count++) { - switch (aep_app_conn_table[count].conn_state) { - case Connected: - rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl); - if (rv != AEP_R_OK) - goto end; - aep_app_conn_table[count].conn_state = NotConnected; - aep_app_conn_table[count].conn_hndl = 0; - break; - case InUse: - (*in_use)++; - break; - case NotConnected: - break; - } - } - end: - if (use_engine_lock) - CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - return rv; -} - -/* - * BigNum call back functions, used to convert OpenSSL bignums into AEP - * bignums. Note only 32bit Openssl build support - */ - -static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32 *BigNumSize) -{ - BIGNUM *bn; - - /* - * Cast the ArbBigNum pointer to our BIGNUM struct - */ - bn = (BIGNUM *)ArbBigNum; - - *BigNumSize = bn->top * BN_BYTES; - - if (BN_BYTES > sizeof(AEP_U32) && (bn->d[bn->top - 1] >> BN_BITS4) == 0) - *BigNumSize -= 4; - - return AEP_R_OK; -} - -static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize, - unsigned char *AEP_BigNum) -{ - BIGNUM *bn; - const union { - long one; - char little; - } is_endian = { - 1 - }; - AEP_U32 i, j; - - /* - * Cast the ArbBigNum pointer to our BIGNUM struct - */ - bn = (BIGNUM *)ArbBigNum; - - /* - * Must copy data into a (monotone) least significant byte first format - * performing endian conversion if necessary - */ - if (is_endian.little && sizeof(bn->d[0]) == BN_BYTES) - memcpy(AEP_BigNum, bn->d, BigNumSize); - else { - BN_ULONG di; - - for (i = 0; BigNumSize >= BN_BYTES; i++) { - di = bn->d[i]; - for (j = 0; j < BN_BYTES; j++) { - AEP_BigNum[j] = (unsigned char)di; - di >>= 8; - } - AEP_BigNum += BN_BYTES; - BigNumSize -= BN_BYTES; - } - - if (BigNumSize) { - di = bn->d[i]; - for (j = 0; j < BigNumSize; j++) { - AEP_BigNum[j] = (unsigned char)di; - di >>= 8; - } - } - } - - return AEP_R_OK; -} - -/* - * Turn an AEP Big Num back to a user big num - */ -static AEP_RV ConvertAEPBigNum(void *ArbBigNum, AEP_U32 BigNumSize, - unsigned char *AEP_BigNum) -{ - BIGNUM *bn; - const union { - long one; - char little; - } is_endian = { - 1 - }; - int i, j, top; - - bn = (BIGNUM *)ArbBigNum; - - /* - * Expand the result bn so that it can hold our big num. Size is in bits - */ - top = (BigNumSize + BN_BYTES - 1) / BN_BYTES; - bn_expand(bn, top); - bn->top = top; - bn->d[top - 1] = 0; - - if (is_endian.little && sizeof(bn->d[0]) == BN_BYTES) - memcpy(bn->d, AEP_BigNum, BigNumSize); - else { - BN_ULONG di; - - for (i = 0; BigNumSize >= BN_BYTES; i++) { - for (di = 0, j = BN_BYTES; j != 0;) { - di <<= 8; - di |= AEP_BigNum[--j]; - } - bn->d[i] = di; - AEP_BigNum += BN_BYTES; - BigNumSize -= BN_BYTES; - } - - if (BigNumSize) { - for (di = 0, j = BigNumSize; j != 0;) { - di <<= 8; - di |= AEP_BigNum[--j]; - } - bn->d[i] = di; - } - } - - return AEP_R_OK; -} - -# endif /* !OPENSSL_NO_HW_AEP */ -#endif /* !OPENSSL_NO_HW */ diff --git a/engines/e_aep.ec b/engines/e_aep.ec deleted file mode 100644 index 8eae642..0000000 --- a/engines/e_aep.ec +++ /dev/null @@ -1 +0,0 @@ -L AEPHK e_aep_err.h e_aep_err.c diff --git a/engines/e_aep_err.c b/engines/e_aep_err.c deleted file mode 100644 index 718db37..0000000 --- a/engines/e_aep_err.c +++ /dev/null @@ -1,159 +0,0 @@ -/* e_aep_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -/* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. - */ - -#include -#include -#include "e_aep_err.h" - -/* BEGIN ERROR CODES */ -#ifndef OPENSSL_NO_ERR - -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - -static ERR_STRING_DATA AEPHK_str_functs[] = { - {ERR_FUNC(AEPHK_F_AEP_CTRL), "AEP_CTRL"}, - {ERR_FUNC(AEPHK_F_AEP_FINISH), "AEP_FINISH"}, - {ERR_FUNC(AEPHK_F_AEP_GET_CONNECTION), "AEP_GET_CONNECTION"}, - {ERR_FUNC(AEPHK_F_AEP_INIT), "AEP_INIT"}, - {ERR_FUNC(AEPHK_F_AEP_MOD_EXP), "AEP_MOD_EXP"}, - {ERR_FUNC(AEPHK_F_AEP_MOD_EXP_CRT), "AEP_MOD_EXP_CRT"}, - {ERR_FUNC(AEPHK_F_AEP_RAND), "AEP_RAND"}, - {ERR_FUNC(AEPHK_F_AEP_RSA_MOD_EXP), "AEP_RSA_MOD_EXP"}, - {0, NULL} -}; - -static ERR_STRING_DATA AEPHK_str_reasons[] = { - {ERR_REASON(AEPHK_R_ALREADY_LOADED), "already loaded"}, - {ERR_REASON(AEPHK_R_CLOSE_HANDLES_FAILED), "close handles failed"}, - {ERR_REASON(AEPHK_R_CONNECTIONS_IN_USE), "connections in use"}, - {ERR_REASON(AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED), - "ctrl command not implemented"}, - {ERR_REASON(AEPHK_R_FINALIZE_FAILED), "finalize failed"}, - {ERR_REASON(AEPHK_R_GET_HANDLE_FAILED), "get handle failed"}, - {ERR_REASON(AEPHK_R_GET_RANDOM_FAILED), "get random failed"}, - {ERR_REASON(AEPHK_R_INIT_FAILURE), "init failure"}, - {ERR_REASON(AEPHK_R_MISSING_KEY_COMPONENTS), "missing key components"}, - {ERR_REASON(AEPHK_R_MOD_EXP_CRT_FAILED), "mod exp crt failed"}, - {ERR_REASON(AEPHK_R_MOD_EXP_FAILED), "mod exp failed"}, - {ERR_REASON(AEPHK_R_NOT_LOADED), "not loaded"}, - {ERR_REASON(AEPHK_R_OK), "ok"}, - {ERR_REASON(AEPHK_R_RETURN_CONNECTION_FAILED), - "return connection failed"}, - {ERR_REASON(AEPHK_R_SETBNCALLBACK_FAILURE), "setbncallback failure"}, - {ERR_REASON(AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL), - "size too large or too small"}, - {ERR_REASON(AEPHK_R_UNIT_FAILURE), "unit failure"}, - {0, NULL} -}; - -#endif - -#ifdef AEPHK_LIB_NAME -static ERR_STRING_DATA AEPHK_lib_name[] = { - {0, AEPHK_LIB_NAME}, - {0, NULL} -}; -#endif - -static int AEPHK_lib_error_code = 0; -static int AEPHK_error_init = 1; - -static void ERR_load_AEPHK_strings(void) -{ - if (AEPHK_lib_error_code == 0) - AEPHK_lib_error_code = ERR_get_next_error_library(); - - if (AEPHK_error_init) { - AEPHK_error_init = 0; -#ifndef OPENSSL_NO_ERR - ERR_load_strings(AEPHK_lib_error_code, AEPHK_str_functs); - ERR_load_strings(AEPHK_lib_error_code, AEPHK_str_reasons); -#endif - -#ifdef AEPHK_LIB_NAME - AEPHK_lib_name->error = ERR_PACK(AEPHK_lib_error_code, 0, 0); - ERR_load_strings(0, AEPHK_lib_name); -#endif - } -} - -static void ERR_unload_AEPHK_strings(void) -{ - if (AEPHK_error_init == 0) { -#ifndef OPENSSL_NO_ERR - ERR_unload_strings(AEPHK_lib_error_code, AEPHK_str_functs); - ERR_unload_strings(AEPHK_lib_error_code, AEPHK_str_reasons); -#endif - -#ifdef AEPHK_LIB_NAME - ERR_unload_strings(0, AEPHK_lib_name); -#endif - AEPHK_error_init = 1; - } -} - -static void ERR_AEPHK_error(int function, int reason, char *file, int line) -{ - if (AEPHK_lib_error_code == 0) - AEPHK_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(AEPHK_lib_error_code, function, reason, file, line); -} diff --git a/engines/e_aep_err.h b/engines/e_aep_err.h deleted file mode 100644 index 2ed0114..0000000 --- a/engines/e_aep_err.h +++ /dev/null @@ -1,106 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#ifndef HEADER_AEPHK_ERR_H -# define HEADER_AEPHK_ERR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -static void ERR_load_AEPHK_strings(void); -static void ERR_unload_AEPHK_strings(void); -static void ERR_AEPHK_error(int function, int reason, char *file, int line); -# define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the AEPHK functions. */ - -/* Function codes. */ -# define AEPHK_F_AEP_CTRL 100 -# define AEPHK_F_AEP_FINISH 101 -# define AEPHK_F_AEP_GET_CONNECTION 102 -# define AEPHK_F_AEP_INIT 103 -# define AEPHK_F_AEP_MOD_EXP 104 -# define AEPHK_F_AEP_MOD_EXP_CRT 105 -# define AEPHK_F_AEP_RAND 106 -# define AEPHK_F_AEP_RSA_MOD_EXP 107 - -/* Reason codes. */ -# define AEPHK_R_ALREADY_LOADED 100 -# define AEPHK_R_CLOSE_HANDLES_FAILED 101 -# define AEPHK_R_CONNECTIONS_IN_USE 102 -# define AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 -# define AEPHK_R_FINALIZE_FAILED 104 -# define AEPHK_R_GET_HANDLE_FAILED 105 -# define AEPHK_R_GET_RANDOM_FAILED 106 -# define AEPHK_R_INIT_FAILURE 107 -# define AEPHK_R_MISSING_KEY_COMPONENTS 108 -# define AEPHK_R_MOD_EXP_CRT_FAILED 109 -# define AEPHK_R_MOD_EXP_FAILED 110 -# define AEPHK_R_NOT_LOADED 111 -# define AEPHK_R_OK 112 -# define AEPHK_R_RETURN_CONNECTION_FAILED 113 -# define AEPHK_R_SETBNCALLBACK_FAILURE 114 -# define AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL 116 -# define AEPHK_R_UNIT_FAILURE 115 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/engines/e_atalla.c b/engines/e_atalla.c deleted file mode 100644 index 211f29f..0000000 --- a/engines/e_atalla.c +++ /dev/null @@ -1,621 +0,0 @@ -/* crypto/engine/hw_atalla.c */ -/* - * Written by Geoff Thorpe (geoff at geoffthorpe.net) for the OpenSSL project - * 2000. - */ -/* ==================================================================== - * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_RSA -# include -#endif -#ifndef OPENSSL_NO_DSA -# include -#endif -#ifndef OPENSSL_NO_DH -# include -#endif -#include - -#ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_ATALLA - -# ifdef FLAT_INC -# include "atalla.h" -# else -# include "vendor_defns/atalla.h" -# endif - -# define ATALLA_LIB_NAME "atalla engine" -# include "e_atalla_err.c" - -static int atalla_destroy(ENGINE *e); -static int atalla_init(ENGINE *e); -static int atalla_finish(ENGINE *e); -static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)); - -/* BIGNUM stuff */ -static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); - -# ifndef OPENSSL_NO_RSA -/* RSA stuff */ -static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx); -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -# ifndef OPENSSL_NO_DSA -/* DSA stuff */ -static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, - BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont); -static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -# ifndef OPENSSL_NO_DH -/* DH stuff */ -/* This function is alised to mod_exp (with the DH and mont dropped). */ -static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r, - const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -/* The definitions for control commands specific to this engine */ -# define ATALLA_CMD_SO_PATH ENGINE_CMD_BASE -static const ENGINE_CMD_DEFN atalla_cmd_defns[] = { - {ATALLA_CMD_SO_PATH, - "SO_PATH", - "Specifies the path to the 'atasi' shared library", - ENGINE_CMD_FLAG_STRING}, - {0, NULL, NULL, 0} -}; - -# ifndef OPENSSL_NO_RSA -/* Our internal RSA_METHOD that we provide pointers to */ -static RSA_METHOD atalla_rsa = { - "Atalla RSA method", - NULL, - NULL, - NULL, - NULL, - atalla_rsa_mod_exp, - atalla_mod_exp_mont, - NULL, - NULL, - 0, - NULL, - NULL, - NULL, - NULL -}; -# endif - -# ifndef OPENSSL_NO_DSA -/* Our internal DSA_METHOD that we provide pointers to */ -static DSA_METHOD atalla_dsa = { - "Atalla DSA method", - NULL, /* dsa_do_sign */ - NULL, /* dsa_sign_setup */ - NULL, /* dsa_do_verify */ - atalla_dsa_mod_exp, /* dsa_mod_exp */ - atalla_mod_exp_dsa, /* bn_mod_exp */ - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - NULL, /* dsa_paramgen */ - NULL /* dsa_keygen */ -}; -# endif - -# ifndef OPENSSL_NO_DH -/* Our internal DH_METHOD that we provide pointers to */ -static DH_METHOD atalla_dh = { - "Atalla DH method", - NULL, - NULL, - atalla_mod_exp_dh, - NULL, - NULL, - 0, - NULL, - NULL -}; -# endif - -/* Constants used when creating the ENGINE */ -static const char *engine_atalla_id = "atalla"; -static const char *engine_atalla_name = "Atalla hardware engine support"; - -/* - * This internal function is used by ENGINE_atalla() and possibly by the - * "dynamic" ENGINE support too - */ -static int bind_helper(ENGINE *e) -{ -# ifndef OPENSSL_NO_RSA - const RSA_METHOD *meth1; -# endif -# ifndef OPENSSL_NO_DSA - const DSA_METHOD *meth2; -# endif -# ifndef OPENSSL_NO_DH - const DH_METHOD *meth3; -# endif - if (!ENGINE_set_id(e, engine_atalla_id) || - !ENGINE_set_name(e, engine_atalla_name) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_RSA(e, &atalla_rsa) || -# endif -# ifndef OPENSSL_NO_DSA - !ENGINE_set_DSA(e, &atalla_dsa) || -# endif -# ifndef OPENSSL_NO_DH - !ENGINE_set_DH(e, &atalla_dh) || -# endif - !ENGINE_set_destroy_function(e, atalla_destroy) || - !ENGINE_set_init_function(e, atalla_init) || - !ENGINE_set_finish_function(e, atalla_finish) || - !ENGINE_set_ctrl_function(e, atalla_ctrl) || - !ENGINE_set_cmd_defns(e, atalla_cmd_defns)) - return 0; - -# ifndef OPENSSL_NO_RSA - /* - * We know that the "PKCS1_SSLeay()" functions hook properly to the - * atalla-specific mod_exp and mod_exp_crt so we use those functions. NB: - * We don't use ENGINE_openssl() or anything "more generic" because - * something like the RSAref code may not hook properly, and if you own - * one of these cards then you have the right to do RSA operations on it - * anyway! - */ - meth1 = RSA_PKCS1_SSLeay(); - atalla_rsa.rsa_pub_enc = meth1->rsa_pub_enc; - atalla_rsa.rsa_pub_dec = meth1->rsa_pub_dec; - atalla_rsa.rsa_priv_enc = meth1->rsa_priv_enc; - atalla_rsa.rsa_priv_dec = meth1->rsa_priv_dec; -# endif - -# ifndef OPENSSL_NO_DSA - /* - * Use the DSA_OpenSSL() method and just hook the mod_exp-ish bits. - */ - meth2 = DSA_OpenSSL(); - atalla_dsa.dsa_do_sign = meth2->dsa_do_sign; - atalla_dsa.dsa_sign_setup = meth2->dsa_sign_setup; - atalla_dsa.dsa_do_verify = meth2->dsa_do_verify; -# endif - -# ifndef OPENSSL_NO_DH - /* Much the same for Diffie-Hellman */ - meth3 = DH_OpenSSL(); - atalla_dh.generate_key = meth3->generate_key; - atalla_dh.compute_key = meth3->compute_key; -# endif - - /* Ensure the atalla error handling is set up */ - ERR_load_ATALLA_strings(); - return 1; -} - -# ifdef OPENSSL_NO_DYNAMIC_ENGINE -static ENGINE *engine_atalla(void) -{ - ENGINE *ret = ENGINE_new(); - if (!ret) - return NULL; - if (!bind_helper(ret)) { - ENGINE_free(ret); - return NULL; - } - return ret; -} - -void ENGINE_load_atalla(void) -{ - /* Copied from eng_[openssl|dyn].c */ - ENGINE *toadd = engine_atalla(); - if (!toadd) - return; - ENGINE_add(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -} -# endif - -/* - * This is a process-global DSO handle used for loading and unloading the - * Atalla library. NB: This is only set (or unset) during an init() or - * finish() call (reference counts permitting) and they're operating with - * global locks, so this should be thread-safe implicitly. - */ -static DSO *atalla_dso = NULL; - -/* - * These are the function pointers that are (un)set when the library has - * successfully (un)loaded. - */ -static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL; -static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL; -static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = - NULL; - -/* - * These are the static string constants for the DSO file name and the - * function symbol names to bind to. Regrettably, the DSO name on *nix - * appears to be "atasi.so" rather than something more consistent like - * "libatasi.so". At the time of writing, I'm not sure what the file name on - * win32 is but clearly native name translation is not possible (eg - * libatasi.so on *nix, and atasi.dll on win32). For the purposes of testing, - * I have created a symbollic link called "libatasi.so" so that we can use - * native name-translation - a better solution will be needed. - */ -static const char *ATALLA_LIBNAME = NULL; -static const char *get_ATALLA_LIBNAME(void) -{ - if (ATALLA_LIBNAME) - return ATALLA_LIBNAME; - return "atasi"; -} - -static void free_ATALLA_LIBNAME(void) -{ - OPENSSL_free(ATALLA_LIBNAME); - ATALLA_LIBNAME = NULL; -} - -static long set_ATALLA_LIBNAME(const char *name) -{ - free_ATALLA_LIBNAME(); - return (((ATALLA_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); -} - -static const char *ATALLA_F1 = "ASI_GetHardwareConfig"; -static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn"; -static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics"; - -/* Destructor (complements the "ENGINE_atalla()" constructor) */ -static int atalla_destroy(ENGINE *e) -{ - free_ATALLA_LIBNAME(); - /* - * Unload the atalla error strings so any error state including our - * functs or reasons won't lead to a segfault (they simply get displayed - * without corresponding string data because none will be found). - */ - ERR_unload_ATALLA_strings(); - return 1; -} - -/* (de)initialisation functions. */ -static int atalla_init(ENGINE *e) -{ - tfnASI_GetHardwareConfig *p1; - tfnASI_RSAPrivateKeyOpFn *p2; - tfnASI_GetPerformanceStatistics *p3; - /* - * Not sure of the origin of this magic value, but Ben's code had it and - * it seemed to have been working for a few people. :-) - */ - unsigned int config_buf[1024]; - - if (atalla_dso != NULL) { - ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_ALREADY_LOADED); - goto err; - } - /* - * Attempt to load libatasi.so/atasi.dll/whatever. Needs to be changed - * unfortunately because the Atalla drivers don't have standard library - * names that can be platform-translated well. - */ - /* - * TODO: Work out how to actually map to the names the Atalla drivers - * really use - for now a symbollic link needs to be created on the host - * system from libatasi.so to atasi.so on unix variants. - */ - atalla_dso = DSO_load(NULL, get_ATALLA_LIBNAME(), NULL, 0); - if (atalla_dso == NULL) { - ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED); - goto err; - } -#define BINDIT(t, name) (t *)DSO_bind_func(atalla_dso, name) - if ((p1 = BINDIT(tfnASI_GetHardwareConfig, ATALLA_F1)) == NULL - || (p2 = BINDIT(tfnASI_RSAPrivateKeyOpFn, ATALLA_F2)) == NULL - || (p3 = BINDIT(tfnASI_GetPerformanceStatistics, ATALLA_F3)) == NULL) { - ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED); - goto err; - } - /* Copy the pointers */ - p_Atalla_GetHardwareConfig = p1; - p_Atalla_RSAPrivateKeyOpFn = p2; - p_Atalla_GetPerformanceStatistics = p3; - /* - * Perform a basic test to see if there's actually any unit running. - */ - if (p1(0L, config_buf) != 0) { - ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_UNIT_FAILURE); - goto err; - } - /* Everything's fine. */ - return 1; - err: - DSO_free(atalla_dso); - atalla_dso = NULL; - p_Atalla_GetHardwareConfig = NULL; - p_Atalla_RSAPrivateKeyOpFn = NULL; - p_Atalla_GetPerformanceStatistics = NULL; - return 0; -} - -static int atalla_finish(ENGINE *e) -{ - free_ATALLA_LIBNAME(); - if (atalla_dso == NULL) { - ATALLAerr(ATALLA_F_ATALLA_FINISH, ATALLA_R_NOT_LOADED); - return 0; - } - if (!DSO_free(atalla_dso)) { - ATALLAerr(ATALLA_F_ATALLA_FINISH, ATALLA_R_UNIT_FAILURE); - return 0; - } - atalla_dso = NULL; - p_Atalla_GetHardwareConfig = NULL; - p_Atalla_RSAPrivateKeyOpFn = NULL; - p_Atalla_GetPerformanceStatistics = NULL; - return 1; -} - -static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) -{ - int initialised = ((atalla_dso == NULL) ? 0 : 1); - switch (cmd) { - case ATALLA_CMD_SO_PATH: - if (p == NULL) { - ATALLAerr(ATALLA_F_ATALLA_CTRL, ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - if (initialised) { - ATALLAerr(ATALLA_F_ATALLA_CTRL, ATALLA_R_ALREADY_LOADED); - return 0; - } - return set_ATALLA_LIBNAME((const char *)p); - default: - break; - } - ATALLAerr(ATALLA_F_ATALLA_CTRL, ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED); - return 0; -} - -static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx) -{ - /* - * I need somewhere to store temporary serialised values for use with the - * Atalla API calls. A neat cheat - I'll use BIGNUMs from the BN_CTX but - * access their arrays directly as byte arrays . This way I don't - * have to clean anything up. - */ - BIGNUM *modulus; - BIGNUM *exponent; - BIGNUM *argument; - BIGNUM *result; - RSAPrivateKey keydata; - int to_return, numbytes; - - modulus = exponent = argument = result = NULL; - to_return = 0; /* expect failure */ - - if (!atalla_dso) { - ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_NOT_LOADED); - goto err; - } - /* Prepare the params */ - BN_CTX_start(ctx); - modulus = BN_CTX_get(ctx); - exponent = BN_CTX_get(ctx); - argument = BN_CTX_get(ctx); - result = BN_CTX_get(ctx); - if (!result) { - ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_BN_CTX_FULL); - goto err; - } - if (!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) || - !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top)) { - ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_BN_EXPAND_FAIL); - goto err; - } - /* Prepare the key-data */ - memset(&keydata, 0, sizeof(keydata)); - numbytes = BN_num_bytes(m); - memset(exponent->d, 0, numbytes); - memset(modulus->d, 0, numbytes); - BN_bn2bin(p, (unsigned char *)exponent->d + numbytes - BN_num_bytes(p)); - BN_bn2bin(m, (unsigned char *)modulus->d + numbytes - BN_num_bytes(m)); - keydata.privateExponent.data = (unsigned char *)exponent->d; - keydata.privateExponent.len = numbytes; - keydata.modulus.data = (unsigned char *)modulus->d; - keydata.modulus.len = numbytes; - /* Prepare the argument */ - memset(argument->d, 0, numbytes); - memset(result->d, 0, numbytes); - BN_bn2bin(a, (unsigned char *)argument->d + numbytes - BN_num_bytes(a)); - /* Perform the operation */ - if (p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d, - (unsigned char *)argument->d, - keydata.modulus.len) != 0) { - ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_REQUEST_FAILED); - goto err; - } - /* Convert the response */ - BN_bin2bn((unsigned char *)result->d, numbytes, r); - to_return = 1; - err: - BN_CTX_end(ctx); - return to_return; -} - -# ifndef OPENSSL_NO_RSA -static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx) -{ - int to_return = 0; - - if (!atalla_dso) { - ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP, ATALLA_R_NOT_LOADED); - goto err; - } - if (!rsa->d || !rsa->n) { - ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP, - ATALLA_R_MISSING_KEY_COMPONENTS); - goto err; - } - to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx); - err: - return to_return; -} -# endif - -# ifndef OPENSSL_NO_DSA -/* - * This code was liberated and adapted from the commented-out code in - * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration (it - * doesn't have a CRT form for RSA), this function means that an Atalla - * system running with a DSA server certificate can handshake around 5 or 6 - * times faster/more than an equivalent system running with RSA. Just check - * out the "signs" statistics from the RSA and DSA parts of "openssl speed - * -engine atalla dsa1024 rsa1024". - */ -static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, - BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont) -{ - BIGNUM t; - int to_return = 0; - - BN_init(&t); - /* let rr = a1 ^ p1 mod m */ - if (!atalla_mod_exp(rr, a1, p1, m, ctx)) - goto end; - /* let t = a2 ^ p2 mod m */ - if (!atalla_mod_exp(&t, a2, p2, m, ctx)) - goto end; - /* let rr = rr * t mod m */ - if (!BN_mod_mul(rr, rr, &t, m, ctx)) - goto end; - to_return = 1; - end: - BN_free(&t); - return to_return; -} - -static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return atalla_mod_exp(r, a, p, m, ctx); -} -# endif - -# ifndef OPENSSL_NO_RSA -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return atalla_mod_exp(r, a, p, m, ctx); -} -# endif - -# ifndef OPENSSL_NO_DH -/* This function is aliased to mod_exp (with the dh and mont dropped). */ -static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r, - const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - return atalla_mod_exp(r, a, p, m, ctx); -} -# endif - -/* - * This stuff is needed if this ENGINE is being compiled into a - * self-contained shared-library. - */ -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -static int bind_fn(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, engine_atalla_id) != 0)) - return 0; - if (!bind_helper(e)) - return 0; - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() - IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) -# endif /* OPENSSL_NO_DYNAMIC_ENGINE */ -# endif /* !OPENSSL_NO_HW_ATALLA */ -#endif /* !OPENSSL_NO_HW */ diff --git a/engines/e_atalla.ec b/engines/e_atalla.ec deleted file mode 100644 index 1d735e1..0000000 --- a/engines/e_atalla.ec +++ /dev/null @@ -1 +0,0 @@ -L ATALLA e_atalla_err.h e_atalla_err.c diff --git a/engines/e_atalla_err.c b/engines/e_atalla_err.c deleted file mode 100644 index ff47322..0000000 --- a/engines/e_atalla_err.c +++ /dev/null @@ -1,145 +0,0 @@ -/* e_atalla_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -/* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. - */ - -#include -#include -#include "e_atalla_err.h" - -/* BEGIN ERROR CODES */ -#ifndef OPENSSL_NO_ERR - -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - -static ERR_STRING_DATA ATALLA_str_functs[] = { - {ERR_FUNC(ATALLA_F_ATALLA_CTRL), "ATALLA_CTRL"}, - {ERR_FUNC(ATALLA_F_ATALLA_FINISH), "ATALLA_FINISH"}, - {ERR_FUNC(ATALLA_F_ATALLA_INIT), "ATALLA_INIT"}, - {ERR_FUNC(ATALLA_F_ATALLA_MOD_EXP), "ATALLA_MOD_EXP"}, - {ERR_FUNC(ATALLA_F_ATALLA_RSA_MOD_EXP), "ATALLA_RSA_MOD_EXP"}, - {0, NULL} -}; - -static ERR_STRING_DATA ATALLA_str_reasons[] = { - {ERR_REASON(ATALLA_R_ALREADY_LOADED), "already loaded"}, - {ERR_REASON(ATALLA_R_BN_CTX_FULL), "bn ctx full"}, - {ERR_REASON(ATALLA_R_BN_EXPAND_FAIL), "bn expand fail"}, - {ERR_REASON(ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED), - "ctrl command not implemented"}, - {ERR_REASON(ATALLA_R_MISSING_KEY_COMPONENTS), "missing key components"}, - {ERR_REASON(ATALLA_R_NOT_LOADED), "not loaded"}, - {ERR_REASON(ATALLA_R_REQUEST_FAILED), "request failed"}, - {ERR_REASON(ATALLA_R_UNIT_FAILURE), "unit failure"}, - {0, NULL} -}; - -#endif - -#ifdef ATALLA_LIB_NAME -static ERR_STRING_DATA ATALLA_lib_name[] = { - {0, ATALLA_LIB_NAME}, - {0, NULL} -}; -#endif - -static int ATALLA_lib_error_code = 0; -static int ATALLA_error_init = 1; - -static void ERR_load_ATALLA_strings(void) -{ - if (ATALLA_lib_error_code == 0) - ATALLA_lib_error_code = ERR_get_next_error_library(); - - if (ATALLA_error_init) { - ATALLA_error_init = 0; -#ifndef OPENSSL_NO_ERR - ERR_load_strings(ATALLA_lib_error_code, ATALLA_str_functs); - ERR_load_strings(ATALLA_lib_error_code, ATALLA_str_reasons); -#endif - -#ifdef ATALLA_LIB_NAME - ATALLA_lib_name->error = ERR_PACK(ATALLA_lib_error_code, 0, 0); - ERR_load_strings(0, ATALLA_lib_name); -#endif - } -} - -static void ERR_unload_ATALLA_strings(void) -{ - if (ATALLA_error_init == 0) { -#ifndef OPENSSL_NO_ERR - ERR_unload_strings(ATALLA_lib_error_code, ATALLA_str_functs); - ERR_unload_strings(ATALLA_lib_error_code, ATALLA_str_reasons); -#endif - -#ifdef ATALLA_LIB_NAME - ERR_unload_strings(0, ATALLA_lib_name); -#endif - ATALLA_error_init = 1; - } -} - -static void ERR_ATALLA_error(int function, int reason, char *file, int line) -{ - if (ATALLA_lib_error_code == 0) - ATALLA_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(ATALLA_lib_error_code, function, reason, file, line); -} diff --git a/engines/e_atalla_err.h b/engines/e_atalla_err.h deleted file mode 100644 index 7b71eff..0000000 --- a/engines/e_atalla_err.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#ifndef HEADER_ATALLA_ERR_H -# define HEADER_ATALLA_ERR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -static void ERR_load_ATALLA_strings(void); -static void ERR_unload_ATALLA_strings(void); -static void ERR_ATALLA_error(int function, int reason, char *file, int line); -# define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the ATALLA functions. */ - -/* Function codes. */ -# define ATALLA_F_ATALLA_CTRL 100 -# define ATALLA_F_ATALLA_FINISH 101 -# define ATALLA_F_ATALLA_INIT 102 -# define ATALLA_F_ATALLA_MOD_EXP 103 -# define ATALLA_F_ATALLA_RSA_MOD_EXP 104 - -/* Reason codes. */ -# define ATALLA_R_ALREADY_LOADED 100 -# define ATALLA_R_BN_CTX_FULL 101 -# define ATALLA_R_BN_EXPAND_FAIL 102 -# define ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 -# define ATALLA_R_MISSING_KEY_COMPONENTS 104 -# define ATALLA_R_NOT_LOADED 105 -# define ATALLA_R_REQUEST_FAILED 106 -# define ATALLA_R_UNIT_FAILURE 107 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/engines/e_cswift.c b/engines/e_cswift.c deleted file mode 100644 index 5553794..0000000 --- a/engines/e_cswift.c +++ /dev/null @@ -1,1081 +0,0 @@ -/* crypto/engine/hw_cswift.c */ -/* - * Written by Geoff Thorpe (geoff at geoffthorpe.net) for the OpenSSL project - * 2000. - */ -/* ==================================================================== - * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_RSA -# include -#endif -#ifndef OPENSSL_NO_DSA -# include -#endif -#ifndef OPENSSL_NO_DH -# include -#endif -#include -#include - -#ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_CSWIFT - -/* - * Attribution notice: Rainbow have generously allowed me to reproduce the - * necessary definitions here from their API. This means the support can - * build independently of whether application builders have the API or - * hardware. This will allow developers to easily produce software that has - * latent hardware support for any users that have accelerators installed, - * without the developers themselves needing anything extra. I have only - * clipped the parts from the CryptoSwift header files that are (or seem) - * relevant to the CryptoSwift support code. This is simply to keep the file - * sizes reasonable. [Geoff] - */ -# ifdef FLAT_INC -# include "cswift.h" -# else -# include "vendor_defns/cswift.h" -# endif - -# define CSWIFT_LIB_NAME "cswift engine" -# include "e_cswift_err.c" - -# define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) - -static int cswift_destroy(ENGINE *e); -static int cswift_init(ENGINE *e); -static int cswift_finish(ENGINE *e); -static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)); -# ifndef OPENSSL_NO_RSA -static int cswift_bn_32copy(SW_LARGENUMBER *out, const BIGNUM *in); -# endif - -/* BIGNUM stuff */ -static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -# ifndef OPENSSL_NO_RSA -static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *q, const BIGNUM *dmp1, - const BIGNUM *dmq1, const BIGNUM *iqmp, - BN_CTX *ctx); -# endif - -# ifndef OPENSSL_NO_RSA -/* RSA stuff */ -static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx); -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -# ifndef OPENSSL_NO_DSA -/* DSA stuff */ -static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, - DSA *dsa); -static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, DSA *dsa); -# endif - -# ifndef OPENSSL_NO_DH -/* DH stuff */ -/* This function is alised to mod_exp (with the DH and mont dropped). */ -static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r, - const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); -# endif - -/* RAND stuff */ -static int cswift_rand_bytes(unsigned char *buf, int num); -static int cswift_rand_status(void); - -/* The definitions for control commands specific to this engine */ -# define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE -static const ENGINE_CMD_DEFN cswift_cmd_defns[] = { - {CSWIFT_CMD_SO_PATH, - "SO_PATH", - "Specifies the path to the 'cswift' shared library", - ENGINE_CMD_FLAG_STRING}, - {0, NULL, NULL, 0} -}; - -# ifndef OPENSSL_NO_RSA -/* Our internal RSA_METHOD that we provide pointers to */ -static RSA_METHOD cswift_rsa = { - "CryptoSwift RSA method", - NULL, - NULL, - NULL, - NULL, - cswift_rsa_mod_exp, - cswift_mod_exp_mont, - NULL, - NULL, - 0, - NULL, - NULL, - NULL, - NULL -}; -# endif - -# ifndef OPENSSL_NO_DSA -/* Our internal DSA_METHOD that we provide pointers to */ -static DSA_METHOD cswift_dsa = { - "CryptoSwift DSA method", - cswift_dsa_sign, - NULL, /* dsa_sign_setup */ - cswift_dsa_verify, - NULL, /* dsa_mod_exp */ - NULL, /* bn_mod_exp */ - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - NULL, /* dsa_paramgen */ - NULL /* dsa_keygen */ -}; -# endif - -# ifndef OPENSSL_NO_DH -/* Our internal DH_METHOD that we provide pointers to */ -static DH_METHOD cswift_dh = { - "CryptoSwift DH method", - NULL, - NULL, - cswift_mod_exp_dh, - NULL, - NULL, - 0, - NULL, - NULL -}; -# endif - -static RAND_METHOD cswift_random = { - /* "CryptoSwift RAND method", */ - NULL, - cswift_rand_bytes, - NULL, - NULL, - cswift_rand_bytes, - cswift_rand_status, -}; - -/* Constants used when creating the ENGINE */ -static const char *engine_cswift_id = "cswift"; -static const char *engine_cswift_name = "CryptoSwift hardware engine support"; - -/* - * This internal function is used by ENGINE_cswift() and possibly by the - * "dynamic" ENGINE support too - */ -static int bind_helper(ENGINE *e) -{ -# ifndef OPENSSL_NO_RSA - const RSA_METHOD *meth1; -# endif -# ifndef OPENSSL_NO_DH - const DH_METHOD *meth2; -# endif - if (!ENGINE_set_id(e, engine_cswift_id) || - !ENGINE_set_name(e, engine_cswift_name) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_RSA(e, &cswift_rsa) || -# endif -# ifndef OPENSSL_NO_DSA - !ENGINE_set_DSA(e, &cswift_dsa) || -# endif -# ifndef OPENSSL_NO_DH - !ENGINE_set_DH(e, &cswift_dh) || -# endif - !ENGINE_set_RAND(e, &cswift_random) || - !ENGINE_set_destroy_function(e, cswift_destroy) || - !ENGINE_set_init_function(e, cswift_init) || - !ENGINE_set_finish_function(e, cswift_finish) || - !ENGINE_set_ctrl_function(e, cswift_ctrl) || - !ENGINE_set_cmd_defns(e, cswift_cmd_defns)) - return 0; - -# ifndef OPENSSL_NO_RSA - /* - * We know that the "PKCS1_SSLeay()" functions hook properly to the - * cswift-specific mod_exp and mod_exp_crt so we use those functions. NB: - * We don't use ENGINE_openssl() or anything "more generic" because - * something like the RSAref code may not hook properly, and if you own - * one of these cards then you have the right to do RSA operations on it - * anyway! - */ - meth1 = RSA_PKCS1_SSLeay(); - cswift_rsa.rsa_pub_enc = meth1->rsa_pub_enc; - cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec; - cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc; - cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec; -# endif - -# ifndef OPENSSL_NO_DH - /* Much the same for Diffie-Hellman */ - meth2 = DH_OpenSSL(); - cswift_dh.generate_key = meth2->generate_key; - cswift_dh.compute_key = meth2->compute_key; -# endif - - /* Ensure the cswift error handling is set up */ - ERR_load_CSWIFT_strings(); - return 1; -} - -# ifdef OPENSSL_NO_DYNAMIC_ENGINE -static ENGINE *engine_cswift(void) -{ - ENGINE *ret = ENGINE_new(); - if (!ret) - return NULL; - if (!bind_helper(ret)) { - ENGINE_free(ret); - return NULL; - } - return ret; -} - -void ENGINE_load_cswift(void) -{ - /* Copied from eng_[openssl|dyn].c */ - ENGINE *toadd = engine_cswift(); - if (!toadd) - return; - ENGINE_add(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -} -# endif - -/* - * This is a process-global DSO handle used for loading and unloading the - * CryptoSwift library. NB: This is only set (or unset) during an init() or - * finish() call (reference counts permitting) and they're operating with - * global locks, so this should be thread-safe implicitly. - */ -static DSO *cswift_dso = NULL; - -/* - * These are the function pointers that are (un)set when the library has - * successfully (un)loaded. - */ -t_swAcquireAccContext *p_CSwift_AcquireAccContext = NULL; -t_swAttachKeyParam *p_CSwift_AttachKeyParam = NULL; -t_swSimpleRequest *p_CSwift_SimpleRequest = NULL; -t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL; - -/* Used in the DSO operations. */ -static const char *CSWIFT_LIBNAME = NULL; -static const char *get_CSWIFT_LIBNAME(void) -{ - if (CSWIFT_LIBNAME) - return CSWIFT_LIBNAME; - return "swift"; -} - -static void free_CSWIFT_LIBNAME(void) -{ - OPENSSL_free(CSWIFT_LIBNAME); - CSWIFT_LIBNAME = NULL; -} - -static long set_CSWIFT_LIBNAME(const char *name) -{ - free_CSWIFT_LIBNAME(); - return (((CSWIFT_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); -} - -static const char *CSWIFT_F1 = "swAcquireAccContext"; -static const char *CSWIFT_F2 = "swAttachKeyParam"; -static const char *CSWIFT_F3 = "swSimpleRequest"; -static const char *CSWIFT_F4 = "swReleaseAccContext"; - -/* - * CryptoSwift library functions and mechanics - these are used by the - * higher-level functions further down. NB: As and where there's no error - * checking, take a look lower down where these functions are called, the - * checking and error handling is probably down there. - */ - -/* utility function to obtain a context */ -static int get_context(SW_CONTEXT_HANDLE *hac) -{ - SW_STATUS status; - - status = p_CSwift_AcquireAccContext(hac); - if (status != SW_OK) - return 0; - return 1; -} - -/* similarly to release one. */ -static void release_context(SW_CONTEXT_HANDLE hac) -{ - p_CSwift_ReleaseAccContext(hac); -} - -/* Destructor (complements the "ENGINE_cswift()" constructor) */ -static int cswift_destroy(ENGINE *e) -{ - free_CSWIFT_LIBNAME(); - ERR_unload_CSWIFT_strings(); - return 1; -} - -/* (de)initialisation functions. */ -static int cswift_init(ENGINE *e) -{ - SW_CONTEXT_HANDLE hac; - t_swAcquireAccContext *p1; - t_swAttachKeyParam *p2; - t_swSimpleRequest *p3; - t_swReleaseAccContext *p4; - - if (cswift_dso != NULL) { - CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_ALREADY_LOADED); - goto err; - } - /* Attempt to load libswift.so/swift.dll/whatever. */ - cswift_dso = DSO_load(NULL, get_CSWIFT_LIBNAME(), NULL, 0); - if (cswift_dso == NULL) { - CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED); - goto err; - } - -#define BINDIT(t, name) (t *)DSO_bind_func(cswift_dso, name) - if ((p1 = BINDIT(t_swAcquireAccContext, CSWIFT_F1)) == NULL - || (p2 = BINDIT(t_swAttachKeyParam, CSWIFT_F2)) == NULL - || (p3 = BINDIT(t_swSimpleRequest *) DSO_bind_func(cswift_dso, CSWIFT_F3)) == NULL - || (p4 = BINDIT(t_swReleaseAccContext *) DSO_bind_func(cswift_dso, CSWIFT_F4)) == NULL) { - CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED); - goto err; - } - /* Copy the pointers */ - p_CSwift_AcquireAccContext = p1; - p_CSwift_AttachKeyParam = p2; - p_CSwift_SimpleRequest = p3; - p_CSwift_ReleaseAccContext = p4; - /* - * Try and get a context - if not, we may have a DSO but no accelerator! - */ - if (!get_context(&hac)) { - CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_UNIT_FAILURE); - goto err; - } - release_context(hac); - /* Everything's fine. */ - return 1; - err: - DSO_free(cswift_dso); - cswift_dso = NULL; - p_CSwift_AcquireAccContext = NULL; - p_CSwift_AttachKeyParam = NULL; - p_CSwift_SimpleRequest = NULL; - p_CSwift_ReleaseAccContext = NULL; - return 0; -} - -static int cswift_finish(ENGINE *e) -{ - free_CSWIFT_LIBNAME(); - if (cswift_dso == NULL) { - CSWIFTerr(CSWIFT_F_CSWIFT_FINISH, CSWIFT_R_NOT_LOADED); - return 0; - } - if (!DSO_free(cswift_dso)) { - CSWIFTerr(CSWIFT_F_CSWIFT_FINISH, CSWIFT_R_UNIT_FAILURE); - return 0; - } - cswift_dso = NULL; - p_CSwift_AcquireAccContext = NULL; - p_CSwift_AttachKeyParam = NULL; - p_CSwift_SimpleRequest = NULL; - p_CSwift_ReleaseAccContext = NULL; - return 1; -} - -static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) -{ - int initialised = ((cswift_dso == NULL) ? 0 : 1); - switch (cmd) { - case CSWIFT_CMD_SO_PATH: - if (p == NULL) { - CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - if (initialised) { - CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_ALREADY_LOADED); - return 0; - } - return set_CSWIFT_LIBNAME((const char *)p); - default: - break; - } - CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED); - return 0; -} - -/* Un petit mod_exp */ -static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx) -{ - /* - * I need somewhere to store temporary serialised values for use with the - * CryptoSwift API calls. A neat cheat - I'll use BIGNUMs from the BN_CTX - * but access their arrays directly as byte arrays . This way I - * don't have to clean anything up. - */ - BIGNUM *modulus; - BIGNUM *exponent; - BIGNUM *argument; - BIGNUM *result; - SW_STATUS sw_status; - SW_LARGENUMBER arg, res; - SW_PARAM sw_param; - SW_CONTEXT_HANDLE hac; - int to_return, acquired; - - modulus = exponent = argument = result = NULL; - to_return = 0; /* expect failure */ - acquired = 0; - - if (!get_context(&hac)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP, CSWIFT_R_UNIT_FAILURE); - goto err; - } - acquired = 1; - /* Prepare the params */ - BN_CTX_start(ctx); - modulus = BN_CTX_get(ctx); - exponent = BN_CTX_get(ctx); - argument = BN_CTX_get(ctx); - result = BN_CTX_get(ctx); - if (!result) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP, CSWIFT_R_BN_CTX_FULL); - goto err; - } - if (!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, p->top) || - !bn_wexpand(argument, a->top) || !bn_wexpand(result, m->top)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - sw_param.type = SW_ALG_EXP; - sw_param.up.exp.modulus.nbytes = BN_bn2bin(m, - (unsigned char *)modulus->d); - sw_param.up.exp.modulus.value = (unsigned char *)modulus->d; - sw_param.up.exp.exponent.nbytes = BN_bn2bin(p, - (unsigned char *)exponent->d); - sw_param.up.exp.exponent.value = (unsigned char *)exponent->d; - /* Attach the key params */ - sw_status = p_CSwift_AttachKeyParam(hac, &sw_param); - switch (sw_status) { - case SW_OK: - break; - case SW_ERR_INPUT_SIZE: - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP, CSWIFT_R_BAD_KEY_SIZE); - goto err; - default: - { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - } - goto err; - } - /* Prepare the argument and response */ - arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d); - arg.value = (unsigned char *)argument->d; - res.nbytes = BN_num_bytes(m); - memset(result->d, 0, res.nbytes); - res.value = (unsigned char *)result->d; - /* Perform the operation */ - if ((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP, &arg, 1, - &res, 1)) != SW_OK) { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - goto err; - } - /* Convert the response */ - BN_bin2bn((unsigned char *)result->d, res.nbytes, r); - to_return = 1; - err: - if (acquired) - release_context(hac); - BN_CTX_end(ctx); - return to_return; -} - -# ifndef OPENSSL_NO_RSA -int cswift_bn_32copy(SW_LARGENUMBER *out, const BIGNUM *in) -{ - int mod; - int numbytes = BN_num_bytes(in); - - mod = 0; - while (((out->nbytes = (numbytes + mod)) % 32)) { - mod++; - } - out->value = OPENSSL_malloc(out->nbytes); - if (!out->value) { - return 0; - } - BN_bn2bin(in, &out->value[mod]); - if (mod) - memset(out->value, 0, mod); - - return 1; -} -# endif - -# ifndef OPENSSL_NO_RSA -/* Un petit mod_exp chinois */ -static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *q, const BIGNUM *dmp1, - const BIGNUM *dmq1, const BIGNUM *iqmp, - BN_CTX *ctx) -{ - SW_STATUS sw_status; - SW_LARGENUMBER arg, res; - SW_PARAM sw_param; - SW_CONTEXT_HANDLE hac; - BIGNUM *result = NULL; - BIGNUM *argument = NULL; - int to_return = 0; /* expect failure */ - int acquired = 0; - - sw_param.up.crt.p.value = NULL; - sw_param.up.crt.q.value = NULL; - sw_param.up.crt.dmp1.value = NULL; - sw_param.up.crt.dmq1.value = NULL; - sw_param.up.crt.iqmp.value = NULL; - - if (!get_context(&hac)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_UNIT_FAILURE); - goto err; - } - acquired = 1; - - /* Prepare the params */ - argument = BN_new(); - result = BN_new(); - if (!result || !argument) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_CTX_FULL); - goto err; - } - - sw_param.type = SW_ALG_CRT; - /************************************************************************/ - /* - * 04/02/2003 - */ - /* - * Modified by Frederic Giudicelli (deny-all.com) to overcome the - */ - /* - * limitation of cswift with values not a multiple of 32 - */ - /************************************************************************/ - if (!cswift_bn_32copy(&sw_param.up.crt.p, p)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - if (!cswift_bn_32copy(&sw_param.up.crt.q, q)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - if (!cswift_bn_32copy(&sw_param.up.crt.dmp1, dmp1)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - if (!cswift_bn_32copy(&sw_param.up.crt.dmq1, dmq1)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - if (!cswift_bn_32copy(&sw_param.up.crt.iqmp, iqmp)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - if (!bn_wexpand(argument, a->top) || !bn_wexpand(result, p->top + q->top)) { - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - - /* Attach the key params */ - sw_status = p_CSwift_AttachKeyParam(hac, &sw_param); - switch (sw_status) { - case SW_OK: - break; - case SW_ERR_INPUT_SIZE: - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_BAD_KEY_SIZE); - goto err; - default: - { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - } - goto err; - } - /* Prepare the argument and response */ - arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d); - arg.value = (unsigned char *)argument->d; - res.nbytes = 2 * BN_num_bytes(p); - memset(result->d, 0, res.nbytes); - res.value = (unsigned char *)result->d; - /* Perform the operation */ - if ((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP_CRT, &arg, 1, - &res, 1)) != SW_OK) { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - goto err; - } - /* Convert the response */ - BN_bin2bn((unsigned char *)result->d, res.nbytes, r); - to_return = 1; - err: - OPENSSL_free(sw_param.up.crt.p.value); - OPENSSL_free(sw_param.up.crt.q.value); - OPENSSL_free(sw_param.up.crt.dmp1.value); - OPENSSL_free(sw_param.up.crt.dmq1.value); - OPENSSL_free(sw_param.up.crt.iqmp.value); - BN_free(result); - BN_free(argument); - if (acquired) - release_context(hac); - return to_return; -} -# endif - -# ifndef OPENSSL_NO_RSA -static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx) -{ - int to_return = 0; - const RSA_METHOD *def_rsa_method; - - if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) { - CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP, - CSWIFT_R_MISSING_KEY_COMPONENTS); - goto err; - } - - /* Try the limits of RSA (2048 bits) */ - if (BN_num_bytes(rsa->p) > 128 || - BN_num_bytes(rsa->q) > 128 || - BN_num_bytes(rsa->dmp1) > 128 || - BN_num_bytes(rsa->dmq1) > 128 || BN_num_bytes(rsa->iqmp) > 128) { -# ifdef RSA_NULL - def_rsa_method = RSA_null_method(); -# else - def_rsa_method = RSA_PKCS1_SSLeay(); -# endif - if (def_rsa_method) - return def_rsa_method->rsa_mod_exp(r0, I, rsa, ctx); - } - - to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1, - rsa->dmq1, rsa->iqmp, ctx); - err: - return to_return; -} - -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - const RSA_METHOD *def_rsa_method; - - /* Try the limits of RSA (2048 bits) */ - if (BN_num_bytes(r) > 256 || - BN_num_bytes(a) > 256 || BN_num_bytes(m) > 256) { -# ifdef RSA_NULL - def_rsa_method = RSA_null_method(); -# else - def_rsa_method = RSA_PKCS1_SSLeay(); -# endif - if (def_rsa_method) - return def_rsa_method->bn_mod_exp(r, a, p, m, ctx, m_ctx); - } - - return cswift_mod_exp(r, a, p, m, ctx); -} -# endif /* OPENSSL_NO_RSA */ - -# ifndef OPENSSL_NO_DSA -static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa) -{ - SW_CONTEXT_HANDLE hac; - SW_PARAM sw_param; - SW_STATUS sw_status; - SW_LARGENUMBER arg, res; - BN_CTX *ctx; - BIGNUM *dsa_p = NULL; - BIGNUM *dsa_q = NULL; - BIGNUM *dsa_g = NULL; - BIGNUM *dsa_key = NULL; - BIGNUM *result = NULL; - DSA_SIG *to_return = NULL; - int acquired = 0; - - if ((ctx = BN_CTX_new()) == NULL) - goto err; - if (!get_context(&hac)) { - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN, CSWIFT_R_UNIT_FAILURE); - goto err; - } - acquired = 1; - /* Prepare the params */ - BN_CTX_start(ctx); - dsa_p = BN_CTX_get(ctx); - dsa_q = BN_CTX_get(ctx); - dsa_g = BN_CTX_get(ctx); - dsa_key = BN_CTX_get(ctx); - result = BN_CTX_get(ctx); - if (!result) { - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN, CSWIFT_R_BN_CTX_FULL); - goto err; - } - if (!bn_wexpand(dsa_p, dsa->p->top) || - !bn_wexpand(dsa_q, dsa->q->top) || - !bn_wexpand(dsa_g, dsa->g->top) || - !bn_wexpand(dsa_key, dsa->priv_key->top) || - !bn_wexpand(result, dsa->p->top)) { - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - sw_param.type = SW_ALG_DSA; - sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p, (unsigned char *)dsa_p->d); - sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d; - sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q, (unsigned char *)dsa_q->d); - sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d; - sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g, (unsigned char *)dsa_g->d); - sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d; - sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->priv_key, - (unsigned char *)dsa_key->d); - sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d; - /* Attach the key params */ - sw_status = p_CSwift_AttachKeyParam(hac, &sw_param); - switch (sw_status) { - case SW_OK: - break; - case SW_ERR_INPUT_SIZE: - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN, CSWIFT_R_BAD_KEY_SIZE); - goto err; - default: - { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - } - goto err; - } - /* Prepare the argument and response */ - arg.nbytes = dlen; - arg.value = (unsigned char *)dgst; - res.nbytes = BN_num_bytes(dsa->p); - memset(result->d, 0, res.nbytes); - res.value = (unsigned char *)result->d; - /* Perform the operation */ - sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_SIGN, &arg, 1, - &res, 1); - if (sw_status != SW_OK) { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - goto err; - } - /* Convert the response */ - if ((to_return = DSA_SIG_new()) == NULL) - goto err; - to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL); - to_return->s = BN_bin2bn((unsigned char *)result->d + 20, 20, NULL); - - err: - if (acquired) - release_context(hac); - if (ctx) - BN_CTX_end(ctx); - BN_CTX_free(ctx); - return to_return; -} - -static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, DSA *dsa) -{ - SW_CONTEXT_HANDLE hac; - SW_PARAM sw_param; - SW_STATUS sw_status; - SW_LARGENUMBER arg[2], res; - unsigned long sig_result; - BN_CTX *ctx; - BIGNUM *dsa_p = NULL; - BIGNUM *dsa_q = NULL; - BIGNUM *dsa_g = NULL; - BIGNUM *dsa_key = NULL; - BIGNUM *argument = NULL; - int to_return = -1; - int acquired = 0; - - if ((ctx = BN_CTX_new()) == NULL) - goto err; - if (!get_context(&hac)) { - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY, CSWIFT_R_UNIT_FAILURE); - goto err; - } - acquired = 1; - /* Prepare the params */ - BN_CTX_start(ctx); - dsa_p = BN_CTX_get(ctx); - dsa_q = BN_CTX_get(ctx); - dsa_g = BN_CTX_get(ctx); - dsa_key = BN_CTX_get(ctx); - argument = BN_CTX_get(ctx); - if (!argument) { - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY, CSWIFT_R_BN_CTX_FULL); - goto err; - } - if (!bn_wexpand(dsa_p, dsa->p->top) || - !bn_wexpand(dsa_q, dsa->q->top) || - !bn_wexpand(dsa_g, dsa->g->top) || - !bn_wexpand(dsa_key, dsa->pub_key->top) || - !bn_wexpand(argument, 40)) { - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY, CSWIFT_R_BN_EXPAND_FAIL); - goto err; - } - sw_param.type = SW_ALG_DSA; - sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p, (unsigned char *)dsa_p->d); - sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d; - sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q, (unsigned char *)dsa_q->d); - sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d; - sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g, (unsigned char *)dsa_g->d); - sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d; - sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->pub_key, - (unsigned char *)dsa_key->d); - sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d; - /* Attach the key params */ - sw_status = p_CSwift_AttachKeyParam(hac, &sw_param); - switch (sw_status) { - case SW_OK: - break; - case SW_ERR_INPUT_SIZE: - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY, CSWIFT_R_BAD_KEY_SIZE); - goto err; - default: - { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - } - goto err; - } - /* Prepare the argument and response */ - arg[0].nbytes = dgst_len; - arg[0].value = (unsigned char *)dgst; - arg[1].nbytes = 40; - arg[1].value = (unsigned char *)argument->d; - memset(arg[1].value, 0, 40); - BN_bn2bin(sig->r, arg[1].value + 20 - BN_num_bytes(sig->r)); - BN_bn2bin(sig->s, arg[1].value + 40 - BN_num_bytes(sig->s)); - res.nbytes = 4; /* unsigned long */ - res.value = (unsigned char *)(&sig_result); - /* Perform the operation */ - sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_VERIFY, arg, 2, - &res, 1); - if (sw_status != SW_OK) { - char tmpbuf[DECIMAL_SIZE(sw_status) + 1]; - CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", sw_status); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - goto err; - } - /* Convert the response */ - to_return = ((sig_result == 0) ? 0 : 1); - - err: - if (acquired) - release_context(hac); - if (ctx) - BN_CTX_end(ctx); - BN_CTX_free(ctx); - return to_return; -} -# endif - -# ifndef OPENSSL_NO_DH -/* This function is aliased to mod_exp (with the dh and mont dropped). */ -static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r, - const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - return cswift_mod_exp(r, a, p, m, ctx); -} -# endif - -/* Random bytes are good */ -static int cswift_rand_bytes(unsigned char *buf, int num) -{ - SW_CONTEXT_HANDLE hac; - SW_STATUS swrc; - SW_LARGENUMBER largenum; - int acquired = 0; - int to_return = 0; /* assume failure */ - unsigned char buf32[1024]; - - if (!get_context(&hac)) { - CSWIFTerr(CSWIFT_F_CSWIFT_RAND_BYTES, CSWIFT_R_UNIT_FAILURE); - goto err; - } - acquired = 1; - - /************************************************************************/ - /* - * 04/02/2003 - */ - /* - * Modified by Frederic Giudicelli (deny-all.com) to overcome the - */ - /* - * limitation of cswift with values not a multiple of 32 - */ - /************************************************************************/ - - while (num >= (int)sizeof(buf32)) { - largenum.value = buf; - largenum.nbytes = sizeof(buf32); - /*- - * tell CryptoSwift how many bytes we want and where we want it. - * Note: - CryptoSwift cannot do more than 4096 bytes at a time. - * - CryptoSwift can only do multiple of 32-bits. - */ - swrc = - p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1); - if (swrc != SW_OK) { - char tmpbuf[20]; - CSWIFTerr(CSWIFT_F_CSWIFT_RAND_BYTES, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", swrc); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - goto err; - } - buf += sizeof(buf32); - num -= sizeof(buf32); - } - if (num) { - largenum.nbytes = sizeof(buf32); - largenum.value = buf32; - swrc = - p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1); - if (swrc != SW_OK) { - char tmpbuf[20]; - CSWIFTerr(CSWIFT_F_CSWIFT_RAND_BYTES, CSWIFT_R_REQUEST_FAILED); - sprintf(tmpbuf, "%ld", swrc); - ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf); - goto err; - } - memcpy(buf, largenum.value, num); - } - - to_return = 1; /* success */ - err: - if (acquired) - release_context(hac); - - return to_return; -} - -static int cswift_rand_status(void) -{ - return 1; -} - -/* - * This stuff is needed if this ENGINE is being compiled into a - * self-contained shared-library. - */ -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -static int bind_fn(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, engine_cswift_id) != 0)) - return 0; - if (!bind_helper(e)) - return 0; - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() - IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) -# endif /* OPENSSL_NO_DYNAMIC_ENGINE */ -# endif /* !OPENSSL_NO_HW_CSWIFT */ -#endif /* !OPENSSL_NO_HW */ diff --git a/engines/e_cswift.ec b/engines/e_cswift.ec deleted file mode 100644 index a7f9d11..0000000 --- a/engines/e_cswift.ec +++ /dev/null @@ -1 +0,0 @@ -L CSWIFT e_cswift_err.h e_cswift_err.c diff --git a/engines/e_cswift_err.c b/engines/e_cswift_err.c deleted file mode 100644 index f8a2cbb..0000000 --- a/engines/e_cswift_err.c +++ /dev/null @@ -1,150 +0,0 @@ -/* e_cswift_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -/* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. - */ - -#include -#include -#include "e_cswift_err.h" - -/* BEGIN ERROR CODES */ -#ifndef OPENSSL_NO_ERR - -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - -static ERR_STRING_DATA CSWIFT_str_functs[] = { - {ERR_FUNC(CSWIFT_F_CSWIFT_CTRL), "CSWIFT_CTRL"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_DSA_SIGN), "CSWIFT_DSA_SIGN"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_DSA_VERIFY), "CSWIFT_DSA_VERIFY"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_FINISH), "CSWIFT_FINISH"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_INIT), "CSWIFT_INIT"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_MOD_EXP), "CSWIFT_MOD_EXP"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_MOD_EXP_CRT), "CSWIFT_MOD_EXP_CRT"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_RAND_BYTES), "CSWIFT_RAND_BYTES"}, - {ERR_FUNC(CSWIFT_F_CSWIFT_RSA_MOD_EXP), "CSWIFT_RSA_MOD_EXP"}, - {0, NULL} -}; - -static ERR_STRING_DATA CSWIFT_str_reasons[] = { - {ERR_REASON(CSWIFT_R_ALREADY_LOADED), "already loaded"}, - {ERR_REASON(CSWIFT_R_BAD_KEY_SIZE), "bad key size"}, - {ERR_REASON(CSWIFT_R_BN_CTX_FULL), "bn ctx full"}, - {ERR_REASON(CSWIFT_R_BN_EXPAND_FAIL), "bn expand fail"}, - {ERR_REASON(CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED), - "ctrl command not implemented"}, - {ERR_REASON(CSWIFT_R_MISSING_KEY_COMPONENTS), "missing key components"}, - {ERR_REASON(CSWIFT_R_NOT_LOADED), "not loaded"}, - {ERR_REASON(CSWIFT_R_REQUEST_FAILED), "request failed"}, - {ERR_REASON(CSWIFT_R_UNIT_FAILURE), "unit failure"}, - {0, NULL} -}; - -#endif - -#ifdef CSWIFT_LIB_NAME -static ERR_STRING_DATA CSWIFT_lib_name[] = { - {0, CSWIFT_LIB_NAME}, - {0, NULL} -}; -#endif - -static int CSWIFT_lib_error_code = 0; -static int CSWIFT_error_init = 1; - -static void ERR_load_CSWIFT_strings(void) -{ - if (CSWIFT_lib_error_code == 0) - CSWIFT_lib_error_code = ERR_get_next_error_library(); - - if (CSWIFT_error_init) { - CSWIFT_error_init = 0; -#ifndef OPENSSL_NO_ERR - ERR_load_strings(CSWIFT_lib_error_code, CSWIFT_str_functs); - ERR_load_strings(CSWIFT_lib_error_code, CSWIFT_str_reasons); -#endif - -#ifdef CSWIFT_LIB_NAME - CSWIFT_lib_name->error = ERR_PACK(CSWIFT_lib_error_code, 0, 0); - ERR_load_strings(0, CSWIFT_lib_name); -#endif - } -} - -static void ERR_unload_CSWIFT_strings(void) -{ - if (CSWIFT_error_init == 0) { -#ifndef OPENSSL_NO_ERR - ERR_unload_strings(CSWIFT_lib_error_code, CSWIFT_str_functs); - ERR_unload_strings(CSWIFT_lib_error_code, CSWIFT_str_reasons); -#endif - -#ifdef CSWIFT_LIB_NAME - ERR_unload_strings(0, CSWIFT_lib_name); -#endif - CSWIFT_error_init = 1; - } -} - -static void ERR_CSWIFT_error(int function, int reason, char *file, int line) -{ - if (CSWIFT_lib_error_code == 0) - CSWIFT_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(CSWIFT_lib_error_code, function, reason, file, line); -} diff --git a/engines/e_cswift_err.h b/engines/e_cswift_err.h deleted file mode 100644 index fde3a82..0000000 --- a/engines/e_cswift_err.h +++ /dev/null @@ -1,99 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#ifndef HEADER_CSWIFT_ERR_H -# define HEADER_CSWIFT_ERR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -static void ERR_load_CSWIFT_strings(void); -static void ERR_unload_CSWIFT_strings(void); -static void ERR_CSWIFT_error(int function, int reason, char *file, int line); -# define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the CSWIFT functions. */ - -/* Function codes. */ -# define CSWIFT_F_CSWIFT_CTRL 100 -# define CSWIFT_F_CSWIFT_DSA_SIGN 101 -# define CSWIFT_F_CSWIFT_DSA_VERIFY 102 -# define CSWIFT_F_CSWIFT_FINISH 103 -# define CSWIFT_F_CSWIFT_INIT 104 -# define CSWIFT_F_CSWIFT_MOD_EXP 105 -# define CSWIFT_F_CSWIFT_MOD_EXP_CRT 106 -# define CSWIFT_F_CSWIFT_RAND_BYTES 108 -# define CSWIFT_F_CSWIFT_RSA_MOD_EXP 107 - -/* Reason codes. */ -# define CSWIFT_R_ALREADY_LOADED 100 -# define CSWIFT_R_BAD_KEY_SIZE 101 -# define CSWIFT_R_BN_CTX_FULL 102 -# define CSWIFT_R_BN_EXPAND_FAIL 103 -# define CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED 104 -# define CSWIFT_R_MISSING_KEY_COMPONENTS 105 -# define CSWIFT_R_NOT_LOADED 106 -# define CSWIFT_R_REQUEST_FAILED 107 -# define CSWIFT_R_UNIT_FAILURE 108 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/engines/e_nuron.c b/engines/e_nuron.c deleted file mode 100644 index 01229b0..0000000 --- a/engines/e_nuron.c +++ /dev/null @@ -1,435 +0,0 @@ -/* crypto/engine/hw_nuron.c */ -/* - * Written by Ben Laurie for the OpenSSL Project, leaning heavily on Geoff - * Thorpe's Atalla implementation. - */ -/* ==================================================================== - * Copyright (c) 2000-2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_RSA -# include -#endif -#ifndef OPENSSL_NO_DSA -# include -#endif -#ifndef OPENSSL_NO_DH -# include -#endif -#include - -#ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_NURON - -# define NURON_LIB_NAME "nuron engine" -# include "e_nuron_err.c" - -static const char *NURON_LIBNAME = NULL; -static const char *get_NURON_LIBNAME(void) -{ - if (NURON_LIBNAME) - return NURON_LIBNAME; - return "nuronssl"; -} - -static void free_NURON_LIBNAME(void) -{ - OPENSSL_free(NURON_LIBNAME); - NURON_LIBNAME = NULL; -} - -static long set_NURON_LIBNAME(const char *name) -{ - free_NURON_LIBNAME(); - return (((NURON_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0); -} - -static const char *NURON_F1 = "nuron_mod_exp"; - -/* The definitions for control commands specific to this engine */ -# define NURON_CMD_SO_PATH ENGINE_CMD_BASE -static const ENGINE_CMD_DEFN nuron_cmd_defns[] = { - {NURON_CMD_SO_PATH, - "SO_PATH", - "Specifies the path to the 'nuronssl' shared library", - ENGINE_CMD_FLAG_STRING}, - {0, NULL, NULL, 0} -}; - -typedef int tfnModExp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m); -static tfnModExp *pfnModExp = NULL; - -static DSO *pvDSOHandle = NULL; - -static int nuron_destroy(ENGINE *e) -{ - free_NURON_LIBNAME(); - ERR_unload_NURON_strings(); - return 1; -} - -static int nuron_init(ENGINE *e) -{ - if (pvDSOHandle != NULL) { - NURONerr(NURON_F_NURON_INIT, NURON_R_ALREADY_LOADED); - return 0; - } - - pvDSOHandle = DSO_load(NULL, get_NURON_LIBNAME(), NULL, - DSO_FLAG_NAME_TRANSLATION_EXT_ONLY); - if (!pvDSOHandle) { - NURONerr(NURON_F_NURON_INIT, NURON_R_DSO_NOT_FOUND); - return 0; - } - - pfnModExp = (tfnModExp *) DSO_bind_func(pvDSOHandle, NURON_F1); - if (!pfnModExp) { - NURONerr(NURON_F_NURON_INIT, NURON_R_DSO_FUNCTION_NOT_FOUND); - return 0; - } - - return 1; -} - -static int nuron_finish(ENGINE *e) -{ - free_NURON_LIBNAME(); - if (pvDSOHandle == NULL) { - NURONerr(NURON_F_NURON_FINISH, NURON_R_NOT_LOADED); - return 0; - } - if (!DSO_free(pvDSOHandle)) { - NURONerr(NURON_F_NURON_FINISH, NURON_R_DSO_FAILURE); - return 0; - } - pvDSOHandle = NULL; - pfnModExp = NULL; - return 1; -} - -static int nuron_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) -{ - int initialised = ((pvDSOHandle == NULL) ? 0 : 1); - switch (cmd) { - case NURON_CMD_SO_PATH: - if (p == NULL) { - NURONerr(NURON_F_NURON_CTRL, ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - if (initialised) { - NURONerr(NURON_F_NURON_CTRL, NURON_R_ALREADY_LOADED); - return 0; - } - return set_NURON_LIBNAME((const char *)p); - default: - break; - } - NURONerr(NURON_F_NURON_CTRL, NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED); - return 0; -} - -static int nuron_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx) -{ - if (!pvDSOHandle) { - NURONerr(NURON_F_NURON_MOD_EXP, NURON_R_NOT_LOADED); - return 0; - } - return pfnModExp(r, a, p, m); -} - -# ifndef OPENSSL_NO_RSA -static int nuron_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx) -{ - return nuron_mod_exp(r0, I, rsa->d, rsa->n, ctx); -} -# endif - -# ifndef OPENSSL_NO_DSA -/* - * This code was liberated and adapted from the commented-out code in - * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration (it - * doesn't have a CRT form for RSA), this function means that an Atalla - * system running with a DSA server certificate can handshake around 5 or 6 - * times faster/more than an equivalent system running with RSA. Just check - * out the "signs" statistics from the RSA and DSA parts of "openssl speed - * -engine atalla dsa1024 rsa1024". - */ -static int nuron_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, - BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont) -{ - BIGNUM t; - int to_return = 0; - - BN_init(&t); - /* let rr = a1 ^ p1 mod m */ - if (!nuron_mod_exp(rr, a1, p1, m, ctx)) - goto end; - /* let t = a2 ^ p2 mod m */ - if (!nuron_mod_exp(&t, a2, p2, m, ctx)) - goto end; - /* let rr = rr * t mod m */ - if (!BN_mod_mul(rr, rr, &t, m, ctx)) - goto end; - to_return = 1; - end: - BN_free(&t); - return to_return; -} - -static int nuron_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return nuron_mod_exp(r, a, p, m, ctx); -} -# endif - -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -# ifndef OPENSSL_NO_RSA -static int nuron_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return nuron_mod_exp(r, a, p, m, ctx); -} -# endif - -# ifndef OPENSSL_NO_DH -/* This function is aliased to mod_exp (with the dh and mont dropped). */ -static int nuron_mod_exp_dh(const DH *dh, BIGNUM *r, - const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - return nuron_mod_exp(r, a, p, m, ctx); -} -# endif - -# ifndef OPENSSL_NO_RSA -static RSA_METHOD nuron_rsa = { - "Nuron RSA method", - NULL, - NULL, - NULL, - NULL, - nuron_rsa_mod_exp, - nuron_mod_exp_mont, - NULL, - NULL, - 0, - NULL, - NULL, - NULL, - NULL -}; -# endif - -# ifndef OPENSSL_NO_DSA -static DSA_METHOD nuron_dsa = { - "Nuron DSA method", - NULL, /* dsa_do_sign */ - NULL, /* dsa_sign_setup */ - NULL, /* dsa_do_verify */ - nuron_dsa_mod_exp, /* dsa_mod_exp */ - nuron_mod_exp_dsa, /* bn_mod_exp */ - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - NULL, /* dsa_paramgen */ - NULL /* dsa_keygen */ -}; -# endif - -# ifndef OPENSSL_NO_DH -static DH_METHOD nuron_dh = { - "Nuron DH method", - NULL, - NULL, - nuron_mod_exp_dh, - NULL, - NULL, - 0, - NULL, - NULL -}; -# endif - -/* Constants used when creating the ENGINE */ -static const char *engine_nuron_id = "nuron"; -static const char *engine_nuron_name = "Nuron hardware engine support"; - -/* - * This internal function is used by ENGINE_nuron() and possibly by the - * "dynamic" ENGINE support too - */ -static int bind_helper(ENGINE *e) -{ -# ifndef OPENSSL_NO_RSA - const RSA_METHOD *meth1; -# endif -# ifndef OPENSSL_NO_DSA - const DSA_METHOD *meth2; -# endif -# ifndef OPENSSL_NO_DH - const DH_METHOD *meth3; -# endif - if (!ENGINE_set_id(e, engine_nuron_id) || - !ENGINE_set_name(e, engine_nuron_name) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_RSA(e, &nuron_rsa) || -# endif -# ifndef OPENSSL_NO_DSA - !ENGINE_set_DSA(e, &nuron_dsa) || -# endif -# ifndef OPENSSL_NO_DH - !ENGINE_set_DH(e, &nuron_dh) || -# endif - !ENGINE_set_destroy_function(e, nuron_destroy) || - !ENGINE_set_init_function(e, nuron_init) || - !ENGINE_set_finish_function(e, nuron_finish) || - !ENGINE_set_ctrl_function(e, nuron_ctrl) || - !ENGINE_set_cmd_defns(e, nuron_cmd_defns)) - return 0; - -# ifndef OPENSSL_NO_RSA - /* - * We know that the "PKCS1_SSLeay()" functions hook properly to the - * nuron-specific mod_exp and mod_exp_crt so we use those functions. NB: - * We don't use ENGINE_openssl() or anything "more generic" because - * something like the RSAref code may not hook properly, and if you own - * one of these cards then you have the right to do RSA operations on it - * anyway! - */ - meth1 = RSA_PKCS1_SSLeay(); - nuron_rsa.rsa_pub_enc = meth1->rsa_pub_enc; - nuron_rsa.rsa_pub_dec = meth1->rsa_pub_dec; - nuron_rsa.rsa_priv_enc = meth1->rsa_priv_enc; - nuron_rsa.rsa_priv_dec = meth1->rsa_priv_dec; -# endif - -# ifndef OPENSSL_NO_DSA - /* - * Use the DSA_OpenSSL() method and just hook the mod_exp-ish bits. - */ - meth2 = DSA_OpenSSL(); - nuron_dsa.dsa_do_sign = meth2->dsa_do_sign; - nuron_dsa.dsa_sign_setup = meth2->dsa_sign_setup; - nuron_dsa.dsa_do_verify = meth2->dsa_do_verify; -# endif - -# ifndef OPENSSL_NO_DH - /* Much the same for Diffie-Hellman */ - meth3 = DH_OpenSSL(); - nuron_dh.generate_key = meth3->generate_key; - nuron_dh.compute_key = meth3->compute_key; -# endif - - /* Ensure the nuron error handling is set up */ - ERR_load_NURON_strings(); - return 1; -} - -# ifdef OPENSSL_NO_DYNAMIC_ENGINE -static ENGINE *engine_nuron(void) -{ - ENGINE *ret = ENGINE_new(); - if (!ret) - return NULL; - if (!bind_helper(ret)) { - ENGINE_free(ret); - return NULL; - } - return ret; -} - -void ENGINE_load_nuron(void) -{ - /* Copied from eng_[openssl|dyn].c */ - ENGINE *toadd = engine_nuron(); - if (!toadd) - return; - ENGINE_add(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -} -# endif - -/* - * This stuff is needed if this ENGINE is being compiled into a - * self-contained shared-library. - */ -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -static int bind_fn(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, engine_nuron_id) != 0)) - return 0; - if (!bind_helper(e)) - return 0; - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() - IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) -# endif /* OPENSSL_NO_DYNAMIC_ENGINE */ -# endif /* !OPENSSL_NO_HW_NURON */ -#endif /* !OPENSSL_NO_HW */ diff --git a/engines/e_nuron.ec b/engines/e_nuron.ec deleted file mode 100644 index cfa430d..0000000 --- a/engines/e_nuron.ec +++ /dev/null @@ -1 +0,0 @@ -L NURON e_nuron_err.h e_nuron_err.c diff --git a/engines/e_nuron_err.c b/engines/e_nuron_err.c deleted file mode 100644 index a02c4f0..0000000 --- a/engines/e_nuron_err.c +++ /dev/null @@ -1,142 +0,0 @@ -/* e_nuron_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -/* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. - */ - -#include -#include -#include "e_nuron_err.h" - -/* BEGIN ERROR CODES */ -#ifndef OPENSSL_NO_ERR - -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - -static ERR_STRING_DATA NURON_str_functs[] = { - {ERR_FUNC(NURON_F_NURON_CTRL), "NURON_CTRL"}, - {ERR_FUNC(NURON_F_NURON_FINISH), "NURON_FINISH"}, - {ERR_FUNC(NURON_F_NURON_INIT), "NURON_INIT"}, - {ERR_FUNC(NURON_F_NURON_MOD_EXP), "NURON_MOD_EXP"}, - {0, NULL} -}; - -static ERR_STRING_DATA NURON_str_reasons[] = { - {ERR_REASON(NURON_R_ALREADY_LOADED), "already loaded"}, - {ERR_REASON(NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED), - "ctrl command not implemented"}, - {ERR_REASON(NURON_R_DSO_FAILURE), "dso failure"}, - {ERR_REASON(NURON_R_DSO_FUNCTION_NOT_FOUND), "dso function not found"}, - {ERR_REASON(NURON_R_DSO_NOT_FOUND), "dso not found"}, - {ERR_REASON(NURON_R_NOT_LOADED), "not loaded"}, - {0, NULL} -}; - -#endif - -#ifdef NURON_LIB_NAME -static ERR_STRING_DATA NURON_lib_name[] = { - {0, NURON_LIB_NAME}, - {0, NULL} -}; -#endif - -static int NURON_lib_error_code = 0; -static int NURON_error_init = 1; - -static void ERR_load_NURON_strings(void) -{ - if (NURON_lib_error_code == 0) - NURON_lib_error_code = ERR_get_next_error_library(); - - if (NURON_error_init) { - NURON_error_init = 0; -#ifndef OPENSSL_NO_ERR - ERR_load_strings(NURON_lib_error_code, NURON_str_functs); - ERR_load_strings(NURON_lib_error_code, NURON_str_reasons); -#endif - -#ifdef NURON_LIB_NAME - NURON_lib_name->error = ERR_PACK(NURON_lib_error_code, 0, 0); - ERR_load_strings(0, NURON_lib_name); -#endif - } -} - -static void ERR_unload_NURON_strings(void) -{ - if (NURON_error_init == 0) { -#ifndef OPENSSL_NO_ERR - ERR_unload_strings(NURON_lib_error_code, NURON_str_functs); - ERR_unload_strings(NURON_lib_error_code, NURON_str_reasons); -#endif - -#ifdef NURON_LIB_NAME - ERR_unload_strings(0, NURON_lib_name); -#endif - NURON_error_init = 1; - } -} - -static void ERR_NURON_error(int function, int reason, char *file, int line) -{ - if (NURON_lib_error_code == 0) - NURON_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(NURON_lib_error_code, function, reason, file, line); -} diff --git a/engines/e_nuron_err.h b/engines/e_nuron_err.h deleted file mode 100644 index aa7849c..0000000 --- a/engines/e_nuron_err.h +++ /dev/null @@ -1,91 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#ifndef HEADER_NURON_ERR_H -# define HEADER_NURON_ERR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -static void ERR_load_NURON_strings(void); -static void ERR_unload_NURON_strings(void); -static void ERR_NURON_error(int function, int reason, char *file, int line); -# define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the NURON functions. */ - -/* Function codes. */ -# define NURON_F_NURON_CTRL 100 -# define NURON_F_NURON_FINISH 101 -# define NURON_F_NURON_INIT 102 -# define NURON_F_NURON_MOD_EXP 103 - -/* Reason codes. */ -# define NURON_R_ALREADY_LOADED 100 -# define NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED 101 -# define NURON_R_DSO_FAILURE 102 -# define NURON_R_DSO_FUNCTION_NOT_FOUND 103 -# define NURON_R_DSO_NOT_FOUND 104 -# define NURON_R_NOT_LOADED 105 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/engines/e_sureware.c b/engines/e_sureware.c deleted file mode 100644 index fb5e55c..0000000 --- a/engines/e_sureware.c +++ /dev/null @@ -1,1074 +0,0 @@ -/*- -* Written by Corinne Dive-Reclus(cdive at baltimore.com) -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* 3. All advertising materials mentioning features or use of this -* software must display the following acknowledgment: -* "This product includes software developed by the OpenSSL Project -* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" -* -* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to -* endorse or promote products derived from this software without -* prior written permission. For written permission, please contact -* licensing at OpenSSL.org. -* -* 5. Products derived from this software may not be called "OpenSSL" -* nor may "OpenSSL" appear in their names without prior written -* permission of the OpenSSL Project. -* -* 6. Redistributions of any form whatsoever must retain the following -* acknowledgment: -* "This product includes software developed by the OpenSSL Project -* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" -* -* Written by Corinne Dive-Reclus(cdive at baltimore.com) -* -* Copyright at 2001 Baltimore Technologies Ltd. -* All right Reserved. -* * -* THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND * -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * -* ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE * -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * -* SUCH DAMAGE. * -====================================================================*/ - -#include -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_RSA -# include -#endif -#ifndef OPENSSL_NO_DSA -# include -#endif -#ifndef OPENSSL_NO_DH -# include -#endif -#include - -#ifndef OPENSSL_NO_HW -# ifndef OPENSSL_NO_HW_SUREWARE - -# ifdef FLAT_INC -# include "sureware.h" -# else -# include "vendor_defns/sureware.h" -# endif - -# define SUREWARE_LIB_NAME "sureware engine" -# include "e_sureware_err.c" - -static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p, - void (*f) (void)); -static int surewarehk_destroy(ENGINE *e); -static int surewarehk_init(ENGINE *e); -static int surewarehk_finish(ENGINE *e); -static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); - -/* RSA stuff */ -# ifndef OPENSSL_NO_RSA -static int surewarehk_rsa_priv_dec(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -static int surewarehk_rsa_sign(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -# endif - -/* RAND stuff */ -static int surewarehk_rand_bytes(unsigned char *buf, int num); -static int surewarehk_rand_seed(const void *buf, int num); -static int surewarehk_rand_add(const void *buf, int num, double entropy); - -/* KM stuff */ -static EVP_PKEY *surewarehk_load_privkey(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, - void *callback_data); -static EVP_PKEY *surewarehk_load_pubkey(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, - void *callback_data); -static void surewarehk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); - -# ifndef OPENSSL_NO_RSA -/* This function is aliased to mod_exp (with the mont stuff dropped). */ -static int surewarehk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *m_ctx) -{ - return surewarehk_modexp(r, a, p, m, ctx); -} - -/* Our internal RSA_METHOD that we provide pointers to */ -static RSA_METHOD surewarehk_rsa = { - "SureWare RSA method", - NULL, /* pub_enc */ - NULL, /* pub_dec */ - surewarehk_rsa_sign, /* our rsa_sign is OpenSSL priv_enc */ - surewarehk_rsa_priv_dec, /* priv_dec */ - NULL, /* mod_exp */ - surewarehk_mod_exp_mont, /* mod_exp_mongomery */ - NULL, /* init */ - NULL, /* finish */ - 0, /* RSA flag */ - NULL, - NULL, /* OpenSSL sign */ - NULL, /* OpenSSL verify */ - NULL /* keygen */ -}; -# endif - -# ifndef OPENSSL_NO_DH -/* Our internal DH_METHOD that we provide pointers to */ -/* This function is aliased to mod_exp (with the dh and mont dropped). */ -static int surewarehk_modexp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx) -{ - return surewarehk_modexp(r, a, p, m, ctx); -} - -static DH_METHOD surewarehk_dh = { - "SureWare DH method", - NULL, /* gen_key */ - NULL, /* agree, */ - surewarehk_modexp_dh, /* dh mod exp */ - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, - NULL -}; -# endif - -static RAND_METHOD surewarehk_rand = { - /* "SureWare RAND method", */ - surewarehk_rand_seed, - surewarehk_rand_bytes, - NULL, /* cleanup */ - surewarehk_rand_add, - surewarehk_rand_bytes, - NULL, /* rand_status */ -}; - -# ifndef OPENSSL_NO_DSA -/* DSA stuff */ -static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *dgst, int dlen, - DSA *dsa); -static int surewarehk_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1, - BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, - BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *in_mont) -{ - BIGNUM t; - int to_return = 0; - BN_init(&t); - /* let rr = a1 ^ p1 mod m */ - if (!surewarehk_modexp(rr, a1, p1, m, ctx)) - goto end; - /* let t = a2 ^ p2 mod m */ - if (!surewarehk_modexp(&t, a2, p2, m, ctx)) - goto end; - /* let rr = rr * t mod m */ - if (!BN_mod_mul(rr, rr, &t, m, ctx)) - goto end; - to_return = 1; - end: - BN_free(&t); - return to_return; -} - -static DSA_METHOD surewarehk_dsa = { - "SureWare DSA method", - surewarehk_dsa_do_sign, - NULL, /* sign setup */ - NULL, /* verify, */ - surewarehk_dsa_mod_exp, /* mod exp */ - NULL, /* bn mod exp */ - NULL, /* init */ - NULL, /* finish */ - 0, - NULL, - NULL, - NULL -}; -# endif - -static const char *engine_sureware_id = "sureware"; -static const char *engine_sureware_name = "SureWare hardware engine support"; - -/* Now, to our own code */ - -/* - * As this is only ever called once, there's no need for locking (indeed - - * the lock will already be held by our caller!!!) - */ -static int bind_sureware(ENGINE *e) -{ -# ifndef OPENSSL_NO_RSA - const RSA_METHOD *meth1; -# endif -# ifndef OPENSSL_NO_DSA - const DSA_METHOD *meth2; -# endif -# ifndef OPENSSL_NO_DH - const DH_METHOD *meth3; -# endif - - if (!ENGINE_set_id(e, engine_sureware_id) || - !ENGINE_set_name(e, engine_sureware_name) || -# ifndef OPENSSL_NO_RSA - !ENGINE_set_RSA(e, &surewarehk_rsa) || -# endif -# ifndef OPENSSL_NO_DSA - !ENGINE_set_DSA(e, &surewarehk_dsa) || -# endif -# ifndef OPENSSL_NO_DH - !ENGINE_set_DH(e, &surewarehk_dh) || -# endif - !ENGINE_set_RAND(e, &surewarehk_rand) || - !ENGINE_set_destroy_function(e, surewarehk_destroy) || - !ENGINE_set_init_function(e, surewarehk_init) || - !ENGINE_set_finish_function(e, surewarehk_finish) || - !ENGINE_set_ctrl_function(e, surewarehk_ctrl) || - !ENGINE_set_load_privkey_function(e, surewarehk_load_privkey) || - !ENGINE_set_load_pubkey_function(e, surewarehk_load_pubkey)) - return 0; - -# ifndef OPENSSL_NO_RSA - /* - * We know that the "PKCS1_SSLeay()" functions hook properly to the - * cswift-specific mod_exp and mod_exp_crt so we use those functions. NB: - * We don't use ENGINE_openssl() or anything "more generic" because - * something like the RSAref code may not hook properly, and if you own - * one of these cards then you have the right to do RSA operations on it - * anyway! - */ - meth1 = RSA_PKCS1_SSLeay(); - if (meth1) { - surewarehk_rsa.rsa_pub_enc = meth1->rsa_pub_enc; - surewarehk_rsa.rsa_pub_dec = meth1->rsa_pub_dec; - } -# endif - -# ifndef OPENSSL_NO_DSA - /* - * Use the DSA_OpenSSL() method and just hook the mod_exp-ish bits. - */ - meth2 = DSA_OpenSSL(); - if (meth2) { - surewarehk_dsa.dsa_do_verify = meth2->dsa_do_verify; - } -# endif - -# ifndef OPENSSL_NO_DH - /* Much the same for Diffie-Hellman */ - meth3 = DH_OpenSSL(); - if (meth3) { - surewarehk_dh.generate_key = meth3->generate_key; - surewarehk_dh.compute_key = meth3->compute_key; - } -# endif - - /* Ensure the sureware error handling is set up */ - ERR_load_SUREWARE_strings(); - return 1; -} - -# ifndef OPENSSL_NO_DYNAMIC_ENGINE -static int bind_helper(ENGINE *e, const char *id) -{ - if (id && (strcmp(id, engine_sureware_id) != 0)) - return 0; - if (!bind_sureware(e)) - return 0; - return 1; -} - -IMPLEMENT_DYNAMIC_CHECK_FN() - IMPLEMENT_DYNAMIC_BIND_FN(bind_helper) -# else -static ENGINE *engine_sureware(void) -{ - ENGINE *ret = ENGINE_new(); - if (!ret) - return NULL; - if (!bind_sureware(ret)) { - ENGINE_free(ret); - return NULL; - } - return ret; -} - -void ENGINE_load_sureware(void) -{ - /* Copied from eng_[openssl|dyn].c */ - ENGINE *toadd = engine_sureware(); - if (!toadd) - return; - ENGINE_add(toadd); - ENGINE_free(toadd); - ERR_clear_error(); -} -# endif - -/* - * This is a process-global DSO handle used for loading and unloading the - * SureWareHook library. NB: This is only set (or unset) during an init() or - * finish() call (reference counts permitting) and they're operating with - * global locks, so this should be thread-safe implicitly. - */ -static DSO *surewarehk_dso = NULL; -# ifndef OPENSSL_NO_RSA -/* Index for KM handle. Not really used yet. */ -static int rsaHndidx = -1; -# endif -# ifndef OPENSSL_NO_DSA -/* Index for KM handle. Not really used yet. */ -static int dsaHndidx = -1; -# endif - -/* - * These are the function pointers that are (un)set when the library has - * successfully (un)loaded. - */ -static SureWareHook_Init_t *p_surewarehk_Init = NULL; -static SureWareHook_Finish_t *p_surewarehk_Finish = NULL; -static SureWareHook_Rand_Bytes_t *p_surewarehk_Rand_Bytes = NULL; -static SureWareHook_Rand_Seed_t *p_surewarehk_Rand_Seed = NULL; -static SureWareHook_Load_Privkey_t *p_surewarehk_Load_Privkey = NULL; -static SureWareHook_Info_Pubkey_t *p_surewarehk_Info_Pubkey = NULL; -static SureWareHook_Load_Rsa_Pubkey_t *p_surewarehk_Load_Rsa_Pubkey = NULL; -static SureWareHook_Load_Dsa_Pubkey_t *p_surewarehk_Load_Dsa_Pubkey = NULL; -static SureWareHook_Free_t *p_surewarehk_Free = NULL; -static SureWareHook_Rsa_Priv_Dec_t *p_surewarehk_Rsa_Priv_Dec = NULL; -static SureWareHook_Rsa_Sign_t *p_surewarehk_Rsa_Sign = NULL; -static SureWareHook_Dsa_Sign_t *p_surewarehk_Dsa_Sign = NULL; -static SureWareHook_Mod_Exp_t *p_surewarehk_Mod_Exp = NULL; - -/* Used in the DSO operations. */ -static const char *surewarehk_LIBNAME = "SureWareHook"; -static const char *n_surewarehk_Init = "SureWareHook_Init"; -static const char *n_surewarehk_Finish = "SureWareHook_Finish"; -static const char *n_surewarehk_Rand_Bytes = "SureWareHook_Rand_Bytes"; -static const char *n_surewarehk_Rand_Seed = "SureWareHook_Rand_Seed"; -static const char *n_surewarehk_Load_Privkey = "SureWareHook_Load_Privkey"; -static const char *n_surewarehk_Info_Pubkey = "SureWareHook_Info_Pubkey"; -static const char *n_surewarehk_Load_Rsa_Pubkey = - "SureWareHook_Load_Rsa_Pubkey"; -static const char *n_surewarehk_Load_Dsa_Pubkey = - "SureWareHook_Load_Dsa_Pubkey"; -static const char *n_surewarehk_Free = "SureWareHook_Free"; -static const char *n_surewarehk_Rsa_Priv_Dec = "SureWareHook_Rsa_Priv_Dec"; -static const char *n_surewarehk_Rsa_Sign = "SureWareHook_Rsa_Sign"; -static const char *n_surewarehk_Dsa_Sign = "SureWareHook_Dsa_Sign"; -static const char *n_surewarehk_Mod_Exp = "SureWareHook_Mod_Exp"; -static BIO *logstream = NULL; - -/* - * SureWareHook library functions and mechanics - these are used by the - * higher-level functions further down. NB: As and where there's no error - * checking, take a look lower down where these functions are called, the - * checking and error handling is probably down there. - */ -static int threadsafe = 1; -static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p, - void (*f) (void)) -{ - int to_return = 1; - - switch (cmd) { - case ENGINE_CTRL_SET_LOGSTREAM: - { - BIO *bio = (BIO *)p; - CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - BIO_free(logstream); - logstream = NULL; - if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1) - logstream = bio; - else - SUREWAREerr(SUREWARE_F_SUREWAREHK_CTRL, - SUREWARE_R_BIO_WAS_FREED); - } - CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - break; - /* - * This will prevent the initialisation function from "installing" - * the mutex-handling callbacks, even if they are available from - * within the library (or were provided to the library from the - * calling application). This is to remove any baggage for - * applications not using multithreading. - */ - case ENGINE_CTRL_CHIL_NO_LOCKING: - CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - threadsafe = 0; - CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); - break; - - /* The command isn't understood by this engine */ - default: - SUREWAREerr(SUREWARE_F_SUREWAREHK_CTRL, - ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED); - to_return = 0; - break; - } - - return to_return; -} - -/* Destructor (complements the "ENGINE_surewarehk()" constructor) */ -static int surewarehk_destroy(ENGINE *e) -{ - ERR_unload_SUREWARE_strings(); - return 1; -} - -/* (de)initialisation functions. */ -static int surewarehk_init(ENGINE *e) -{ - char msg[64] = "ENGINE_init"; - SureWareHook_Init_t *p1 = NULL; - SureWareHook_Finish_t *p2 = NULL; - SureWareHook_Rand_Bytes_t *p3 = NULL; - SureWareHook_Rand_Seed_t *p4 = NULL; - SureWareHook_Load_Privkey_t *p5 = NULL; - SureWareHook_Load_Rsa_Pubkey_t *p6 = NULL; - SureWareHook_Free_t *p7 = NULL; - SureWareHook_Rsa_Priv_Dec_t *p8 = NULL; - SureWareHook_Rsa_Sign_t *p9 = NULL; - SureWareHook_Dsa_Sign_t *p12 = NULL; - SureWareHook_Info_Pubkey_t *p13 = NULL; - SureWareHook_Load_Dsa_Pubkey_t *p14 = NULL; - SureWareHook_Mod_Exp_t *p15 = NULL; - - if (surewarehk_dso != NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT, ENGINE_R_ALREADY_LOADED); - goto err; - } - /* Attempt to load libsurewarehk.so/surewarehk.dll/whatever. */ - surewarehk_dso = DSO_load(NULL, surewarehk_LIBNAME, NULL, 0); - if (surewarehk_dso == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT, ENGINE_R_DSO_FAILURE); - goto err; - } - if (! - (p1 = - (SureWareHook_Init_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Init)) -|| !(p2 = - (SureWareHook_Finish_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Finish)) -|| !(p3 = - (SureWareHook_Rand_Bytes_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Rand_Bytes)) -|| !(p4 = - (SureWareHook_Rand_Seed_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Rand_Seed)) -|| !(p5 = - (SureWareHook_Load_Privkey_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Load_Privkey)) -|| !(p6 = - (SureWareHook_Load_Rsa_Pubkey_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Load_Rsa_Pubkey)) -|| !(p7 = - (SureWareHook_Free_t *) DSO_bind_func(surewarehk_dso, n_surewarehk_Free)) -|| !(p8 = - (SureWareHook_Rsa_Priv_Dec_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Rsa_Priv_Dec)) -|| !(p9 = - (SureWareHook_Rsa_Sign_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Rsa_Sign)) -|| !(p12 = - (SureWareHook_Dsa_Sign_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Dsa_Sign)) -|| !(p13 = - (SureWareHook_Info_Pubkey_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Info_Pubkey)) -|| !(p14 = - (SureWareHook_Load_Dsa_Pubkey_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Load_Dsa_Pubkey)) -|| !(p15 = - (SureWareHook_Mod_Exp_t *) DSO_bind_func(surewarehk_dso, - n_surewarehk_Mod_Exp))) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT, ENGINE_R_DSO_FAILURE); - goto err; - } - /* Copy the pointers */ - p_surewarehk_Init = p1; - p_surewarehk_Finish = p2; - p_surewarehk_Rand_Bytes = p3; - p_surewarehk_Rand_Seed = p4; - p_surewarehk_Load_Privkey = p5; - p_surewarehk_Load_Rsa_Pubkey = p6; - p_surewarehk_Free = p7; - p_surewarehk_Rsa_Priv_Dec = p8; - p_surewarehk_Rsa_Sign = p9; - p_surewarehk_Dsa_Sign = p12; - p_surewarehk_Info_Pubkey = p13; - p_surewarehk_Load_Dsa_Pubkey = p14; - p_surewarehk_Mod_Exp = p15; - /* Contact the hardware and initialises it. */ - if (p_surewarehk_Init(msg, threadsafe) == SUREWAREHOOK_ERROR_UNIT_FAILURE) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT, SUREWARE_R_UNIT_FAILURE); - goto err; - } - if (p_surewarehk_Init(msg, threadsafe) == SUREWAREHOOK_ERROR_UNIT_FAILURE) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT, SUREWARE_R_UNIT_FAILURE); - goto err; - } - /* - * try to load the default private key, if failed does not return a - * failure but wait for an explicit ENGINE_load_privakey - */ - surewarehk_load_privkey(e, NULL, NULL, NULL); - - /* Everything's fine. */ -# ifndef OPENSSL_NO_RSA - if (rsaHndidx == -1) - rsaHndidx = RSA_get_ex_new_index(0, - "SureWareHook RSA key handle", - NULL, NULL, surewarehk_ex_free); -# endif -# ifndef OPENSSL_NO_DSA - if (dsaHndidx == -1) - dsaHndidx = DSA_get_ex_new_index(0, - "SureWareHook DSA key handle", - NULL, NULL, surewarehk_ex_free); -# endif - - return 1; - err: - DSO_free(surewarehk_dso); - surewarehk_dso = NULL; - p_surewarehk_Init = NULL; - p_surewarehk_Finish = NULL; - p_surewarehk_Rand_Bytes = NULL; - p_surewarehk_Rand_Seed = NULL; - p_surewarehk_Load_Privkey = NULL; - p_surewarehk_Load_Rsa_Pubkey = NULL; - p_surewarehk_Free = NULL; - p_surewarehk_Rsa_Priv_Dec = NULL; - p_surewarehk_Rsa_Sign = NULL; - p_surewarehk_Dsa_Sign = NULL; - p_surewarehk_Info_Pubkey = NULL; - p_surewarehk_Load_Dsa_Pubkey = NULL; - p_surewarehk_Mod_Exp = NULL; - return 0; -} - -static int surewarehk_finish(ENGINE *e) -{ - int to_return = 1; - if (surewarehk_dso == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_FINISH, ENGINE_R_NOT_LOADED); - to_return = 0; - goto err; - } - p_surewarehk_Finish(); - if (!DSO_free(surewarehk_dso)) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_FINISH, ENGINE_R_DSO_FAILURE); - to_return = 0; - goto err; - } - err: - BIO_free(logstream); - surewarehk_dso = NULL; - p_surewarehk_Init = NULL; - p_surewarehk_Finish = NULL; - p_surewarehk_Rand_Bytes = NULL; - p_surewarehk_Rand_Seed = NULL; - p_surewarehk_Load_Privkey = NULL; - p_surewarehk_Load_Rsa_Pubkey = NULL; - p_surewarehk_Free = NULL; - p_surewarehk_Rsa_Priv_Dec = NULL; - p_surewarehk_Rsa_Sign = NULL; - p_surewarehk_Dsa_Sign = NULL; - p_surewarehk_Info_Pubkey = NULL; - p_surewarehk_Load_Dsa_Pubkey = NULL; - p_surewarehk_Mod_Exp = NULL; - return to_return; -} - -static void surewarehk_error_handling(char *const msg, int func, int ret) -{ - switch (ret) { - case SUREWAREHOOK_ERROR_UNIT_FAILURE: - ENGINEerr(func, SUREWARE_R_UNIT_FAILURE); - break; - case SUREWAREHOOK_ERROR_FALLBACK: - ENGINEerr(func, SUREWARE_R_REQUEST_FALLBACK); - break; - case SUREWAREHOOK_ERROR_DATA_SIZE: - ENGINEerr(func, SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL); - break; - case SUREWAREHOOK_ERROR_INVALID_PAD: - ENGINEerr(func, SUREWARE_R_PADDING_CHECK_FAILED); - break; - default: - ENGINEerr(func, SUREWARE_R_REQUEST_FAILED); - break; - case 1: /* nothing */ - msg[0] = '\0'; - } - if (*msg) { - ERR_add_error_data(1, msg); - if (logstream) { - CRYPTO_w_lock(CRYPTO_LOCK_BIO); - BIO_write(logstream, msg, strlen(msg)); - CRYPTO_w_unlock(CRYPTO_LOCK_BIO); - } - } -} - -static int surewarehk_rand_bytes(unsigned char *buf, int num) -{ - int ret = 0; - char msg[64] = "ENGINE_rand_bytes"; - if (!p_surewarehk_Rand_Bytes) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RAND_BYTES, - ENGINE_R_NOT_INITIALISED); - } else { - ret = p_surewarehk_Rand_Bytes(msg, buf, num); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_RAND_BYTES, ret); - } - return ret == 1 ? 1 : 0; -} - -static int surewarehk_rand_seed(const void *buf, int num) -{ - int ret = 0; - char msg[64] = "ENGINE_rand_seed"; - if (!p_surewarehk_Rand_Seed) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RAND_SEED, - ENGINE_R_NOT_INITIALISED); - return 0; - } else { - ret = p_surewarehk_Rand_Seed(msg, buf, num); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_RAND_SEED, ret); - if (ret == 1) - return 1; - else - return 0; - } -} - -static int surewarehk_rand_add(const void *buf, int num, double entropy) -{ - return surewarehk_rand_seed(buf, num); -} - -static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id, - char *hptr, unsigned long el, - char keytype) -{ - EVP_PKEY *res = NULL; -# ifndef OPENSSL_NO_RSA - RSA *rsatmp = NULL; -# endif -# ifndef OPENSSL_NO_DSA - DSA *dsatmp = NULL; -# endif - char msg[64] = "sureware_load_public"; - int ret = 0; - if (!p_surewarehk_Load_Rsa_Pubkey || !p_surewarehk_Load_Dsa_Pubkey) { - SUREWAREerr(SUREWARE_F_SUREWARE_LOAD_PUBLIC, - ENGINE_R_NOT_INITIALISED); - goto err; - } - switch (keytype) { -# ifndef OPENSSL_NO_RSA - case 1: - /*RSA*/ - /* set private external reference */ - rsatmp = RSA_new_method(e); - RSA_set_ex_data(rsatmp, rsaHndidx, hptr); - rsatmp->flags |= RSA_FLAG_EXT_PKEY; - - /* set public big nums */ - rsatmp->e = BN_new(); - rsatmp->n = BN_new(); - if (!rsatmp->e || !rsatmp->n) - goto err; - bn_expand2(rsatmp->e, el / sizeof(BN_ULONG)); - bn_expand2(rsatmp->n, el / sizeof(BN_ULONG)); - if (rsatmp->e->dmax != (int)(el / sizeof(BN_ULONG)) || - rsatmp->n->dmax != (int)(el / sizeof(BN_ULONG))) - goto err; - ret = p_surewarehk_Load_Rsa_Pubkey(msg, key_id, el, - (unsigned long *)rsatmp->n->d, - (unsigned long *)rsatmp->e->d); - surewarehk_error_handling(msg, SUREWARE_F_SUREWARE_LOAD_PUBLIC, ret); - if (ret != 1) { - SUREWAREerr(SUREWARE_F_SUREWARE_LOAD_PUBLIC, - ENGINE_R_FAILED_LOADING_PUBLIC_KEY); - goto err; - } - /* normalise pub e and pub n */ - rsatmp->e->top = el / sizeof(BN_ULONG); - bn_fix_top(rsatmp->e); - rsatmp->n->top = el / sizeof(BN_ULONG); - bn_fix_top(rsatmp->n); - /* create an EVP object: engine + rsa key */ - res = EVP_PKEY_new(); - EVP_PKEY_assign_RSA(res, rsatmp); - break; -# endif - -# ifndef OPENSSL_NO_DSA - case 2: - /*DSA*/ - /* set private/public external reference */ - dsatmp = DSA_new_method(e); - DSA_set_ex_data(dsatmp, dsaHndidx, hptr); - /* - * dsatmp->flags |= DSA_FLAG_EXT_PKEY; - */ - - /* set public key */ - dsatmp->pub_key = BN_new(); - dsatmp->p = BN_new(); - dsatmp->q = BN_new(); - dsatmp->g = BN_new(); - if (!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g) - goto err; - bn_expand2(dsatmp->pub_key, el / sizeof(BN_ULONG)); - bn_expand2(dsatmp->p, el / sizeof(BN_ULONG)); - bn_expand2(dsatmp->q, 20 / sizeof(BN_ULONG)); - bn_expand2(dsatmp->g, el / sizeof(BN_ULONG)); - if (dsatmp->pub_key->dmax != (int)(el / sizeof(BN_ULONG)) - || dsatmp->p->dmax != (int)(el / sizeof(BN_ULONG)) - || dsatmp->q->dmax != 20 / sizeof(BN_ULONG) - || dsatmp->g->dmax != (int)(el / sizeof(BN_ULONG))) - goto err; - - ret = p_surewarehk_Load_Dsa_Pubkey(msg, key_id, el, - (unsigned long *)dsatmp-> - pub_key->d, - (unsigned long *)dsatmp->p->d, - (unsigned long *)dsatmp->q->d, - (unsigned long *)dsatmp->g->d); - surewarehk_error_handling(msg, SUREWARE_F_SUREWARE_LOAD_PUBLIC, ret); - if (ret != 1) { - SUREWAREerr(SUREWARE_F_SUREWARE_LOAD_PUBLIC, - ENGINE_R_FAILED_LOADING_PUBLIC_KEY); - goto err; - } - /* set parameters */ - /* normalise pubkey and parameters in case of */ - dsatmp->pub_key->top = el / sizeof(BN_ULONG); - bn_fix_top(dsatmp->pub_key); - dsatmp->p->top = el / sizeof(BN_ULONG); - bn_fix_top(dsatmp->p); - dsatmp->q->top = 20 / sizeof(BN_ULONG); - bn_fix_top(dsatmp->q); - dsatmp->g->top = el / sizeof(BN_ULONG); - bn_fix_top(dsatmp->g); - - /* create an EVP object: engine + rsa key */ - res = EVP_PKEY_new(); - EVP_PKEY_assign_DSA(res, dsatmp); - break; -# endif - - default: - SUREWAREerr(SUREWARE_F_SUREWARE_LOAD_PUBLIC, - ENGINE_R_FAILED_LOADING_PRIVATE_KEY); - goto err; - } - return res; - err: -# ifndef OPENSSL_NO_RSA - RSA_free(rsatmp); -# endif -# ifndef OPENSSL_NO_DSA - DSA_free(dsatmp); -# endif - return NULL; -} - -static EVP_PKEY *surewarehk_load_privkey(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, - void *callback_data) -{ - EVP_PKEY *res = NULL; - int ret = 0; - unsigned long el = 0; - char *hptr = NULL; - char keytype = 0; - char msg[64] = "ENGINE_load_privkey"; - - if (!p_surewarehk_Load_Privkey) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVKEY, - ENGINE_R_NOT_INITIALISED); - } else { - ret = p_surewarehk_Load_Privkey(msg, key_id, &hptr, &el, &keytype); - if (ret != 1) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVKEY, - ENGINE_R_FAILED_LOADING_PRIVATE_KEY); - ERR_add_error_data(1, msg); - } else - res = sureware_load_public(e, key_id, hptr, el, keytype); - } - return res; -} - -static EVP_PKEY *surewarehk_load_pubkey(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, - void *callback_data) -{ - EVP_PKEY *res = NULL; - int ret = 0; - unsigned long el = 0; - char *hptr = NULL; - char keytype = 0; - char msg[64] = "ENGINE_load_pubkey"; - - if (!p_surewarehk_Info_Pubkey) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBKEY, - ENGINE_R_NOT_INITIALISED); - } else { - /* call once to identify if DSA or RSA */ - ret = p_surewarehk_Info_Pubkey(msg, key_id, &el, &keytype); - if (ret != 1) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBKEY, - ENGINE_R_FAILED_LOADING_PUBLIC_KEY); - ERR_add_error_data(1, msg); - } else - res = sureware_load_public(e, key_id, hptr, el, keytype); - } - return res; -} - -/* - * This cleans up an RSA/DSA KM key(do not destroy the key into the hardware) - * , called when ex_data is freed - */ -static void surewarehk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp) -{ - if (!p_surewarehk_Free) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_EX_FREE, ENGINE_R_NOT_INITIALISED); - } else - p_surewarehk_Free((char *)item, 0); -} - -/* - * return number of decrypted bytes - */ -# ifndef OPENSSL_NO_RSA -static int surewarehk_rsa_priv_dec(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding) -{ - int ret = 0, tlen; - char *buf = NULL, *hptr = NULL; - char msg[64] = "ENGINE_rsa_priv_dec"; - if (!p_surewarehk_Rsa_Priv_Dec) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - ENGINE_R_NOT_INITIALISED); - } - /* extract ref to private key */ - else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - SUREWARE_R_MISSING_KEY_COMPONENTS); - goto err; - } - /* analyse what padding we can do into the hardware */ - if (padding == RSA_PKCS1_PADDING) { - /* do it one shot */ - ret = - p_surewarehk_Rsa_Priv_Dec(msg, flen, (unsigned char *)from, &tlen, - to, hptr, SUREWARE_PKCS1_PAD); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - ret); - if (ret != 1) - goto err; - ret = tlen; - } else { /* do with no padding into hardware */ - - ret = - p_surewarehk_Rsa_Priv_Dec(msg, flen, (unsigned char *)from, &tlen, - to, hptr, SUREWARE_NO_PAD); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - ret); - if (ret != 1) - goto err; - /* intermediate buffer for padding */ - if ((buf = OPENSSL_malloc(tlen)) == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - ERR_R_MALLOC_FAILURE); - goto err; - } - memcpy(buf, to, tlen); /* transfert to into buf */ - switch (padding) { /* check padding in software */ - case RSA_PKCS1_OAEP_PADDING: - ret = - RSA_padding_check_PKCS1_OAEP(to, tlen, (unsigned char *)buf, - tlen, tlen, NULL, 0); - break; - case RSA_SSLV23_PADDING: - ret = - RSA_padding_check_SSLv23(to, tlen, (unsigned char *)buf, flen, - tlen); - break; - case RSA_NO_PADDING: - ret = - RSA_padding_check_none(to, tlen, (unsigned char *)buf, flen, - tlen); - break; - default: - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - SUREWARE_R_UNKNOWN_PADDING_TYPE); - goto err; - } - if (ret < 0) - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC, - SUREWARE_R_PADDING_CHECK_FAILED); - } - err: - OPENSSL_clear_free(buf, tlen); - return ret; -} - -/* - * Does what OpenSSL rsa_priv_enc does. - */ -static int surewarehk_rsa_sign(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding) -{ - int ret = 0, tlen; - char *hptr = NULL; - char msg[64] = "ENGINE_rsa_sign"; - if (!p_surewarehk_Rsa_Sign) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN, ENGINE_R_NOT_INITIALISED); - } - /* extract ref to private key */ - else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN, - SUREWARE_R_MISSING_KEY_COMPONENTS); - } else { - switch (padding) { - case RSA_PKCS1_PADDING: /* do it in one shot */ - ret = - p_surewarehk_Rsa_Sign(msg, flen, (unsigned char *)from, &tlen, - to, hptr, SUREWARE_PKCS1_PAD); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_RSA_SIGN, - ret); - break; - case RSA_NO_PADDING: - default: - SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN, - SUREWARE_R_UNKNOWN_PADDING_TYPE); - } - } - return ret == 1 ? tlen : ret; -} - -# endif - -# ifndef OPENSSL_NO_DSA -/* DSA sign and verify */ -static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *from, int flen, - DSA *dsa) -{ - int ret = 0; - char *hptr = NULL; - DSA_SIG *psign = NULL; - char msg[64] = "ENGINE_dsa_do_sign"; - if (!p_surewarehk_Dsa_Sign) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN, - ENGINE_R_NOT_INITIALISED); - goto err; - } - /* extract ref to private key */ - else if ((hptr = DSA_get_ex_data(dsa, dsaHndidx)) == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN, - SUREWARE_R_MISSING_KEY_COMPONENTS); - goto err; - } else { - if ((psign = DSA_SIG_new()) == NULL) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN, - ERR_R_MALLOC_FAILURE); - goto err; - } - psign->r = BN_new(); - psign->s = BN_new(); - if (!psign->r || !psign->s) - goto err; - bn_expand2(psign->r, 20 / sizeof(BN_ULONG)); - bn_expand2(psign->s, 20 / sizeof(BN_ULONG)); - if (psign->r->dmax != 20 / sizeof(BN_ULONG) || - psign->s->dmax != 20 / sizeof(BN_ULONG)) - goto err; - ret = p_surewarehk_Dsa_Sign(msg, flen, from, - (unsigned long *)psign->r->d, - (unsigned long *)psign->s->d, hptr); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_DSA_DO_SIGN, - ret); - } - psign->r->top = 20 / sizeof(BN_ULONG); - bn_fix_top(psign->r); - psign->s->top = 20 / sizeof(BN_ULONG); - bn_fix_top(psign->s); - - err: - if (psign) { - DSA_SIG_free(psign); - psign = NULL; - } - return psign; -} -# endif - -static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx) -{ - int ret = 0; - char msg[64] = "ENGINE_modexp"; - if (!p_surewarehk_Mod_Exp) { - SUREWAREerr(SUREWARE_F_SUREWAREHK_MODEXP, ENGINE_R_NOT_INITIALISED); - } else if (r) { - bn_expand2(r, m->top); - if (r->dmax == m->top) { - /* do it */ - ret = p_surewarehk_Mod_Exp(msg, - m->top * sizeof(BN_ULONG), - (unsigned long *)m->d, - p->top * sizeof(BN_ULONG), - (unsigned long *)p->d, - a->top * sizeof(BN_ULONG), - (unsigned long *)a->d, - (unsigned long *)r->d); - surewarehk_error_handling(msg, SUREWARE_F_SUREWAREHK_MODEXP, ret); - if (ret == 1) { - /* normalise result */ - r->top = m->top; - bn_fix_top(r); - } - } - } - return ret; -} -# endif /* !OPENSSL_NO_HW_SUREWARE */ -#endif /* !OPENSSL_NO_HW */ diff --git a/engines/e_sureware.ec b/engines/e_sureware.ec deleted file mode 100644 index 3d266b8..0000000 --- a/engines/e_sureware.ec +++ /dev/null @@ -1 +0,0 @@ -L SUREWARE e_sureware_err.h e_sureware_err.c diff --git a/engines/e_sureware_err.c b/engines/e_sureware_err.c deleted file mode 100644 index f6f7eff..0000000 --- a/engines/e_sureware_err.c +++ /dev/null @@ -1,154 +0,0 @@ -/* e_sureware_err.c */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -/* - * NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file, - * only reason strings will be preserved. - */ - -#include -#include -#include "e_sureware_err.h" - -/* BEGIN ERROR CODES */ -#ifndef OPENSSL_NO_ERR - -# define ERR_FUNC(func) ERR_PACK(0,func,0) -# define ERR_REASON(reason) ERR_PACK(0,0,reason) - -static ERR_STRING_DATA SUREWARE_str_functs[] = { - {ERR_FUNC(SUREWARE_F_SUREWAREHK_CTRL), "SUREWAREHK_CTRL"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_DH_EX_FREE), "SUREWAREHK_DH_EX_FREE"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN), "SUREWAREHK_DSA_DO_SIGN"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_EX_FREE), "SUREWAREHK_EX_FREE"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_FINISH), "SUREWAREHK_FINISH"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_INIT), "SUREWAREHK_INIT"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_LOAD_PRIVKEY), "SUREWAREHK_LOAD_PRIVKEY"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_LOAD_PUBKEY), "SUREWAREHK_LOAD_PUBKEY"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_MODEXP), "SUREWAREHK_MODEXP"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_RAND_BYTES), "SUREWAREHK_RAND_BYTES"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_RAND_SEED), "SUREWAREHK_RAND_SEED"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC), "SUREWAREHK_RSA_PRIV_DEC"}, - {ERR_FUNC(SUREWARE_F_SUREWAREHK_RSA_SIGN), "SUREWAREHK_RSA_SIGN"}, - {ERR_FUNC(SUREWARE_F_SUREWARE_LOAD_PUBLIC), "SUREWARE_LOAD_PUBLIC"}, - {0, NULL} -}; - -static ERR_STRING_DATA SUREWARE_str_reasons[] = { - {ERR_REASON(SUREWARE_R_BIO_WAS_FREED), "bio was freed"}, - {ERR_REASON(SUREWARE_R_MISSING_KEY_COMPONENTS), "missing key components"}, - {ERR_REASON(SUREWARE_R_PADDING_CHECK_FAILED), "padding check failed"}, - {ERR_REASON(SUREWARE_R_REQUEST_FAILED), "request failed"}, - {ERR_REASON(SUREWARE_R_REQUEST_FALLBACK), "request fallback"}, - {ERR_REASON(SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL), - "size too large or too small"}, - {ERR_REASON(SUREWARE_R_UNIT_FAILURE), "unit failure"}, - {ERR_REASON(SUREWARE_R_UNKNOWN_PADDING_TYPE), "unknown padding type"}, - {0, NULL} -}; - -#endif - -#ifdef SUREWARE_LIB_NAME -static ERR_STRING_DATA SUREWARE_lib_name[] = { - {0, SUREWARE_LIB_NAME}, - {0, NULL} -}; -#endif - -static int SUREWARE_lib_error_code = 0; -static int SUREWARE_error_init = 1; - -static void ERR_load_SUREWARE_strings(void) -{ - if (SUREWARE_lib_error_code == 0) - SUREWARE_lib_error_code = ERR_get_next_error_library(); - - if (SUREWARE_error_init) { - SUREWARE_error_init = 0; -#ifndef OPENSSL_NO_ERR - ERR_load_strings(SUREWARE_lib_error_code, SUREWARE_str_functs); - ERR_load_strings(SUREWARE_lib_error_code, SUREWARE_str_reasons); -#endif - -#ifdef SUREWARE_LIB_NAME - SUREWARE_lib_name->error = ERR_PACK(SUREWARE_lib_error_code, 0, 0); - ERR_load_strings(0, SUREWARE_lib_name); -#endif - } -} - -static void ERR_unload_SUREWARE_strings(void) -{ - if (SUREWARE_error_init == 0) { -#ifndef OPENSSL_NO_ERR - ERR_unload_strings(SUREWARE_lib_error_code, SUREWARE_str_functs); - ERR_unload_strings(SUREWARE_lib_error_code, SUREWARE_str_reasons); -#endif - -#ifdef SUREWARE_LIB_NAME - ERR_unload_strings(0, SUREWARE_lib_name); -#endif - SUREWARE_error_init = 1; - } -} - -static void ERR_SUREWARE_error(int function, int reason, char *file, int line) -{ - if (SUREWARE_lib_error_code == 0) - SUREWARE_lib_error_code = ERR_get_next_error_library(); - ERR_PUT_error(SUREWARE_lib_error_code, function, reason, file, line); -} diff --git a/engines/e_sureware_err.h b/engines/e_sureware_err.h deleted file mode 100644 index bef8623..0000000 --- a/engines/e_sureware_err.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#ifndef HEADER_SUREWARE_ERR_H -# define HEADER_SUREWARE_ERR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -static void ERR_load_SUREWARE_strings(void); -static void ERR_unload_SUREWARE_strings(void); -static void ERR_SUREWARE_error(int function, int reason, char *file, - int line); -# define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),__FILE__,__LINE__) - -/* Error codes for the SUREWARE functions. */ - -/* Function codes. */ -# define SUREWARE_F_SUREWAREHK_CTRL 100 -# define SUREWARE_F_SUREWAREHK_DH_EX_FREE 112 -# define SUREWARE_F_SUREWAREHK_DSA_DO_SIGN 101 -# define SUREWARE_F_SUREWAREHK_EX_FREE 102 -# define SUREWARE_F_SUREWAREHK_FINISH 103 -# define SUREWARE_F_SUREWAREHK_INIT 104 -# define SUREWARE_F_SUREWAREHK_LOAD_PRIVKEY 105 -# define SUREWARE_F_SUREWAREHK_LOAD_PUBKEY 113 -# define SUREWARE_F_SUREWAREHK_MODEXP 107 -# define SUREWARE_F_SUREWAREHK_RAND_BYTES 108 -# define SUREWARE_F_SUREWAREHK_RAND_SEED 109 -# define SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC 110 -# define SUREWARE_F_SUREWAREHK_RSA_SIGN 111 -# define SUREWARE_F_SUREWARE_LOAD_PUBLIC 106 - -/* Reason codes. */ -# define SUREWARE_R_BIO_WAS_FREED 100 -# define SUREWARE_R_MISSING_KEY_COMPONENTS 105 -# define SUREWARE_R_PADDING_CHECK_FAILED 106 -# define SUREWARE_R_REQUEST_FAILED 101 -# define SUREWARE_R_REQUEST_FALLBACK 102 -# define SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL 103 -# define SUREWARE_R_UNIT_FAILURE 104 -# define SUREWARE_R_UNKNOWN_PADDING_TYPE 107 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/engines/makeengines.com b/engines/makeengines.com index a0bd168..944e415 100644 --- a/engines/makeengines.com +++ b/engines/makeengines.com @@ -94,7 +94,7 @@ $! library that isn't necessarely ported to VMS. $! $ ENGINES = "," + P6 $ IF ENGINES .EQS. "," THEN - - ENGINES = ",4758cca,padlock,capi," + ENGINES = ",padlock,capi," $! $! GOST requires a 64-bit integer type, unavailable on VAX. $! @@ -155,7 +155,6 @@ $ ENGINE_ = "engine_vector.mar" $ TV_OBJ_NAME = OBJ_DIR + F$PARSE(ENGINE_,,,"NAME","SYNTAX_ONLY") + ".OBJ" $ TV_OBJ = ",''TV_OBJ_NAME'" $ ENDIF -$ ENGINE_4758CCA = "e_4758cca" $ ENGINE_padlock = "e_padlock" $ ENGINE_capi = "e_capi" $ diff --git a/engines/vendor_defns/aep.h b/engines/vendor_defns/aep.h deleted file mode 100644 index 04ab87e..0000000 --- a/engines/vendor_defns/aep.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - * This header declares the necessary definitions for using the - * exponentiation acceleration capabilities, and rnd number generation of the - * AEP card. - */ - -/* - * - * Some AEP defines - * - */ - -/* - * Successful return value - */ -#define AEP_R_OK 0x00000000 - -/* - * Miscelleanous unsuccessful return value - */ -#define AEP_R_GENERAL_ERROR 0x10000001 - -/* - * Insufficient host memory - */ -#define AEP_R_HOST_MEMORY 0x10000002 - -#define AEP_R_FUNCTION_FAILED 0x10000006 - -/* - * Invalid arguments in function call - */ -#define AEP_R_ARGUMENTS_BAD 0x10020000 - -#define AEP_R_NO_TARGET_RESOURCES 0x10030000 - -/* - * Error occuring on socket operation - */ -#define AEP_R_SOCKERROR 0x10000010 - -/* - * Socket has been closed from the other end - */ -#define AEP_R_SOCKEOF 0x10000011 - -/* - * Invalid handles - */ -#define AEP_R_CONNECTION_HANDLE_INVALID 0x100000B3 - -#define AEP_R_TRANSACTION_HANDLE_INVALID 0x10040000 - -/* - * Transaction has not yet returned from accelerator - */ -#define AEP_R_TRANSACTION_NOT_READY 0x00010000 - -/* - * There is already a thread waiting on this transaction - */ -#define AEP_R_TRANSACTION_CLAIMED 0x10050000 - -/* - * The transaction timed out - */ -#define AEP_R_TIMED_OUT 0x10060000 - -#define AEP_R_FXN_NOT_IMPLEMENTED 0x10070000 - -#define AEP_R_TARGET_ERROR 0x10080000 - -/* - * Error in the AEP daemon process - */ -#define AEP_R_DAEMON_ERROR 0x10090000 - -/* - * Invalid ctx id - */ -#define AEP_R_INVALID_CTX_ID 0x10009000 - -#define AEP_R_NO_KEY_MANAGER 0x1000a000 - -/* - * Error obtaining a mutex - */ -#define AEP_R_MUTEX_BAD 0x000001A0 - -/* - * Fxn call before AEP_Initialise ot after AEP_Finialise - */ -#define AEP_R_AEPAPI_NOT_INITIALIZED 0x10000190 - -/* - * AEP_Initialise has already been called - */ -#define AEP_R_AEPAPI_ALREADY_INITIALIZED 0x10000191 - -/* - * Maximum number of connections to daemon reached - */ -#define AEP_R_NO_MORE_CONNECTION_HNDLS 0x10000200 - -/* - * - * Some AEP Type definitions - * - */ - -/* an unsigned 8-bit value */ -typedef unsigned char AEP_U8; - -/* an unsigned 8-bit character */ -typedef char AEP_CHAR; - -/* a BYTE-sized Boolean flag */ -typedef AEP_U8 AEP_BBOOL; - -/* - * Unsigned value, at least 16 bits long - */ -typedef unsigned short AEP_U16; - -/* an unsigned value, at least 32 bits long */ -#ifdef SIXTY_FOUR_BIT_LONG -typedef unsigned int AEP_U32; -#else -typedef unsigned long AEP_U32; -#endif - -#ifdef SIXTY_FOUR_BIT_LONG -typedef unsigned long AEP_U64; -#else -typedef struct { - unsigned long l1, l2; -} AEP_U64; -#endif - -/* at least 32 bits; each bit is a Boolean flag */ -typedef AEP_U32 AEP_FLAGS; - -typedef AEP_U8 *AEP_U8_PTR; -typedef AEP_CHAR *AEP_CHAR_PTR; -typedef AEP_U32 *AEP_U32_PTR; -typedef AEP_U64 *AEP_U64_PTR; -typedef void *AEP_VOID_PTR; - -/* Pointer to a AEP_VOID_PTR-- i.e., pointer to pointer to void */ -typedef AEP_VOID_PTR *AEP_VOID_PTR_PTR; - -/* - * Used to identify an AEP connection handle - */ -typedef AEP_U32 AEP_CONNECTION_HNDL; - -/* - * Pointer to an AEP connection handle - */ -typedef AEP_CONNECTION_HNDL *AEP_CONNECTION_HNDL_PTR; - -/* - * Used by an application (in conjunction with the apps process id) to - * identify an individual transaction - */ -typedef AEP_U32 AEP_TRANSACTION_ID; - -/* - * Pointer to an applications transaction identifier - */ -typedef AEP_TRANSACTION_ID *AEP_TRANSACTION_ID_PTR; - -/* - * Return value type - */ -typedef AEP_U32 AEP_RV; - -#define MAX_PROCESS_CONNECTIONS 256 - -#define RAND_BLK_SIZE 1024 - -typedef enum { - NotConnected = 0, - Connected = 1, - InUse = 2 -} AEP_CONNECTION_STATE; - -typedef struct AEP_CONNECTION_ENTRY { - AEP_CONNECTION_STATE conn_state; - AEP_CONNECTION_HNDL conn_hndl; -} AEP_CONNECTION_ENTRY; - -typedef AEP_RV t_AEP_OpenConnection(AEP_CONNECTION_HNDL_PTR phConnection); -typedef AEP_RV t_AEP_CloseConnection(AEP_CONNECTION_HNDL hConnection); - -typedef AEP_RV t_AEP_ModExp(AEP_CONNECTION_HNDL hConnection, - AEP_VOID_PTR pA, AEP_VOID_PTR pP, - AEP_VOID_PTR pN, - AEP_VOID_PTR pResult, - AEP_TRANSACTION_ID *pidTransID); - -typedef AEP_RV t_AEP_ModExpCrt(AEP_CONNECTION_HNDL hConnection, - AEP_VOID_PTR pA, AEP_VOID_PTR pP, - AEP_VOID_PTR pQ, - AEP_VOID_PTR pDmp1, AEP_VOID_PTR pDmq1, - AEP_VOID_PTR pIqmp, - AEP_VOID_PTR pResult, - AEP_TRANSACTION_ID *pidTransID); - -#ifdef AEPRAND -typedef AEP_RV t_AEP_GenRandom(AEP_CONNECTION_HNDL hConnection, - AEP_U32 Len, - AEP_U32 Type, - AEP_VOID_PTR pResult, - AEP_TRANSACTION_ID *pidTransID); -#endif - -typedef AEP_RV t_AEP_Initialize(AEP_VOID_PTR pInitArgs); -typedef AEP_RV t_AEP_Finalize(void); -typedef AEP_RV t_AEP_SetBNCallBacks(AEP_RV (*GetBigNumSizeFunc) - (AEP_VOID_PTR ArbBigNum, - AEP_U32 *BigNumSize), - AEP_RV (*MakeAEPBigNumFunc) (AEP_VOID_PTR - ArbBigNum, - AEP_U32 - BigNumSize, - unsigned char - *AEP_BigNum), - AEP_RV (*ConverAEPBigNumFunc) (void - *ArbBigNum, - AEP_U32 - BigNumSize, - unsigned - char - *AEP_BigNum)); diff --git a/engines/vendor_defns/atalla.h b/engines/vendor_defns/atalla.h deleted file mode 100644 index 60e7eda..0000000 --- a/engines/vendor_defns/atalla.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This header declares the necessary definitions for using the - * exponentiation acceleration capabilities of Atalla cards. The only - * cryptographic operation is performed by "ASI_RSAPrivateKeyOpFn" and this - * takes a structure that defines an "RSA private key". However, it is really - * only performing a regular mod_exp using the supplied modulus and exponent - * - no CRT form is being used. Hence, it is a generic mod_exp function in - * disguise, and we use it as such. Thanks to the people at Atalla for - * letting me know these definitions are fine and that they can be reproduced - * here. Geoff. - */ - -typedef struct ItemStr { - unsigned char *data; - int len; -} Item; - -typedef struct RSAPrivateKeyStr { - void *reserved; - Item version; - Item modulus; - Item publicExponent; - Item privateExponent; - Item prime[2]; - Item exponent[2]; - Item coefficient; -} RSAPrivateKey; - -/* - * Predeclare the function pointer types that we dynamically load from the - * DSO. These use the same names and form that Ben's original support code - * had (in crypto/bn/bn_exp.c) unless of course I've inadvertently changed - * the style somewhere along the way! - */ - -typedef int tfnASI_GetPerformanceStatistics(int reset_flag, - unsigned int *ret_buf); - -typedef int tfnASI_GetHardwareConfig(long card_num, unsigned int *ret_buf); - -typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey, - unsigned char *output, - unsigned char *input, - unsigned int modulus_len); diff --git a/engines/vendor_defns/cswift.h b/engines/vendor_defns/cswift.h deleted file mode 100644 index a5af762..0000000 --- a/engines/vendor_defns/cswift.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Attribution notice: Rainbow have generously allowed me to reproduce the - * necessary definitions here from their API. This means the support can - * build independently of whether application builders have the API or - * hardware. This will allow developers to easily produce software that has - * latent hardware support for any users that have accelertors installed, - * without the developers themselves needing anything extra. I have only - * clipped the parts from the CryptoSwift header files that are (or seem) - * relevant to the CryptoSwift support code. This is simply to keep the file - * sizes reasonable. [Geoff] - */ - -/* - * NB: These type widths do *not* seem right in general, in particular - * they're not terribly friendly to 64-bit architectures (unsigned long) will - * be 64-bit on IA-64 for a start. I'm leaving these alone as they agree with - * Rainbow's API and this will only be called into question on platforms with - * Rainbow support anyway! ;-) - */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - typedef long SW_STATUS; /* status */ - typedef unsigned char SW_BYTE; /* 8 bit byte */ - typedef unsigned short SW_U16; /* 16 bit number */ -#if defined(_IRIX) -# include - typedef __uint32_t SW_U32; -#else - typedef unsigned long SW_U32; /* 32 bit integer */ -#endif - -#if defined(OPENSSL_SYS_WIN32) - typedef struct _SW_U64 { - SW_U32 low32; - SW_U32 high32; - } SW_U64; /* 64 bit integer */ -#else /* Unix variants */ - typedef struct _SW_U64 { - SW_U32 low32; - SW_U32 high32; - } SW_U64; /* 64 bit integer */ -#endif - -/* status codes */ -#define SW_OK (0L) -#define SW_ERR_BASE (-10000L) -#define SW_ERR_NO_CARD (SW_ERR_BASE-1) /* The Card is not present */ -#define SW_ERR_CARD_NOT_READY (SW_ERR_BASE-2) /* The card has not powered */ - /* up yet */ -#define SW_ERR_TIME_OUT (SW_ERR_BASE-3) /* Execution of a command */ - /* time out */ -#define SW_ERR_NO_EXECUTE (SW_ERR_BASE-4) /* The Card failed to */ - /* execute the command */ -#define SW_ERR_INPUT_NULL_PTR (SW_ERR_BASE-5) /* a required pointer is */ - /* NULL */ -#define SW_ERR_INPUT_SIZE (SW_ERR_BASE-6) /* size is invalid, too */ - /* small, too large. */ -#define SW_ERR_INVALID_HANDLE (SW_ERR_BASE-7) /* Invalid SW_ACC_CONTEXT */ - /* handle */ -#define SW_ERR_PENDING (SW_ERR_BASE-8) /* A request is already out- */ - /* standing at this */ - /* context handle */ -#define SW_ERR_AVAILABLE (SW_ERR_BASE-9) /* A result is available. */ -#define SW_ERR_NO_PENDING (SW_ERR_BASE-10) /* No request is pending. */ -#define SW_ERR_NO_MEMORY (SW_ERR_BASE-11) /* Not enough memory */ -#define SW_ERR_BAD_ALGORITHM (SW_ERR_BASE-12) /* Invalid algorithm type */ - /* in SW_PARAM structure */ -#define SW_ERR_MISSING_KEY (SW_ERR_BASE-13) /* No key is associated with */ - /* context. */ - /* swAttachKeyParam() is */ - /* not called. */ -#define SW_ERR_KEY_CMD_MISMATCH \ - (SW_ERR_BASE-14) /* Cannot perform requested */ - /* SW_COMMAND_CODE since */ - /* key attached via */ - /* swAttachKeyParam() */ - /* cannot be used for this */ - /* SW_COMMAND_CODE. */ -#define SW_ERR_NOT_IMPLEMENTED \ - (SW_ERR_BASE-15) /* Not implemented */ -#define SW_ERR_BAD_COMMAND (SW_ERR_BASE-16) /* Bad command code */ -#define SW_ERR_BAD_ITEM_SIZE (SW_ERR_BASE-17) /* too small or too large in */ - /* the "initems" or */ - /* "outitems". */ -#define SW_ERR_BAD_ACCNUM (SW_ERR_BASE-18) /* Bad accelerator number */ -#define SW_ERR_SELFTEST_FAIL (SW_ERR_BASE-19) /* At least one of the self */ - /* test fail, look at the */ - /* selfTestBitmap in */ - /* SW_ACCELERATOR_INFO for */ - /* details. */ -#define SW_ERR_MISALIGN (SW_ERR_BASE-20) /* Certain alogrithms require */ - /* key materials aligned */ - /* in certain order, e.g. */ - /* 128 bit for CRT */ -#define SW_ERR_OUTPUT_NULL_PTR \ - (SW_ERR_BASE-21) /* a required pointer is */ - /* NULL */ -#define SW_ERR_OUTPUT_SIZE \ - (SW_ERR_BASE-22) /* size is invalid, too */ - /* small, too large. */ -#define SW_ERR_FIRMWARE_CHECKSUM \ - (SW_ERR_BASE-23) /* firmware checksum mismatch */ - /* download failed. */ -#define SW_ERR_UNKNOWN_FIRMWARE \ - (SW_ERR_BASE-24) /* unknown firmware error */ -#define SW_ERR_INTERRUPT (SW_ERR_BASE-25) /* request is abort when */ - /* it's waiting to be */ - /* completed. */ -#define SW_ERR_NVWRITE_FAIL (SW_ERR_BASE-26) /* error in writing to Non- */ - /* volatile memory */ -#define SW_ERR_NVWRITE_RANGE (SW_ERR_BASE-27) /* out of range error in */ - /* writing to NV memory */ -#define SW_ERR_RNG_ERROR (SW_ERR_BASE-28) /* Random Number Generation */ - /* failure */ -#define SW_ERR_DSS_FAILURE (SW_ERR_BASE-29) /* DSS Sign or Verify failure */ -#define SW_ERR_MODEXP_FAILURE (SW_ERR_BASE-30) /* Failure in various math */ - /* calculations */ -#define SW_ERR_ONBOARD_MEMORY (SW_ERR_BASE-31) /* Error in accessing on - */ - /* board memory */ -#define SW_ERR_FIRMWARE_VERSION \ - (SW_ERR_BASE-32) /* Wrong version in firmware */ - /* update */ -#define SW_ERR_ZERO_WORKING_ACCELERATOR \ - (SW_ERR_BASE-44) /* All accelerators are bad */ - - /* algorithm type */ -#define SW_ALG_CRT 1 -#define SW_ALG_EXP 2 -#define SW_ALG_DSA 3 -#define SW_ALG_NVDATA 4 - - /* command code */ -#define SW_CMD_MODEXP_CRT 1 /* perform Modular Exponentiation using */ - /* Chinese Remainder Theorem (CRT) */ -#define SW_CMD_MODEXP 2 /* perform Modular Exponentiation */ -#define SW_CMD_DSS_SIGN 3 /* perform DSS sign */ -#define SW_CMD_DSS_VERIFY 4 /* perform DSS verify */ -#define SW_CMD_RAND 5 /* perform random number generation */ -#define SW_CMD_NVREAD 6 /* perform read to nonvolatile RAM */ -#define SW_CMD_NVWRITE 7 /* perform write to nonvolatile RAM */ - - typedef SW_U32 SW_ALGTYPE; /* alogrithm type */ - typedef SW_U32 SW_STATE; /* state */ - typedef SW_U32 SW_COMMAND_CODE; /* command code */ - typedef SW_U32 SW_COMMAND_BITMAP[4]; /* bitmap */ - - typedef struct _SW_LARGENUMBER { - SW_U32 nbytes; /* number of bytes in the buffer "value" */ - SW_BYTE *value; /* the large integer as a string of */ - /* bytes in network (big endian) order */ - } SW_LARGENUMBER; - -#if defined(OPENSSL_SYS_WIN32) -# include - typedef HANDLE SW_OSHANDLE; /* handle to kernel object */ -# define SW_OS_INVALID_HANDLE INVALID_HANDLE_VALUE -# define SW_CALLCONV _stdcall -#else /* Unix variants */ - typedef int SW_OSHANDLE; /* handle to driver */ -# define SW_OS_INVALID_HANDLE (-1) -# define SW_CALLCONV -#endif - - typedef struct _SW_CRT { - SW_LARGENUMBER p; /* prime number p */ - SW_LARGENUMBER q; /* prime number q */ - SW_LARGENUMBER dmp1; /* exponent1 */ - SW_LARGENUMBER dmq1; /* exponent2 */ - SW_LARGENUMBER iqmp; /* CRT coefficient */ - } SW_CRT; - - typedef struct _SW_EXP { - SW_LARGENUMBER modulus; /* modulus */ - SW_LARGENUMBER exponent; /* exponent */ - } SW_EXP; - - typedef struct _SW_DSA { - SW_LARGENUMBER p; /* */ - SW_LARGENUMBER q; /* */ - SW_LARGENUMBER g; /* */ - SW_LARGENUMBER key; /* private/public key */ - } SW_DSA; - - typedef struct _SW_NVDATA { - SW_U32 accnum; /* accelerator board number */ - SW_U32 offset; /* offset in byte */ - } SW_NVDATA; - - typedef struct _SW_PARAM { - SW_ALGTYPE type; /* type of the alogrithm */ - union { - SW_CRT crt; - SW_EXP exp; - SW_DSA dsa; - SW_NVDATA nvdata; - } up; - } SW_PARAM; - - typedef SW_U32 SW_CONTEXT_HANDLE; /* opaque context handle */ - - /* - * Now the OpenSSL bits, these function types are the for the function - * pointers that will bound into the Rainbow shared libraries. - */ - typedef SW_STATUS SW_CALLCONV t_swAcquireAccContext(SW_CONTEXT_HANDLE - *hac); - typedef SW_STATUS SW_CALLCONV t_swAttachKeyParam(SW_CONTEXT_HANDLE hac, - SW_PARAM *key_params); - typedef SW_STATUS SW_CALLCONV t_swSimpleRequest(SW_CONTEXT_HANDLE hac, - SW_COMMAND_CODE cmd, - SW_LARGENUMBER pin[], - SW_U32 pin_count, - SW_LARGENUMBER pout[], - SW_U32 pout_count); - typedef SW_STATUS SW_CALLCONV t_swReleaseAccContext(SW_CONTEXT_HANDLE - hac); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ diff --git a/engines/vendor_defns/hw_4758_cca.h b/engines/vendor_defns/hw_4758_cca.h deleted file mode 100644 index 235543a..0000000 --- a/engines/vendor_defns/hw_4758_cca.h +++ /dev/null @@ -1,150 +0,0 @@ -/**********************************************************************/ -/* */ -/* Prototypes of the CCA verbs used by the 4758 CCA openssl driver */ -/* */ -/* Maurice Gittens */ -/* */ -/**********************************************************************/ - -#ifndef __HW_4758_CCA__ -# define __HW_4758_CCA__ - -/* - * Only WIN32 support for now - */ -# if defined(WIN32) - -# define CCA_LIB_NAME "CSUNSAPI" - -# define CSNDPKX "CSNDPKX_32" -# define CSNDKRR "CSNDKRR_32" -# define CSNDPKE "CSNDPKE_32" -# define CSNDPKD "CSNDPKD_32" -# define CSNDDSV "CSNDDSV_32" -# define CSNDDSG "CSNDDSG_32" -# define CSNBRNG "CSNBRNG_32" - -# define SECURITYAPI __stdcall -# else - /* - * Fixme!! Find out the values of these constants for other platforms. - */ -# define CCA_LIB_NAME "CSUNSAPI" - -# define CSNDPKX "CSNDPKX" -# define CSNDKRR "CSNDKRR" -# define CSNDPKE "CSNDPKE" -# define CSNDPKD "CSNDPKD" -# define CSNDDSV "CSNDDSV" -# define CSNDDSG "CSNDDSG" -# define CSNBRNG "CSNBRNG" - -# define SECURITYAPI -# endif - -/* - * security API prototypes - */ - -/* PKA Key Record Read */ -typedef void (SECURITYAPI * F_KEYRECORDREAD) - (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char *exit_data, - long *rule_array_count, - unsigned char *rule_array, - unsigned char *key_label, long *key_token_length, unsigned char *key_token); - -/* Random Number Generate */ -typedef void (SECURITYAPI * F_RANDOMNUMBERGENERATE) - (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char *exit_data, - unsigned char *form, unsigned char *random_number); - -/* Digital Signature Generate */ -typedef void (SECURITYAPI * F_DIGITALSIGNATUREGENERATE) - (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char *exit_data, - long *rule_array_count, - unsigned char *rule_array, - long *PKA_private_key_id_length, - unsigned char *PKA_private_key_id, - long *hash_length, - unsigned char *hash, - long *signature_field_length, - long *signature_bit_length, unsigned char *signature_field); - -/* Digital Signature Verify */ -typedef void (SECURITYAPI * F_DIGITALSIGNATUREVERIFY) (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char - *exit_data, - long *rule_array_count, - unsigned char - *rule_array, - long - *PKA_public_key_id_length, - unsigned char - *PKA_public_key_id, - long *hash_length, - unsigned char *hash, - long - *signature_field_length, - unsigned char - *signature_field); - -/* PKA Public Key Extract */ -typedef void (SECURITYAPI * F_PUBLICKEYEXTRACT) (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char *exit_data, - long *rule_array_count, - unsigned char *rule_array, - long - *source_key_identifier_length, - unsigned char - *source_key_identifier, - long - *target_key_token_length, - unsigned char - *target_key_token); - -/* PKA Encrypt */ -typedef void (SECURITYAPI * F_PKAENCRYPT) - (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char *exit_data, - long *rule_array_count, - unsigned char *rule_array, - long *key_value_length, - unsigned char *key_value, - long *data_struct_length, - unsigned char *data_struct, - long *RSA_public_key_length, - unsigned char *RSA_public_key, - long *RSA_encipher_length, unsigned char *RSA_encipher); - -/* PKA Decrypt */ -typedef void (SECURITYAPI * F_PKADECRYPT) - (long *return_code, - long *reason_code, - long *exit_data_length, - unsigned char *exit_data, - long *rule_array_count, - unsigned char *rule_array, - long *enciphered_key_length, - unsigned char *enciphered_key, - long *data_struct_length, - unsigned char *data_struct, - long *RSA_private_key_length, - unsigned char *RSA_private_key, - long *key_value_length, unsigned char *key_value); - -#endif diff --git a/engines/vendor_defns/sureware.h b/engines/vendor_defns/sureware.h deleted file mode 100644 index b1423e1..0000000 --- a/engines/vendor_defns/sureware.h +++ /dev/null @@ -1,250 +0,0 @@ -/*- - * Written by Corinne Dive-Reclus(cdive at baltimore.com) - * - * Copyright at 2001 Baltimore Technologies Ltd. - * - * THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef WIN32 -# define SW_EXPORT __declspec ( dllexport ) -#else -# define SW_EXPORT -#endif - -/* - * List of exposed SureWare errors - */ -#define SUREWAREHOOK_ERROR_FAILED -1 -#define SUREWAREHOOK_ERROR_FALLBACK -2 -#define SUREWAREHOOK_ERROR_UNIT_FAILURE -3 -#define SUREWAREHOOK_ERROR_DATA_SIZE -4 -#define SUREWAREHOOK_ERROR_INVALID_PAD -5 -/*- -* -----------------WARNING----------------------------------- -* In all the following functions: -* msg is a string with at least 24 bytes free. -* A 24 bytes string will be concatenated to the existing content of msg. -*/ -/*- -* SureWare Initialisation function -* in param threadsafe, if !=0, thread safe enabled -* return SureWareHOOK_ERROR_UNIT_FAILURE if failure, 1 if success -*/ -typedef int SureWareHook_Init_t(char *const msg, int threadsafe); -extern SW_EXPORT SureWareHook_Init_t SureWareHook_Init; -/*- -* SureWare Finish function -*/ -typedef void SureWareHook_Finish_t(void); -extern SW_EXPORT SureWareHook_Finish_t SureWareHook_Finish; -/*- -* PRE_CONDITION: -* DO NOT CALL ANY OF THE FOLLOWING FUNCTIONS IN CASE OF INIT FAILURE -*/ -/*- -* SureWare RAND Bytes function -* In case of failure, the content of buf is unpredictable. -* return 1 if success -* SureWareHOOK_ERROR_FALLBACK if function not available in hardware -* SureWareHOOK_ERROR_FAILED if error while processing -* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure -* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf -* -* in/out param buf : a num bytes long buffer where random bytes will be put -* in param num : the number of bytes into buf -*/ -typedef int SureWareHook_Rand_Bytes_t(char *const msg, unsigned char *buf, - int num); -extern SW_EXPORT SureWareHook_Rand_Bytes_t SureWareHook_Rand_Bytes; - -/*- -* SureWare RAND Seed function -* Adds some seed to the Hardware Random Number Generator -* return 1 if success -* SureWareHOOK_ERROR_FALLBACK if function not available in hardware -* SureWareHOOK_ERROR_FAILED if error while processing -* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure -* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf -* -* in param buf : the seed to add into the HRNG -* in param num : the number of bytes into buf -*/ -typedef int SureWareHook_Rand_Seed_t(char *const msg, const void *buf, - int num); -extern SW_EXPORT SureWareHook_Rand_Seed_t SureWareHook_Rand_Seed; - -/*- -* SureWare Load Private Key function -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* No hardware is contact for this function. -* -* in param key_id :the name of the private protected key file without the extension - ".sws" -* out param hptr : a pointer to a buffer allocated by SureWare_Hook -* out param num: the effective key length in bytes -* out param keytype: 1 if RSA 2 if DSA -*/ -typedef int SureWareHook_Load_Privkey_t(char *const msg, const char *key_id, - char **hptr, unsigned long *num, - char *keytype); -extern SW_EXPORT SureWareHook_Load_Privkey_t SureWareHook_Load_Privkey; - -/*- -* SureWare Info Public Key function -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* No hardware is contact for this function. -* -* in param key_id :the name of the private protected key file without the extension - ".swp" -* out param hptr : a pointer to a buffer allocated by SureWare_Hook -* out param num: the effective key length in bytes -* out param keytype: 1 if RSA 2 if DSA -*/ -typedef int SureWareHook_Info_Pubkey_t(char *const msg, const char *key_id, - unsigned long *num, char *keytype); -extern SW_EXPORT SureWareHook_Info_Pubkey_t SureWareHook_Info_Pubkey; - -/*- -* SureWare Load Public Key function -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* No hardware is contact for this function. -* -* in param key_id :the name of the public protected key file without the extension - ".swp" -* in param num : the bytes size of n and e -* out param n: where to write modulus in bn format -* out param e: where to write exponent in bn format -*/ -typedef int SureWareHook_Load_Rsa_Pubkey_t(char *const msg, - const char *key_id, - unsigned long num, - unsigned long *n, - unsigned long *e); -extern SW_EXPORT SureWareHook_Load_Rsa_Pubkey_t SureWareHook_Load_Rsa_Pubkey; - -/*- -* SureWare Load DSA Public Key function -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* No hardware is contact for this function. -* -* in param key_id :the name of the public protected key file without the extension - ".swp" -* in param num : the bytes size of n and e -* out param pub: where to write pub key in bn format -* out param p: where to write prime in bn format -* out param q: where to write sunprime (length 20 bytes) in bn format -* out param g: where to write base in bn format -*/ -typedef int SureWareHook_Load_Dsa_Pubkey_t(char *const msg, - const char *key_id, - unsigned long num, - unsigned long *pub, - unsigned long *p, unsigned long *q, - unsigned long *g); -extern SW_EXPORT SureWareHook_Load_Dsa_Pubkey_t SureWareHook_Load_Dsa_Pubkey; - -/*- -* SureWare Free function -* Destroy the key into the hardware if destroy==1 -*/ -typedef void SureWareHook_Free_t(char *p, int destroy); -extern SW_EXPORT SureWareHook_Free_t SureWareHook_Free; - -#define SUREWARE_PKCS1_PAD 1 -#define SUREWARE_ISO9796_PAD 2 -#define SUREWARE_NO_PAD 0 -/*- -* SureWare RSA Private Decryption -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure -* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf -* -* in param flen : byte size of from and to -* in param from : encrypted data buffer, should be a not-null valid pointer -* out param tlen: byte size of decrypted data, if error, unexpected value -* out param to : decrypted data buffer, should be a not-null valid pointer -* in param prsa: a protected key pointer, should be a not-null valid pointer -* int padding: padding id as follow -* SUREWARE_PKCS1_PAD -* SUREWARE_NO_PAD -* -*/ -typedef int SureWareHook_Rsa_Priv_Dec_t(char *const msg, int flen, - unsigned char *from, int *tlen, - unsigned char *to, char *prsa, - int padding); -extern SW_EXPORT SureWareHook_Rsa_Priv_Dec_t SureWareHook_Rsa_Priv_Dec; -/*- -* SureWare RSA Signature -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure -* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf -* -* in param flen : byte size of from and to -* in param from : encrypted data buffer, should be a not-null valid pointer -* out param tlen: byte size of decrypted data, if error, unexpected value -* out param to : decrypted data buffer, should be a not-null valid pointer -* in param prsa: a protected key pointer, should be a not-null valid pointer -* int padding: padding id as follow -* SUREWARE_PKCS1_PAD -* SUREWARE_ISO9796_PAD -* -*/ -typedef int SureWareHook_Rsa_Sign_t(char *const msg, int flen, - unsigned char *from, int *tlen, - unsigned char *to, char *prsa, - int padding); -extern SW_EXPORT SureWareHook_Rsa_Sign_t SureWareHook_Rsa_Sign; -/*- -* SureWare DSA Signature -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure -* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf -* -* in param flen : byte size of from and to -* in param from : encrypted data buffer, should be a not-null valid pointer -* out param to : decrypted data buffer, should be a 40bytes valid pointer -* in param pdsa: a protected key pointer, should be a not-null valid pointer -* -*/ -typedef int SureWareHook_Dsa_Sign_t(char *const msg, int flen, - const unsigned char *from, - unsigned long *r, unsigned long *s, - char *pdsa); -extern SW_EXPORT SureWareHook_Dsa_Sign_t SureWareHook_Dsa_Sign; - -/*- -* SureWare Mod Exp -* return 1 if success -* SureWareHOOK_ERROR_FAILED if error while processing -* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure -* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf -* -* mod and res are mlen bytes long. -* exp is elen bytes long -* data is dlen bytes long -* mlen,elen and dlen are all multiple of sizeof(unsigned long) -*/ -typedef int SureWareHook_Mod_Exp_t(char *const msg, int mlen, - const unsigned long *mod, int elen, - const unsigned long *exponent, int dlen, - unsigned long *data, unsigned long *res); -extern SW_EXPORT SureWareHook_Mod_Exp_t SureWareHook_Mod_Exp; From matt at openssl.org Fri Oct 16 09:49:43 2015 From: matt at openssl.org (Matt Caswell) Date: Fri, 16 Oct 2015 09:49:43 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1444988983.449962.6929.nullmailer@dev.openssl.org> The branch master has been updated via 1f08d945a79ad79c98fb84167c613934ee96d8e1 (commit) from 8b7080b0b7f30669c0784d8aa73388f95bbd056b (commit) - Log ----------------------------------------------------------------- commit 1f08d945a79ad79c98fb84167c613934ee96d8e1 Author: Dmitry Belyavsky Date: Fri Oct 16 10:07:57 2015 +0100 Fix error message when loading engines from config When using command line applications errors occur when trying to load engines specified in a config file. Introduced by commit a0a82324f96 RT#4093 Reviewed-by: Richard Levitte Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: apps/openssl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openssl.c b/apps/openssl.c index 565903f..2b0425b 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -175,6 +175,10 @@ static int apps_startup() ERR_load_crypto_strings(); ERR_load_SSL_strings(); + OPENSSL_load_builtin_modules(); +#ifndef OPENSSL_NO_ENGINE + ENGINE_load_builtin_engines(); +#endif if (!app_load_modules(NULL)) { ERR_print_errors(bio_err); BIO_printf(bio_err, "Error loading default configuration\n"); @@ -183,12 +187,8 @@ static int apps_startup() OpenSSL_add_all_algorithms(); OpenSSL_add_ssl_algorithms(); - OPENSSL_load_builtin_modules(); setup_ui_method(); /*SSL_library_init();*/ -#ifndef OPENSSL_NO_ENGINE - ENGINE_load_builtin_engines(); -#endif return 1; } From rsalz at openssl.org Fri Oct 16 15:20:32 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 16 Oct 2015 15:20:32 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445008832.269502.7522.nullmailer@dev.openssl.org> The branch master has been updated via 1a3ae7883f9cbab9c32a9773882f4b1d7ecf8d31 (commit) from 1f08d945a79ad79c98fb84167c613934ee96d8e1 (commit) - Log ----------------------------------------------------------------- commit 1a3ae7883f9cbab9c32a9773882f4b1d7ecf8d31 Author: Rich Salz Date: Fri Oct 16 11:19:04 2015 -0400 Run tests on Travis for mingw builds as well Signed-off-by: Rich Salz Reviewed-by: Andy Polyakov ----------------------------------------------------------------------- Summary of changes: .travis.yml | 10 +++++++++- Makefile.org | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3deea54..5d7cf69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ addons: - gcc-5 - binutils-mingw-w64 - gcc-mingw-w64 + - wine sources: - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test @@ -51,6 +52,10 @@ matrix: compiler: i686-w64-mingw32-gcc - os: osx compiler: x86_64-w64-mingw32-gcc + - compiler: i686-w64-mingw32-gcc + env: CONFIG_OPTS="shared" + - compiler: x86_64-w64-mingw32-gcc + env: CONFIG_OPTS="shared" allow_failures: - compiler: i686-w64-mingw32-gcc env: CONFIG_OPTS="--debug --strict-warnings" @@ -70,7 +75,10 @@ before_script: script: - make - - if [ -z "$CROSS_COMPILE" ]; then make test; fi + - if [ -n "$CROSS_COMPILE" ]; then + export EXE_SHELL="wine" WINEPREFIX=`pwd`; + fi + - make test notifications: email: diff --git a/Makefile.org b/Makefile.org index 3ecc5c5..5aa721f 100644 --- a/Makefile.org +++ b/Makefile.org @@ -437,7 +437,9 @@ test: tests tests: rehash @(cd test && echo "testing..." && \ $(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests ); - OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a + @if [ -z "$(CROSS_COMPILE)" ]; then \ + OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a; \ + fi list-tests: @(cd test && \ From levitte at openssl.org Sat Oct 17 13:27:24 2015 From: levitte at openssl.org (Richard Levitte) Date: Sat, 17 Oct 2015 13:27:24 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445088444.558744.4829.nullmailer@dev.openssl.org> The branch master has been updated via eb05f17344c6538d9ee48770d963ae2c1822d070 (commit) from 1a3ae7883f9cbab9c32a9773882f4b1d7ecf8d31 (commit) - Log ----------------------------------------------------------------- commit eb05f17344c6538d9ee48770d963ae2c1822d070 Author: Manish Goregaokar Date: Sat Oct 17 16:40:55 2015 +0530 Move contributing info to CONTRIBUTING Reviewed-by: Matt Caswell Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: CONTRIBUTING | 43 +++++++++++++++++++++++++++++++++++++++++++ README | 38 +------------------------------------- 2 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 CONTRIBUTING diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 0000000..a04dbea --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,43 @@ +HOW TO CONTRIBUTE TO OpenSSL +---------------------------- + +Development is coordinated on the openssl-dev mailing list (see +http://www.openssl.org for information on subscribing). If you +would like to submit a patch, send it to rt at openssl.org with +the string "[PATCH]" in the subject. Please be sure to include a +textual explanation of what your patch does. + +You can also make GitHub pull requests. If you do this, please also send mail to +rt at openssl.org with a brief description and a link to the PR so that we can more +easily keep track of it. + +If you are unsure as to whether a feature will be useful for the general +OpenSSL community please discuss it on the openssl-dev mailing list first. +Someone may be already working on the same thing or there may be a good +reason as to why that feature isn't implemented. + +Patches should be as up to date as possible, preferably relative to the +current Git or the last snapshot. They should follow our coding style +(see https://www.openssl.org/policies/codingstyle.html) and compile without +warnings using the --strict-warnings flag. OpenSSL compiles on many +varied platforms: try to ensure you only use portable features. + +Note: For legal reasons, contributions from the US can be accepted only +if a TSU notification and a copy of the patch are sent to crypt at bis.doc.gov +(formerly BXA) with a copy to the ENC Encryption Request Coordinator; +please take some time to look at +http://www.bis.doc.gov/Encryption/PubAvailEncSourceCodeNofify.html [sic] +and +http://w3.access.gpo.gov/bis/ear/pdf/740.pdf (EAR Section 740.13(e)) +for the details. If "your encryption source code is too large to serve as +an email attachment", they are glad to receive it by fax instead; hope you +have a cheap long-distance plan. + +Our preferred format for changes is "diff -u" output. You might +generate it like this: + +# cd openssl-work +# [your changes] +# ./Configure dist; make clean +# cd .. +# diff -ur openssl-orig openssl-work > mydiffs.patch diff --git a/README b/README index 13464f2..1ee02b3 100644 --- a/README +++ b/README @@ -158,40 +158,4 @@ HOW TO CONTRIBUTE TO OpenSSL ---------------------------- - Development is coordinated on the openssl-dev mailing list (see - http://www.openssl.org for information on subscribing). If you - would like to submit a patch, send it to openssl-bugs at openssl.org with - the string "[PATCH]" in the subject. Please be sure to include a - textual explanation of what your patch does. - - If you are unsure as to whether a feature will be useful for the general - OpenSSL community please discuss it on the openssl-dev mailing list first. - Someone may be already working on the same thing or there may be a good - reason as to why that feature isn't implemented. - - Patches should be as up to date as possible, preferably relative to the - current Git or the last snapshot. They should follow our coding style - (see http://openssl.org/about/codingstyle.txt) and compile without - warnings using the --strict-warnings flag. OpenSSL compiles on many - varied platforms: try to ensure you only use portable features. - - Note: For legal reasons, contributions from the US can be accepted only - if a TSU notification and a copy of the patch are sent to crypt at bis.doc.gov - (formerly BXA) with a copy to the ENC Encryption Request Coordinator; - please take some time to look at - http://www.bis.doc.gov/Encryption/PubAvailEncSourceCodeNofify.html [sic] - and - http://w3.access.gpo.gov/bis/ear/pdf/740.pdf (EAR Section 740.13(e)) - for the details. If "your encryption source code is too large to serve as - an email attachment", they are glad to receive it by fax instead; hope you - have a cheap long-distance plan. - - Our preferred format for changes is "diff -u" output. You might - generate it like this: - - # cd openssl-work - # [your changes] - # ./Configure dist; make clean - # cd .. - # diff -ur openssl-orig openssl-work > mydiffs.patch - + See CONTRIBUTING From steve at openssl.org Sun Oct 18 11:17:25 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sun, 18 Oct 2015 11:17:25 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445167045.288782.855.nullmailer@dev.openssl.org> The branch master has been updated via 7f3e6f8c243710b8dc89f385196987ad83c7848d (commit) from eb05f17344c6538d9ee48770d963ae2c1822d070 (commit) - Log ----------------------------------------------------------------- commit 7f3e6f8c243710b8dc89f385196987ad83c7848d Author: Dr. Stephen Henson Date: Sun Oct 18 00:54:13 2015 +0100 set string type when embedding Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: crypto/asn1/tasn_new.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index 33a8e97..6a2ad62 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -352,6 +352,7 @@ static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, if (embed) { str = *(ASN1_STRING **)pval; memset(str, 0, sizeof(*str)); + str->type = utype; str->flags = ASN1_STRING_FLAG_EMBED; } else { str = ASN1_STRING_type_new(utype); From steve at openssl.org Sun Oct 18 13:37:14 2015 From: steve at openssl.org (Dr. Stephen Henson) Date: Sun, 18 Oct 2015 13:37:14 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445175434.265172.11930.nullmailer@dev.openssl.org> The branch master has been updated via 76e0cd12f68f0b8173bc71ee6e9ad3ca453d5a28 (commit) via bb7fc98c43e29b9169522f6e25aa5988ce931c6c (commit) from 7f3e6f8c243710b8dc89f385196987ad83c7848d (commit) - Log ----------------------------------------------------------------- commit 76e0cd12f68f0b8173bc71ee6e9ad3ca453d5a28 Author: Dr. Stephen Henson Date: Sun Oct 18 00:16:23 2015 +0100 Move auto Host adding to query_responder Check for Host header in query_responder instead of process_responder. This also fixes a memory leak in the old code if the headers was NULL. Reviewed-by: Richard Levitte commit bb7fc98c43e29b9169522f6e25aa5988ce931c6c Author: Dr. Stephen Henson Date: Sun Oct 18 00:04:10 2015 +0100 Fix memory leak with -issuer option. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: apps/ocsp.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/apps/ocsp.c b/apps/ocsp.c index 0f8ddcc..2ef4278 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -118,7 +118,8 @@ static BIO *init_responder(const char *port); static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, const char *port); static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp); -static OCSP_RESPONSE *query_responder(BIO *cbio, const char *path, +static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, + const char *path, const STACK_OF(CONF_VALUE) *headers, OCSP_REQUEST *req, int req_timeout); @@ -404,13 +405,14 @@ int ocsp_main(int argc, char **argv) path = opt_arg(); break; case OPT_ISSUER: - X509_free(issuer); issuer = load_cert(opt_arg(), FORMAT_PEM, NULL, NULL, "issuer certificate"); if (issuer == NULL) goto end; - if ((issuers = sk_X509_new_null()) == NULL) - goto end; + if (issuers == NULL) { + if ((issuers = sk_X509_new_null()) == NULL) + goto end; + } sk_X509_push(issuers, issuer); break; case OPT_CERT: @@ -750,6 +752,7 @@ int ocsp_main(int argc, char **argv) EVP_PKEY_free(key); EVP_PKEY_free(rkey); X509_free(cert); + sk_X509_pop_free(issuers, X509_free); X509_free(rsigner); X509_free(rca_cert); free_index(rdb); @@ -1175,13 +1178,15 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp) return 1; } -static OCSP_RESPONSE *query_responder(BIO *cbio, const char *path, +static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, + const char *path, const STACK_OF(CONF_VALUE) *headers, OCSP_REQUEST *req, int req_timeout) { int fd; int rv; int i; + int add_host = 1; OCSP_REQ_CTX *ctx = NULL; OCSP_RESPONSE *rsp = NULL; fd_set confds; @@ -1220,10 +1225,15 @@ static OCSP_RESPONSE *query_responder(BIO *cbio, const char *path, for (i = 0; i < sk_CONF_VALUE_num(headers); i++) { CONF_VALUE *hdr = sk_CONF_VALUE_value(headers, i); + if (add_host == 1 && strcasecmp("host", hdr->name) == 0) + add_host = 0; if (!OCSP_REQ_CTX_add1_header(ctx, hdr->name, hdr->value)) goto err; } + if (add_host == 1 && OCSP_REQ_CTX_add1_header(ctx, "Host", host) == 0) + goto err; + if (!OCSP_REQ_CTX_set1_req(ctx, req)) goto err; @@ -1270,7 +1280,6 @@ OCSP_RESPONSE *process_responder(OCSP_REQUEST *req, BIO *cbio = NULL; SSL_CTX *ctx = NULL; OCSP_RESPONSE *resp = NULL; - int found, i; cbio = BIO_new_connect(host); if (!cbio) { @@ -1290,18 +1299,8 @@ OCSP_RESPONSE *process_responder(OCSP_REQUEST *req, sbio = BIO_new_ssl(ctx, 1); cbio = BIO_push(sbio, cbio); } - for (found = i = 0; i < sk_CONF_VALUE_num(headers); i++) { - CONF_VALUE *hdr = sk_CONF_VALUE_value(headers, i); - if (strcasecmp("host", hdr->name) == 0) { - found = 1; - break; - } - } - - if (!found && !X509V3_add_value("Host", host, &headers)) - BIO_printf(bio_err, "Error setting HTTP Host header\n"); - resp = query_responder(cbio, path, headers, req, req_timeout); + resp = query_responder(cbio, host, path, headers, req, req_timeout); if (!resp) BIO_printf(bio_err, "Error querying OCSP responder\n"); end: From levitte at openssl.org Sun Oct 18 18:35:30 2015 From: levitte at openssl.org (Richard Levitte) Date: Sun, 18 Oct 2015 18:35:30 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445193330.341381.30941.nullmailer@dev.openssl.org> The branch master has been updated via 338cb76220e641bba9684cab745b2105d6ac0558 (commit) via d865cb13ba7118e74b83238c074ca548e0177663 (commit) via eb6d5f99831e013945f002989e1060095b51345e (commit) from 76e0cd12f68f0b8173bc71ee6e9ad3ca453d5a28 (commit) - Log ----------------------------------------------------------------- commit 338cb76220e641bba9684cab745b2105d6ac0558 Author: Richard Levitte Date: Sun Oct 18 08:59:51 2015 +0200 make update Reviewed-by: Rich Salz commit d865cb13ba7118e74b83238c074ca548e0177663 Author: Richard Levitte Date: Sun Oct 18 08:59:00 2015 +0200 Add crypto/include/internal to the directories to scan for stack declarations Reviewed-by: Rich Salz commit eb6d5f99831e013945f002989e1060095b51345e Author: Richard Levitte Date: Sun Oct 18 08:57:37 2015 +0200 Because ct_locl.h is used between modules, move it to internal headers Rename it to ct_int.h Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: crypto/ct/Makefile | 2 +- crypto/ct/ct_lib.c | 2 +- crypto/{ct/ct_locl.h => include/internal/ct_int.h} | 0 crypto/x509v3/Makefile | 5 +++-- crypto/x509v3/v3_scts.c | 2 +- util/mkstack.pl | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) rename crypto/{ct/ct_locl.h => include/internal/ct_int.h} (100%) diff --git a/crypto/ct/Makefile b/crypto/ct/Makefile index fe2341d..3c89ac7 100644 --- a/crypto/ct/Makefile +++ b/crypto/ct/Makefile @@ -80,4 +80,4 @@ ct_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h ct_lib.o: ../../include/openssl/tls1.h ../../include/openssl/x509.h ct_lib.o: ../../include/openssl/x509_vfy.h ../../ssl/packet_locl.h ct_lib.o: ../../ssl/record/record.h ../../ssl/ssl_locl.h -ct_lib.o: ../include/internal/cryptlib.h ct_lib.c ct_locl.h +ct_lib.o: ../include/internal/cryptlib.h ../include/internal/ct_int.h ct_lib.c diff --git a/crypto/ct/ct_lib.c b/crypto/ct/ct_lib.c index 7945745..eac6035 100644 --- a/crypto/ct/ct_lib.c +++ b/crypto/ct/ct_lib.c @@ -61,7 +61,7 @@ # include # include "internal/cryptlib.h" # include "../ssl/ssl_locl.h" -# include "ct_locl.h" +# include "internal/ct_int.h" SCT *SCT_new(void) { diff --git a/crypto/ct/ct_locl.h b/crypto/include/internal/ct_int.h similarity index 100% rename from crypto/ct/ct_locl.h rename to crypto/include/internal/ct_int.h diff --git a/crypto/x509v3/Makefile b/crypto/x509v3/Makefile index 87fc083..2188041 100644 --- a/crypto/x509v3/Makefile +++ b/crypto/x509v3/Makefile @@ -523,7 +523,7 @@ v3_purp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h v3_purp.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h v3_purp.o: ../../include/openssl/x509v3.h ../include/internal/cryptlib.h v3_purp.o: ../include/internal/x509_int.h v3_purp.c -v3_scts.o: ../../crypto/ct/ct_locl.h ../../e_os.h ../../include/openssl/asn1.h +v3_scts.o: ../../e_os.h ../../include/openssl/asn1.h v3_scts.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h v3_scts.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h v3_scts.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h @@ -536,7 +536,8 @@ v3_scts.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h v3_scts.o: ../../include/openssl/sha.h ../../include/openssl/stack.h v3_scts.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h v3_scts.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h -v3_scts.o: ../include/internal/cryptlib.h ext_dat.h v3_scts.c +v3_scts.o: ../include/internal/cryptlib.h ../include/internal/ct_int.h +v3_scts.o: ext_dat.h v3_scts.c v3_skey.o: ../../e_os.h ../../include/openssl/asn1.h v3_skey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h v3_skey.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h diff --git a/crypto/x509v3/v3_scts.c b/crypto/x509v3/v3_scts.c index 6d3665c..777378c 100644 --- a/crypto/x509v3/v3_scts.c +++ b/crypto/x509v3/v3_scts.c @@ -61,7 +61,7 @@ #include #include #include "ext_dat.h" -#include "crypto/ct/ct_locl.h" +#include "internal/ct_int.h" #ifndef OPENSSL_NO_CT /* Signature and hash algorithms from RFC 5246 */ diff --git a/util/mkstack.pl b/util/mkstack.pl index 8daa1f8..16a0172 100755 --- a/util/mkstack.pl +++ b/util/mkstack.pl @@ -15,7 +15,7 @@ my @sstacklst; my @asn1setlst; my @p12stklst; my @lhashlst; -my @source = (, , , , ); +my @source = (, , , , , ); foreach $file (@source) { next if -l $file; From levitte at openssl.org Sun Oct 18 20:27:46 2015 From: levitte at openssl.org (Richard Levitte) Date: Sun, 18 Oct 2015 20:27:46 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445200066.753925.17126.nullmailer@dev.openssl.org> The branch master has been updated via 788d72ba021fdd29f6b3e573adc313d97f7d224d (commit) from 338cb76220e641bba9684cab745b2105d6ac0558 (commit) - Log ----------------------------------------------------------------- commit 788d72ba021fdd29f6b3e573adc313d97f7d224d Author: Richard Levitte Date: Sun Oct 18 21:31:21 2015 +0200 ct_locl.h moved, reflect it in crypto/ct/Makefile Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: crypto/ct/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/ct/Makefile b/crypto/ct/Makefile index 3c89ac7..8d6e6b7 100644 --- a/crypto/ct/Makefile +++ b/crypto/ct/Makefile @@ -20,7 +20,7 @@ LIBOBJ= ct_lib.o SRC= $(LIBSRC) -HEADER= ct_locl.h +HEADER= ALL= $(GENERAL) $(SRC) $(HEADER) From matt at openssl.org Wed Oct 21 15:15:56 2015 From: matt at openssl.org (Matt Caswell) Date: Wed, 21 Oct 2015 15:15:56 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445440556.980720.30809.nullmailer@dev.openssl.org> The branch master has been updated via 3fde6c9276c9cd6e56e8e06e756350a4fbdd7031 (commit) from 788d72ba021fdd29f6b3e573adc313d97f7d224d (commit) - Log ----------------------------------------------------------------- commit 3fde6c9276c9cd6e56e8e06e756350a4fbdd7031 Author: Matt Caswell Date: Wed Oct 21 10:00:24 2015 +0100 Avoid undefined behaviour in PACKET_buf_init Change the sanity check in PACKET_buf_init to check for excessive length buffers, which should catch the interesting cases where len has been cast from a negative value whilst avoiding any undefined behaviour. RT#4094 Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: ssl/packet_locl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h index 507d64f..cb61a93 100644 --- a/ssl/packet_locl.h +++ b/ssl/packet_locl.h @@ -111,7 +111,7 @@ __owur static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf, size_t len) { /* Sanity check for negative values. */ - if (buf + len < buf) + if (len > (size_t)(SIZE_MAX / 2)) return 0; pkt->curr = buf; From matt at openssl.org Wed Oct 21 15:22:56 2015 From: matt at openssl.org (Matt Caswell) Date: Wed, 21 Oct 2015 15:22:56 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445440976.695098.11998.nullmailer@dev.openssl.org> The branch master has been updated via 21cd6e006cc1ea9a1ba13c45c6858118e34604f6 (commit) from 3fde6c9276c9cd6e56e8e06e756350a4fbdd7031 (commit) - Log ----------------------------------------------------------------- commit 21cd6e006cc1ea9a1ba13c45c6858118e34604f6 Author: Matt Caswell Date: Wed Oct 21 14:40:15 2015 +0100 Don't use SSLv23_server_method in an example The function SSLv23_server_method() is an old name. New code should use TLS_server_method() instead. Therefore don't use SSLv23_server_method() in an example in the docs. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: doc/ssl/SSL_CTX_new.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ssl/SSL_CTX_new.pod b/doc/ssl/SSL_CTX_new.pod index 3cbf7a7..15011f8 100644 --- a/doc/ssl/SSL_CTX_new.pod +++ b/doc/ssl/SSL_CTX_new.pod @@ -73,7 +73,7 @@ those functions instead. The list of protocols available can later be limited using the SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1 and SSL_OP_NO_TLSv1_2 options of the SSL_CTX_set_options() or SSL_set_options() functions. -Using these options it is possible to choose e.g. SSLv23_server_method() and +Using these options it is possible to choose e.g. TLS_server_method() and be able to negotiate with all possible clients, but to only allow newer protocols like TLSv1, TLSv1.1 or TLS v1.2. From levitte at openssl.org Wed Oct 21 22:05:44 2015 From: levitte at openssl.org (Richard Levitte) Date: Wed, 21 Oct 2015 22:05:44 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445465144.917465.31895.nullmailer@dev.openssl.org> The branch master has been updated via 15db6a40d3569789329d3f6f84e47e0e0e8f9caa (commit) via a0e8da5d92718052343146e5b5ed85c2fe74492b (commit) via cc79f06c0af2a23cc6f7c01599f484a094b37c3a (commit) from 21cd6e006cc1ea9a1ba13c45c6858118e34604f6 (commit) - Log ----------------------------------------------------------------- commit 15db6a40d3569789329d3f6f84e47e0e0e8f9caa Author: Richard Levitte Date: Mon Oct 19 20:53:14 2015 +0200 make update Reviewed-by: Matt Caswell commit a0e8da5d92718052343146e5b5ed85c2fe74492b Author: Richard Levitte Date: Mon Oct 19 05:24:16 2015 +0200 Don't forget to load the CT error strings Reviewed-by: Matt Caswell commit cc79f06c0af2a23cc6f7c01599f484a094b37c3a Author: Richard Levitte Date: Mon Oct 19 04:20:01 2015 +0200 Handle CT error macros separately Because the default error macro generator assumes the header file with error macros is in include/openssl and therefore generates a C file with error texts that include , we need to generate the error macros and texts for CT separately, since the CT module doesn't follow the default criteria. Reviewed-by: Matt Caswell ----------------------------------------------------------------------- Summary of changes: Makefile.org | 1 + crypto/ct/Makefile | 14 ++++++++++++-- crypto/ct/ct.ec | 6 ++++++ crypto/ct/ct_err.c | 4 ++-- crypto/err/Makefile | 3 ++- crypto/err/err_all.c | 4 ++++ crypto/err/openssl.ec | 1 - 7 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 crypto/ct/ct.ec diff --git a/Makefile.org b/Makefile.org index 5aa721f..629cdae 100644 --- a/Makefile.org +++ b/Makefile.org @@ -468,6 +468,7 @@ errors: $(PERL) util/ck_errf.pl -strict */*.c */*/*.c $(PERL) util/mkerr.pl -recurse -write (cd engines; $(MAKE) PERL=$(PERL) errors) + (cd crypto/ct; $(MAKE) PERL=$(PERL) errors) stacks: $(PERL) util/mkstack.pl -write diff --git a/crypto/ct/Makefile b/crypto/ct/Makefile index 8d6e6b7..2f55a2d 100644 --- a/crypto/ct/Makefile +++ b/crypto/ct/Makefile @@ -15,8 +15,8 @@ CFLAGS= $(INCLUDES) $(CFLAG) GENERAL=Makefile LIB=$(TOP)/libcrypto.a -LIBSRC= ct_lib.c -LIBOBJ= ct_lib.o +LIBSRC= ct_lib.c ct_err.c +LIBOBJ= ct_lib.o ct_err.o SRC= $(LIBSRC) @@ -42,6 +42,9 @@ files: tags: ctags $(SRC) +errors: + $(PERL) $(TOP)/util/mkerr.pl -conf ct.ec -hprefix internal/ -write *.c + lint: lint -DLINT $(INCLUDES) $(SRC)>fluff @@ -60,6 +63,13 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. +ct_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h +ct_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +ct_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h +ct_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +ct_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +ct_err.o: ../../include/openssl/symhacks.h ../include/internal/ct_int.h +ct_err.o: ct_err.c ct_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h ct_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h ct_lib.o: ../../include/openssl/comp.h ../../include/openssl/crypto.h diff --git a/crypto/ct/ct.ec b/crypto/ct/ct.ec new file mode 100644 index 0000000..6f50f9a --- /dev/null +++ b/crypto/ct/ct.ec @@ -0,0 +1,6 @@ +# crypto/ct/ct.ec + +# configuration file for util/mkerr.pl + +# files that may have to be rewritten by util/mkerr.pl +L CT ../../crypto/include/internal/ct_int.h ct_err.c diff --git a/crypto/ct/ct_err.c b/crypto/ct/ct_err.c index d2781c5..df79252 100644 --- a/crypto/ct/ct_err.c +++ b/crypto/ct/ct_err.c @@ -1,4 +1,4 @@ -/* crypto/ct/ct_err.c */ +/* ct_err.c */ /* ==================================================================== * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved. * @@ -61,7 +61,7 @@ #include #include -#include +#include /* BEGIN ERROR CODES */ #ifndef OPENSSL_NO_ERR diff --git a/crypto/err/Makefile b/crypto/err/Makefile index e384e62..dcd7347 100644 --- a/crypto/err/Makefile +++ b/crypto/err/Makefile @@ -86,7 +86,8 @@ err_all.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h err_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h err_all.o: ../../include/openssl/ts.h ../../include/openssl/ui.h err_all.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h -err_all.o: ../../include/openssl/x509v3.h err_all.c +err_all.o: ../../include/openssl/x509v3.h ../include/internal/ct_int.h +err_all.o: err_all.c err_prn.o: ../../e_os.h ../../include/openssl/bio.h err_prn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h err_prn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h diff --git a/crypto/err/err_all.c b/crypto/err/err_all.c index b844167..d9a2a57 100644 --- a/crypto/err/err_all.c +++ b/crypto/err/err_all.c @@ -105,6 +105,7 @@ #ifndef OPENSSL_NO_JPAKE # include #endif +#include void ERR_load_crypto_strings(void) { @@ -161,5 +162,8 @@ void ERR_load_crypto_strings(void) # ifndef OPENSSL_NO_JPAKE ERR_load_JPAKE_strings(); # endif +# ifndef OPENSSL_NO_CT + ERR_load_CT_strings(); +# endif #endif } diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec index 08b0c0b..8a10b80 100644 --- a/crypto/err/openssl.ec +++ b/crypto/err/openssl.ec @@ -36,7 +36,6 @@ L HMAC include/openssl/hmac.h crypto/hmac/hmac_err.c L CMS include/openssl/cms.h crypto/cms/cms_err.c L JPAKE include/openssl/jpake.h crypto/jpake/jpake_err.c L FIPS include/openssl/fips.h crypto/fips_err.h -L CT crypto/ct/ct_locl.h crypto/ct/ct_err.c # additional header files to be scanned for function names L NONE crypto/x509/x509_vfy.h NONE From builds at travis-ci.org Wed Oct 21 22:31:00 2015 From: builds at travis-ci.org (Travis CI) Date: Wed, 21 Oct 2015 22:31:00 +0000 Subject: [openssl-commits] Broken: openssl/openssl#470 (master - 15db6a4) In-Reply-To: Message-ID: <562812242b750_317a24e94187@8ce1afd4-5493-4a13-a402-9e0961464fc2.mail> Build Update for openssl/openssl ------------------------------------- Build: #470 Status: Broken Duration: 24 minutes and 40 seconds Commit: 15db6a4 (master) Author: Richard Levitte Message: make update Reviewed-by: Matt Caswell View the changeset: https://github.com/openssl/openssl/compare/21cd6e006cc1...15db6a40d356 View the full build log and details: https://travis-ci.org/openssl/openssl/builds/86723145 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From levitte at openssl.org Thu Oct 22 15:46:10 2015 From: levitte at openssl.org (Richard Levitte) Date: Thu, 22 Oct 2015 15:46:10 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445528770.915330.3967.nullmailer@dev.openssl.org> The branch master has been updated via 489eb74090a6327454f4a53213480eaa6659704b (commit) via 8b527be2db48064673640dda2d57edc6b362ae64 (commit) from 15db6a40d3569789329d3f6f84e47e0e0e8f9caa (commit) - Log ----------------------------------------------------------------- commit 489eb74090a6327454f4a53213480eaa6659704b Author: Richard Levitte Date: Thu Oct 22 17:33:47 2015 +0200 Make Configure die when unsupported options are given Reviewed-by: Rich Salz commit 8b527be2db48064673640dda2d57edc6b362ae64 Author: Richard Levitte Date: Thu Oct 22 17:09:14 2015 +0200 Add an explicit list of options that can be disabled, enabled, ... Configure has, so far, had no control at all of which 'no-' options it can be given. This means that, for example, someone could configure with something absurd like 'no-stack' and then watch the build crumble to dust... or file a bug report. This introduces some sanity into the possible choices. The added list comes from looking for the explicit ones used in Configure, and from grepping after OPENSSL_NO_ in all source files. Reviewed-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: Configure | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/Configure b/Configure index 9ff6e70..7956247 100755 --- a/Configure +++ b/Configure @@ -796,6 +796,86 @@ my $default_ranlib; my $perl; my $fips=0; +# Explicitelly known options that are possible to disable. They can +# be regexps, and will be used like this: /^no-${option}$/ +# For developers: keep it sorted alphabetically + +my @disablables = ( + "aes", + "asm", + "bf", + "camellia", + "capieng", + "cast", + "cmac", + "cms", + "comp", + "ct", + "deprecated", + "des", + "dgram", + "dh", + "dsa", + "dso", + "dtls1?", + "dynamic[-_]engine", + "ec", + "ec2m", + "ec_nistp_64_gcc_128", + "engine", + "err", # Really??? + "gmp", + "gost", + "heartbeats", + "hmac", + "hw(-.+)?", + "idea", + "jpake", + "locking", # Really??? + "md2", + "md4", + "md5", + "mdc2", + "md[-_]ghost94", + "nextprotoneg", + "ocb", + "ocsp", + "posix-io", + "psk", + "rc2", + "rc4", + "rc5", + "rdrand", + "rfc3779", + "rijndael", # Old AES name + "rmd160", + "rsa", + "scrypt", + "sct", + "sctp", + "seed", + "sha", + "shared", + "sock", + "srp", + "srtp", + "sse2", + "ssl", + "ssl3", + "ssl3-method", + "ssl-trace", + "static-engine", + "stdio", + "store", + "threads", + "tls", + "tls1", + "unit-test", + "whirlpool", + "zlib", + "zlib-dynamic", + ); + # All of the following is disabled by default (RC5 was enabled before 0.9.8): my %disabled = ( # "what" => "comment" [or special keyword "experimental"] @@ -867,6 +947,7 @@ while($argv_unprocessed) $argvstring=join(' ', at argvcopy); PROCESS_ARGS: + my %unsupported_options = (); foreach (@argvcopy) { s /^-no-/no-/; # some people just can't read the instructions @@ -878,6 +959,15 @@ PROCESS_ARGS: s /^zlib$/enable-zlib/; s /^zlib-dynamic$/enable-zlib-dynamic/; + if (/^(no|disable|enable|experimental)-(.+)$/) + { + my $word = $2; + if (!grep { $word =~ /^${_}$/ } @disablables) + { + $unsupported_options{$_} = 1; + next; + } + } if (/^no-(.+)$/ || /^disable-(.+)$/) { if (!($disabled{$1} eq "experimental")) @@ -1046,6 +1136,12 @@ PROCESS_ARGS: { $options .= " ".$_; } } } + + if (keys %unsupported_options) + { + die "***** Unsupported options: ", + join(", ", keys %unsupported_options), "\n"; + } } From builds at travis-ci.org Thu Oct 22 16:21:34 2015 From: builds at travis-ci.org (Travis CI) Date: Thu, 22 Oct 2015 16:21:34 +0000 Subject: [openssl-commits] Fixed: openssl/openssl#475 (master - 489eb74) In-Reply-To: Message-ID: <56290d0e8e558_315fba4e755689@2ba35ca2-0718-458c-8298-706e9f931610.mail> Build Update for openssl/openssl ------------------------------------- Build: #475 Status: Fixed Duration: 34 minutes and 29 seconds Commit: 489eb74 (master) Author: Richard Levitte Message: Make Configure die when unsupported options are given Reviewed-by: Rich Salz View the changeset: https://github.com/openssl/openssl/compare/15db6a40d356...489eb74090a6 View the full build log and details: https://travis-ci.org/openssl/openssl/builds/86853832 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From levitte at openssl.org Thu Oct 22 22:17:54 2015 From: levitte at openssl.org (Richard Levitte) Date: Thu, 22 Oct 2015 22:17:54 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445552274.488452.7229.nullmailer@dev.openssl.org> The branch master has been updated via 5212d39bd92ede18b22fe8173e724a7eac35cb8a (commit) from 489eb74090a6327454f4a53213480eaa6659704b (commit) - Log ----------------------------------------------------------------- commit 5212d39bd92ede18b22fe8173e724a7eac35cb8a Author: Richard Levitte Date: Thu Oct 22 23:45:45 2015 +0200 Only include SRP headers when OPENSSL_NO_SRP is undefined [fixes github issue #447] Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: crypto/bn/bn_srp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/bn/bn_srp.c b/crypto/bn/bn_srp.c index c575e6a..a1e438c 100644 --- a/crypto/bn/bn_srp.c +++ b/crypto/bn/bn_srp.c @@ -1,10 +1,11 @@ #include "bn_lcl.h" #include "e_os.h" -#include -#include #ifndef OPENSSL_NO_SRP +#include +#include + # if (BN_BYTES == 8) # if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) # define bn_pack4(a1,a2,a3,a4) ((a1##UI64<<48)|(a2##UI64<<32)|(a3##UI64<<16)|a4##UI64) From rsalz at openssl.org Thu Oct 22 22:28:19 2015 From: rsalz at openssl.org (Rich Salz) Date: Thu, 22 Oct 2015 22:28:19 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445552899.909514.10633.nullmailer@dev.openssl.org> The branch master has been updated via 8cbb048c3ea416f2bd8a3706d027f3aa26ef08d9 (commit) from 5212d39bd92ede18b22fe8173e724a7eac35cb8a (commit) - Log ----------------------------------------------------------------- commit 8cbb048c3ea416f2bd8a3706d027f3aa26ef08d9 Author: Adam Eijdenberg Date: Mon Oct 19 11:16:25 2015 -0700 Clarify return values for EVP_DigestVerifyFinal. Previous language was unclear. New language isn't pretty but I believe it is more accurate. Signed-off-by: Rich Salz Reviewed-by: Ben Laurie Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: doc/crypto/EVP_DigestVerifyInit.pod | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/crypto/EVP_DigestVerifyInit.pod b/doc/crypto/EVP_DigestVerifyInit.pod index 44d3cdb..338fc74 100644 --- a/doc/crypto/EVP_DigestVerifyInit.pod +++ b/doc/crypto/EVP_DigestVerifyInit.pod @@ -36,10 +36,11 @@ B of length B. EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return 1 for success and 0 for failure. -Unlike other functions the return value 0 from EVP_DigestVerifyFinal() only -indicates that the signature did not verify successfully (that is tbs did -not match the original data or the signature was of invalid form) it is not an -indication of a more serious error. +EVP_DigestVerifyFinal() returns 1 for success; any other value indicates +failure. A return value of zero indicates that the signature did not verify +successfully (that is, tbs did not match the original data or the signature had +an invalid form), while other values indicate a more serious error (and +sometimes also indicate an invalid signature form). The error codes can be obtained from L. From rsalz at openssl.org Thu Oct 22 22:28:50 2015 From: rsalz at openssl.org (Rich Salz) Date: Thu, 22 Oct 2015 22:28:50 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1445552930.672294.11526.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via 8d43c0053b0df225f1c30b50af2aa1a0fc64b015 (commit) from e272f8ef8f63298466494adcd29512797ab1eece (commit) - Log ----------------------------------------------------------------- commit 8d43c0053b0df225f1c30b50af2aa1a0fc64b015 Author: Adam Eijdenberg Date: Mon Oct 19 11:16:25 2015 -0700 Clarify return values for EVP_DigestVerifyFinal. Previous language was unclear. New language isn't pretty but I believe it is more accurate. Signed-off-by: Rich Salz Reviewed-by: Ben Laurie Reviewed-by: Richard Levitte (cherry picked from commit 8cbb048c3ea416f2bd8a3706d027f3aa26ef08d9) ----------------------------------------------------------------------- Summary of changes: doc/crypto/EVP_DigestVerifyInit.pod | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/crypto/EVP_DigestVerifyInit.pod b/doc/crypto/EVP_DigestVerifyInit.pod index e0217e4..0ead2d2 100644 --- a/doc/crypto/EVP_DigestVerifyInit.pod +++ b/doc/crypto/EVP_DigestVerifyInit.pod @@ -37,10 +37,11 @@ EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return 1 for success and 0 or a negative value for failure. In particular a return value of -2 indicates the operation is not supported by the public key algorithm. -Unlike other functions the return value 0 from EVP_DigestVerifyFinal() only -indicates that the signature did not verify successfully (that is tbs did -not match the original data or the signature was of invalid form) it is not an -indication of a more serious error. +EVP_DigestVerifyFinal() returns 1 for success; any other value indicates +failure. A return value of zero indicates that the signature did not verify +successfully (that is, tbs did not match the original data or the signature had +an invalid form), while other values indicate a more serious error (and +sometimes also indicate an invalid signature form). The error codes can be obtained from L. From rsalz at openssl.org Fri Oct 23 01:11:26 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 23 Oct 2015 01:11:26 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1445562686.503315.8772.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 2d404dc38031122147043af31a1f1de364903be2 (commit) from b2593839da1e0c5af5fedf3fce3fd43c400199b4 (commit) - Log ----------------------------------------------------------------- commit 2d404dc38031122147043af31a1f1de364903be2 Author: Adam Eijdenberg Date: Mon Oct 19 11:16:25 2015 -0700 Clarify return values for EVP_DigestVerifyFinal. Previous language was unclear. New language isn't pretty but I believe it is more accurate. Signed-off-by: Rich Salz Reviewed-by: Ben Laurie Reviewed-by: Richard Levitte (cherry picked from commit 8cbb048c3ea416f2bd8a3706d027f3aa26ef08d9) ----------------------------------------------------------------------- Summary of changes: doc/crypto/EVP_DigestVerifyInit.pod | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/crypto/EVP_DigestVerifyInit.pod b/doc/crypto/EVP_DigestVerifyInit.pod index cfeccd9..54cad92 100644 --- a/doc/crypto/EVP_DigestVerifyInit.pod +++ b/doc/crypto/EVP_DigestVerifyInit.pod @@ -37,10 +37,11 @@ EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return 1 for success and 0 or a negative value for failure. In particular a return value of -2 indicates the operation is not supported by the public key algorithm. -Unlike other functions the return value 0 from EVP_DigestVerifyFinal() only -indicates that the signature did not verify successfully (that is tbs did -not match the original data or the signature was of invalid form) it is not an -indication of a more serious error. +EVP_DigestVerifyFinal() returns 1 for success; any other value indicates +failure. A return value of zero indicates that the signature did not verify +successfully (that is, tbs did not match the original data or the signature had +an invalid form), while other values indicate a more serious error (and +sometimes also indicate an invalid signature form). The error codes can be obtained from L. From levitte at openssl.org Fri Oct 23 12:39:11 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 12:39:11 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1445603951.945167.2531.nullmailer@dev.openssl.org> The branch master has been updated via dde0a59b225168d49a5f6d90dd03b07727c321b0 (commit) via b8b16c9fa6d82b90b692298aa0cfa09202e2d184 (commit) from 04aec9e4e49adb97b496b6e9bbd172bdab36cfe2 (commit) - Log ----------------------------------------------------------------- commit dde0a59b225168d49a5f6d90dd03b07727c321b0 Author: Richard Levitte Date: Fri Oct 23 14:38:44 2015 +0200 Avoid loops. commit b8b16c9fa6d82b90b692298aa0cfa09202e2d184 Author: Richard Levitte Date: Fri Oct 23 14:38:28 2015 +0200 Incorporate source/.htaccess in version control ----------------------------------------------------------------------- Summary of changes: .gitignore | 1 - docs/.htaccess | 14 +++++++------- source/.htaccess | 30 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 source/.htaccess diff --git a/.gitignore b/.gitignore index ed3211e..f99f40b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ news/vulnerabilities.inc newsflash.inc source/*.gz* source/*.patch -source/.htaccess source/index.inc source/license.txt source/old/*/*.patch diff --git a/docs/.htaccess b/docs/.htaccess index b6710c3..cc9c083 100644 --- a/docs/.htaccess +++ b/docs/.htaccess @@ -1,12 +1,12 @@ RewriteEngine on -RewriteRule fips/fipsnotes.html /docs/fipsnotes.html [L,R=302,NC] -RewriteRule fips/fipsvalidation.html /docs/fipsvalidation.html [L,R=302,NC] -RewriteRule fips/index.html /docs/fips/fips.html [L,R=302,NC] +RewriteRule ^/fips/fipsnotes.html /docs/fipsnotes.html [L,R=302,NC] +RewriteRule ^/fips/fipsvalidation.html /docs/fipsvalidation.html [L,R=302,NC] +RewriteRule ^/fips/index.html /docs/fips/fips.html [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule manmaster/apps/1/(.*) /docs/manmaster/apps/$1 [L,R=302,NC] +RewriteRule ^/manmaster/apps/1/(.*) /docs/manmaster/apps/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule apps/(..*) /docs/manmaster/apps/$1 [L,R=302,NC] +RewriteRule ^/apps/(..*) /docs/manmaster/apps/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule crypto/(..*) /docs/manmaster/crypto/$1 [L,R=302,NC] +RewriteRule ^/crypto/(..*) /docs/manmaster/crypto/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ssl/(..*) /docs/manmaster/ssl/$1 [L,R=302,NC] +RewriteRule ^/ssl/(..*) /docs/manmaster/ssl/$1 [L,R=302,NC] diff --git a/source/.htaccess b/source/.htaccess new file mode 100644 index 0000000..6a2766d --- /dev/null +++ b/source/.htaccess @@ -0,0 +1,30 @@ +RewriteEngine on +RewriteBase /source +# First, rewrite all the 'latest' URLs +RewriteRule ^latest.tar.gz$ openssl-1.0.2d.tar.gz [L,R=302,NC] +RewriteRule ^openssl-0.9.8-latest.tar.gz$ openssl-0.9.8zg.tar.gz [L,R=302,NC] +RewriteRule ^openssl-1.0.0-latest.tar.gz$ openssl-1.0.0s.tar.gz [L,R=302,NC] +RewriteRule ^openssl-1.0.1-latest.tar.gz$ openssl-1.0.1p.tar.gz [L,R=302,NC] +RewriteRule ^openssl-1.0.2-latest.tar.gz$ openssl-1.0.2d.tar.gz [L,R=302,NC] + +# Old distro's are in subdirs. +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^(openssl-0\.9\.8.*) old/0.9.x/$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^openssl-(1\.0\.0.*) old/1.0.0/openssl-$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^openssl-(1\.0\.1.*) old/1.0.1/openssl-$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^openssl-(1\.0\.2.*) old/1.0.1/openssl-$1 [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^openssl-(fips.*) old/fips/openssl-$1 [L] + + + RemoveEncoding .gz + + + RemoveEncoding .gz + + + RemoveEncoding .gz + From levitte at openssl.org Fri Oct 23 12:43:19 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 12:43:19 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1445604199.829162.12576.nullmailer@dev.openssl.org> The branch master has been updated via 33234594a21af56e14bf891d8cdbe8657784eff7 (commit) from dde0a59b225168d49a5f6d90dd03b07727c321b0 (commit) - Log ----------------------------------------------------------------- commit 33234594a21af56e14bf891d8cdbe8657784eff7 Author: Richard Levitte Date: Fri Oct 23 14:43:10 2015 +0200 Adjust some rewrite rules ----------------------------------------------------------------------- Summary of changes: docs/.htaccess | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/.htaccess b/docs/.htaccess index cc9c083..41be47c 100644 --- a/docs/.htaccess +++ b/docs/.htaccess @@ -3,10 +3,10 @@ RewriteRule ^/fips/fipsnotes.html /docs/fipsnotes.html [L,R=302,NC] RewriteRule ^/fips/fipsvalidation.html /docs/fipsvalidation.html [L,R=302,NC] RewriteRule ^/fips/index.html /docs/fips/fips.html [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/manmaster/apps/1/(.*) /docs/manmaster/apps/$1 [L,R=302,NC] +RewriteRule ^/docs/manmaster/apps/1/(.*) /docs/manmaster/apps/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/apps/(..*) /docs/manmaster/apps/$1 [L,R=302,NC] +RewriteRule ^/docs/apps/(..*) /docs/manmaster/apps/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/crypto/(..*) /docs/manmaster/crypto/$1 [L,R=302,NC] +RewriteRule ^/docs/crypto/(..*) /docs/manmaster/crypto/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/ssl/(..*) /docs/manmaster/ssl/$1 [L,R=302,NC] +RewriteRule ^/docs/ssl/(..*) /docs/manmaster/ssl/$1 [L,R=302,NC] From levitte at openssl.org Fri Oct 23 12:45:55 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 12:45:55 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1445604355.405318.19026.nullmailer@dev.openssl.org> The branch master has been updated via ce4c485f1b7a545781f757ba2a810ed1d865ad2b (commit) from 33234594a21af56e14bf891d8cdbe8657784eff7 (commit) - Log ----------------------------------------------------------------- commit ce4c485f1b7a545781f757ba2a810ed1d865ad2b Author: Richard Levitte Date: Fri Oct 23 14:45:48 2015 +0200 Learn what per-directory means... ----------------------------------------------------------------------- Summary of changes: docs/.htaccess | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/.htaccess b/docs/.htaccess index 41be47c..bddf41d 100644 --- a/docs/.htaccess +++ b/docs/.htaccess @@ -1,12 +1,12 @@ RewriteEngine on -RewriteRule ^/fips/fipsnotes.html /docs/fipsnotes.html [L,R=302,NC] -RewriteRule ^/fips/fipsvalidation.html /docs/fipsvalidation.html [L,R=302,NC] -RewriteRule ^/fips/index.html /docs/fips/fips.html [L,R=302,NC] +RewriteRule ^fips/fipsnotes.html /docs/fipsnotes.html [L,R=302,NC] +RewriteRule ^fips/fipsvalidation.html /docs/fipsvalidation.html [L,R=302,NC] +RewriteRule ^fips/index.html /docs/fips/fips.html [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/docs/manmaster/apps/1/(.*) /docs/manmaster/apps/$1 [L,R=302,NC] +RewriteRule ^manmaster/apps/1/(.*) /docs/manmaster/apps/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/docs/apps/(..*) /docs/manmaster/apps/$1 [L,R=302,NC] +RewriteRule ^apps/(..*) /docs/manmaster/apps/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/docs/crypto/(..*) /docs/manmaster/crypto/$1 [L,R=302,NC] +RewriteRule ^crypto/(..*) /docs/manmaster/crypto/$1 [L,R=302,NC] RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^/docs/ssl/(..*) /docs/manmaster/ssl/$1 [L,R=302,NC] +RewriteRule ^ssl/(..*) /docs/manmaster/ssl/$1 [L,R=302,NC] From levitte at openssl.org Fri Oct 23 17:33:35 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 17:33:35 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445621615.237471.22333.nullmailer@dev.openssl.org> The branch master has been updated via dad0b512e649336440e2b3cc9d667c56d9a91eff (commit) from 8cbb048c3ea416f2bd8a3706d027f3aa26ef08d9 (commit) - Log ----------------------------------------------------------------- commit dad0b512e649336440e2b3cc9d667c56d9a91eff Author: Alessandro Ghedini Date: Fri Oct 23 17:55:27 2015 +0200 Remove bugs/ and crypto/threads/ Reviewed-by: Rich Salz Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: bugs/MS | 7 - bugs/SSLv3 | 49 -- bugs/alpha.c | 92 ---- bugs/sgiccbug.c | 60 --- bugs/sslref.dif | 26 - bugs/stream.c | 132 ----- bugs/ultrixcc.c | 44 -- crypto/threads/mttest.c | 1071 --------------------------------------- crypto/threads/netware.bat | 79 --- crypto/threads/profile.sh | 4 - crypto/threads/ptest.bat | 4 - crypto/threads/pthread.sh | 9 - crypto/threads/pthread2.sh | 6 - crypto/threads/pthreads-vms.com | 14 - crypto/threads/purify.sh | 4 - crypto/threads/solaris.sh | 4 - crypto/threads/th-lock.c | 364 ------------- crypto/threads/win32.bat | 4 - 18 files changed, 1973 deletions(-) delete mode 100644 bugs/MS delete mode 100644 bugs/SSLv3 delete mode 100644 bugs/alpha.c delete mode 100644 bugs/sgiccbug.c delete mode 100644 bugs/sslref.dif delete mode 100644 bugs/stream.c delete mode 100644 bugs/ultrixcc.c delete mode 100644 crypto/threads/mttest.c delete mode 100644 crypto/threads/netware.bat delete mode 100644 crypto/threads/profile.sh delete mode 100755 crypto/threads/ptest.bat delete mode 100644 crypto/threads/pthread.sh delete mode 100755 crypto/threads/pthread2.sh delete mode 100644 crypto/threads/pthreads-vms.com delete mode 100644 crypto/threads/purify.sh delete mode 100644 crypto/threads/solaris.sh delete mode 100644 crypto/threads/th-lock.c delete mode 100755 crypto/threads/win32.bat diff --git a/bugs/MS b/bugs/MS deleted file mode 100644 index a1dcfb9..0000000 --- a/bugs/MS +++ /dev/null @@ -1,7 +0,0 @@ -If you use the function that does an fopen inside the DLL, it's malloc -will be used and when the function is then written inside, more -hassles -.... - - -think about it. diff --git a/bugs/SSLv3 b/bugs/SSLv3 deleted file mode 100644 index a75a165..0000000 --- a/bugs/SSLv3 +++ /dev/null @@ -1,49 +0,0 @@ -So far... - -ssl3.netscape.com:443 does not support client side dynamic -session-renegotiation. - -ssl3.netscape.com:444 (asks for client cert) sends out all the CA RDN -in an invalid format (the outer sequence is removed). - -Netscape-Commerce/1.12, when talking SSLv2, accepts a 32 byte -challenge but then appears to only use 16 bytes when generating the -encryption keys. Using 16 bytes is ok but it should be ok to use 32. -According to the SSLv3 spec, one should use 32 bytes for the challenge -when opperating in SSLv2/v3 compatablity mode, but as mentioned above, -this breaks this server so 16 bytes is the way to go. - -www.microsoft.com - when talking SSLv2, if session-id reuse is -performed, the session-id passed back in the server-finished message -is different from the one decided upon. - -ssl3.netscape.com:443, first a connection is established with RC4-MD5. -If it is then resumed, we end up using DES-CBC3-SHA. It should be -RC4-MD5 according to 7.6.1.3, 'cipher_suite'. -Netscape-Enterprise/2.01 (https://merchant.netscape.com) has this bug. -It only really shows up when connecting via SSLv2/v3 then reconnecting -via SSLv3. The cipher list changes.... -NEW INFORMATION. Try connecting with a cipher list of just -DES-CBC-SHA:RC4-MD5. For some weird reason, each new connection uses -RC4-MD5, but a re-connect tries to use DES-CBC-SHA. So netscape, when -doing a re-connect, always takes the first cipher in the cipher list. - -If we accept a netscape connection, demand a client cert, have a -non-self-signed CA which does not have it's CA in netscape, and the -browser has a cert, it will crash/hang. Works for 3.x and 4.xbeta - -Netscape browsers do not really notice the server sending a -close notify message. I was sending one, and then some invalid data. -netscape complained of an invalid mac. (a fork()ed child doing a -SSL_shutdown() and still sharing the socket with its parent). - -Netscape, when using export ciphers, will accept a 1024 bit temporary -RSA key. It is supposed to only accept 512. - -If Netscape connects to a server which requests a client certificate -it will frequently hang after the user has selected one and never -complete the connection. Hitting "Stop" and reload fixes this and -all subsequent connections work fine. This appears to be because -Netscape wont read any new records in when it is awaiting a server -done message at this point. The fix is to send the certificate request -and server done messages in one record. diff --git a/bugs/alpha.c b/bugs/alpha.c deleted file mode 100644 index 3b4bc93..0000000 --- a/bugs/alpha.c +++ /dev/null @@ -1,92 +0,0 @@ -/* bugs/alpha.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* - * while not exactly a bug (ASN1 C leaves this undefined) it is something to - * watch out for. This was fine on linux/NT/Solaris but not Alpha - */ - -/*- - * it is basically an example of - * func(*(a++),*(a++)) - * which parameter is evaluated first? It is not defined in ASN1 C. - */ - -#include - -#define TYPE unsigned int - -void func(a, b) -TYPE *a; -TYPE b; -{ - printf("%ld -1 == %ld\n", a[0], b); -} - -main() -{ - TYPE data[5] = { 1L, 2L, 3L, 4L, 5L }; - TYPE *p; - int i; - - p = data; - - for (i = 0; i < 4; i++) { - func(p, *(p++)); - } -} diff --git a/bugs/sgiccbug.c b/bugs/sgiccbug.c deleted file mode 100644 index 6b1b3d4..0000000 --- a/bugs/sgiccbug.c +++ /dev/null @@ -1,60 +0,0 @@ -/* NOCW */ -/* sgibug.c */ -/* bug found by Eric Young (eay at mincom.oz.au) May 95 */ - -#include - -/* - * This compiler bug it present on IRIX 5.3, 5.1 and 4.0.5 (these are the - * only versions of IRIX I have access to. defining FIXBUG removes the bug. - * (bug is still present in IRIX 6.3 according to Gage - * - */ - -/*- - * Compare the output from - * cc sgiccbug.c; ./a.out - * and - * cc -O sgiccbug.c; ./a.out - */ - -static unsigned long a[4] = - { 0x01234567, 0x89ABCDEF, 0xFEDCBA98, 0x76543210 }; -static unsigned long b[4] = - { 0x89ABCDEF, 0xFEDCBA98, 0x76543210, 0x01234567 }; -static unsigned long c[4] = - { 0x77777778, 0x8ACF1357, 0x88888888, 0x7530ECA9 }; - -main() -{ - unsigned long r[4]; - sub(r, a, b); - fprintf(stderr, "input a= %08X %08X %08X %08X\n", a[3], a[2], a[1], a[0]); - fprintf(stderr, "input b= %08X %08X %08X %08X\n", b[3], b[2], b[1], b[0]); - fprintf(stderr, "output = %08X %08X %08X %08X\n", r[3], r[2], r[1], r[0]); - fprintf(stderr, "correct= %08X %08X %08X %08X\n", c[3], c[2], c[1], c[0]); -} - -int sub(r, a, b) -unsigned long *r, *a, *b; -{ - register unsigned long t1, t2, *ap, *bp, *rp; - int i, carry; -#ifdef FIXBUG - unsigned long dummy; -#endif - - ap = a; - bp = b; - rp = r; - carry = 0; - for (i = 0; i < 4; i++) { - t1 = *(ap++); - t2 = *(bp++); - t1 = (t1 - t2); -#ifdef FIXBUG - dummy = t1; -#endif - *(rp++) = t1 & 0xffffffff; - } -} diff --git a/bugs/sslref.dif b/bugs/sslref.dif deleted file mode 100644 index 0817009..0000000 --- a/bugs/sslref.dif +++ /dev/null @@ -1,26 +0,0 @@ -The February 9th, 1995 version of the SSL document differs from -https://www.netscape.com in the following ways. -===== -The key material for generating a SSL_CK_DES_64_CBC_WITH_MD5 key is -KEY-MATERIAL-0 = MD5[MASTER-KEY,"0",CHALLENGE,CONNECTION-ID] -not -KEY-MATERIAL-0 = MD5[MASTER-KEY,CHALLENGE,CONNECTION-ID] -as specified in the documentation. -===== -From the section 2.6 Server Only Protocol Messages - -If the SESSION-ID-HIT flag is non-zero then the CERTIFICATE-TYPE, -CERTIFICATE-LENGTH and CIPHER-SPECS-LENGTH fields will be zero. - -This is not true for https://www.netscape.com. The CERTIFICATE-TYPE -is returned as 1. -===== -I have not tested the following but it is reported by holtzman at mit.edu. - -SSLref clients wait to receive a server-verify before they send a -client-finished. Besides this not being evident from the examples in -2.2.1, it makes more sense to always send all packets you can before -reading. SSLeay was waiting in the server to receive a client-finish -before sending the server-verify :-). I have changed SSLeay to send a -server-verify before trying to read the client-finished. - diff --git a/bugs/stream.c b/bugs/stream.c deleted file mode 100644 index 9af2395..0000000 --- a/bugs/stream.c +++ /dev/null @@ -1,132 +0,0 @@ -/* bugs/stream.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include -#ifdef OPENSSL_NO_DES -# include -#else -# include -#endif - -/* - * show how stream ciphers are not very good. The mac has no affect on RC4 - * while it does for cfb DES - */ - -main() -{ - fprintf(stderr, "rc4\n"); - rc4(); - fprintf(stderr, "cfb des\n"); - des(); -} - -int des() -{ - des_key_schedule ks; - des_cblock iv, key; - int num; - static char *keystr = "01234567"; - static char *in1 = "0123456789ABCEDFdata 12345"; - static char *in2 = "9876543210abcdefdata 12345"; - unsigned char out[100]; - int i; - - des_set_key((des_cblock *)keystr, ks); - - num = 0; - memset(iv, 0, 8); - des_cfb64_encrypt(in1, out, 26, ks, (des_cblock *)iv, &num, 1); - for (i = 0; i < 26; i++) - fprintf(stderr, "%02X ", out[i]); - fprintf(stderr, "\n"); - - num = 0; - memset(iv, 0, 8); - des_cfb64_encrypt(in2, out, 26, ks, (des_cblock *)iv, &num, 1); - for (i = 0; i < 26; i++) - fprintf(stderr, "%02X ", out[i]); - fprintf(stderr, "\n"); -} - -int rc4() -{ - static char *keystr = "0123456789abcdef"; - RC4_KEY key; - unsigned char in[100], out[100]; - int i; - - RC4_set_key(&key, 16, keystr); - in[0] = '\0'; - strcpy(in, "0123456789ABCEDFdata 12345"); - RC4(key, 26, in, out); - - for (i = 0; i < 26; i++) - fprintf(stderr, "%02X ", out[i]); - fprintf(stderr, "\n"); - - RC4_set_key(&key, 16, keystr); - in[0] = '\0'; - strcpy(in, "9876543210abcdefdata 12345"); - RC4(key, 26, in, out); - - for (i = 0; i < 26; i++) - fprintf(stderr, "%02X ", out[i]); - fprintf(stderr, "\n"); -} diff --git a/bugs/ultrixcc.c b/bugs/ultrixcc.c deleted file mode 100644 index 6e24549..0000000 --- a/bugs/ultrixcc.c +++ /dev/null @@ -1,44 +0,0 @@ -#include - -/*- - * This is a cc optimiser bug for ultrix 4.3, mips CPU. - * What happens is that the compiler, due to the (a)&7, - * does - * i=a&7; - * i--; - * i*=4; - * Then uses i as the offset into a jump table. - * The problem is that a value of 0 generates an offset of - * 0xfffffffc. - */ - -main() -{ - f(5); - f(0); -} - -int f(a) -int a; -{ - switch (a & 7) { - case 7: - printf("7\n"); - case 6: - printf("6\n"); - case 5: - printf("5\n"); - case 4: - printf("4\n"); - case 3: - printf("3\n"); - case 2: - printf("2\n"); - case 1: - printf("1\n"); -#ifdef FIX_BUG - case 0: - ; -#endif - } -} diff --git a/crypto/threads/mttest.c b/crypto/threads/mttest.c deleted file mode 100644 index 914ba7b..0000000 --- a/crypto/threads/mttest.c +++ /dev/null @@ -1,1071 +0,0 @@ -/* crypto/threads/mttest.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include -#include -#ifdef LINUX -# include -#endif -#ifdef OPENSSL_SYS_WIN32 -# include -#endif -#ifdef SOLARIS -# include -# include -#endif -#ifdef IRIX -# include -# include -#endif -#ifdef PTHREADS -# include -#endif -#ifdef OPENSSL_SYS_NETWARE -# if !defined __int64 -# define __int64 long long -# endif -# include -#endif -#include -#include -#include -#include -#include -#include -#include - -#ifdef OPENSSL_SYS_NETWARE -# define TEST_SERVER_CERT "/openssl/apps/server.pem" -# define TEST_CLIENT_CERT "/openssl/apps/client.pem" -#else -# define TEST_SERVER_CERT "../../apps/server.pem" -# define TEST_CLIENT_CERT "../../apps/client.pem" -#endif - -#define MAX_THREAD_NUMBER 100 - -int verify_callback(int ok, X509_STORE_CTX *xs); -void thread_setup(void); -void thread_cleanup(void); -void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx); - -void irix_locking_callback(int mode, int type, const char *file, int line); -void solaris_locking_callback(int mode, int type, const char *file, int line); -void win32_locking_callback(int mode, int type, const char *file, int line); -void pthreads_locking_callback(int mode, int type, const char *file, int line); -void netware_locking_callback(int mode, int type, const char *file, int line); -void beos_locking_callback(int mode, int type, const char *file, int line); - -void irix_thread_id(CRYPTO_THREADID *tid); -void solaris_thread_id(CRYPTO_THREADID *tid); -void pthreads_thread_id(CRYPTO_THREADID *tid); -void netware_thread_id(CRYPTO_THREADID *tid); -void beos_thread_id(CRYPTO_THREADID *tid); - -#if defined(OPENSSL_SYS_NETWARE) -static MPKMutex *lock_cs; -static MPKSema ThreadSem; -static long *lock_count; -#endif - -BIO *bio_err = NULL; -BIO *bio_stdout = NULL; - -static char *cipher = NULL; -int verbose = 0; -#ifdef FIONBIO -static int s_nbio = 0; -#endif - -int thread_number = 10; -int number_of_loops = 10; -int reconnect = 0; -int cache_stats = 0; - -static const char rnd_seed[] = - "string to make the random number generator think it has entropy"; - -int doit(char *ctx[4]); -static void print_stats(BIO *bio, SSL_CTX *ctx) -{ - BIO_printf(bio, "%4ld items in the session cache\n", - SSL_CTX_sess_number(ctx)); - BIO_printf(bio, "%4d client connects (SSL_connect())\n", - SSL_CTX_sess_connect(ctx)); - BIO_printf(bio, "%4d client connects that finished\n", - SSL_CTX_sess_connect_good(ctx)); - BIO_printf(bio, "%4d server connects (SSL_accept())\n", - SSL_CTX_sess_accept(ctx)); - BIO_printf(bio, "%4d server connects that finished\n", - SSL_CTX_sess_accept_good(ctx)); - BIO_printf(bio, "%4d session cache hits\n", SSL_CTX_sess_hits(ctx)); - BIO_printf(bio, "%4d session cache misses\n", SSL_CTX_sess_misses(ctx)); - BIO_printf(bio, "%4d session cache timeouts\n", SSL_CTX_sess_timeouts(ctx)); -} - -static void sv_usage(void) -{ - BIO_printf(bio_err, "usage: ssltest [args ...]\n"); - BIO_printf(bio_err, "\n"); - BIO_printf(bio_err, " -server_auth - check server certificate\n"); - BIO_printf(bio_err, " -client_auth - do client authentication\n"); - BIO_printf(bio_err, " -v - more output\n"); - BIO_printf(bio_err, " -CApath arg - PEM format directory of CA's\n"); - BIO_printf(bio_err, " -CAfile arg - PEM format file of CA's\n"); - BIO_printf(bio_err, " -threads arg - number of threads\n"); - BIO_printf(bio_err, " -loops arg - number of 'connections', per thread\n"); - BIO_printf(bio_err, " -reconnect - reuse session-id's\n"); - BIO_printf(bio_err, " -stats - server session-id cache stats\n"); - BIO_printf(bio_err, " -cert arg - server certificate/key\n"); - BIO_printf(bio_err, " -ccert arg - client certificate/key\n"); - BIO_printf(bio_err, " -ssl3 - just SSLv3n\n"); -} - -int main(int argc, char *argv[]) -{ - char *CApath = NULL, *CAfile = NULL; - int badop = 0; - int ret = 1; - int client_auth = 0; - int server_auth = 0; - SSL_CTX *s_ctx = NULL; - SSL_CTX *c_ctx = NULL; - char *scert = TEST_SERVER_CERT; - char *ccert = TEST_CLIENT_CERT; - const SSL_METHOD *ssl_method = TLS_method(); - - RAND_seed(rnd_seed, sizeof rnd_seed); - - if (bio_err == NULL) - bio_err = BIO_new_fd(2, BIO_NOCLOSE); - if (bio_stdout == NULL) - bio_stdout = BIO_new_fd(1, BIO_NOCLOSE); - argc--; - argv++; - - while (argc >= 1) { - if (strcmp(*argv, "-server_auth") == 0) - server_auth = 1; - else if (strcmp(*argv, "-client_auth") == 0) - client_auth = 1; - else if (strcmp(*argv, "-reconnect") == 0) - reconnect = 1; - else if (strcmp(*argv, "-stats") == 0) - cache_stats = 1; - else if (strcmp(*argv, "-ssl3") == 0) - ssl_method = SSLv3_method(); - else if (strcmp(*argv, "-CApath") == 0) { - if (--argc < 1) - goto bad; - CApath = *(++argv); - } else if (strcmp(*argv, "-CAfile") == 0) { - if (--argc < 1) - goto bad; - CAfile = *(++argv); - } else if (strcmp(*argv, "-cert") == 0) { - if (--argc < 1) - goto bad; - scert = *(++argv); - } else if (strcmp(*argv, "-ccert") == 0) { - if (--argc < 1) - goto bad; - ccert = *(++argv); - } else if (strcmp(*argv, "-threads") == 0) { - if (--argc < 1) - goto bad; - thread_number = atoi(*(++argv)); - if (thread_number == 0) - thread_number = 1; - if (thread_number > MAX_THREAD_NUMBER) - thread_number = MAX_THREAD_NUMBER; - } else if (strcmp(*argv, "-loops") == 0) { - if (--argc < 1) - goto bad; - number_of_loops = atoi(*(++argv)); - if (number_of_loops == 0) - number_of_loops = 1; - } else { - BIO_printf(bio_err, "unknown option %s\n", *argv); - badop = 1; - break; - } - argc--; - argv++; - } - if (badop) { - bad: - sv_usage(); - goto end; - } - - if (cipher == NULL && OPENSSL_issetugid() == 0) - cipher = getenv("SSL_CIPHER"); - - SSL_load_error_strings(); - OpenSSL_add_ssl_algorithms(); - - c_ctx = SSL_CTX_new(ssl_method); - s_ctx = SSL_CTX_new(ssl_method); - if ((c_ctx == NULL) || (s_ctx == NULL)) { - ERR_print_errors(bio_err); - goto end; - } - - SSL_CTX_set_session_cache_mode(s_ctx, - SSL_SESS_CACHE_NO_AUTO_CLEAR | - SSL_SESS_CACHE_SERVER); - SSL_CTX_set_session_cache_mode(c_ctx, - SSL_SESS_CACHE_NO_AUTO_CLEAR | - SSL_SESS_CACHE_SERVER); - - if (!SSL_CTX_use_certificate_file(s_ctx, scert, SSL_FILETYPE_PEM)) { - BIO_printf(bio_err, "SSL_CTX_use_certificate_file (%s)\n", scert); - ERR_print_errors(bio_err); - goto end; - } else - if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx, scert, SSL_FILETYPE_PEM)) { - BIO_printf(bio_err, "SSL_CTX_use_RSAPrivateKey_file (%s)\n", scert); - ERR_print_errors(bio_err); - goto end; - } - - if (client_auth) { - SSL_CTX_use_certificate_file(c_ctx, ccert, SSL_FILETYPE_PEM); - SSL_CTX_use_RSAPrivateKey_file(c_ctx, ccert, SSL_FILETYPE_PEM); - } - - if ((!SSL_CTX_load_verify_locations(s_ctx, CAfile, CApath)) || - (!SSL_CTX_set_default_verify_paths(s_ctx)) || - (!SSL_CTX_load_verify_locations(c_ctx, CAfile, CApath)) || - (!SSL_CTX_set_default_verify_paths(c_ctx))) { - BIO_printf(bio_err, "SSL_load_verify_locations\n"); - ERR_print_errors(bio_err); - goto end; - } - - if (client_auth) { - BIO_printf(bio_err, "client authentication\n"); - SSL_CTX_set_verify(s_ctx, - SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, - verify_callback); - } - if (server_auth) { - BIO_printf(bio_err, "server authentication\n"); - SSL_CTX_set_verify(c_ctx, SSL_VERIFY_PEER, verify_callback); - } - - thread_setup(); - do_threads(s_ctx, c_ctx); - thread_cleanup(); - end: - - if (c_ctx != NULL) { - BIO_printf(bio_err, "Client SSL_CTX stats then free it\n"); - print_stats(bio_err, c_ctx); - SSL_CTX_free(c_ctx); - } - if (s_ctx != NULL) { - BIO_printf(bio_err, "Server SSL_CTX stats then free it\n"); - print_stats(bio_err, s_ctx); - if (cache_stats) { - BIO_printf(bio_err, "-----\n"); - lh_SSL_SESSION_stats_bio(SSL_CTX_sessions(s_ctx), bio_err); - BIO_printf(bio_err, "-----\n"); - /*- lh_SSL_SESSION_node_stats_bio(SSL_CTX_sessions(s_ctx),bio_err); - BIO_printf(bio_err,"-----\n"); */ - lh_SSL_SESSION_node_usage_stats_bio(SSL_CTX_sessions(s_ctx), bio_err); - BIO_printf(bio_err, "-----\n"); - } - SSL_CTX_free(s_ctx); - BIO_printf(bio_err, "done free\n"); - } - exit(ret); - return (0); -} - -#define W_READ 1 -#define W_WRITE 2 -#define C_DONE 1 -#define S_DONE 2 - -int ndoit(SSL_CTX *ssl_ctx[2]) -{ - int i; - int ret; - char *ctx[4]; - CRYPTO_THREADID thread_id; - - ctx[0] = (char *)ssl_ctx[0]; - ctx[1] = (char *)ssl_ctx[1]; - - if (reconnect) { - ctx[2] = (char *)SSL_new(ssl_ctx[0]); - ctx[3] = (char *)SSL_new(ssl_ctx[1]); - } else { - ctx[2] = NULL; - ctx[3] = NULL; - } - - CRYPTO_THREADID_current(&thread_id); - BIO_printf(bio_stdout, "started thread %lu\n", - CRYPTO_THREADID_hash(&thread_id)); - for (i = 0; i < number_of_loops; i++) { -/*- BIO_printf(bio_err,"%4d %2d ctx->ref (%3d,%3d)\n", - CRYPTO_THREADID_hash(&thread_id),i, - ssl_ctx[0]->references, - ssl_ctx[1]->references); */ -/* pthread_delay_np(&tm); */ - - ret = doit(ctx); - if (ret != 0) { - BIO_printf(bio_stdout, "error[%d] %lu - %d\n", - i, CRYPTO_THREADID_hash(&thread_id), ret); - return (ret); - } - } - BIO_printf(bio_stdout, "DONE %lu\n", CRYPTO_THREADID_hash(&thread_id)); - if (reconnect) { - SSL_free((SSL *)ctx[2]); - SSL_free((SSL *)ctx[3]); - } -#ifdef OPENSSL_SYS_NETWARE - MPKSemaphoreSignal(ThreadSem); -#endif - return (0); -} - -int doit(char *ctx[4]) -{ - SSL_CTX *s_ctx, *c_ctx; - static char cbuf[200], sbuf[200]; - SSL *c_ssl = NULL; - SSL *s_ssl = NULL; - BIO *c_to_s = NULL; - BIO *s_to_c = NULL; - BIO *c_bio = NULL; - BIO *s_bio = NULL; - int c_r, c_w, s_r, s_w; - int c_want, s_want; - int i; - int done = 0; - int c_write, s_write; - int do_server = 0, do_client = 0; - - s_ctx = (SSL_CTX *)ctx[0]; - c_ctx = (SSL_CTX *)ctx[1]; - - if (ctx[2] != NULL) - s_ssl = (SSL *)ctx[2]; - else - s_ssl = SSL_new(s_ctx); - - if (ctx[3] != NULL) - c_ssl = (SSL *)ctx[3]; - else - c_ssl = SSL_new(c_ctx); - - if ((s_ssl == NULL) || (c_ssl == NULL)) - goto err; - - c_to_s = BIO_new(BIO_s_mem()); - s_to_c = BIO_new(BIO_s_mem()); - if ((s_to_c == NULL) || (c_to_s == NULL)) - goto err; - - c_bio = BIO_new(BIO_f_ssl()); - s_bio = BIO_new(BIO_f_ssl()); - if ((c_bio == NULL) || (s_bio == NULL)) - goto err; - - SSL_set_connect_state(c_ssl); - SSL_set_bio(c_ssl, s_to_c, c_to_s); - BIO_set_ssl(c_bio, c_ssl, (ctx[2] == NULL) ? BIO_CLOSE : BIO_NOCLOSE); - - SSL_set_accept_state(s_ssl); - SSL_set_bio(s_ssl, c_to_s, s_to_c); - BIO_set_ssl(s_bio, s_ssl, (ctx[3] == NULL) ? BIO_CLOSE : BIO_NOCLOSE); - - c_r = 0; - s_r = 1; - c_w = 1; - s_w = 0; - c_want = W_WRITE; - s_want = 0; - c_write = 1, s_write = 0; - - /* We can always do writes */ - for (;;) { - do_server = 0; - do_client = 0; - - i = (int)BIO_pending(s_bio); - if ((i && s_r) || s_w) - do_server = 1; - - i = (int)BIO_pending(c_bio); - if ((i && c_r) || c_w) - do_client = 1; - - if (do_server && verbose) { - if (SSL_in_init(s_ssl)) - BIO_printf(bio_stdout, "server waiting in SSL_accept - %s\n", - SSL_state_string_long(s_ssl)); - else if (s_write) - BIO_printf(bio_stdout, "server:SSL_write()\n"); - else - BIO_printf(bio_stdout, "server:SSL_read()\n"); - } - - if (do_client && verbose) { - if (SSL_in_init(c_ssl)) - BIO_printf(bio_stdout, "client waiting in SSL_connect - %s\n", - SSL_state_string_long(c_ssl)); - else if (c_write) - BIO_printf(bio_stdout, "client:SSL_write()\n"); - else - BIO_printf(bio_stdout, "client:SSL_read()\n"); - } - - if (!do_client && !do_server) { - BIO_printf(bio_stdout, "ERROR IN STARTUP\n"); - break; - } - if (do_client && !(done & C_DONE)) { - if (c_write) { - i = BIO_write(c_bio, "hello from client\n", 18); - if (i < 0) { - c_r = 0; - c_w = 0; - if (BIO_should_retry(c_bio)) { - if (BIO_should_read(c_bio)) - c_r = 1; - if (BIO_should_write(c_bio)) - c_w = 1; - } else { - BIO_printf(bio_err, "ERROR in CLIENT\n"); - ERR_print_errors_fp(stderr); - return (1); - } - } else if (i == 0) { - BIO_printf(bio_err, "SSL CLIENT STARTUP FAILED\n"); - return (1); - } else { - /* ok */ - c_write = 0; - } - } else { - i = BIO_read(c_bio, cbuf, 100); - if (i < 0) { - c_r = 0; - c_w = 0; - if (BIO_should_retry(c_bio)) { - if (BIO_should_read(c_bio)) - c_r = 1; - if (BIO_should_write(c_bio)) - c_w = 1; - } else { - BIO_printf(bio_err, "ERROR in CLIENT\n"); - ERR_print_errors_fp(stderr); - return (1); - } - } else if (i == 0) { - BIO_printf(bio_err, "SSL CLIENT STARTUP FAILED\n"); - return (1); - } else { - done |= C_DONE; - } - } - } - - if (do_server && !(done & S_DONE)) { - if (!s_write) { - i = BIO_read(s_bio, sbuf, 100); - if (i < 0) { - s_r = 0; - s_w = 0; - if (BIO_should_retry(s_bio)) { - if (BIO_should_read(s_bio)) - s_r = 1; - if (BIO_should_write(s_bio)) - s_w = 1; - } else { - BIO_printf(bio_err, "ERROR in SERVER\n"); - ERR_print_errors_fp(stderr); - return (1); - } - } else if (i == 0) { - BIO_printf(bio_err, "SSL SERVER STARTUP FAILED\n"); - return (1); - } else { - s_write = 1; - s_w = 1; - } - } else { - i = BIO_write(s_bio, "hello from server\n", 18); - if (i < 0) { - s_r = 0; - s_w = 0; - if (BIO_should_retry(s_bio)) { - if (BIO_should_read(s_bio)) - s_r = 1; - if (BIO_should_write(s_bio)) - s_w = 1; - } else { - BIO_printf(bio_err, "ERROR in SERVER\n"); - ERR_print_errors_fp(stderr); - return (1); - } - } else if (i == 0) { - BIO_printf(bio_err, "SSL SERVER STARTUP FAILED\n"); - return (1); - } else { - s_write = 0; - s_r = 1; - done |= S_DONE; - } - } - } - - if ((done & S_DONE) && (done & C_DONE)) - break; -#if defined(OPENSSL_SYS_NETWARE) - ThreadSwitchWithDelay(); -#endif - } - - SSL_set_shutdown(c_ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); - SSL_set_shutdown(s_ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); - - err: -#if 0 - /* - * We have to set the BIO's to NULL otherwise they will be free()ed - * twice. Once when th s_ssl is SSL_free()ed and again when c_ssl is - * SSL_free()ed. This is a hack required because s_ssl and c_ssl are - * sharing the same BIO structure and SSL_set_bio() and SSL_free() - * automatically BIO_free non NULL entries. You should not normally do - * this or be required to do this - */ - - if (s_ssl != NULL) { - s_ssl->rbio = NULL; - s_ssl->wbio = NULL; - } - if (c_ssl != NULL) { - c_ssl->rbio = NULL; - c_ssl->wbio = NULL; - } - - /* The SSL's are optionally freed in the following calls */ - BIO_free(c_to_s); - BIO_free(s_to_c); -#endif - - BIO_free(c_bio); - BIO_free(s_bio); - return (0); -} - -int verify_callback(int ok, X509_STORE_CTX *ctx) -{ - char *s, buf[256]; - - if (verbose) { - s = X509_NAME_oneline(X509_get_subject_name(ctx->current_cert), - buf, 256); - if (s != NULL) { - if (ok) - BIO_printf(bio_err, "depth=%d %s\n", ctx->error_depth, buf); - else - BIO_printf(bio_err, "depth=%d error=%d %s\n", - ctx->error_depth, ctx->error, buf); - } - } - return (ok); -} - -#define THREAD_STACK_SIZE (16*1024) - -#ifdef OPENSSL_SYS_WIN32 - -static HANDLE *lock_cs; - -void thread_setup(void) -{ - int i; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE)); - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_cs[i] = CreateMutex(NULL, FALSE, NULL); - } - - CRYPTO_set_locking_callback((void (*)(int, int, char *, int)) - win32_locking_callback); - /* id callback defined */ -} - -void thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) - CloseHandle(lock_cs[i]); - OPENSSL_free(lock_cs); -} - -void win32_locking_callback(int mode, int type, const char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - WaitForSingleObject(lock_cs[type], INFINITE); - } else { - ReleaseMutex(lock_cs[type]); - } -} - -void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) -{ - double ret; - SSL_CTX *ssl_ctx[2]; - DWORD thread_id[MAX_THREAD_NUMBER]; - HANDLE thread_handle[MAX_THREAD_NUMBER]; - int i; - SYSTEMTIME start, end; - - ssl_ctx[0] = s_ctx; - ssl_ctx[1] = c_ctx; - - GetSystemTime(&start); - for (i = 0; i < thread_number; i++) { - thread_handle[i] = CreateThread(NULL, - THREAD_STACK_SIZE, - (LPTHREAD_START_ROUTINE) ndoit, - (void *)ssl_ctx, 0L, &(thread_id[i])); - } - - BIO_printf(bio_stdout, "reaping\n"); - for (i = 0; i < thread_number; i += 50) { - int j; - - j = (thread_number < (i + 50)) ? (thread_number - i) : 50; - - if (WaitForMultipleObjects(j, - (CONST HANDLE *) & (thread_handle[i]), - TRUE, INFINITE) - == WAIT_FAILED) { - BIO_printf(bio_err, "WaitForMultipleObjects failed:%d\n", - GetLastError()); - exit(1); - } - } - GetSystemTime(&end); - - if (start.wDayOfWeek > end.wDayOfWeek) - end.wDayOfWeek += 7; - ret = (end.wDayOfWeek - start.wDayOfWeek) * 24; - - ret = (ret + end.wHour - start.wHour) * 60; - ret = (ret + end.wMinute - start.wMinute) * 60; - ret = (ret + end.wSecond - start.wSecond); - ret += (end.wMilliseconds - start.wMilliseconds) / 1000.0; - - BIO_printf(bio_stdout, "win32 threads done - %.3f seconds\n", ret); -} - -#endif /* OPENSSL_SYS_WIN32 */ - -#ifdef SOLARIS - -static mutex_t *lock_cs; -/* - * static rwlock_t *lock_cs; - */ -static long *lock_count; - -void thread_setup(void) -{ - int i; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(mutex_t)); - lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_count[i] = 0; - /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */ - mutex_init(&(lock_cs[i]), USYNC_THREAD, NULL); - } - - CRYPTO_set_id_callback(solaris_thread_id); - CRYPTO_set_locking_callback(solaris_locking_callback); -} - -void thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - - BIO_printf(bio_err, "cleanup\n"); - - for (i = 0; i < CRYPTO_num_locks(); i++) { - /* rwlock_destroy(&(lock_cs[i])); */ - mutex_destroy(&(lock_cs[i])); - BIO_printf(bio_err, "%8ld:%s\n", lock_count[i], CRYPTO_get_lock_name(i)); - } - OPENSSL_free(lock_cs); - OPENSSL_free(lock_count); - - BIO_printf(bio_err, "done cleanup\n"); - -} - -void solaris_locking_callback(int mode, int type, const char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - mutex_lock(&(lock_cs[type])); - lock_count[type]++; - } else { - mutex_unlock(&(lock_cs[type])); - } -} - -void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) -{ - SSL_CTX *ssl_ctx[2]; - thread_t thread_ctx[MAX_THREAD_NUMBER]; - int i; - - ssl_ctx[0] = s_ctx; - ssl_ctx[1] = c_ctx; - - thr_setconcurrency(thread_number); - for (i = 0; i < thread_number; i++) { - thr_create(NULL, THREAD_STACK_SIZE, - (void *(*)())ndoit, (void *)ssl_ctx, 0L, &(thread_ctx[i])); - } - - BIO_printf(bio_stdout, "reaping\n"); - for (i = 0; i < thread_number; i++) { - thr_join(thread_ctx[i], NULL, NULL); - } - -#if 0 /* We can't currently find out the reference amount */ - BIO_printf(bio_stdout, "solaris threads done (%d,%d)\n", - s_ctx->references, c_ctx->references); -#else - BIO_printf(bio_stdout, "solaris threads done\n"); -#endif -} - -void solaris_thread_id(CRYPTO_THREADID *tid) -{ - CRYPTO_THREADID_set_numeric((unsigned long)thr_self()); -} -#endif /* SOLARIS */ - -#ifdef IRIX - -static usptr_t *arena; -static usema_t **lock_cs; - -void thread_setup(void) -{ - int i; - char filename[20]; - - strcpy(filename, "/tmp/mttest.XXXXXX"); - mktemp(filename); - - usconfig(CONF_STHREADIOOFF); - usconfig(CONF_STHREADMALLOCOFF); - usconfig(CONF_INITUSERS, 100); - usconfig(CONF_LOCKTYPE, US_DEBUGPLUS); - arena = usinit(filename); - unlink(filename); - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(usema_t *)); - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_cs[i] = usnewsema(arena, 1); - } - - CRYPTO_set_id_callback(irix_thread_id); - CRYPTO_set_locking_callback(irix_locking_callback); -} - -void thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) { - char buf[10]; - - sprintf(buf, "%2d:", i); - usdumpsema(lock_cs[i], stdout, buf); - usfreesema(lock_cs[i], arena); - } - OPENSSL_free(lock_cs); -} - -void irix_locking_callback(int mode, int type, const char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - BIO_printf(bio_stdout, "lock %d\n", type); - uspsema(lock_cs[type]); - } else { - BIO_printf(bio_stdout, "unlock %d\n", type); - usvsema(lock_cs[type]); - } -} - -void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) -{ - SSL_CTX *ssl_ctx[2]; - int thread_ctx[MAX_THREAD_NUMBER]; - int i; - - ssl_ctx[0] = s_ctx; - ssl_ctx[1] = c_ctx; - - for (i = 0; i < thread_number; i++) { - thread_ctx[i] = sproc((void (*)())ndoit, - PR_SADDR | PR_SFDS, (void *)ssl_ctx); - } - - BIO_printf(bio_stdout, "reaping\n"); - for (i = 0; i < thread_number; i++) { - wait(NULL); - } - -#if 0 /* We can't currently find out the reference amount */ - BIO_printf(bio_stdout, "irix threads done (%d,%d)\n", - s_ctx->references, c_ctx->references); -#else - BIO_printf(bio_stdout, "irix threads done\n"); -#endif -} - -unsigned long irix_thread_id(void) -{ - CRYPTO_THREADID_set_numeric((unsigned long)getpid()); -} -#endif /* IRIX */ - -#ifdef PTHREADS - -static pthread_mutex_t *lock_cs; -static long *lock_count; - -void thread_setup(void) -{ - int i; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); - lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_count[i] = 0; - pthread_mutex_init(&(lock_cs[i]), NULL); - } - - CRYPTO_THREADID_set_callback(pthreads_thread_id); - CRYPTO_set_locking_callback(pthreads_locking_callback); -} - -void thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - BIO_printf(bio_err, "cleanup\n"); - for (i = 0; i < CRYPTO_num_locks(); i++) { - pthread_mutex_destroy(&(lock_cs[i])); - BIO_printf(bio_err, "%8ld:%s\n", lock_count[i], CRYPTO_get_lock_name(i)); - } - OPENSSL_free(lock_cs); - OPENSSL_free(lock_count); - - BIO_printf(bio_err, "done cleanup\n"); -} - -void pthreads_locking_callback(int mode, int type, const char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - pthread_mutex_lock(&(lock_cs[type])); - lock_count[type]++; - } else { - pthread_mutex_unlock(&(lock_cs[type])); - } -} - -void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) -{ - SSL_CTX *ssl_ctx[2]; - pthread_t thread_ctx[MAX_THREAD_NUMBER]; - int i; - - ssl_ctx[0] = s_ctx; - ssl_ctx[1] = c_ctx; - - /* - * thr_setconcurrency(thread_number); - */ - for (i = 0; i < thread_number; i++) { - pthread_create(&(thread_ctx[i]), NULL, - (void *(*)())ndoit, (void *)ssl_ctx); - } - - BIO_printf(bio_stdout, "reaping\n"); - for (i = 0; i < thread_number; i++) { - pthread_join(thread_ctx[i], NULL); - } - -#if 0 /* We can't currently find out the reference amount */ - BIO_printf(bio_stdout, "pthreads threads done (%d,%d)\n", - s_ctx->references, c_ctx->references); -#else - BIO_printf(bio_stdout, "pthreads threads done\n"); -#endif -} - -void pthreads_thread_id(CRYPTO_THREADID *tid) -{ - CRYPTO_THREADID_set_numeric(tid, (unsigned long)pthread_self()); -} - -#endif /* PTHREADS */ - -#ifdef OPENSSL_SYS_NETWARE - -void thread_setup(void) -{ - int i; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(MPKMutex)); - lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_count[i] = 0; - lock_cs[i] = MPKMutexAlloc("OpenSSL mutex"); - } - - ThreadSem = MPKSemaphoreAlloc("OpenSSL mttest semaphore", 0); - - CRYPTO_set_id_callback(netware_thread_id); - CRYPTO_set_locking_callback(netware_locking_callback); -} - -void thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - - BIO_printf(bio_stdout, "thread_cleanup\n"); - - for (i = 0; i < CRYPTO_num_locks(); i++) { - MPKMutexFree(lock_cs[i]); - BIO_printf(bio_stdout, "%8ld:%s\n", lock_count[i], CRYPTO_get_lock_name(i)); - } - OPENSSL_free(lock_cs); - OPENSSL_free(lock_count); - - MPKSemaphoreFree(ThreadSem); - - BIO_printf(bio_stdout, "done cleanup\n"); -} - -void netware_locking_callback(int mode, int type, const char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - MPKMutexLock(lock_cs[type]); - lock_count[type]++; - } else - MPKMutexUnlock(lock_cs[type]); -} - -void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) -{ - SSL_CTX *ssl_ctx[2]; - int i; - ssl_ctx[0] = s_ctx; - ssl_ctx[1] = c_ctx; - - for (i = 0; i < thread_number; i++) { - BeginThread((void (*)(void *))ndoit, NULL, THREAD_STACK_SIZE, - (void *)ssl_ctx); - ThreadSwitchWithDelay(); - } - - BIO_printf(bio_stdout, "reaping\n"); - - /* loop until all threads have signaled the semaphore */ - for (i = 0; i < thread_number; i++) { - MPKSemaphoreWait(ThreadSem); - } -#if 0 /* We can't currently find out the reference amount */ - BIO_printf(bio_stdout, "netware threads done (%d,%d)\n", - s_ctx->references, c_ctx->references); -#else - BIO_printf(bio_stdout, "netware threads done\n"); -#endif -} - -unsigned long netware_thread_id(void) -{ - CRYPTO_THREADID_set_numeric((unsigned long)GetThreadID()); -} -#endif /* NETWARE */ diff --git a/crypto/threads/netware.bat b/crypto/threads/netware.bat deleted file mode 100644 index 0b3eca3..0000000 --- a/crypto/threads/netware.bat +++ /dev/null @@ -1,79 +0,0 @@ - at echo off -rem batch file to build multi-thread test ( mttest.nlm ) - -rem command line arguments: -rem debug => build using debug settings - -rem -rem After building, copy mttest.nlm to the server and run it, you'll probably -rem want to redirect stdout and stderr. An example command line would be -rem "mttest.nlm -thread 20 -loops 10 -CAfile \openssl\apps\server.pem >mttest.out 2>mttest.err" -rem - -del mttest.nlm - -set BLD_DEBUG= -set CFLAGS= -set LFLAGS= -set LIBS= - -if "%1" == "DEBUG" set BLD_DEBUG=YES -if "%1" == "debug" set BLD_DEBUG=YES - -if "%MWCIncludes%" == "" goto inc_error -if "%PRELUDE%" == "" goto prelude_error -if "%IMPORTS%" == "" goto imports_error - -set CFLAGS=-c -I..\..\outinc_nw -nosyspath -DOPENSSL_SYS_NETWARE -opt off -g -sym internal -maxerrors 20 - -if "%BLD_DEBUG%" == "YES" set LIBS=..\..\out_nw.dbg\ssl.lib ..\..\out_nw.dbg\crypto.lib -if "%BLD_DEBUG%" == "" set LIBS=..\..\out_nw\ssl.lib ..\..\out_nw\crypto.lib - -set LFLAGS=-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal - -rem generate command file for metrowerks -echo. -echo Generating Metrowerks command file: mttest.def -echo # dynamically generated command file for metrowerks build > mttest.def -echo IMPORT @%IMPORTS%\clib.imp >> mttest.def -echo IMPORT @%IMPORTS%\threads.imp >> mttest.def -echo IMPORT @%IMPORTS%\ws2nlm.imp >> mttest.def -echo IMPORT GetProcessSwitchCount >> mttest.def -echo MODULE clib >> mttest.def - -rem compile -echo. -echo Compiling mttest.c -mwccnlm.exe mttest.c %CFLAGS% -if errorlevel 1 goto end - -rem link -echo. -echo Linking mttest.nlm -mwldnlm.exe %LFLAGS% -screenname mttest -commandfile mttest.def mttest.o "%PRELUDE%" %LIBS% -o mttest.nlm -if errorlevel 1 goto end - -goto end - -:inc_error -echo. -echo Environment variable MWCIncludes is not set - see install.nw -goto end - -:prelude_error -echo. -echo Environment variable PRELUDE is not set - see install.nw -goto end - -:imports_error -echo. -echo Environment variable IMPORTS is not set - see install.nw -goto end - - -:end -set BLD_DEBUG= -set CFLAGS= -set LFLAGS= -set LIBS= - diff --git a/crypto/threads/profile.sh b/crypto/threads/profile.sh deleted file mode 100644 index 6e3e342..0000000 --- a/crypto/threads/profile.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -/bin/rm -f mttest -cc -p -DSOLARIS -I../../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L../.. -lthread -lssl -lcrypto -lnsl -lsocket - diff --git a/crypto/threads/ptest.bat b/crypto/threads/ptest.bat deleted file mode 100755 index 4071b5f..0000000 --- a/crypto/threads/ptest.bat +++ /dev/null @@ -1,4 +0,0 @@ -del mttest.exe - -purify cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssl32.lib ..\..\out\crypt32.lib - diff --git a/crypto/threads/pthread.sh b/crypto/threads/pthread.sh deleted file mode 100644 index f1c4982..0000000 --- a/crypto/threads/pthread.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# -# build using pthreads -# -# http://www.mit.edu:8001/people/proven/pthreads.html -# -/bin/rm -f mttest -pgcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto - diff --git a/crypto/threads/pthread2.sh b/crypto/threads/pthread2.sh deleted file mode 100755 index ec945c4..0000000 --- a/crypto/threads/pthread2.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# -# build using pthreads where it's already built into the system -# -/bin/rm -f mttest -gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread -ldl diff --git a/crypto/threads/pthreads-vms.com b/crypto/threads/pthreads-vms.com deleted file mode 100644 index 1cf92bd..0000000 --- a/crypto/threads/pthreads-vms.com +++ /dev/null @@ -1,14 +0,0 @@ -$! To compile mttest on VMS. -$! -$! WARNING: only tested with DEC C so far. -$ -$ if (f$getsyi("cpu").lt.128) -$ then -$ arch := VAX -$ else -$ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE") -$ if (arch .eqs. "") then arch = "UNK" -$ endif -$ define/user openssl [--.include.openssl] -$ cc/def=PTHREADS mttest.c -$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib diff --git a/crypto/threads/purify.sh b/crypto/threads/purify.sh deleted file mode 100644 index 6d44fe2..0000000 --- a/crypto/threads/purify.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -/bin/rm -f mttest -purify cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket - diff --git a/crypto/threads/solaris.sh b/crypto/threads/solaris.sh deleted file mode 100644 index bc93094..0000000 --- a/crypto/threads/solaris.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -/bin/rm -f mttest -cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket - diff --git a/crypto/threads/th-lock.c b/crypto/threads/th-lock.c deleted file mode 100644 index e74474a..0000000 --- a/crypto/threads/th-lock.c +++ /dev/null @@ -1,364 +0,0 @@ -/* crypto/threads/th-lock.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include -#include -#include -#ifdef LINUX -# include -#endif -#ifdef OPENSSL_SYS_WIN32 -# include -#endif -#ifdef SOLARIS -# include -# include -#endif -#ifdef IRIX -# include -# include -#endif -#ifdef PTHREADS -# include -#endif -#include -#include -#include -#include "../../e_os.h" -#include -#include -#include - -void CRYPTO_thread_setup(void); -void CRYPTO_thread_cleanup(void); - -static void irix_locking_callback(int mode, int type, char *file, int line); -static void solaris_locking_callback(int mode, int type, char *file, - int line); -static void win32_locking_callback(int mode, int type, char *file, int line); -static void pthreads_locking_callback(int mode, int type, char *file, - int line); - -static unsigned long irix_thread_id(void); -static unsigned long solaris_thread_id(void); -static unsigned long pthreads_thread_id(void); - -/*- - * usage: - * CRYPTO_thread_setup(); - * application code - * CRYPTO_thread_cleanup(); - */ - -#define THREAD_STACK_SIZE (16*1024) - -#ifdef OPENSSL_SYS_WIN32 - -static HANDLE *lock_cs; - -void CRYPTO_thread_setup(void) -{ - int i; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE)); - if (!lock_cs) { - /* Nothing we can do about this...void function! */ - return; - } - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_cs[i] = CreateMutex(NULL, FALSE, NULL); - } - - CRYPTO_set_locking_callback((void (*)(int, int, char *, int)) - win32_locking_callback); - /* id callback defined */ - return (1); -} - -static void CRYPTO_thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) - CloseHandle(lock_cs[i]); - OPENSSL_free(lock_cs); -} - -void win32_locking_callback(int mode, int type, char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - WaitForSingleObject(lock_cs[type], INFINITE); - } else { - ReleaseMutex(lock_cs[type]); - } -} - -#endif /* OPENSSL_SYS_WIN32 */ - -#ifdef SOLARIS - -# define USE_MUTEX - -# ifdef USE_MUTEX -static mutex_t *lock_cs; -# else -static rwlock_t *lock_cs; -# endif -static long *lock_count; - -void CRYPTO_thread_setup(void) -{ - int i; - -# ifdef USE_MUTEX - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(mutex_t)); -# else - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(rwlock_t)); -# endif - if (!lock_cs) { - /* Nothing we can do about this...void function! */ - return; - } - lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_count[i] = 0; -# ifdef USE_MUTEX - mutex_init(&(lock_cs[i]), USYNC_THREAD, NULL); -# else - rwlock_init(&(lock_cs[i]), USYNC_THREAD, NULL); -# endif - } - - CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id); - CRYPTO_set_locking_callback((void (*)())solaris_locking_callback); -} - -void CRYPTO_thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) { -# ifdef USE_MUTEX - mutex_destroy(&(lock_cs[i])); -# else - rwlock_destroy(&(lock_cs[i])); -# endif - } - OPENSSL_free(lock_cs); - OPENSSL_free(lock_count); -} - -void solaris_locking_callback(int mode, int type, char *file, int line) -{ - if (mode & CRYPTO_LOCK) { -# ifdef USE_MUTEX - mutex_lock(&(lock_cs[type])); -# else - if (mode & CRYPTO_READ) - rw_rdlock(&(lock_cs[type])); - else - rw_wrlock(&(lock_cs[type])); -# endif - lock_count[type]++; - } else { -# ifdef USE_MUTEX - mutex_unlock(&(lock_cs[type])); -# else - rw_unlock(&(lock_cs[type])); -# endif - } -} - -unsigned long solaris_thread_id(void) -{ - unsigned long ret; - - ret = (unsigned long)thr_self(); - return (ret); -} -#endif /* SOLARIS */ - -#ifdef IRIX -/* I don't think this works..... */ - -static usptr_t *arena; -static usema_t **lock_cs; - -void CRYPTO_thread_setup(void) -{ - int i; - char filename[20]; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(usema_t *)); - if (!lock_cs) { - /* Nothing we can do about this...void function! */ - return; - } - - strcpy(filename, "/tmp/mttest.XXXXXX"); - mktemp(filename); - - usconfig(CONF_STHREADIOOFF); - usconfig(CONF_STHREADMALLOCOFF); - usconfig(CONF_INITUSERS, 100); - usconfig(CONF_LOCKTYPE, US_DEBUGPLUS); - arena = usinit(filename); - unlink(filename); - - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_cs[i] = usnewsema(arena, 1); - } - - CRYPTO_set_id_callback((unsigned long (*)())irix_thread_id); - CRYPTO_set_locking_callback((void (*)())irix_locking_callback); -} - -void CRYPTO_thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) { - char buf[10]; - - sprintf(buf, "%2d:", i); - usdumpsema(lock_cs[i], stdout, buf); - usfreesema(lock_cs[i], arena); - } - OPENSSL_free(lock_cs); -} - -void irix_locking_callback(int mode, int type, char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - uspsema(lock_cs[type]); - } else { - usvsema(lock_cs[type]); - } -} - -unsigned long irix_thread_id(void) -{ - unsigned long ret; - - ret = (unsigned long)getpid(); - return (ret); -} -#endif /* IRIX */ - -/* Linux and a few others */ -#ifdef PTHREADS - -static pthread_mutex_t *lock_cs; -static long *lock_count; - -void CRYPTO_thread_setup(void) -{ - int i; - - lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); - lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); - if (!lock_cs || !lock_count) { - /* Nothing we can do about this...void function! */ - OPENSSL_free(lock_cs); - OPENSSL_free(lock_count); - return; - } - for (i = 0; i < CRYPTO_num_locks(); i++) { - lock_count[i] = 0; - pthread_mutex_init(&(lock_cs[i]), NULL); - } - - CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id); - CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback); -} - -void thread_cleanup(void) -{ - int i; - - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) { - pthread_mutex_destroy(&(lock_cs[i])); - } - OPENSSL_free(lock_cs); - OPENSSL_free(lock_count); -} - -void pthreads_locking_callback(int mode, int type, char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - pthread_mutex_lock(&(lock_cs[type])); - lock_count[type]++; - } else { - pthread_mutex_unlock(&(lock_cs[type])); - } -} - -unsigned long pthreads_thread_id(void) -{ - unsigned long ret; - - ret = (unsigned long)pthread_self(); - return (ret); -} - -#endif /* PTHREADS */ diff --git a/crypto/threads/win32.bat b/crypto/threads/win32.bat deleted file mode 100755 index ee6da80..0000000 --- a/crypto/threads/win32.bat +++ /dev/null @@ -1,4 +0,0 @@ -del mttest.exe - -cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssleay32.lib ..\..\out\libeay32.lib - From levitte at openssl.org Fri Oct 23 17:53:54 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 17:53:54 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445622834.037453.6147.nullmailer@dev.openssl.org> The branch master has been updated via 070c23325af4526c9a8532a60d63522c58d5554b (commit) via 8cf9d71a3a43d9b98a8a278d47dc08088a954a7b (commit) via 3240e7cf5f651d9d94814b4d494fbe294e463b72 (commit) via d900a015b5a89ea2018e6122dd2738925e4d68ab (commit) via c2319cf9fce87a2e82efb6e58ced11a85190dc3d (commit) via 3f6c7691870d1cd2ad0e0c83638cef3f35a0b548 (commit) via 8acaabec429b39f9436f6a88006384d72d292539 (commit) via 4428c7dba8f6f407d915c1226f4e0f673e8be241 (commit) from dad0b512e649336440e2b3cc9d667c56d9a91eff (commit) - Log ----------------------------------------------------------------- commit 070c23325af4526c9a8532a60d63522c58d5554b Author: Alessandro Ghedini Date: Thu Oct 8 22:00:27 2015 +0200 Remove useless code RT#4081 Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit 8cf9d71a3a43d9b98a8a278d47dc08088a954a7b Author: Alessandro Ghedini Date: Thu Oct 8 14:50:27 2015 +0200 Check memory allocation Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit 3240e7cf5f651d9d94814b4d494fbe294e463b72 Author: Alessandro Ghedini Date: Thu Oct 8 14:41:09 2015 +0200 Fix references to various RFCs Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit d900a015b5a89ea2018e6122dd2738925e4d68ab Author: Alessandro Ghedini Date: Thu Oct 8 14:40:42 2015 +0200 Fix typos Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit c2319cf9fce87a2e82efb6e58ced11a85190dc3d Author: Alessandro Ghedini Date: Thu Oct 8 14:39:58 2015 +0200 Set salt length after the malloc has succeeded Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit 3f6c7691870d1cd2ad0e0c83638cef3f35a0b548 Author: Alessandro Ghedini Date: Thu Oct 8 14:38:57 2015 +0200 Fix memory leaks and other mistakes on errors Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit 8acaabec429b39f9436f6a88006384d72d292539 Author: Alessandro Ghedini Date: Thu Oct 8 14:37:21 2015 +0200 Replace malloc+strlcpy with strdup Reviewed-by: Rich Salz Reviewed-by: Richard Levitte commit 4428c7dba8f6f407d915c1226f4e0f673e8be241 Author: Alessandro Ghedini Date: Fri Oct 2 15:16:08 2015 +0200 Do not treat 0 return value from BIO_get_fd() as error 0 is a valid file descriptor. RT#4068 Reviewed-by: Rich Salz Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: apps/apps.c | 3 -- apps/ca.c | 12 ++---- apps/ecparam.c | 2 - apps/engine.c | 5 --- apps/gendsa.c | 2 - apps/ocsp.c | 2 +- crypto/aes/asm/aesni-x86.pl | 2 +- crypto/bio/b_dump.c | 1 - crypto/bn/asm/ia64.S | 2 +- crypto/bn/bn_gf2m.c | 2 +- crypto/bn/bn_recp.c | 4 +- crypto/bn/bn_x931p.c | 7 +++- crypto/conf/conf_def.c | 3 +- crypto/dsa/dsa_gen.c | 18 +++------ crypto/evp/e_aes_cbc_hmac_sha256.c | 2 - crypto/evp/e_dsa.c | 69 --------------------------------- crypto/evp/evp_key.c | 4 +- crypto/evp/evp_pbe.c | 15 +++++-- crypto/hmac/hm_ameth.c | 9 ++++- crypto/ocsp/ocsp_lib.c | 6 --- crypto/ocsp/ocsp_prn.c | 1 - crypto/pem/pvkfmt.c | 10 ++--- crypto/pkcs12/p12_add.c | 27 +++++++++---- crypto/pkcs12/p12_mutl.c | 2 +- crypto/pkcs7/pk7_doit.c | 1 - crypto/sha/asm/sha1-s390x.pl | 2 +- crypto/sha/asm/sha512-parisc.pl | 2 +- crypto/x509/t_crl.c | 1 - crypto/x509/x509_lu.c | 2 - demos/engines/zencod/hw_zencod.c | 2 +- doc/crypto/BIO_read.pod | 6 +-- doc/crypto/BN_rand.pod | 2 +- doc/crypto/EC_GROUP_copy.pod | 2 +- doc/crypto/EC_KEY_new.pod | 2 +- doc/crypto/X509_get_extension_flags.pod | 2 +- doc/crypto/d2i_X509_NAME.pod | 2 +- include/openssl/tls1.h | 37 ++++++------------ ssl/s3_clnt.c | 2 +- ssl/s3_srvr.c | 1 - ssl/t1_lib.c | 1 - test/evp_test.c | 2 +- 41 files changed, 91 insertions(+), 188 deletions(-) delete mode 100644 crypto/evp/e_dsa.c diff --git a/apps/apps.c b/apps/apps.c index 39ca963..c519ae6 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -118,9 +118,6 @@ #include #include #include -#if !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_WINCE) && !defined(NETWARE_CLIB) -# include -#endif #ifndef NO_SYS_TYPES_H # include #endif diff --git a/apps/ca.c b/apps/ca.c index 586fbe4..691f4e7 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -98,24 +98,18 @@ #undef BSIZE #define BSIZE 256 -#define BASE_SECTION "ca" +#define BASE_SECTION "ca" #define ENV_DEFAULT_CA "default_ca" -#define STRING_MASK "string_mask" +#define STRING_MASK "string_mask" #define UTF8_IN "utf8" -#define ENV_DIR "dir" -#define ENV_CERTS "certs" -#define ENV_CRL_DIR "crl_dir" -#define ENV_CA_DB "CA_DB" #define ENV_NEW_CERTS_DIR "new_certs_dir" -#define ENV_CERTIFICATE "certificate" +#define ENV_CERTIFICATE "certificate" #define ENV_SERIAL "serial" #define ENV_CRLNUMBER "crlnumber" -#define ENV_CRL "crl" #define ENV_PRIVATE_KEY "private_key" -#define ENV_RANDFILE "RANDFILE" #define ENV_DEFAULT_DAYS "default_days" #define ENV_DEFAULT_STARTDATE "default_startdate" #define ENV_DEFAULT_ENDDATE "default_enddate" diff --git a/apps/ecparam.c b/apps/ecparam.c index 9d13447..122125e 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -317,8 +317,6 @@ int ecparam_main(int argc, char **argv) } if (check) { - if (group == NULL) - BIO_printf(bio_err, "no elliptic curve parameters\n"); BIO_printf(bio_err, "checking elliptic curve parameters: "); if (!EC_GROUP_check(group, NULL)) { BIO_printf(bio_err, "failed\n"); diff --git a/apps/engine.c b/apps/engine.c index b4da23e..17e6f78 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -94,17 +94,12 @@ static void identity(char *ptr) static int append_buf(char **buf, const char *s, int *size, int step) { - int l = strlen(s); - if (*buf == NULL) { *size = step; *buf = app_malloc(*size, "engine buffer"); **buf = '\0'; } - if (**buf != '\0') - l += 2; /* ", " */ - if (strlen(*buf) + strlen(s) >= (unsigned int)*size) { *size += step; *buf = OPENSSL_realloc(*buf, *size); diff --git a/apps/gendsa.c b/apps/gendsa.c index 5d5cb5e..9259c6c 100644 --- a/apps/gendsa.c +++ b/apps/gendsa.c @@ -69,8 +69,6 @@ # include # include -# define DEFBITS 512 - typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_RAND, OPT_CIPHER diff --git a/apps/ocsp.c b/apps/ocsp.c index 2ef4278..c599ffb 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -1202,7 +1202,7 @@ static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, return NULL; } - if (BIO_get_fd(cbio, &fd) <= 0) { + if (BIO_get_fd(cbio, &fd) < 0) { BIO_puts(bio_err, "Can't get connection fd\n"); goto err; } diff --git a/crypto/aes/asm/aesni-x86.pl b/crypto/aes/asm/aesni-x86.pl index f67df8c..9b2e37a 100644 --- a/crypto/aes/asm/aesni-x86.pl +++ b/crypto/aes/asm/aesni-x86.pl @@ -88,7 +88,7 @@ $inout3="xmm5"; $in1="xmm5"; $inout4="xmm6"; $in0="xmm6"; $inout5="xmm7"; $ivec="xmm7"; -# AESNI extenstion +# AESNI extension sub aeskeygenassist { my($dst,$src,$imm)=@_; if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index 33191c1..55792b9 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -104,7 +104,6 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), if ((rows * dump_width) < len) rows++; for (i = 0; i < rows; i++) { - buf[0] = '\0'; /* start with empty string */ BUF_strlcpy(buf, str, sizeof buf); BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width); BUF_strlcat(buf, tmp, sizeof buf); diff --git a/crypto/bn/asm/ia64.S b/crypto/bn/asm/ia64.S index c0cee82..a9a42ab 100644 --- a/crypto/bn/asm/ia64.S +++ b/crypto/bn/asm/ia64.S @@ -422,7 +422,7 @@ bn_mul_add_words: // This loop spins in 3*(n+10) ticks on Itanium and in 2*(n+10) on // Itanium 2. Yes, unlike previous versions it scales:-) Previous -// version was peforming *all* additions in IALU and was starving +// version was performing *all* additions in IALU and was starving // for those even on Itanium 2. In this version one addition is // moved to FPU and is folded with multiplication. This is at cost // of propogating the result from previous call to this subroutine diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index cd137c3..3b6c883 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -574,7 +574,7 @@ int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], bn_check_top(a); BN_CTX_start(ctx); if ((s = BN_CTX_get(ctx)) == NULL) - return 0; + goto err; if (!bn_wexpand(s, 2 * a->top)) goto err; diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 3dc2166..39eed8b 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -151,8 +151,10 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, if (BN_ucmp(m, &(recp->N)) < 0) { BN_zero(d); - if (!BN_copy(r, m)) + if (!BN_copy(r, m)) { + BN_CTX_end(ctx); return 0; + } BN_CTX_end(ctx); return (1); } diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c index 15ba41d..76ce6f6 100644 --- a/crypto/bn/bn_x931p.c +++ b/crypto/bn/bn_x931p.c @@ -214,14 +214,14 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) * exceeded. */ if (!BN_rand(Xp, nbits, 1, 0)) - return 0; + goto err; BN_CTX_start(ctx); t = BN_CTX_get(ctx); for (i = 0; i < 1000; i++) { if (!BN_rand(Xq, nbits, 1, 0)) - return 0; + goto err; /* Check that |Xp - Xq| > 2^(nbits - 100) */ BN_sub(t, Xp, Xq); if (BN_num_bits(t) > (nbits - 100)) @@ -235,6 +235,9 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) return 0; + err: + BN_CTX_end(ctx); + return 0; } /* diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index b490377..1da68f9 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -223,12 +223,11 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) goto err; } - section = OPENSSL_malloc(10); + section = BUF_strdup("default"); if (section == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } - BUF_strlcpy(section, "default", 10); if (_CONF_new_data(conf) == 0) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 056e500..480c29d 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -83,16 +83,8 @@ int DSA_generate_parameters_ex(DSA *ret, int bits, return ret->meth->dsa_paramgen(ret, bits, seed_in, seed_len, counter_ret, h_ret, cb); else { - const EVP_MD *evpmd; - size_t qbits = bits >= 2048 ? 256 : 160; - - if (bits >= 2048) { - qbits = 256; - evpmd = EVP_sha256(); - } else { - qbits = 160; - evpmd = EVP_sha1(); - } + const EVP_MD *evpmd = bits >= 2048 ? EVP_sha256() : EVP_sha1(); + size_t qbits = EVP_MD_size(evpmd) * 8; return dsa_builtin_paramgen(ret, bits, qbits, evpmd, seed_in, seed_len, NULL, counter_ret, @@ -142,14 +134,14 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, memcpy(seed, seed_in, seed_len); } + if ((mont = BN_MONT_CTX_new()) == NULL) + goto err; + if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); - if ((mont = BN_MONT_CTX_new()) == NULL) - goto err; - r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); diff --git a/crypto/evp/e_aes_cbc_hmac_sha256.c b/crypto/evp/e_aes_cbc_hmac_sha256.c index e83969d..411c770 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha256.c +++ b/crypto/evp/e_aes_cbc_hmac_sha256.c @@ -820,8 +820,6 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, if (arg != EVP_AEAD_TLS1_AAD_LEN) return -1; - len = p[arg - 2] << 8 | p[arg - 1]; - if (ctx->encrypt) { key->payload_length = len; if ((key->aux.tls_ver = diff --git a/crypto/evp/e_dsa.c b/crypto/evp/e_dsa.c deleted file mode 100644 index 2217e37..0000000 --- a/crypto/evp/e_dsa.c +++ /dev/null @@ -1,69 +0,0 @@ -/* crypto/evp/e_dsa.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include "internal/cryptlib.h" -#include -#include -#include - -static EVP_PKEY_METHOD dss_method = { - DSA_sign, - DSA_verify, - {EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, NULL}, -}; diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c index 9c34a03..5c03a91 100644 --- a/crypto/evp/evp_key.c +++ b/crypto/evp/evp_key.c @@ -137,7 +137,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, EVP_MD_CTX_init(&c); for (;;) { if (!EVP_DigestInit_ex(&c, md, NULL)) - return 0; + goto err; if (addmd++) if (!EVP_DigestUpdate(&c, &(md_buf[0]), mds)) goto err; @@ -188,6 +188,6 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, rv = type->key_len; err: EVP_MD_CTX_cleanup(&c); - OPENSSL_cleanse(&(md_buf[0]), EVP_MAX_MD_SIZE); + OPENSSL_cleanse(md_buf, sizeof(md_buf)); return rv; } diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index fb7947e..e5b1739 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -209,12 +209,15 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, { EVP_PBE_CTL *pbe_tmp; - if (pbe_algs == NULL) + if (pbe_algs == NULL) { pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); - if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) { - EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); - return 0; + if (pbe_algs == NULL) + goto err; } + + if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) + goto err; + pbe_tmp->pbe_type = pbe_type; pbe_tmp->pbe_nid = pbe_nid; pbe_tmp->cipher_nid = cipher_nid; @@ -223,6 +226,10 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, sk_EVP_PBE_CTL_push(pbe_algs, pbe_tmp); return 1; + + err: + EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); + return 0; } int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, diff --git a/crypto/hmac/hm_ameth.c b/crypto/hmac/hm_ameth.c index cd29c0c..20abe4f 100644 --- a/crypto/hmac/hm_ameth.c +++ b/crypto/hmac/hm_ameth.c @@ -108,9 +108,14 @@ static int old_hmac_decode(EVP_PKEY *pkey, ASN1_OCTET_STRING *os; os = ASN1_OCTET_STRING_new(); if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) - return 0; - EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); + goto err; + if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os)) + goto err; return 1; + + err: + ASN1_OCTET_STRING_free(os); + return 0; } static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index 0120194..9784294 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -242,12 +242,6 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, if ((p = strchr(p, ':'))) { *p = 0; port = p + 1; - } else { - /* Not found: set default port */ - if (*pssl) - port = "443"; - else - port = "80"; } *pport = BUF_strdup(port); diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c index 70b6904..1137d61 100644 --- a/crypto/ocsp/ocsp_prn.c +++ b/crypto/ocsp/ocsp_prn.c @@ -213,7 +213,6 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags) return 1; } - i = ASN1_STRING_length(rb->response); if ((br = OCSP_response_get1_basic(o)) == NULL) goto err; rd = &br->tbsResponseData; diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index c682fc7..47fb9ac 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -617,13 +617,11 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } - length -= 20; } else { if (length < 24) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } - length -= 24; pvk_magic = read_ledword(&p); if (pvk_magic != MS_PVKMAGIC) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER); @@ -686,23 +684,23 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in, inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); if (inlen <= 0) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_PASSWORD_READ); - return NULL; + goto err; } enctmp = OPENSSL_malloc(keylen + 8); if (!enctmp) { PEMerr(PEM_F_DO_PVK_BODY, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!derive_pvk_key(keybuf, p, saltlen, (unsigned char *)psbuf, inlen)) - return NULL; + goto err; p += saltlen; /* Copy BLOBHEADER across, decrypt rest */ memcpy(enctmp, p, 8); p += 8; if (keylen < 8) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_PVK_TOO_SHORT); - return NULL; + goto err; } inlen = keylen - 8; q = enctmp + 8; diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c index 29abe2e..648b16b 100644 --- a/crypto/pkcs12/p12_add.c +++ b/crypto/pkcs12/p12_add.c @@ -76,15 +76,19 @@ PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, bag->type = OBJ_nid2obj(nid1); if (!ASN1_item_pack(obj, it, &bag->value.octet)) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if ((safebag = PKCS12_SAFEBAG_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } safebag->value.bag = bag; safebag->type = OBJ_nid2obj(nid2); return safebag; + + err: + PKCS12_BAGS_free(bag); + return NULL; } /* Turn PKCS8 object into a keybag */ @@ -129,6 +133,7 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, p8))) { PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); + PKCS12_SAFEBAG_free(bag); return NULL; } @@ -147,14 +152,18 @@ PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) p7->type = OBJ_nid2obj(NID_pkcs7_data); if ((p7->d.data = ASN1_OCTET_STRING_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!ASN1_item_pack(sk, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), &p7->d.data)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE); - return NULL; + goto err; } return p7; + + err: + PKCS7_free(p7); + return NULL; } /* Unpack SAFEBAGS from PKCS#7 data ContentInfo */ @@ -185,7 +194,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, if (!PKCS7_set_type(p7, NID_pkcs7_encrypted)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); - return NULL; + goto err; } pbe_ciph = EVP_get_cipherbynid(pbe_nid); @@ -197,7 +206,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, if (!pbe) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); p7->d.encrypted->enc_data->algorithm = pbe; @@ -206,10 +215,14 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), pass, passlen, bags, 1))) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR); - return NULL; + goto err; } return p7; + + err: + PKCS7_free(p7); + return NULL; } STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 9da65fe..4cf68e1 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -208,11 +208,11 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, } if (!saltlen) saltlen = PKCS12_SALT_LEN; - p12->mac->salt->length = saltlen; if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } + p12->mac->salt->length = saltlen; if (!salt) { if (RAND_bytes(p12->mac->salt->data, saltlen) <= 0) return 0; diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c index 1ac6893..b3b4ae3 100644 --- a/crypto/pkcs7/pk7_doit.c +++ b/crypto/pkcs7/pk7_doit.c @@ -1089,7 +1089,6 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx) rsk = p7->d.signed_and_enveloped->recipientinfo; if (rsk == NULL) return NULL; - ri = sk_PKCS7_RECIP_INFO_value(rsk, 0); if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return (NULL); ri = sk_PKCS7_RECIP_INFO_value(rsk, idx); diff --git a/crypto/sha/asm/sha1-s390x.pl b/crypto/sha/asm/sha1-s390x.pl index 18d127d..9ce8a4c 100644 --- a/crypto/sha/asm/sha1-s390x.pl +++ b/crypto/sha/asm/sha1-s390x.pl @@ -28,7 +28,7 @@ # instructions and achieve "64-bit" performance even in 31-bit legacy # application context. The feature is not specific to any particular # processor, as long as it's "z-CPU". Latter implies that the code -# remains z/Architecture specific. On z990 it was measured to peform +# remains z/Architecture specific. On z990 it was measured to perform # 23% better than code generated by gcc 4.3. $kimdfunc=1; # magic function code for kimd instruction diff --git a/crypto/sha/asm/sha512-parisc.pl b/crypto/sha/asm/sha512-parisc.pl index fc0e15b..6cad72e 100755 --- a/crypto/sha/asm/sha512-parisc.pl +++ b/crypto/sha/asm/sha512-parisc.pl @@ -19,7 +19,7 @@ # SHA512 performance is >2.9x better than gcc 3.2 generated code on # PA-7100LC, PA-RISC 1.1 processor. Then implementation detects if the # code is executed on PA-RISC 2.0 processor and switches to 64-bit -# code path delivering adequate peformance even in "blended" 32-bit +# code path delivering adequate performance even in "blended" 32-bit # build. Though 64-bit code is not any faster than code generated by # vendor compiler on PA-8600... # diff --git a/crypto/x509/t_crl.c b/crypto/x509/t_crl.c index 8400e85..f1440eb 100644 --- a/crypto/x509/t_crl.c +++ b/crypto/x509/t_crl.c @@ -96,7 +96,6 @@ int X509_CRL_print(BIO *out, X509_CRL *x) l = X509_CRL_get_version(x); BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); X509_CRL_get0_signature(&sig, &sig_alg, x); - i = X509_CRL_get_signature_nid(x); X509_signature_print(out, sig_alg, NULL); p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); BIO_printf(out, "%8sIssuer: %s\n", "", p); diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 71a22d0..2bcac35 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -523,8 +523,6 @@ STACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm) X509_OBJECT *obj, xobj; sk = sk_X509_CRL_new_null(); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); - /* Check cache first */ - idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt); /* * Always do lookup to possibly add new CRLs to cache diff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c index f13cf37..5f50980 100644 --- a/demos/engines/zencod/hw_zencod.c +++ b/demos/engines/zencod/hw_zencod.c @@ -592,7 +592,7 @@ static int zencod_init(ENGINE *e) ptr_zencod_rc4_cipher = ptr_rc4_1; /* - * We should peform a test to see if there is actually any unit runnig on + * We should perform a test to see if there is actually any unit runnig on * the system ... Even if the cryptozen library is loaded the module coul * not be loaded on the system ... For now we may just open and close the * device !! diff --git a/doc/crypto/BIO_read.pod b/doc/crypto/BIO_read.pod index 960ea45..09ee39f 100644 --- a/doc/crypto/BIO_read.pod +++ b/doc/crypto/BIO_read.pod @@ -9,9 +9,9 @@ BIO_read, BIO_write, BIO_gets, BIO_puts - BIO I/O functions #include int BIO_read(BIO *b, void *buf, int len); - int BIO_gets(BIO *b,char *buf, int size); + int BIO_gets(BIO *b, char *buf, int size); int BIO_write(BIO *b, const void *buf, int len); - int BIO_puts(BIO *b,const char *buf); + int BIO_puts(BIO *b, const char *buf); =head1 DESCRIPTION @@ -26,7 +26,7 @@ return the digest and other BIOs may not support BIO_gets() at all. BIO_write() attempts to write B bytes from B to BIO B. -BIO_puts() attempts to write a null terminated string B to BIO B +BIO_puts() attempts to write a null terminated string B to BIO B. =head1 RETURN VALUES diff --git a/doc/crypto/BN_rand.pod b/doc/crypto/BN_rand.pod index 0676063..1abcdd4 100644 --- a/doc/crypto/BN_rand.pod +++ b/doc/crypto/BN_rand.pod @@ -19,7 +19,7 @@ BN_rand, BN_pseudo_rand, BN_rand_range, BN_pseudo_rand_range - generate pseudo-r =head1 DESCRIPTION BN_rand() generates a cryptographically strong pseudo-random number of -B bits in length and stores it in B. If B is -1, the +B in length and stores it in B. If B is -1, the most significant bit of the random number can be zero. If B is 0, it is set to 1, and if B is 1, the two most significant bits of the number will be set to 1, so that the product of two such random diff --git a/doc/crypto/EC_GROUP_copy.pod b/doc/crypto/EC_GROUP_copy.pod index 591ba90..837995b 100644 --- a/doc/crypto/EC_GROUP_copy.pod +++ b/doc/crypto/EC_GROUP_copy.pod @@ -166,7 +166,7 @@ EC_GROUP_get0_seed returns a pointer to the seed that was used to generate the p specified. EC_GROUP_get_seed_len returns the length of the seed or 0 if the seed is not specified. EC_GROUP_set_seed returns the length of the seed that has been set. If the supplied seed is NULL, or the supplied seed length is -0, the the return value will be 1. On error 0 is returned. +0, the return value will be 1. On error 0 is returned. EC_GROUP_cmp returns 0 if the curves are equal, 1 if they are not equal, or -1 on error. diff --git a/doc/crypto/EC_KEY_new.pod b/doc/crypto/EC_KEY_new.pod index 71095e5..a317a1e 100644 --- a/doc/crypto/EC_KEY_new.pod +++ b/doc/crypto/EC_KEY_new.pod @@ -72,7 +72,7 @@ The functions EC_KEY_get_conv_form and EC_KEY_set_conv_form get and set the poin of point_conversion_forms please refer to L. EC_KEY_insert_key_method_data and EC_KEY_get_key_method_data enable the caller to associate arbitrary additional data specific to the -elliptic curve scheme being used with the EC_KEY object. This data is treated as a "black box" by the ec library. The data to be stored by EC_KEY_insert_key_method_data is provided in the B parameter, which must have have associated functions for duplicating, freeing and "clear_freeing" the data item. If a subsequent EC_KEY_get_key_method_data call is issued, the functions for duplicating, freeing and "clear_freeing" the data item must be provided again, and they must be the same as they were when the data item was inserted. +elliptic curve scheme being used with the EC_KEY object. This data is treated as a "black box" by the ec library. The data to be stored by EC_KEY_insert_key_method_data is provided in the B parameter, which must have associated functions for duplicating, freeing and "clear_freeing" the data item. If a subsequent EC_KEY_get_key_method_data call is issued, the functions for duplicating, freeing and "clear_freeing" the data item must be provided again, and they must be the same as they were when the data item was inserted. EC_KEY_set_flags sets the flags in the B parameter on the EC_KEY object. Any flags that are already set are left set. The currently defined standard flags are EC_FLAG_NON_FIPS_ALLOW and EC_FLAG_FIPS_CHECKED. In addition there is the flag EC_FLAG_COFACTOR_ECDH which is specific to ECDH and is defined in ecdh.h. EC_KEY_get_flags returns the current flags that are set for this EC_KEY. EC_KEY_clear_flags clears the flags indicated by the B parameter. All other flags are left in their existing state. diff --git a/doc/crypto/X509_get_extension_flags.pod b/doc/crypto/X509_get_extension_flags.pod index d19eb89..c6e2486 100644 --- a/doc/crypto/X509_get_extension_flags.pod +++ b/doc/crypto/X509_get_extension_flags.pod @@ -121,7 +121,7 @@ certificate extension values. X509_get0_subject_key_id() returns the subject key identifier as a pointer to an B structure or B if the extension -is absent or an error occured during parsing. +is absent or an error occurred during parsing. =head1 SEE ALSO diff --git a/doc/crypto/d2i_X509_NAME.pod b/doc/crypto/d2i_X509_NAME.pod index 69f3762..ca52f53 100644 --- a/doc/crypto/d2i_X509_NAME.pod +++ b/doc/crypto/d2i_X509_NAME.pod @@ -14,7 +14,7 @@ d2i_X509_NAME, i2d_X509_NAME - X509_NAME encoding functions =head1 DESCRIPTION These functions decode and encode an B structure which is the -the same as the B type defined in RFC2459 (and elsewhere) and used +same as the B type defined in RFC2459 (and elsewhere) and used for example in certificate subject and issuer names. Otherwise the functions behave in a similar way to d2i_X509() and i2d_X509() diff --git a/include/openssl/tls1.h b/include/openssl/tls1.h index 6adfcf3..5d7b64f 100644 --- a/include/openssl/tls1.h +++ b/include/openssl/tls1.h @@ -237,25 +237,19 @@ extern "C" { /* ExtensionType value from RFC5620 */ # define TLSEXT_TYPE_heartbeat 15 -/* ExtensionType value from draft-ietf-tls-applayerprotoneg-00 */ +/* ExtensionType value from RFC7301 */ # define TLSEXT_TYPE_application_layer_protocol_negotiation 16 /* * ExtensionType value for TLS padding extension. - * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - * http://tools.ietf.org/html/draft-agl-tls-padding-03 + * http://tools.ietf.org/html/draft-agl-tls-padding */ # define TLSEXT_TYPE_padding 21 -/* - * Extension type for Encrypt-then-MAC - * http://www.ietf.org/id/draft-ietf-tls-encrypt-then-mac-02.txt - */ + +/* ExtensionType value from RFC7366 */ # define TLSEXT_TYPE_encrypt_then_mac 22 -/* - * Extended master secret extension. - * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - * https://tools.ietf.org/id/draft-ietf-tls-session-hash-03.txt - */ + +/* ExtensionType value from RFC7627 */ # define TLSEXT_TYPE_extended_master_secret 23 /* ExtensionType value from RFC4507 */ @@ -269,20 +263,19 @@ extern "C" { # define TLSEXT_TYPE_next_proto_neg 13172 # endif -/* NameType value from RFC 3546 */ +/* NameType value from RFC3546 */ # define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC 3546 */ +/* status request value from RFC3546 */ # define TLSEXT_STATUSTYPE_ocsp 1 -/* ECPointFormat values from draft-ietf-tls-ecc-12 */ +/* ECPointFormat values from RFC4492 */ # define TLSEXT_ECPOINTFORMAT_first 0 # define TLSEXT_ECPOINTFORMAT_uncompressed 0 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 # define TLSEXT_ECPOINTFORMAT_last 2 -/* Signature and hash algorithms from RFC 5246 */ - +/* Signature and hash algorithms from RFC5246 */ # define TLSEXT_signature_anonymous 0 # define TLSEXT_signature_rsa 1 # define TLSEXT_signature_dsa 2 @@ -443,13 +436,11 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_CK_RSA_PSK_WITH_NULL_SHA384 0x030000B9 /* NULL PSK ciphersuites from RFC4785 */ - # define TLS1_CK_PSK_WITH_NULL_SHA 0x0300002C # define TLS1_CK_DHE_PSK_WITH_NULL_SHA 0x0300002D # define TLS1_CK_RSA_PSK_WITH_NULL_SHA 0x0300002E /* AES ciphersuites from RFC3268 */ - # define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F # define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 # define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 @@ -538,7 +529,6 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8 0x0300C0AB /* CCM ciphersuites from RFC7251 */ - # define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM 0x0300C0AC # define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM 0x0300C0AD # define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8 0x0300C0AE @@ -559,10 +549,7 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C4 # define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256 0x030000C5 -/* - * ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in - * draft 13 - */ +/* ECC ciphersuites from RFC4492 */ # define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 # define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 # define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 @@ -692,7 +679,7 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" # define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" -/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +/* ECC ciphersuites from RFC4492 */ # define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index 2df5afe..8a89b42 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -2411,6 +2411,7 @@ int ssl3_send_client_key_exchange(SSL *s) || (pkey->pkey.rsa == NULL)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + EVP_PKEY_free(pkey); goto err; } rsa = pkey->pkey.rsa; @@ -3101,7 +3102,6 @@ int ssl3_send_client_certificate(SSL *s) * If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP; * return(-1); We then get retied later */ - i = 0; i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 7bf5828..376ab71 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -370,7 +370,6 @@ int ssl3_accept(SSL *s) */ if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); - ret = SSL_TLSEXT_ERR_ALERT_FATAL; ret = -1; s->state = SSL_ST_ERR; goto end; diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index f18f502..6446623 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -3938,7 +3938,6 @@ int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain, idx = ssl_cert_type(x, pk); if (idx == -1) return 0; - cpk = c->pkeys + idx; pvalid = s->s3->tmp.valid_flags + idx; if (c->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT) diff --git a/test/evp_test.c b/test/evp_test.c index eb7ef50..83d1749 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -639,7 +639,7 @@ struct digest_data { static int digest_test_init(struct evp_test *t, const char *alg) { const EVP_MD *digest; - struct digest_data *mdat = t->data; + struct digest_data *mdat; digest = EVP_get_digestbyname(alg); if (!digest) { /* If alg has an OID assume disabled algorithm */ From levitte at openssl.org Fri Oct 23 18:33:09 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 18:33:09 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1445625189.565139.30691.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via b62a2f8a373d1889672599834acf95161f2883ce (commit) via a8bd9f90edcabf0550dca6771f890956b0434cbb (commit) via 43679fc35e14cf417b96ad7583b179de6c8e49a9 (commit) via ec3a7c9b3729cd45c550222556100666aedc5bbc (commit) via 72895f5112452ff63d16a02e50a8282a419ccaf7 (commit) via e90f1d9b74275c11e3492e521e46f4b1afa6f883 (commit) via 5a1e6b1342f776f9304d9fa374149e317903b737 (commit) via 51a1cc4ffc68ee72ae8330cb35318995f8611027 (commit) from 8d43c0053b0df225f1c30b50af2aa1a0fc64b015 (commit) - Log ----------------------------------------------------------------- commit b62a2f8a373d1889672599834acf95161f2883ce Author: Alessandro Ghedini Date: Thu Oct 8 22:00:27 2015 +0200 Remove useless code RT#4081 Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 070c23325af4526c9a8532a60d63522c58d5554b) commit a8bd9f90edcabf0550dca6771f890956b0434cbb Author: Alessandro Ghedini Date: Thu Oct 8 14:50:27 2015 +0200 Check memory allocation Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 8cf9d71a3a43d9b98a8a278d47dc08088a954a7b) commit 43679fc35e14cf417b96ad7583b179de6c8e49a9 Author: Alessandro Ghedini Date: Thu Oct 8 14:41:09 2015 +0200 Fix references to various RFCs Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 3240e7cf5f651d9d94814b4d494fbe294e463b72) commit ec3a7c9b3729cd45c550222556100666aedc5bbc Author: Alessandro Ghedini Date: Thu Oct 8 14:40:42 2015 +0200 Fix typos Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit d900a015b5a89ea2018e6122dd2738925e4d68ab) commit 72895f5112452ff63d16a02e50a8282a419ccaf7 Author: Alessandro Ghedini Date: Thu Oct 8 14:39:58 2015 +0200 Set salt length after the malloc has succeeded Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit c2319cf9fce87a2e82efb6e58ced11a85190dc3d) commit e90f1d9b74275c11e3492e521e46f4b1afa6f883 Author: Alessandro Ghedini Date: Thu Oct 8 14:38:57 2015 +0200 Fix memory leaks and other mistakes on errors Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 3f6c7691870d1cd2ad0e0c83638cef3f35a0b548) commit 5a1e6b1342f776f9304d9fa374149e317903b737 Author: Alessandro Ghedini Date: Thu Oct 8 14:37:21 2015 +0200 Replace malloc+strlcpy with strdup Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 8acaabec429b39f9436f6a88006384d72d292539) commit 51a1cc4ffc68ee72ae8330cb35318995f8611027 Author: Alessandro Ghedini Date: Fri Oct 2 15:16:08 2015 +0200 Do not treat 0 return value from BIO_get_fd() as error 0 is a valid file descriptor. RT#4068 Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 4428c7dba8f6f407d915c1226f4e0f673e8be241) ----------------------------------------------------------------------- Summary of changes: apps/apps.c | 3 --- apps/ca.c | 12 +++--------- apps/ecparam.c | 2 -- apps/engine.c | 5 ----- apps/ocsp.c | 4 ++-- crypto/aes/asm/aesni-x86.pl | 2 +- crypto/bio/b_dump.c | 1 - crypto/bn/asm/ia64.S | 2 +- crypto/bn/bn_gf2m.c | 2 +- crypto/bn/bn_recp.c | 4 +++- crypto/bn/bn_x931p.c | 7 +++++-- crypto/conf/conf_def.c | 3 +-- crypto/dsa/dsa_gen.c | 18 +++++------------- crypto/evp/e_aes_cbc_hmac_sha256.c | 2 -- crypto/evp/evp_key.c | 4 ++-- crypto/evp/evp_pbe.c | 16 ++++++++++++---- crypto/hmac/hm_ameth.c | 9 +++++++-- crypto/ocsp/ocsp_lib.c | 6 ------ crypto/ocsp/ocsp_prn.c | 3 +-- crypto/pem/pvkfmt.c | 10 ++++------ crypto/pkcs12/p12_add.c | 27 ++++++++++++++++++++------- crypto/pkcs12/p12_mutl.c | 4 ++-- crypto/pkcs7/pk7_doit.c | 1 - crypto/sha/asm/sha512-parisc.pl | 2 +- crypto/x509/x509_lu.c | 2 -- demos/engines/zencod/hw_zencod.c | 2 +- doc/crypto/BIO_read.pod | 6 +++--- doc/crypto/BN_rand.pod | 2 +- doc/crypto/EC_GROUP_copy.pod | 2 +- doc/crypto/EC_KEY_new.pod | 4 ++-- doc/crypto/d2i_X509_NAME.pod | 2 +- ssl/s3_clnt.c | 2 +- ssl/s3_srvr.c | 1 - ssl/tls1.h | 17 +++++++---------- 34 files changed, 88 insertions(+), 101 deletions(-) diff --git a/apps/apps.c b/apps/apps.c index 68287b1..2e77805 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -119,9 +119,6 @@ #include #include #include -#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(OPENSSL_SYSNAME_WINCE) && !defined(NETWARE_CLIB) -# include -#endif #include #include #include diff --git a/apps/ca.c b/apps/ca.c index 3b7336c..7fb9285 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -99,25 +99,19 @@ #undef PROG #define PROG ca_main -#define BASE_SECTION "ca" -#define CONFIG_FILE "openssl.cnf" +#define BASE_SECTION "ca" +#define CONFIG_FILE "openssl.cnf" #define ENV_DEFAULT_CA "default_ca" -#define STRING_MASK "string_mask" +#define STRING_MASK "string_mask" #define UTF8_IN "utf8" -#define ENV_DIR "dir" -#define ENV_CERTS "certs" -#define ENV_CRL_DIR "crl_dir" -#define ENV_CA_DB "CA_DB" #define ENV_NEW_CERTS_DIR "new_certs_dir" #define ENV_CERTIFICATE "certificate" #define ENV_SERIAL "serial" #define ENV_CRLNUMBER "crlnumber" -#define ENV_CRL "crl" #define ENV_PRIVATE_KEY "private_key" -#define ENV_RANDFILE "RANDFILE" #define ENV_DEFAULT_DAYS "default_days" #define ENV_DEFAULT_STARTDATE "default_startdate" #define ENV_DEFAULT_ENDDATE "default_enddate" diff --git a/apps/ecparam.c b/apps/ecparam.c index f09c802..71b67f4 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -416,8 +416,6 @@ int MAIN(int argc, char **argv) } if (check) { - if (group == NULL) - BIO_printf(bio_err, "no elliptic curve parameters\n"); BIO_printf(bio_err, "checking elliptic curve parameters: "); if (!EC_GROUP_check(group, NULL)) { BIO_printf(bio_err, "failed\n"); diff --git a/apps/engine.c b/apps/engine.c index 3d70cac..460ec60 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -99,8 +99,6 @@ static void identity(char *ptr) static int append_buf(char **buf, const char *s, int *size, int step) { - int l = strlen(s); - if (*buf == NULL) { *size = step; *buf = OPENSSL_malloc(*size); @@ -109,9 +107,6 @@ static int append_buf(char **buf, const char *s, int *size, int step) **buf = '\0'; } - if (**buf != '\0') - l += 2; /* ", " */ - if (strlen(*buf) + strlen(s) >= (unsigned int)*size) { *size += step; *buf = OPENSSL_realloc(*buf, *size); diff --git a/apps/ocsp.c b/apps/ocsp.c index 926083d..6ed255d 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -1261,8 +1261,8 @@ static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, const char *path, return NULL; } - if (BIO_get_fd(cbio, &fd) <= 0) { - BIO_puts(err, "Can't get connection fd\n"); + if (BIO_get_fd(cbio, &fd) < 0) { + BIO_puts(bio_err, "Can't get connection fd\n"); goto err; } diff --git a/crypto/aes/asm/aesni-x86.pl b/crypto/aes/asm/aesni-x86.pl index f67df8c..9b2e37a 100644 --- a/crypto/aes/asm/aesni-x86.pl +++ b/crypto/aes/asm/aesni-x86.pl @@ -88,7 +88,7 @@ $inout3="xmm5"; $in1="xmm5"; $inout4="xmm6"; $in0="xmm6"; $inout5="xmm7"; $ivec="xmm7"; -# AESNI extenstion +# AESNI extension sub aeskeygenassist { my($dst,$src,$imm)=@_; if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index ed8e521..ccf0e28 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -104,7 +104,6 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), if ((rows * dump_width) < len) rows++; for (i = 0; i < rows; i++) { - buf[0] = '\0'; /* start with empty string */ BUF_strlcpy(buf, str, sizeof buf); BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width); BUF_strlcat(buf, tmp, sizeof buf); diff --git a/crypto/bn/asm/ia64.S b/crypto/bn/asm/ia64.S index c0cee82..a9a42ab 100644 --- a/crypto/bn/asm/ia64.S +++ b/crypto/bn/asm/ia64.S @@ -422,7 +422,7 @@ bn_mul_add_words: // This loop spins in 3*(n+10) ticks on Itanium and in 2*(n+10) on // Itanium 2. Yes, unlike previous versions it scales:-) Previous -// version was peforming *all* additions in IALU and was starving +// version was performing *all* additions in IALU and was starving // for those even on Itanium 2. In this version one addition is // moved to FPU and is folded with multiplication. This is at cost // of propogating the result from previous call to this subroutine diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index cfa1c7c..e48ca95 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -575,7 +575,7 @@ int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], bn_check_top(a); BN_CTX_start(ctx); if ((s = BN_CTX_get(ctx)) == NULL) - return 0; + goto err; if (!bn_wexpand(s, 2 * a->top)) goto err; diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 6826f93..7497ac6 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -152,8 +152,10 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, if (BN_ucmp(m, &(recp->N)) < 0) { BN_zero(d); - if (!BN_copy(r, m)) + if (!BN_copy(r, m)) { + BN_CTX_end(ctx); return 0; + } BN_CTX_end(ctx); return (1); } diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c index 6d76b12..efa48bd 100644 --- a/crypto/bn/bn_x931p.c +++ b/crypto/bn/bn_x931p.c @@ -213,14 +213,14 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) * exceeded. */ if (!BN_rand(Xp, nbits, 1, 0)) - return 0; + goto err; BN_CTX_start(ctx); t = BN_CTX_get(ctx); for (i = 0; i < 1000; i++) { if (!BN_rand(Xq, nbits, 1, 0)) - return 0; + goto err; /* Check that |Xp - Xq| > 2^(nbits - 100) */ BN_sub(t, Xp, Xq); if (BN_num_bits(t) > (nbits - 100)) @@ -234,6 +234,9 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) return 0; + err: + BN_CTX_end(ctx); + return 0; } /* diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index faca9ae..68c77ce 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -225,12 +225,11 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) goto err; } - section = (char *)OPENSSL_malloc(10); + section = BUF_strdup("default"); if (section == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } - BUF_strlcpy(section, "default", 10); if (_CONF_new_data(conf) == 0) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 6bc86dd..15f3bb4 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -114,16 +114,8 @@ int DSA_generate_parameters_ex(DSA *ret, int bits, } # endif else { - const EVP_MD *evpmd; - size_t qbits = bits >= 2048 ? 256 : 160; - - if (bits >= 2048) { - qbits = 256; - evpmd = EVP_sha256(); - } else { - qbits = 160; - evpmd = EVP_sha1(); - } + const EVP_MD *evpmd = bits >= 2048 ? EVP_sha256() : EVP_sha1(); + size_t qbits = EVP_MD_size(evpmd) * 8; return dsa_builtin_paramgen(ret, bits, qbits, evpmd, seed_in, seed_len, NULL, counter_ret, @@ -176,14 +168,14 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, if (seed_in != NULL) memcpy(seed, seed_in, seed_len); + if ((mont = BN_MONT_CTX_new()) == NULL) + goto err; + if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); - if ((mont = BN_MONT_CTX_new()) == NULL) - goto err; - r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); diff --git a/crypto/evp/e_aes_cbc_hmac_sha256.c b/crypto/evp/e_aes_cbc_hmac_sha256.c index b1c586e..028658b 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha256.c +++ b/crypto/evp/e_aes_cbc_hmac_sha256.c @@ -816,8 +816,6 @@ static int aesni_cbc_hmac_sha256_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, if (arg != EVP_AEAD_TLS1_AAD_LEN) return -1; - len = p[arg - 2] << 8 | p[arg - 1]; - if (ctx->encrypt) { key->payload_length = len; if ((key->aux.tls_ver = diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c index 71fa627..122bc28 100644 --- a/crypto/evp/evp_key.c +++ b/crypto/evp/evp_key.c @@ -137,7 +137,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, EVP_MD_CTX_init(&c); for (;;) { if (!EVP_DigestInit_ex(&c, md, NULL)) - return 0; + goto err; if (addmd++) if (!EVP_DigestUpdate(&c, &(md_buf[0]), mds)) goto err; @@ -188,6 +188,6 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, rv = type->key_len; err: EVP_MD_CTX_cleanup(&c); - OPENSSL_cleanse(&(md_buf[0]), EVP_MAX_MD_SIZE); + OPENSSL_cleanse(md_buf, sizeof(md_buf)); return rv; } diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index e3fa95d..7934c95 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -228,12 +228,16 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid, EVP_PBE_KEYGEN *keygen) { EVP_PBE_CTL *pbe_tmp; - if (!pbe_algs) + + if (pbe_algs == NULL) { pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); - if (!(pbe_tmp = (EVP_PBE_CTL *)OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) { - EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); - return 0; + if (pbe_algs == NULL) + goto err; } + + if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) + goto err; + pbe_tmp->pbe_type = pbe_type; pbe_tmp->pbe_nid = pbe_nid; pbe_tmp->cipher_nid = cipher_nid; @@ -242,6 +246,10 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, sk_EVP_PBE_CTL_push(pbe_algs, pbe_tmp); return 1; + + err: + EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); + return 0; } int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, diff --git a/crypto/hmac/hm_ameth.c b/crypto/hmac/hm_ameth.c index 29b2b5d..944c6c8 100644 --- a/crypto/hmac/hm_ameth.c +++ b/crypto/hmac/hm_ameth.c @@ -108,9 +108,14 @@ static int old_hmac_decode(EVP_PKEY *pkey, ASN1_OCTET_STRING *os; os = ASN1_OCTET_STRING_new(); if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) - return 0; - EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); + goto err; + if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os)) + goto err; return 1; + + err: + ASN1_OCTET_STRING_free(os); + return 0; } static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index 442a5b6..cabf539 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -246,12 +246,6 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, if ((p = strchr(p, ':'))) { *p = 0; port = p + 1; - } else { - /* Not found: set default port */ - if (*pssl) - port = "443"; - else - port = "80"; } *pport = BUF_strdup(port); diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c index 1834256..47d5f83 100644 --- a/crypto/ocsp/ocsp_prn.c +++ b/crypto/ocsp/ocsp_prn.c @@ -212,8 +212,7 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags) return 1; } - i = ASN1_STRING_length(rb->response); - if (!(br = OCSP_response_get1_basic(o))) + if ((br = OCSP_response_get1_basic(o)) == NULL) goto err; rd = br->tbsResponseData; l = ASN1_INTEGER_get(rd->version); diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index ee4b6a8..82d4527 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -624,13 +624,11 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } - length -= 20; } else { if (length < 24) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } - length -= 24; pvk_magic = read_ledword(&p); if (pvk_magic != MS_PVKMAGIC) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER); @@ -692,23 +690,23 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in, inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); if (inlen <= 0) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_PASSWORD_READ); - return NULL; + goto err; } enctmp = OPENSSL_malloc(keylen + 8); if (!enctmp) { PEMerr(PEM_F_DO_PVK_BODY, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!derive_pvk_key(keybuf, p, saltlen, (unsigned char *)psbuf, inlen)) - return NULL; + goto err; p += saltlen; /* Copy BLOBHEADER across, decrypt rest */ memcpy(enctmp, p, 8); p += 8; if (keylen < 8) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_PVK_TOO_SHORT); - return NULL; + goto err; } inlen = keylen - 8; q = enctmp + 8; diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c index 982805d..d9f03a3 100644 --- a/crypto/pkcs12/p12_add.c +++ b/crypto/pkcs12/p12_add.c @@ -75,15 +75,19 @@ PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, bag->type = OBJ_nid2obj(nid1); if (!ASN1_item_pack(obj, it, &bag->value.octet)) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!(safebag = PKCS12_SAFEBAG_new())) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } safebag->value.bag = bag; safebag->type = OBJ_nid2obj(nid2); return safebag; + + err: + PKCS12_BAGS_free(bag); + return NULL; } /* Turn PKCS8 object into a keybag */ @@ -127,6 +131,7 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, p8))) { PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); + PKCS12_SAFEBAG_free(bag); return NULL; } @@ -144,14 +149,18 @@ PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) p7->type = OBJ_nid2obj(NID_pkcs7_data); if (!(p7->d.data = M_ASN1_OCTET_STRING_new())) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!ASN1_item_pack(sk, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), &p7->d.data)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE); - return NULL; + goto err; } return p7; + + err: + PKCS7_free(p7); + return NULL; } /* Unpack SAFEBAGS from PKCS#7 data ContentInfo */ @@ -181,7 +190,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, if (!PKCS7_set_type(p7, NID_pkcs7_encrypted)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); - return NULL; + goto err; } pbe_ciph = EVP_get_cipherbynid(pbe_nid); @@ -193,7 +202,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, if (!pbe) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); p7->d.encrypted->enc_data->algorithm = pbe; @@ -202,10 +211,14 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), pass, passlen, bags, 1))) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR); - return NULL; + goto err; } return p7; + + err: + PKCS7_free(p7); + return NULL; } STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 5ab4bf2..a927782 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -173,11 +173,11 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, } if (!saltlen) saltlen = PKCS12_SALT_LEN; - p12->mac->salt->length = saltlen; - if (!(p12->mac->salt->data = OPENSSL_malloc(saltlen))) { + if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } + p12->mac->salt->length = saltlen; if (!salt) { if (RAND_pseudo_bytes(p12->mac->salt->data, saltlen) < 0) return 0; diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c index c8d7db0..83f3b77 100644 --- a/crypto/pkcs7/pk7_doit.c +++ b/crypto/pkcs7/pk7_doit.c @@ -1156,7 +1156,6 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx) rsk = p7->d.signed_and_enveloped->recipientinfo; if (rsk == NULL) return NULL; - ri = sk_PKCS7_RECIP_INFO_value(rsk, 0); if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return (NULL); ri = sk_PKCS7_RECIP_INFO_value(rsk, idx); diff --git a/crypto/sha/asm/sha512-parisc.pl b/crypto/sha/asm/sha512-parisc.pl index fc0e15b..6cad72e 100755 --- a/crypto/sha/asm/sha512-parisc.pl +++ b/crypto/sha/asm/sha512-parisc.pl @@ -19,7 +19,7 @@ # SHA512 performance is >2.9x better than gcc 3.2 generated code on # PA-7100LC, PA-RISC 1.1 processor. Then implementation detects if the # code is executed on PA-RISC 2.0 processor and switches to 64-bit -# code path delivering adequate peformance even in "blended" 32-bit +# code path delivering adequate performance even in "blended" 32-bit # build. Though 64-bit code is not any faster than code generated by # vendor compiler on PA-8600... # diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index b0d6539..50120a4 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -536,8 +536,6 @@ STACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm) X509_OBJECT *obj, xobj; sk = sk_X509_CRL_new_null(); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); - /* Check cache first */ - idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt); /* * Always do lookup to possibly add new CRLs to cache diff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c index 0c0f524..daf0aef 100644 --- a/demos/engines/zencod/hw_zencod.c +++ b/demos/engines/zencod/hw_zencod.c @@ -610,7 +610,7 @@ static int zencod_init(ENGINE *e) ptr_zencod_rc4_cipher = ptr_rc4_1; /* - * We should peform a test to see if there is actually any unit runnig on + * We should perform a test to see if there is actually any unit runnig on * the system ... Even if the cryptozen library is loaded the module coul * not be loaded on the system ... For now we may just open and close the * device !! diff --git a/doc/crypto/BIO_read.pod b/doc/crypto/BIO_read.pod index b345281..2c177f0 100644 --- a/doc/crypto/BIO_read.pod +++ b/doc/crypto/BIO_read.pod @@ -9,9 +9,9 @@ BIO_read, BIO_write, BIO_gets, BIO_puts - BIO I/O functions #include int BIO_read(BIO *b, void *buf, int len); - int BIO_gets(BIO *b,char *buf, int size); + int BIO_gets(BIO *b, char *buf, int size); int BIO_write(BIO *b, const void *buf, int len); - int BIO_puts(BIO *b,const char *buf); + int BIO_puts(BIO *b, const char *buf); =head1 DESCRIPTION @@ -26,7 +26,7 @@ return the digest and other BIOs may not support BIO_gets() at all. BIO_write() attempts to write B bytes from B to BIO B. -BIO_puts() attempts to write a null terminated string B to BIO B +BIO_puts() attempts to write a null terminated string B to BIO B. =head1 RETURN VALUES diff --git a/doc/crypto/BN_rand.pod b/doc/crypto/BN_rand.pod index b3aec96..e8cbf65 100644 --- a/doc/crypto/BN_rand.pod +++ b/doc/crypto/BN_rand.pod @@ -19,7 +19,7 @@ BN_rand, BN_pseudo_rand, BN_rand_range, BN_pseudo_rand_range - generate pseudo-r =head1 DESCRIPTION BN_rand() generates a cryptographically strong pseudo-random number of -B bits in length and stores it in B. If B is -1, the +B in length and stores it in B. If B is -1, the most significant bit of the random number can be zero. If B is 0, it is set to 1, and if B is 1, the two most significant bits of the number will be set to 1, so that the product of two such random diff --git a/doc/crypto/EC_GROUP_copy.pod b/doc/crypto/EC_GROUP_copy.pod index 954af46..49dc01c 100644 --- a/doc/crypto/EC_GROUP_copy.pod +++ b/doc/crypto/EC_GROUP_copy.pod @@ -158,7 +158,7 @@ EC_GROUP_get0_seed returns a pointer to the seed that was used to generate the p specified. EC_GROUP_get_seed_len returns the length of the seed or 0 if the seed is not specified. EC_GROUP_set_seed returns the length of the seed that has been set. If the supplied seed is NULL, or the supplied seed length is -0, the the return value will be 1. On error 0 is returned. +0, the return value will be 1. On error 0 is returned. EC_GROUP_cmp returns 0 if the curves are equal, 1 if they are not equal, or -1 on error. diff --git a/doc/crypto/EC_KEY_new.pod b/doc/crypto/EC_KEY_new.pod index e859689..0fa2de1 100644 --- a/doc/crypto/EC_KEY_new.pod +++ b/doc/crypto/EC_KEY_new.pod @@ -70,8 +70,8 @@ The functions EC_KEY_get0_group, EC_KEY_set_group, EC_KEY_get0_private_key, EC_K The functions EC_KEY_get_conv_form and EC_KEY_set_conv_form get and set the point_conversion_form for the B. For a description of point_conversion_forms please refer to L. -EC_KEY_insert_key_method_data and EC_KEY_get_key_method_data enable the caller to associate arbitary additional data specific to the -elliptic curve scheme being used with the EC_KEY object. This data is treated as a "black box" by the ec library. The data to be stored by EC_KEY_insert_key_method_data is provided in the B parameter, which must have have associated functions for duplicating, freeing and "clear_freeing" the data item. If a subsequent EC_KEY_get_key_method_data call is issued, the functions for duplicating, freeing and "clear_freeing" the data item must be provided again, and they must be the same as they were when the data item was inserted. +EC_KEY_insert_key_method_data and EC_KEY_get_key_method_data enable the caller to associate arbitrary additional data specific to the +elliptic curve scheme being used with the EC_KEY object. This data is treated as a "black box" by the ec library. The data to be stored by EC_KEY_insert_key_method_data is provided in the B parameter, which must have associated functions for duplicating, freeing and "clear_freeing" the data item. If a subsequent EC_KEY_get_key_method_data call is issued, the functions for duplicating, freeing and "clear_freeing" the data item must be provided again, and they must be the same as they were when the data item was inserted. EC_KEY_set_flags sets the flags in the B parameter on the EC_KEY object. Any flags that are already set are left set. The currently defined standard flags are EC_FLAG_NON_FIPS_ALLOW and EC_FLAG_FIPS_CHECKED. In addition there is the flag EC_FLAG_COFACTOR_ECDH which is specific to ECDH and is defined in ecdh.h. EC_KEY_get_flags returns the current flags that are set for this EC_KEY. EC_KEY_clear_flags clears the flags indicated by the B parameter. All other flags are left in their existing state. diff --git a/doc/crypto/d2i_X509_NAME.pod b/doc/crypto/d2i_X509_NAME.pod index 343ffe1..b025de7 100644 --- a/doc/crypto/d2i_X509_NAME.pod +++ b/doc/crypto/d2i_X509_NAME.pod @@ -14,7 +14,7 @@ d2i_X509_NAME, i2d_X509_NAME - X509_NAME encoding functions =head1 DESCRIPTION These functions decode and encode an B structure which is the -the same as the B type defined in RFC2459 (and elsewhere) and used +same as the B type defined in RFC2459 (and elsewhere) and used for example in certificate subject and issuer names. Othewise the functions behave in a similar way to d2i_X509() and i2d_X509() diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index 12f1f8e..c5e0e36 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -2485,6 +2485,7 @@ int ssl3_send_client_key_exchange(SSL *s) || (pkey->pkey.rsa == NULL)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + EVP_PKEY_free(pkey); goto err; } rsa = pkey->pkey.rsa; @@ -3388,7 +3389,6 @@ int ssl3_send_client_certificate(SSL *s) * If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP; * return(-1); We then get retied later */ - i = 0; i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index a355fde..704289a 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -383,7 +383,6 @@ int ssl3_accept(SSL *s) */ if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); - ret = SSL_TLSEXT_ERR_ALERT_FATAL; ret = -1; s->state = SSL_ST_ERR; goto end; diff --git a/ssl/tls1.h b/ssl/tls1.h index 5929607..7e237d0 100644 --- a/ssl/tls1.h +++ b/ssl/tls1.h @@ -231,13 +231,12 @@ extern "C" { /* ExtensionType value from RFC5620 */ # define TLSEXT_TYPE_heartbeat 15 -/* ExtensionType value from draft-ietf-tls-applayerprotoneg-00 */ +/* ExtensionType value from RFC7301 */ # define TLSEXT_TYPE_application_layer_protocol_negotiation 16 /* * ExtensionType value for TLS padding extension. - * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - * http://tools.ietf.org/html/draft-agl-tls-padding-03 + * http://tools.ietf.org/html/draft-agl-tls-padding */ # define TLSEXT_TYPE_padding 21 @@ -262,20 +261,19 @@ extern "C" { # define TLSEXT_TYPE_next_proto_neg 13172 # endif -/* NameType value from RFC 3546 */ +/* NameType value from RFC3546 */ # define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC 3546 */ +/* status request value from RFC3546 */ # define TLSEXT_STATUSTYPE_ocsp 1 -/* ECPointFormat values from draft-ietf-tls-ecc-12 */ +/* ECPointFormat values from RFC4492 */ # define TLSEXT_ECPOINTFORMAT_first 0 # define TLSEXT_ECPOINTFORMAT_uncompressed 0 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 # define TLSEXT_ECPOINTFORMAT_last 2 -/* Signature and hash algorithms from RFC 5246 */ - +/* Signature and hash algorithms from RFC5246 */ # define TLSEXT_signature_anonymous 0 # define TLSEXT_signature_rsa 1 # define TLSEXT_signature_dsa 2 @@ -430,7 +428,6 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 /* AES ciphersuites from RFC3268 */ - # define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F # define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 # define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 @@ -595,7 +592,7 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" # define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" -/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +/* ECC ciphersuites from RFC4492 */ # define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" From levitte at openssl.org Fri Oct 23 18:53:39 2015 From: levitte at openssl.org (Richard Levitte) Date: Fri, 23 Oct 2015 18:53:39 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1445626419.177350.10821.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 200c8ed4f5dd5fce21a3688c2f41d474a3aceca4 (commit) via a5524e534b22fa6fbba53dddb6a5543371a66a03 (commit) via edd0f5c201823cea2947506619d1936e9b5c4b92 (commit) via 020bc42893e579cb3c586386de9f800c6fe0ae54 (commit) via 61587d65eabb90d78aad46c674f14707f4407acf (commit) via 71d5679cd31f52472b1a42b12af2562edb05fb0f (commit) via 418c0511610677c74ee63bd916ab3015e57ef40b (commit) via 6a3dd58678b3dcd2bb40d4b0d9965c786d10342a (commit) from 2d404dc38031122147043af31a1f1de364903be2 (commit) - Log ----------------------------------------------------------------- commit 200c8ed4f5dd5fce21a3688c2f41d474a3aceca4 Author: Alessandro Ghedini Date: Thu Oct 8 22:00:27 2015 +0200 Remove useless code RT#4081 Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 070c23325af4526c9a8532a60d63522c58d5554b) commit a5524e534b22fa6fbba53dddb6a5543371a66a03 Author: Alessandro Ghedini Date: Thu Oct 8 14:50:27 2015 +0200 Check memory allocation Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 8cf9d71a3a43d9b98a8a278d47dc08088a954a7b) commit edd0f5c201823cea2947506619d1936e9b5c4b92 Author: Alessandro Ghedini Date: Thu Oct 8 14:41:09 2015 +0200 Fix references to various RFCs Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 3240e7cf5f651d9d94814b4d494fbe294e463b72) commit 020bc42893e579cb3c586386de9f800c6fe0ae54 Author: Alessandro Ghedini Date: Thu Oct 8 14:40:42 2015 +0200 Fix typos Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit d900a015b5a89ea2018e6122dd2738925e4d68ab) commit 61587d65eabb90d78aad46c674f14707f4407acf Author: Alessandro Ghedini Date: Thu Oct 8 14:39:58 2015 +0200 Set salt length after the malloc has succeeded Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit c2319cf9fce87a2e82efb6e58ced11a85190dc3d) commit 71d5679cd31f52472b1a42b12af2562edb05fb0f Author: Alessandro Ghedini Date: Thu Oct 8 14:38:57 2015 +0200 Fix memory leaks and other mistakes on errors Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 3f6c7691870d1cd2ad0e0c83638cef3f35a0b548) commit 418c0511610677c74ee63bd916ab3015e57ef40b Author: Alessandro Ghedini Date: Thu Oct 8 14:37:21 2015 +0200 Replace malloc+strlcpy with strdup Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 8acaabec429b39f9436f6a88006384d72d292539) commit 6a3dd58678b3dcd2bb40d4b0d9965c786d10342a Author: Alessandro Ghedini Date: Fri Oct 2 15:16:08 2015 +0200 Do not treat 0 return value from BIO_get_fd() as error 0 is a valid file descriptor. RT#4068 Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (cherry picked from commit 4428c7dba8f6f407d915c1226f4e0f673e8be241) ----------------------------------------------------------------------- Summary of changes: apps/apps.c | 3 --- apps/ca.c | 12 +++--------- apps/ecparam.c | 2 -- apps/engine.c | 5 ----- apps/ocsp.c | 4 ++-- crypto/aes/asm/aesni-x86.pl | 2 +- crypto/bio/b_dump.c | 1 - crypto/bn/asm/ia64.S | 2 +- crypto/bn/bn_gf2m.c | 2 +- crypto/bn/bn_recp.c | 4 +++- crypto/bn/bn_x931p.c | 7 +++++-- crypto/conf/conf_def.c | 3 +-- crypto/dsa/dsa_gen.c | 18 +++++------------- crypto/evp/evp_key.c | 4 ++-- crypto/evp/evp_pbe.c | 16 ++++++++++++---- crypto/hmac/hm_ameth.c | 9 +++++++-- crypto/ocsp/ocsp_lib.c | 6 ------ crypto/ocsp/ocsp_prn.c | 3 +-- crypto/pem/pvkfmt.c | 10 ++++------ crypto/pkcs12/p12_add.c | 27 ++++++++++++++++++++------- crypto/pkcs12/p12_mutl.c | 4 ++-- crypto/pkcs7/pk7_doit.c | 1 - crypto/sha/asm/sha512-parisc.pl | 2 +- crypto/x509/x509_lu.c | 2 -- demos/engines/zencod/hw_zencod.c | 2 +- doc/crypto/BIO_read.pod | 6 +++--- doc/crypto/BN_rand.pod | 2 +- doc/crypto/d2i_X509_NAME.pod | 2 +- ssl/s3_clnt.c | 2 +- ssl/s3_srvr.c | 1 - ssl/tls1.h | 15 ++++++--------- 31 files changed, 84 insertions(+), 95 deletions(-) diff --git a/apps/apps.c b/apps/apps.c index 1e48307..8ab4833 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -119,9 +119,6 @@ #include #include #include -#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(NETWARE_CLIB) -# include -#endif #include #include #include diff --git a/apps/ca.c b/apps/ca.c index 97ad0c1..73846de 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -99,25 +99,19 @@ #undef PROG #define PROG ca_main -#define BASE_SECTION "ca" -#define CONFIG_FILE "openssl.cnf" +#define BASE_SECTION "ca" +#define CONFIG_FILE "openssl.cnf" #define ENV_DEFAULT_CA "default_ca" -#define STRING_MASK "string_mask" +#define STRING_MASK "string_mask" #define UTF8_IN "utf8" -#define ENV_DIR "dir" -#define ENV_CERTS "certs" -#define ENV_CRL_DIR "crl_dir" -#define ENV_CA_DB "CA_DB" #define ENV_NEW_CERTS_DIR "new_certs_dir" #define ENV_CERTIFICATE "certificate" #define ENV_SERIAL "serial" #define ENV_CRLNUMBER "crlnumber" -#define ENV_CRL "crl" #define ENV_PRIVATE_KEY "private_key" -#define ENV_RANDFILE "RANDFILE" #define ENV_DEFAULT_DAYS "default_days" #define ENV_DEFAULT_STARTDATE "default_startdate" #define ENV_DEFAULT_ENDDATE "default_enddate" diff --git a/apps/ecparam.c b/apps/ecparam.c index 88ecbc0..402fb31 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -413,8 +413,6 @@ int MAIN(int argc, char **argv) } if (check) { - if (group == NULL) - BIO_printf(bio_err, "no elliptic curve parameters\n"); BIO_printf(bio_err, "checking elliptic curve parameters: "); if (!EC_GROUP_check(group, NULL)) { BIO_printf(bio_err, "failed\n"); diff --git a/apps/engine.c b/apps/engine.c index 3d70cac..460ec60 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -99,8 +99,6 @@ static void identity(char *ptr) static int append_buf(char **buf, const char *s, int *size, int step) { - int l = strlen(s); - if (*buf == NULL) { *size = step; *buf = OPENSSL_malloc(*size); @@ -109,9 +107,6 @@ static int append_buf(char **buf, const char *s, int *size, int step) **buf = '\0'; } - if (**buf != '\0') - l += 2; /* ", " */ - if (strlen(*buf) + strlen(s) >= (unsigned int)*size) { *size += step; *buf = OPENSSL_realloc(*buf, *size); diff --git a/apps/ocsp.c b/apps/ocsp.c index 572f064..9fd9568 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -1220,8 +1220,8 @@ static OCSP_RESPONSE *query_responder(BIO *err, BIO *cbio, char *path, return NULL; } - if (BIO_get_fd(cbio, &fd) <= 0) { - BIO_puts(err, "Can't get connection fd\n"); + if (BIO_get_fd(cbio, &fd) < 0) { + BIO_puts(bio_err, "Can't get connection fd\n"); goto err; } diff --git a/crypto/aes/asm/aesni-x86.pl b/crypto/aes/asm/aesni-x86.pl index 3dc345b..8c1d0b5 100644 --- a/crypto/aes/asm/aesni-x86.pl +++ b/crypto/aes/asm/aesni-x86.pl @@ -74,7 +74,7 @@ $inout3="xmm5"; $in1="xmm5"; $inout4="xmm6"; $in0="xmm6"; $inout5="xmm7"; $ivec="xmm7"; -# AESNI extenstion +# AESNI extension sub aeskeygenassist { my($dst,$src,$imm)=@_; if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index 3293c72..87c8162 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -104,7 +104,6 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), if ((rows * dump_width) < len) rows++; for (i = 0; i < rows; i++) { - buf[0] = '\0'; /* start with empty string */ BUF_strlcpy(buf, str, sizeof buf); BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width); BUF_strlcat(buf, tmp, sizeof buf); diff --git a/crypto/bn/asm/ia64.S b/crypto/bn/asm/ia64.S index c0cee82..a9a42ab 100644 --- a/crypto/bn/asm/ia64.S +++ b/crypto/bn/asm/ia64.S @@ -422,7 +422,7 @@ bn_mul_add_words: // This loop spins in 3*(n+10) ticks on Itanium and in 2*(n+10) on // Itanium 2. Yes, unlike previous versions it scales:-) Previous -// version was peforming *all* additions in IALU and was starving +// version was performing *all* additions in IALU and was starving // for those even on Itanium 2. In this version one addition is // moved to FPU and is folded with multiplication. This is at cost // of propogating the result from previous call to this subroutine diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index a0ba8de..a7a04f8 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -576,7 +576,7 @@ int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], bn_check_top(a); BN_CTX_start(ctx); if ((s = BN_CTX_get(ctx)) == NULL) - return 0; + goto err; if (!bn_wexpand(s, 2 * a->top)) goto err; diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 6826f93..7497ac6 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -152,8 +152,10 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, if (BN_ucmp(m, &(recp->N)) < 0) { BN_zero(d); - if (!BN_copy(r, m)) + if (!BN_copy(r, m)) { + BN_CTX_end(ctx); return 0; + } BN_CTX_end(ctx); return (1); } diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c index 6d76b12..efa48bd 100644 --- a/crypto/bn/bn_x931p.c +++ b/crypto/bn/bn_x931p.c @@ -213,14 +213,14 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) * exceeded. */ if (!BN_rand(Xp, nbits, 1, 0)) - return 0; + goto err; BN_CTX_start(ctx); t = BN_CTX_get(ctx); for (i = 0; i < 1000; i++) { if (!BN_rand(Xq, nbits, 1, 0)) - return 0; + goto err; /* Check that |Xp - Xq| > 2^(nbits - 100) */ BN_sub(t, Xp, Xq); if (BN_num_bits(t) > (nbits - 100)) @@ -234,6 +234,9 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) return 0; + err: + BN_CTX_end(ctx); + return 0; } /* diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index faca9ae..68c77ce 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -225,12 +225,11 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) goto err; } - section = (char *)OPENSSL_malloc(10); + section = BUF_strdup("default"); if (section == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; } - BUF_strlcpy(section, "default", 10); if (_CONF_new_data(conf) == 0) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index 0dada3d..34c6113 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -112,16 +112,8 @@ int DSA_generate_parameters_ex(DSA *ret, int bits, } # endif else { - const EVP_MD *evpmd; - size_t qbits = bits >= 2048 ? 256 : 160; - - if (bits >= 2048) { - qbits = 256; - evpmd = EVP_sha256(); - } else { - qbits = 160; - evpmd = EVP_sha1(); - } + const EVP_MD *evpmd = bits >= 2048 ? EVP_sha256() : EVP_sha1(); + size_t qbits = EVP_MD_size(evpmd) * 8; return dsa_builtin_paramgen(ret, bits, qbits, evpmd, seed_in, seed_len, NULL, counter_ret, @@ -174,14 +166,14 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, if (seed_in != NULL) memcpy(seed, seed_in, seed_len); + if ((mont = BN_MONT_CTX_new()) == NULL) + goto err; + if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); - if ((mont = BN_MONT_CTX_new()) == NULL) - goto err; - r0 = BN_CTX_get(ctx); g = BN_CTX_get(ctx); W = BN_CTX_get(ctx); diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c index 71fa627..122bc28 100644 --- a/crypto/evp/evp_key.c +++ b/crypto/evp/evp_key.c @@ -137,7 +137,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, EVP_MD_CTX_init(&c); for (;;) { if (!EVP_DigestInit_ex(&c, md, NULL)) - return 0; + goto err; if (addmd++) if (!EVP_DigestUpdate(&c, &(md_buf[0]), mds)) goto err; @@ -188,6 +188,6 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, rv = type->key_len; err: EVP_MD_CTX_cleanup(&c); - OPENSSL_cleanse(&(md_buf[0]), EVP_MAX_MD_SIZE); + OPENSSL_cleanse(md_buf, sizeof(md_buf)); return rv; } diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index e3fa95d..7934c95 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -228,12 +228,16 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid, EVP_PBE_KEYGEN *keygen) { EVP_PBE_CTL *pbe_tmp; - if (!pbe_algs) + + if (pbe_algs == NULL) { pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); - if (!(pbe_tmp = (EVP_PBE_CTL *)OPENSSL_malloc(sizeof(EVP_PBE_CTL)))) { - EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); - return 0; + if (pbe_algs == NULL) + goto err; } + + if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) + goto err; + pbe_tmp->pbe_type = pbe_type; pbe_tmp->pbe_nid = pbe_nid; pbe_tmp->cipher_nid = cipher_nid; @@ -242,6 +246,10 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, sk_EVP_PBE_CTL_push(pbe_algs, pbe_tmp); return 1; + + err: + EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); + return 0; } int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, diff --git a/crypto/hmac/hm_ameth.c b/crypto/hmac/hm_ameth.c index 641c797..cf14743 100644 --- a/crypto/hmac/hm_ameth.c +++ b/crypto/hmac/hm_ameth.c @@ -108,9 +108,14 @@ static int old_hmac_decode(EVP_PKEY *pkey, ASN1_OCTET_STRING *os; os = ASN1_OCTET_STRING_new(); if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen)) - return 0; - EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os); + goto err; + if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os)) + goto err; return 1; + + err: + ASN1_OCTET_STRING_free(os); + return 0; } static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index d28d6b5..8db62ba 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -246,12 +246,6 @@ int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, if ((p = strchr(p, ':'))) { *p = 0; port = p + 1; - } else { - /* Not found: set default port */ - if (*pssl) - port = "443"; - else - port = "80"; } *pport = BUF_strdup(port); diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c index 1834256..47d5f83 100644 --- a/crypto/ocsp/ocsp_prn.c +++ b/crypto/ocsp/ocsp_prn.c @@ -212,8 +212,7 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags) return 1; } - i = ASN1_STRING_length(rb->response); - if (!(br = OCSP_response_get1_basic(o))) + if ((br = OCSP_response_get1_basic(o)) == NULL) goto err; rd = br->tbsResponseData; l = ASN1_INTEGER_get(rd->version); diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index ee4b6a8..82d4527 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -624,13 +624,11 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } - length -= 20; } else { if (length < 24) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); return 0; } - length -= 24; pvk_magic = read_ledword(&p); if (pvk_magic != MS_PVKMAGIC) { PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER); @@ -692,23 +690,23 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in, inlen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u); if (inlen <= 0) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_BAD_PASSWORD_READ); - return NULL; + goto err; } enctmp = OPENSSL_malloc(keylen + 8); if (!enctmp) { PEMerr(PEM_F_DO_PVK_BODY, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!derive_pvk_key(keybuf, p, saltlen, (unsigned char *)psbuf, inlen)) - return NULL; + goto err; p += saltlen; /* Copy BLOBHEADER across, decrypt rest */ memcpy(enctmp, p, 8); p += 8; if (keylen < 8) { PEMerr(PEM_F_DO_PVK_BODY, PEM_R_PVK_TOO_SHORT); - return NULL; + goto err; } inlen = keylen - 8; q = enctmp + 8; diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c index 982805d..d9f03a3 100644 --- a/crypto/pkcs12/p12_add.c +++ b/crypto/pkcs12/p12_add.c @@ -75,15 +75,19 @@ PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, bag->type = OBJ_nid2obj(nid1); if (!ASN1_item_pack(obj, it, &bag->value.octet)) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!(safebag = PKCS12_SAFEBAG_new())) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } safebag->value.bag = bag; safebag->type = OBJ_nid2obj(nid2); return safebag; + + err: + PKCS12_BAGS_free(bag); + return NULL; } /* Turn PKCS8 object into a keybag */ @@ -127,6 +131,7 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass, PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, p8))) { PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); + PKCS12_SAFEBAG_free(bag); return NULL; } @@ -144,14 +149,18 @@ PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) p7->type = OBJ_nid2obj(NID_pkcs7_data); if (!(p7->d.data = M_ASN1_OCTET_STRING_new())) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } if (!ASN1_item_pack(sk, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), &p7->d.data)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE); - return NULL; + goto err; } return p7; + + err: + PKCS7_free(p7); + return NULL; } /* Unpack SAFEBAGS from PKCS#7 data ContentInfo */ @@ -181,7 +190,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, if (!PKCS7_set_type(p7, NID_pkcs7_encrypted)) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE); - return NULL; + goto err; } pbe_ciph = EVP_get_cipherbynid(pbe_nid); @@ -193,7 +202,7 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, if (!pbe) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm); p7->d.encrypted->enc_data->algorithm = pbe; @@ -202,10 +211,14 @@ PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, PKCS12_item_i2d_encrypt(pbe, ASN1_ITEM_rptr(PKCS12_SAFEBAGS), pass, passlen, bags, 1))) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR); - return NULL; + goto err; } return p7; + + err: + PKCS7_free(p7); + return NULL; } STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 5ab4bf2..a927782 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -173,11 +173,11 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, } if (!saltlen) saltlen = PKCS12_SALT_LEN; - p12->mac->salt->length = saltlen; - if (!(p12->mac->salt->data = OPENSSL_malloc(saltlen))) { + if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } + p12->mac->salt->length = saltlen; if (!salt) { if (RAND_pseudo_bytes(p12->mac->salt->data, saltlen) < 0) return 0; diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c index c8d7db0..83f3b77 100644 --- a/crypto/pkcs7/pk7_doit.c +++ b/crypto/pkcs7/pk7_doit.c @@ -1156,7 +1156,6 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx) rsk = p7->d.signed_and_enveloped->recipientinfo; if (rsk == NULL) return NULL; - ri = sk_PKCS7_RECIP_INFO_value(rsk, 0); if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) return (NULL); ri = sk_PKCS7_RECIP_INFO_value(rsk, idx); diff --git a/crypto/sha/asm/sha512-parisc.pl b/crypto/sha/asm/sha512-parisc.pl index fc0e15b..6cad72e 100755 --- a/crypto/sha/asm/sha512-parisc.pl +++ b/crypto/sha/asm/sha512-parisc.pl @@ -19,7 +19,7 @@ # SHA512 performance is >2.9x better than gcc 3.2 generated code on # PA-7100LC, PA-RISC 1.1 processor. Then implementation detects if the # code is executed on PA-RISC 2.0 processor and switches to 64-bit -# code path delivering adequate peformance even in "blended" 32-bit +# code path delivering adequate performance even in "blended" 32-bit # build. Though 64-bit code is not any faster than code generated by # vendor compiler on PA-8600... # diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 8415d1d..8084c4a 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -523,8 +523,6 @@ STACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm) X509_OBJECT *obj, xobj; sk = sk_X509_CRL_new_null(); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); - /* Check cache first */ - idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt); /* * Always do lookup to possibly add new CRLs to cache diff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c index 0c0f524..daf0aef 100644 --- a/demos/engines/zencod/hw_zencod.c +++ b/demos/engines/zencod/hw_zencod.c @@ -610,7 +610,7 @@ static int zencod_init(ENGINE *e) ptr_zencod_rc4_cipher = ptr_rc4_1; /* - * We should peform a test to see if there is actually any unit runnig on + * We should perform a test to see if there is actually any unit runnig on * the system ... Even if the cryptozen library is loaded the module coul * not be loaded on the system ... For now we may just open and close the * device !! diff --git a/doc/crypto/BIO_read.pod b/doc/crypto/BIO_read.pod index b345281..2c177f0 100644 --- a/doc/crypto/BIO_read.pod +++ b/doc/crypto/BIO_read.pod @@ -9,9 +9,9 @@ BIO_read, BIO_write, BIO_gets, BIO_puts - BIO I/O functions #include int BIO_read(BIO *b, void *buf, int len); - int BIO_gets(BIO *b,char *buf, int size); + int BIO_gets(BIO *b, char *buf, int size); int BIO_write(BIO *b, const void *buf, int len); - int BIO_puts(BIO *b,const char *buf); + int BIO_puts(BIO *b, const char *buf); =head1 DESCRIPTION @@ -26,7 +26,7 @@ return the digest and other BIOs may not support BIO_gets() at all. BIO_write() attempts to write B bytes from B to BIO B. -BIO_puts() attempts to write a null terminated string B to BIO B +BIO_puts() attempts to write a null terminated string B to BIO B. =head1 RETURN VALUES diff --git a/doc/crypto/BN_rand.pod b/doc/crypto/BN_rand.pod index b91231c..fde5f72 100644 --- a/doc/crypto/BN_rand.pod +++ b/doc/crypto/BN_rand.pod @@ -19,7 +19,7 @@ BN_rand, BN_pseudo_rand - generate pseudo-random number =head1 DESCRIPTION BN_rand() generates a cryptographically strong pseudo-random number of -B bits in length and stores it in B. If B is -1, the +B in length and stores it in B. If B is -1, the most significant bit of the random number can be zero. If B is 0, it is set to 1, and if B is 1, the two most significant bits of the number will be set to 1, so that the product of two such random diff --git a/doc/crypto/d2i_X509_NAME.pod b/doc/crypto/d2i_X509_NAME.pod index 343ffe1..b025de7 100644 --- a/doc/crypto/d2i_X509_NAME.pod +++ b/doc/crypto/d2i_X509_NAME.pod @@ -14,7 +14,7 @@ d2i_X509_NAME, i2d_X509_NAME - X509_NAME encoding functions =head1 DESCRIPTION These functions decode and encode an B structure which is the -the same as the B type defined in RFC2459 (and elsewhere) and used +same as the B type defined in RFC2459 (and elsewhere) and used for example in certificate subject and issuer names. Othewise the functions behave in a similar way to d2i_X509() and i2d_X509() diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index 47b3189..104349e 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -2377,6 +2377,7 @@ int ssl3_send_client_key_exchange(SSL *s) || (pkey->pkey.rsa == NULL)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + EVP_PKEY_free(pkey); goto err; } rsa = pkey->pkey.rsa; @@ -3217,7 +3218,6 @@ int ssl3_send_client_certificate(SSL *s) * If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP; * return(-1); We then get retied later */ - i = 0; i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 208063c..aa57937 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -383,7 +383,6 @@ int ssl3_accept(SSL *s) */ if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); - ret = SSL_TLSEXT_ERR_ALERT_FATAL; ret = -1; s->state = SSL_ST_ERR; goto end; diff --git a/ssl/tls1.h b/ssl/tls1.h index 69d8186..91504b1 100644 --- a/ssl/tls1.h +++ b/ssl/tls1.h @@ -235,8 +235,7 @@ extern "C" { /* * ExtensionType value for TLS padding extension. - * http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - * http://tools.ietf.org/html/draft-agl-tls-padding-03 + * http://tools.ietf.org/html/draft-agl-tls-padding */ # define TLSEXT_TYPE_padding 21 @@ -261,20 +260,19 @@ extern "C" { # define TLSEXT_TYPE_next_proto_neg 13172 # endif -/* NameType value from RFC 3546 */ +/* NameType value from RFC3546 */ # define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC 3546 */ +/* status request value from RFC3546 */ # define TLSEXT_STATUSTYPE_ocsp 1 -/* ECPointFormat values from draft-ietf-tls-ecc-12 */ +/* ECPointFormat values from RFC4492 */ # define TLSEXT_ECPOINTFORMAT_first 0 # define TLSEXT_ECPOINTFORMAT_uncompressed 0 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 # define TLSEXT_ECPOINTFORMAT_last 2 -/* Signature and hash algorithms from RFC 5246 */ - +/* Signature and hash algorithms from RFC5246 */ # define TLSEXT_signature_anonymous 0 # define TLSEXT_signature_rsa 1 # define TLSEXT_signature_dsa 2 @@ -404,7 +402,6 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 /* AES ciphersuites from RFC3268 */ - # define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F # define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 # define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 @@ -570,7 +567,7 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" # define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" -/* ECC ciphersuites from draft-ietf-tls-ecc-01.txt (Mar 15, 2001) */ +/* ECC ciphersuites from RFC4492 */ # define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" From ben at openssl.org Sat Oct 24 16:11:10 2015 From: ben at openssl.org (Ben Laurie) Date: Sat, 24 Oct 2015 16:11:10 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445703070.404955.4624.nullmailer@dev.openssl.org> The branch master has been updated via 2f1a5d1694c4b59ea94115ed4e9577c5bb826c26 (commit) from 070c23325af4526c9a8532a60d63522c58d5554b (commit) - Log ----------------------------------------------------------------- commit 2f1a5d1694c4b59ea94115ed4e9577c5bb826c26 Author: Ben Laurie Date: Sat Oct 3 16:43:21 2015 +0100 Fix undeclared variable warnings. Reviewed-by: Kurt Roeckx ----------------------------------------------------------------------- Summary of changes: crypto/bn/Makefile | 4 ++-- crypto/bn/bn_dh.c | 1 + crypto/dh/Makefile | 4 ++-- crypto/dh/dh_rfc5114.c | 4 +--- crypto/engine/Makefile | 15 ++++++++------- crypto/evp/Makefile | 1 - crypto/include/internal/bn_dh.h | 8 ++++++++ test/Makefile | 6 ++---- 8 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 crypto/include/internal/bn_dh.h diff --git a/crypto/bn/Makefile b/crypto/bn/Makefile index 5d05e1b..2ca62a8 100644 --- a/crypto/bn/Makefile +++ b/crypto/bn/Makefile @@ -224,8 +224,8 @@ bn_dh.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h bn_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h bn_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h bn_dh.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -bn_dh.o: ../../include/openssl/symhacks.h ../include/internal/bn_int.h bn_dh.c -bn_dh.o: bn_lcl.h +bn_dh.o: ../../include/openssl/symhacks.h ../include/internal/bn_dh.h +bn_dh.o: ../include/internal/bn_int.h bn_dh.c bn_lcl.h bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h diff --git a/crypto/bn/bn_dh.c b/crypto/bn/bn_dh.c index 5572a2d..ad4a16e 100644 --- a/crypto/bn/bn_dh.c +++ b/crypto/bn/bn_dh.c @@ -61,6 +61,7 @@ #ifndef OPENSSL_NO_DH #include +#include "internal/bn_dh.h" /* DH parameters from RFC5114 */ # if BN_BITS2 == 64 diff --git a/crypto/dh/Makefile b/crypto/dh/Makefile index 655bca0..6beecef 100644 --- a/crypto/dh/Makefile +++ b/crypto/dh/Makefile @@ -189,5 +189,5 @@ dh_rfc5114.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h dh_rfc5114.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h dh_rfc5114.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h dh_rfc5114.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -dh_rfc5114.o: ../../include/openssl/symhacks.h ../include/internal/cryptlib.h -dh_rfc5114.o: dh_rfc5114.c +dh_rfc5114.o: ../../include/openssl/symhacks.h ../include/internal/bn_dh.h +dh_rfc5114.o: ../include/internal/cryptlib.h dh_rfc5114.c diff --git a/crypto/dh/dh_rfc5114.c b/crypto/dh/dh_rfc5114.c index 8819ac0..da998f5 100644 --- a/crypto/dh/dh_rfc5114.c +++ b/crypto/dh/dh_rfc5114.c @@ -60,6 +60,7 @@ #include "internal/cryptlib.h" #include #include +#include "internal/bn_dh.h" /* * Macro to make a DH structure from BIGNUM data. NB: although just copying @@ -68,9 +69,6 @@ */ #define make_dh(x) \ -\ -extern const BIGNUM _bignum_dh##x##_p, _bignum_dh##x##_g, _bignum_dh##x##_q; \ -\ DH *DH_get_##x(void) \ { \ DH *dh = DH_new(); \ diff --git a/crypto/engine/Makefile b/crypto/engine/Makefile index 532fadd..dae2926 100644 --- a/crypto/engine/Makefile +++ b/crypto/engine/Makefile @@ -100,19 +100,20 @@ eng_cnf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h eng_cnf.o: ../include/internal/cryptlib.h eng_cnf.c eng_int.h eng_cryptodev.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h eng_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h -eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h +eng_cryptodev.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h eng_cryptodev.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h eng_cryptodev.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h -eng_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h -eng_cryptodev.o: ../../include/openssl/obj_mac.h +eng_cryptodev.o: ../../include/openssl/err.h ../../include/openssl/evp.h +eng_cryptodev.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h eng_cryptodev.o: ../../include/openssl/objects.h eng_cryptodev.o: ../../include/openssl/opensslconf.h eng_cryptodev.o: ../../include/openssl/opensslv.h eng_cryptodev.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h -eng_cryptodev.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h -eng_cryptodev.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -eng_cryptodev.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h -eng_cryptodev.o: eng_cryptodev.c +eng_cryptodev.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +eng_cryptodev.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +eng_cryptodev.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h +eng_cryptodev.o: ../../include/openssl/x509_vfy.h eng_cryptodev.c eng_ctrl.o: ../../e_os.h ../../include/openssl/asn1.h eng_ctrl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h eng_ctrl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h diff --git a/crypto/evp/Makefile b/crypto/evp/Makefile index 1a65b46..a175d0b 100644 --- a/crypto/evp/Makefile +++ b/crypto/evp/Makefile @@ -290,7 +290,6 @@ e_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h e_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h e_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h e_null.o: ../include/internal/cryptlib.h e_null.c -e_old.o: e_old.c e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h diff --git a/crypto/include/internal/bn_dh.h b/crypto/include/internal/bn_dh.h new file mode 100644 index 0000000..3810514 --- /dev/null +++ b/crypto/include/internal/bn_dh.h @@ -0,0 +1,8 @@ +#define declare_dh_bn(x) \ + const extern BIGNUM _bignum_dh##x##_p; \ + const extern BIGNUM _bignum_dh##x##_g; \ + const extern BIGNUM _bignum_dh##x##_q; + +declare_dh_bn(1024_160) +declare_dh_bn(2048_224) +declare_dh_bn(2048_256) diff --git a/test/Makefile b/test/Makefile index 6f32758..e938633 100644 --- a/test/Makefile +++ b/test/Makefile @@ -416,8 +416,7 @@ clienthellotest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h clienthellotest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h clienthellotest.o: clienthellotest.c constant_time_test.o: ../e_os.h ../include/internal/constant_time_locl.h -constant_time_test.o: ../include/openssl/e_os2.h -constant_time_test.o: ../include/openssl/opensslconf.h constant_time_test.c +constant_time_test.o: constant_time_test.c destest.o: ../include/openssl/des.h ../include/openssl/e_os2.h destest.o: ../include/openssl/opensslconf.h destest.c dhtest.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/bn.h @@ -682,8 +681,7 @@ ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssltest.o: ../include/openssl/x509v3.h ../ssl/packet_locl.h ssltest.o: ../ssl/record/record.h ../ssl/ssl_locl.h ssltest.c -testutil.o: ../e_os.h ../include/openssl/e_os2.h -testutil.o: ../include/openssl/opensslconf.h testutil.c testutil.h +testutil.o: ../e_os.h testutil.c testutil.h v3nametest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h v3nametest.o: ../include/openssl/buffer.h ../include/openssl/conf.h v3nametest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h From ben at openssl.org Sat Oct 24 16:35:56 2015 From: ben at openssl.org (Ben Laurie) Date: Sat, 24 Oct 2015 16:35:56 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445704556.261142.27644.nullmailer@dev.openssl.org> The branch master has been updated via 84cf97af0691290d53c0a51807fa15f0843219ef (commit) from 2f1a5d1694c4b59ea94115ed4e9577c5bb826c26 (commit) - Log ----------------------------------------------------------------- commit 84cf97af0691290d53c0a51807fa15f0843219ef Author: Ben Laurie Date: Sat Oct 3 16:43:21 2015 +0100 Improve make depend. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: crypto/engine/eng_cryptodev.c | 34 ++++++++++++++++++---------------- crypto/evp/Makefile | 1 + test/Makefile | 6 ++++-- util/clean-depend.pl | 7 +++++++ 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c index 65fc29e..c67ecc5 100644 --- a/crypto/engine/eng_cryptodev.c +++ b/crypto/engine/eng_cryptodev.c @@ -42,6 +42,24 @@ # endif #endif +#include +#ifdef HAVE_CRYPTODEV +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #ifndef HAVE_CRYPTODEV void ENGINE_load_cryptodev(void) @@ -52,22 +70,6 @@ void ENGINE_load_cryptodev(void) #else -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - struct dev_crypto_state { struct session_op d_sess; int d_fd; diff --git a/crypto/evp/Makefile b/crypto/evp/Makefile index a175d0b..1a65b46 100644 --- a/crypto/evp/Makefile +++ b/crypto/evp/Makefile @@ -290,6 +290,7 @@ e_null.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h e_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h e_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h e_null.o: ../include/internal/cryptlib.h e_null.c +e_old.o: e_old.c e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h diff --git a/test/Makefile b/test/Makefile index e938633..6f32758 100644 --- a/test/Makefile +++ b/test/Makefile @@ -416,7 +416,8 @@ clienthellotest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h clienthellotest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h clienthellotest.o: clienthellotest.c constant_time_test.o: ../e_os.h ../include/internal/constant_time_locl.h -constant_time_test.o: constant_time_test.c +constant_time_test.o: ../include/openssl/e_os2.h +constant_time_test.o: ../include/openssl/opensslconf.h constant_time_test.c destest.o: ../include/openssl/des.h ../include/openssl/e_os2.h destest.o: ../include/openssl/opensslconf.h destest.c dhtest.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/bn.h @@ -681,7 +682,8 @@ ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssltest.o: ../include/openssl/x509v3.h ../ssl/packet_locl.h ssltest.o: ../ssl/record/record.h ../ssl/ssl_locl.h ssltest.c -testutil.o: ../e_os.h testutil.c testutil.h +testutil.o: ../e_os.h ../include/openssl/e_os2.h +testutil.o: ../include/openssl/opensslconf.h testutil.c testutil.h v3nametest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h v3nametest.o: ../include/openssl/buffer.h ../include/openssl/conf.h v3nametest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h diff --git a/util/clean-depend.pl b/util/clean-depend.pl index 30197b7..f29192f 100755 --- a/util/clean-depend.pl +++ b/util/clean-depend.pl @@ -3,6 +3,11 @@ # Written by Ben Laurie 19 Jan 1999 use strict; +use Cwd; + +my $path = getcwd(); +$path =~ /([^\/]+)$/; +$path = $1; while() { print; @@ -56,6 +61,8 @@ foreach $file (sort keys %files) { # Remove leading ./ before sorting my @deps = map { $_ =~ s/^\.\///; $_ } @{$files{$file}}; + # Remove ../thisdir/ + @deps = map { $_ =~ s|^../$path/||; $_ } @deps; foreach $dep (sort @deps) { $dep=~s/^\.\///; From builds at travis-ci.org Sat Oct 24 16:59:38 2015 From: builds at travis-ci.org (Travis CI) Date: Sat, 24 Oct 2015 16:59:38 +0000 Subject: [openssl-commits] Broken: openssl/openssl#494 (master - 84cf97a) In-Reply-To: Message-ID: <562bb8fa1ccf0_3a46b3e3896cf@bf5294f3-0275-456c-afd8-0bd672e2024f.mail> Build Update for openssl/openssl ------------------------------------- Build: #494 Status: Broken Duration: 23 minutes and 4 seconds Commit: 84cf97a (master) Author: Ben Laurie Message: Improve make depend. Reviewed-by: Richard Levitte View the changeset: https://github.com/openssl/openssl/compare/2f1a5d1694c4...84cf97af0691 View the full build log and details: https://travis-ci.org/openssl/openssl/builds/87211579 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at openssl.org Sun Oct 25 17:24:31 2015 From: ben at openssl.org (Ben Laurie) Date: Sun, 25 Oct 2015 17:24:31 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445793871.123868.28608.nullmailer@dev.openssl.org> The branch master has been updated via d2c3d5d4fcfee0820ed3e7018f9b1537a97cbe2e (commit) from 84cf97af0691290d53c0a51807fa15f0843219ef (commit) - Log ----------------------------------------------------------------- commit d2c3d5d4fcfee0820ed3e7018f9b1537a97cbe2e Author: Ben Laurie Date: Sat Oct 24 18:37:12 2015 +0100 Probably fix travis (wine build). Reviewed-by: Stephen Henson ----------------------------------------------------------------------- Summary of changes: crypto/engine/eng_cryptodev.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c index c67ecc5..c660bb3 100644 --- a/crypto/engine/eng_cryptodev.c +++ b/crypto/engine/eng_cryptodev.c @@ -45,20 +45,20 @@ #include #ifdef HAVE_CRYPTODEV # include +# include +# include +# include +# include +# include +# include +# include +# include +# include #endif #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #ifndef HAVE_CRYPTODEV From builds at travis-ci.org Sun Oct 25 17:47:05 2015 From: builds at travis-ci.org (Travis CI) Date: Sun, 25 Oct 2015 17:47:05 +0000 Subject: [openssl-commits] Fixed: openssl/openssl#504 (master - d2c3d5d) In-Reply-To: Message-ID: <562d159914438_3546ac2237d@f5ebf283-d604-409b-b313-5a7967e3aeda.mail> Build Update for openssl/openssl ------------------------------------- Build: #504 Status: Fixed Duration: 22 minutes and 7 seconds Commit: d2c3d5d (master) Author: Ben Laurie Message: Probably fix travis (wine build). Reviewed-by: Stephen Henson View the changeset: https://github.com/openssl/openssl/compare/84cf97af0691...d2c3d5d4fcfe View the full build log and details: https://travis-ci.org/openssl/openssl/builds/87332949 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From levitte at openssl.org Mon Oct 26 18:47:12 2015 From: levitte at openssl.org (Richard Levitte) Date: Mon, 26 Oct 2015 18:47:12 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1445885232.225971.17584.nullmailer@dev.openssl.org> The branch master has been updated via b18bb5d816a762968429b29d6787728aa4afb6f1 (commit) from ce4c485f1b7a545781f757ba2a810ed1d865ad2b (commit) - Log ----------------------------------------------------------------- commit b18bb5d816a762968429b29d6787728aa4afb6f1 Author: Richard Levitte Date: Mon Oct 26 19:46:56 2015 +0100 Redirect the old releasestrat.html location ----------------------------------------------------------------------- Summary of changes: .htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/.htaccess b/.htaccess index cf39f01..803ad34 100644 --- a/.htaccess +++ b/.htaccess @@ -2,6 +2,7 @@ RedirectMatch 404 .*/\.git/.* Options +ExecCGI +FollowSymLinks +Redirect permanent /about/releasestrat.html /policies/releasestrat.html Redirect permanent /licenses/openssl_ccla.pdf /policies/openssl_ccla.pdf Redirect permanent /licenses/openssl_icla.pdf /policies/openssl_icla.pdf Redirect permanent /support/faq.html /docs/faq.html From rsalz at openssl.org Mon Oct 26 20:36:08 2015 From: rsalz at openssl.org (Rich Salz) Date: Mon, 26 Oct 2015 20:36:08 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445891768.720010.3408.nullmailer@dev.openssl.org> The branch master has been updated via 0e56b4b42439d0842956a6730dec904ed70bbef7 (commit) from d2c3d5d4fcfee0820ed3e7018f9b1537a97cbe2e (commit) - Log ----------------------------------------------------------------- commit 0e56b4b42439d0842956a6730dec904ed70bbef7 Author: Rich Salz Date: Mon Oct 26 16:00:23 2015 -0400 Move crypto/threads to demo/threads Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: CHANGES | 3 + demos/threads/README | 7 + demos/threads/mttest.c | 773 ++++++++++++++++++++++ demos/threads/pthread.sh | 6 + crypto/asn1/a_digest.c => demos/threads/th-lock.c | 151 ++++- demos/threads/win32.bat | 4 + 6 files changed, 910 insertions(+), 34 deletions(-) create mode 100644 demos/threads/README create mode 100644 demos/threads/mttest.c create mode 100644 demos/threads/pthread.sh copy crypto/asn1/a_digest.c => demos/threads/th-lock.c (52%) create mode 100644 demos/threads/win32.bat diff --git a/CHANGES b/CHANGES index 3408794..7f33901 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Changes between 1.0.2 and 1.1.0 [xx XXX xxxx] + *) The demo files in crypto/threads were moved to demo/threads. + [Rich Salz] + *) Removed obsolete engines: 4758cca, aep, atalla, cswift, nuron and sureware. [Matt Caswell] diff --git a/demos/threads/README b/demos/threads/README new file mode 100644 index 0000000..d8f358b --- /dev/null +++ b/demos/threads/README @@ -0,0 +1,7 @@ +This shows how to set up the OpenSSL callbacks for use in +multi-threaded programs. + +Two implementations, one for Win32 native and one for pthreads, are provided +in th-lock.c A test program is in mttest.c + +Build scripts are in pthread.sh and win32.bat diff --git a/demos/threads/mttest.c b/demos/threads/mttest.c new file mode 100644 index 0000000..797a2ca --- /dev/null +++ b/demos/threads/mttest.c @@ -0,0 +1,773 @@ +/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay at cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh at cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay at cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include +#include +#include +#ifdef LINUX +# include +#endif +#ifdef OPENSSL_SYS_WIN32 +# include +#endif +#ifdef PTHREADS +# include +#endif +#include +#include +#include +#include +#include +#include +#include + +#define TEST_SERVER_CERT "../../apps/server.pem" +#define TEST_CLIENT_CERT "../../apps/client.pem" + +#define MAX_THREAD_NUMBER 100 + +int verify_callback(int ok, X509_STORE_CTX *xs); +void thread_setup(void); +void thread_cleanup(void); +void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx); + +void win32_locking_callback(int mode, int type, const char *file, int line); +void pthreads_locking_callback(int mode, int type, const char *file, int line); + +void irix_thread_id(CRYPTO_THREADID *tid); +void pthreads_thread_id(CRYPTO_THREADID *tid); + +BIO *bio_err = NULL; +BIO *bio_stdout = NULL; + +static char *cipher = NULL; +int verbose = 0; +#ifdef FIONBIO +static int s_nbio = 0; +#endif + +int thread_number = 10; +int number_of_loops = 10; +int reconnect = 0; +int cache_stats = 0; + +static const char rnd_seed[] = + "string to make the random number generator think it has entropy"; + +int doit(char *ctx[4]); +static void print_stats(BIO *bio, SSL_CTX *ctx) +{ + BIO_printf(bio, "%4ld items in the session cache\n", + SSL_CTX_sess_number(ctx)); + BIO_printf(bio, "%4d client connects (SSL_connect())\n", + SSL_CTX_sess_connect(ctx)); + BIO_printf(bio, "%4d client connects that finished\n", + SSL_CTX_sess_connect_good(ctx)); + BIO_printf(bio, "%4d server connects (SSL_accept())\n", + SSL_CTX_sess_accept(ctx)); + BIO_printf(bio, "%4d server connects that finished\n", + SSL_CTX_sess_accept_good(ctx)); + BIO_printf(bio, "%4d session cache hits\n", SSL_CTX_sess_hits(ctx)); + BIO_printf(bio, "%4d session cache misses\n", SSL_CTX_sess_misses(ctx)); + BIO_printf(bio, "%4d session cache timeouts\n", SSL_CTX_sess_timeouts(ctx)); +} + +static void sv_usage(void) +{ + BIO_printf(bio_err, "usage: ssltest [args ...]\n"); + BIO_printf(bio_err, "\n"); + BIO_printf(bio_err, " -server_auth - check server certificate\n"); + BIO_printf(bio_err, " -client_auth - do client authentication\n"); + BIO_printf(bio_err, " -v - more output\n"); + BIO_printf(bio_err, " -CApath arg - PEM format directory of CA's\n"); + BIO_printf(bio_err, " -CAfile arg - PEM format file of CA's\n"); + BIO_printf(bio_err, " -threads arg - number of threads\n"); + BIO_printf(bio_err, " -loops arg - number of 'connections', per thread\n"); + BIO_printf(bio_err, " -reconnect - reuse session-id's\n"); + BIO_printf(bio_err, " -stats - server session-id cache stats\n"); + BIO_printf(bio_err, " -cert arg - server certificate/key\n"); + BIO_printf(bio_err, " -ccert arg - client certificate/key\n"); + BIO_printf(bio_err, " -ssl3 - just SSLv3n\n"); +} + +int main(int argc, char *argv[]) +{ + char *CApath = NULL, *CAfile = NULL; + int badop = 0; + int ret = 1; + int client_auth = 0; + int server_auth = 0; + SSL_CTX *s_ctx = NULL; + SSL_CTX *c_ctx = NULL; + char *scert = TEST_SERVER_CERT; + char *ccert = TEST_CLIENT_CERT; + const SSL_METHOD *ssl_method = TLS_method(); + + RAND_seed(rnd_seed, sizeof rnd_seed); + + if (bio_err == NULL) + bio_err = BIO_new_fd(2, BIO_NOCLOSE); + if (bio_stdout == NULL) + bio_stdout = BIO_new_fd(1, BIO_NOCLOSE); + argc--; + argv++; + + while (argc >= 1) { + if (strcmp(*argv, "-server_auth") == 0) + server_auth = 1; + else if (strcmp(*argv, "-client_auth") == 0) + client_auth = 1; + else if (strcmp(*argv, "-reconnect") == 0) + reconnect = 1; + else if (strcmp(*argv, "-stats") == 0) + cache_stats = 1; + else if (strcmp(*argv, "-ssl3") == 0) + ssl_method = SSLv3_method(); + else if (strcmp(*argv, "-CApath") == 0) { + if (--argc < 1) + goto bad; + CApath = *(++argv); + } else if (strcmp(*argv, "-CAfile") == 0) { + if (--argc < 1) + goto bad; + CAfile = *(++argv); + } else if (strcmp(*argv, "-cert") == 0) { + if (--argc < 1) + goto bad; + scert = *(++argv); + } else if (strcmp(*argv, "-ccert") == 0) { + if (--argc < 1) + goto bad; + ccert = *(++argv); + } else if (strcmp(*argv, "-threads") == 0) { + if (--argc < 1) + goto bad; + thread_number = atoi(*(++argv)); + if (thread_number == 0) + thread_number = 1; + if (thread_number > MAX_THREAD_NUMBER) + thread_number = MAX_THREAD_NUMBER; + } else if (strcmp(*argv, "-loops") == 0) { + if (--argc < 1) + goto bad; + number_of_loops = atoi(*(++argv)); + if (number_of_loops == 0) + number_of_loops = 1; + } else { + BIO_printf(bio_err, "unknown option %s\n", *argv); + badop = 1; + break; + } + argc--; + argv++; + } + if (badop) { + bad: + sv_usage(); + goto end; + } + + if (cipher == NULL && OPENSSL_issetugid() == 0) + cipher = getenv("SSL_CIPHER"); + + SSL_load_error_strings(); + OpenSSL_add_ssl_algorithms(); + + c_ctx = SSL_CTX_new(ssl_method); + s_ctx = SSL_CTX_new(ssl_method); + if ((c_ctx == NULL) || (s_ctx == NULL)) { + ERR_print_errors(bio_err); + goto end; + } + + SSL_CTX_set_session_cache_mode(s_ctx, + SSL_SESS_CACHE_NO_AUTO_CLEAR | + SSL_SESS_CACHE_SERVER); + SSL_CTX_set_session_cache_mode(c_ctx, + SSL_SESS_CACHE_NO_AUTO_CLEAR | + SSL_SESS_CACHE_SERVER); + + if (!SSL_CTX_use_certificate_file(s_ctx, scert, SSL_FILETYPE_PEM)) { + BIO_printf(bio_err, "SSL_CTX_use_certificate_file (%s)\n", scert); + ERR_print_errors(bio_err); + goto end; + } else + if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx, scert, SSL_FILETYPE_PEM)) { + BIO_printf(bio_err, "SSL_CTX_use_RSAPrivateKey_file (%s)\n", scert); + ERR_print_errors(bio_err); + goto end; + } + + if (client_auth) { + SSL_CTX_use_certificate_file(c_ctx, ccert, SSL_FILETYPE_PEM); + SSL_CTX_use_RSAPrivateKey_file(c_ctx, ccert, SSL_FILETYPE_PEM); + } + + if ((!SSL_CTX_load_verify_locations(s_ctx, CAfile, CApath)) || + (!SSL_CTX_set_default_verify_paths(s_ctx)) || + (!SSL_CTX_load_verify_locations(c_ctx, CAfile, CApath)) || + (!SSL_CTX_set_default_verify_paths(c_ctx))) { + BIO_printf(bio_err, "SSL_load_verify_locations\n"); + ERR_print_errors(bio_err); + goto end; + } + + if (client_auth) { + BIO_printf(bio_err, "client authentication\n"); + SSL_CTX_set_verify(s_ctx, + SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + verify_callback); + } + if (server_auth) { + BIO_printf(bio_err, "server authentication\n"); + SSL_CTX_set_verify(c_ctx, SSL_VERIFY_PEER, verify_callback); + } + + thread_setup(); + do_threads(s_ctx, c_ctx); + thread_cleanup(); + end: + + if (c_ctx != NULL) { + BIO_printf(bio_err, "Client SSL_CTX stats then free it\n"); + print_stats(bio_err, c_ctx); + SSL_CTX_free(c_ctx); + } + if (s_ctx != NULL) { + BIO_printf(bio_err, "Server SSL_CTX stats then free it\n"); + print_stats(bio_err, s_ctx); + if (cache_stats) { + BIO_printf(bio_err, "-----\n"); + lh_SSL_SESSION_stats_bio(SSL_CTX_sessions(s_ctx), bio_err); + BIO_printf(bio_err, "-----\n"); + /*- lh_SSL_SESSION_node_stats_bio(SSL_CTX_sessions(s_ctx),bio_err); + BIO_printf(bio_err,"-----\n"); */ + lh_SSL_SESSION_node_usage_stats_bio(SSL_CTX_sessions(s_ctx), bio_err); + BIO_printf(bio_err, "-----\n"); + } + SSL_CTX_free(s_ctx); + BIO_printf(bio_err, "done free\n"); + } + exit(ret); + return (0); +} + +#define W_READ 1 +#define W_WRITE 2 +#define C_DONE 1 +#define S_DONE 2 + +int ndoit(SSL_CTX *ssl_ctx[2]) +{ + int i; + int ret; + char *ctx[4]; + CRYPTO_THREADID thread_id; + + ctx[0] = (char *)ssl_ctx[0]; + ctx[1] = (char *)ssl_ctx[1]; + + if (reconnect) { + ctx[2] = (char *)SSL_new(ssl_ctx[0]); + ctx[3] = (char *)SSL_new(ssl_ctx[1]); + } else { + ctx[2] = NULL; + ctx[3] = NULL; + } + + CRYPTO_THREADID_current(&thread_id); + BIO_printf(bio_stdout, "started thread %lu\n", + CRYPTO_THREADID_hash(&thread_id)); + for (i = 0; i < number_of_loops; i++) { +/*- BIO_printf(bio_err,"%4d %2d ctx->ref (%3d,%3d)\n", + CRYPTO_THREADID_hash(&thread_id),i, + ssl_ctx[0]->references, + ssl_ctx[1]->references); */ +/* pthread_delay_np(&tm); */ + + ret = doit(ctx); + if (ret != 0) { + BIO_printf(bio_stdout, "error[%d] %lu - %d\n", + i, CRYPTO_THREADID_hash(&thread_id), ret); + return (ret); + } + } + BIO_printf(bio_stdout, "DONE %lu\n", CRYPTO_THREADID_hash(&thread_id)); + if (reconnect) { + SSL_free((SSL *)ctx[2]); + SSL_free((SSL *)ctx[3]); + } + return (0); +} + +int doit(char *ctx[4]) +{ + SSL_CTX *s_ctx, *c_ctx; + static char cbuf[200], sbuf[200]; + SSL *c_ssl = NULL; + SSL *s_ssl = NULL; + BIO *c_to_s = NULL; + BIO *s_to_c = NULL; + BIO *c_bio = NULL; + BIO *s_bio = NULL; + int c_r, c_w, s_r, s_w; + int c_want, s_want; + int i; + int done = 0; + int c_write, s_write; + int do_server = 0, do_client = 0; + + s_ctx = (SSL_CTX *)ctx[0]; + c_ctx = (SSL_CTX *)ctx[1]; + + if (ctx[2] != NULL) + s_ssl = (SSL *)ctx[2]; + else + s_ssl = SSL_new(s_ctx); + + if (ctx[3] != NULL) + c_ssl = (SSL *)ctx[3]; + else + c_ssl = SSL_new(c_ctx); + + if ((s_ssl == NULL) || (c_ssl == NULL)) + goto err; + + c_to_s = BIO_new(BIO_s_mem()); + s_to_c = BIO_new(BIO_s_mem()); + if ((s_to_c == NULL) || (c_to_s == NULL)) + goto err; + + c_bio = BIO_new(BIO_f_ssl()); + s_bio = BIO_new(BIO_f_ssl()); + if ((c_bio == NULL) || (s_bio == NULL)) + goto err; + + SSL_set_connect_state(c_ssl); + SSL_set_bio(c_ssl, s_to_c, c_to_s); + BIO_set_ssl(c_bio, c_ssl, (ctx[2] == NULL) ? BIO_CLOSE : BIO_NOCLOSE); + + SSL_set_accept_state(s_ssl); + SSL_set_bio(s_ssl, c_to_s, s_to_c); + BIO_set_ssl(s_bio, s_ssl, (ctx[3] == NULL) ? BIO_CLOSE : BIO_NOCLOSE); + + c_r = 0; + s_r = 1; + c_w = 1; + s_w = 0; + c_want = W_WRITE; + s_want = 0; + c_write = 1, s_write = 0; + + /* We can always do writes */ + for (;;) { + do_server = 0; + do_client = 0; + + i = (int)BIO_pending(s_bio); + if ((i && s_r) || s_w) + do_server = 1; + + i = (int)BIO_pending(c_bio); + if ((i && c_r) || c_w) + do_client = 1; + + if (do_server && verbose) { + if (SSL_in_init(s_ssl)) + BIO_printf(bio_stdout, "server waiting in SSL_accept - %s\n", + SSL_state_string_long(s_ssl)); + else if (s_write) + BIO_printf(bio_stdout, "server:SSL_write()\n"); + else + BIO_printf(bio_stdout, "server:SSL_read()\n"); + } + + if (do_client && verbose) { + if (SSL_in_init(c_ssl)) + BIO_printf(bio_stdout, "client waiting in SSL_connect - %s\n", + SSL_state_string_long(c_ssl)); + else if (c_write) + BIO_printf(bio_stdout, "client:SSL_write()\n"); + else + BIO_printf(bio_stdout, "client:SSL_read()\n"); + } + + if (!do_client && !do_server) { + BIO_printf(bio_stdout, "ERROR IN STARTUP\n"); + break; + } + if (do_client && !(done & C_DONE)) { + if (c_write) { + i = BIO_write(c_bio, "hello from client\n", 18); + if (i < 0) { + c_r = 0; + c_w = 0; + if (BIO_should_retry(c_bio)) { + if (BIO_should_read(c_bio)) + c_r = 1; + if (BIO_should_write(c_bio)) + c_w = 1; + } else { + BIO_printf(bio_err, "ERROR in CLIENT\n"); + ERR_print_errors_fp(stderr); + return (1); + } + } else if (i == 0) { + BIO_printf(bio_err, "SSL CLIENT STARTUP FAILED\n"); + return (1); + } else { + /* ok */ + c_write = 0; + } + } else { + i = BIO_read(c_bio, cbuf, 100); + if (i < 0) { + c_r = 0; + c_w = 0; + if (BIO_should_retry(c_bio)) { + if (BIO_should_read(c_bio)) + c_r = 1; + if (BIO_should_write(c_bio)) + c_w = 1; + } else { + BIO_printf(bio_err, "ERROR in CLIENT\n"); + ERR_print_errors_fp(stderr); + return (1); + } + } else if (i == 0) { + BIO_printf(bio_err, "SSL CLIENT STARTUP FAILED\n"); + return (1); + } else { + done |= C_DONE; + } + } + } + + if (do_server && !(done & S_DONE)) { + if (!s_write) { + i = BIO_read(s_bio, sbuf, 100); + if (i < 0) { + s_r = 0; + s_w = 0; + if (BIO_should_retry(s_bio)) { + if (BIO_should_read(s_bio)) + s_r = 1; + if (BIO_should_write(s_bio)) + s_w = 1; + } else { + BIO_printf(bio_err, "ERROR in SERVER\n"); + ERR_print_errors_fp(stderr); + return (1); + } + } else if (i == 0) { + BIO_printf(bio_err, "SSL SERVER STARTUP FAILED\n"); + return (1); + } else { + s_write = 1; + s_w = 1; + } + } else { + i = BIO_write(s_bio, "hello from server\n", 18); + if (i < 0) { + s_r = 0; + s_w = 0; + if (BIO_should_retry(s_bio)) { + if (BIO_should_read(s_bio)) + s_r = 1; + if (BIO_should_write(s_bio)) + s_w = 1; + } else { + BIO_printf(bio_err, "ERROR in SERVER\n"); + ERR_print_errors_fp(stderr); + return (1); + } + } else if (i == 0) { + BIO_printf(bio_err, "SSL SERVER STARTUP FAILED\n"); + return (1); + } else { + s_write = 0; + s_r = 1; + done |= S_DONE; + } + } + } + + if ((done & S_DONE) && (done & C_DONE)) + break; + } + + SSL_set_shutdown(c_ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); + SSL_set_shutdown(s_ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); + + err: +#if 0 + /* + * We have to set the BIO's to NULL otherwise they will be free()ed + * twice. Once when th s_ssl is SSL_free()ed and again when c_ssl is + * SSL_free()ed. This is a hack required because s_ssl and c_ssl are + * sharing the same BIO structure and SSL_set_bio() and SSL_free() + * automatically BIO_free non NULL entries. You should not normally do + * this or be required to do this + */ + + if (s_ssl != NULL) { + s_ssl->rbio = NULL; + s_ssl->wbio = NULL; + } + if (c_ssl != NULL) { + c_ssl->rbio = NULL; + c_ssl->wbio = NULL; + } + + /* The SSL's are optionally freed in the following calls */ + BIO_free(c_to_s); + BIO_free(s_to_c); +#endif + + BIO_free(c_bio); + BIO_free(s_bio); + return (0); +} + +int verify_callback(int ok, X509_STORE_CTX *ctx) +{ + char *s, buf[256]; + + if (verbose) { + s = X509_NAME_oneline(X509_get_subject_name(ctx->current_cert), + buf, 256); + if (s != NULL) { + if (ok) + BIO_printf(bio_err, "depth=%d %s\n", ctx->error_depth, buf); + else + BIO_printf(bio_err, "depth=%d error=%d %s\n", + ctx->error_depth, ctx->error, buf); + } + } + return (ok); +} + +#define THREAD_STACK_SIZE (16*1024) + +#ifdef OPENSSL_SYS_WIN32 + +static HANDLE *lock_cs; + +void thread_setup(void) +{ + int i; + + lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE)); + for (i = 0; i < CRYPTO_num_locks(); i++) { + lock_cs[i] = CreateMutex(NULL, FALSE, NULL); + } + + CRYPTO_set_locking_callback((void (*)(int, int, char *, int)) + win32_locking_callback); + /* id callback defined */ +} + +void thread_cleanup(void) +{ + int i; + + CRYPTO_set_locking_callback(NULL); + for (i = 0; i < CRYPTO_num_locks(); i++) + CloseHandle(lock_cs[i]); + OPENSSL_free(lock_cs); +} + +void win32_locking_callback(int mode, int type, const char *file, int line) +{ + if (mode & CRYPTO_LOCK) { + WaitForSingleObject(lock_cs[type], INFINITE); + } else { + ReleaseMutex(lock_cs[type]); + } +} + +void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) +{ + double ret; + SSL_CTX *ssl_ctx[2]; + DWORD thread_id[MAX_THREAD_NUMBER]; + HANDLE thread_handle[MAX_THREAD_NUMBER]; + int i; + SYSTEMTIME start, end; + + ssl_ctx[0] = s_ctx; + ssl_ctx[1] = c_ctx; + + GetSystemTime(&start); + for (i = 0; i < thread_number; i++) { + thread_handle[i] = CreateThread(NULL, + THREAD_STACK_SIZE, + (LPTHREAD_START_ROUTINE) ndoit, + (void *)ssl_ctx, 0L, &(thread_id[i])); + } + + BIO_printf(bio_stdout, "reaping\n"); + for (i = 0; i < thread_number; i += 50) { + int j; + + j = (thread_number < (i + 50)) ? (thread_number - i) : 50; + + if (WaitForMultipleObjects(j, + (CONST HANDLE *) & (thread_handle[i]), + TRUE, INFINITE) + == WAIT_FAILED) { + BIO_printf(bio_err, "WaitForMultipleObjects failed:%d\n", + GetLastError()); + exit(1); + } + } + GetSystemTime(&end); + + if (start.wDayOfWeek > end.wDayOfWeek) + end.wDayOfWeek += 7; + ret = (end.wDayOfWeek - start.wDayOfWeek) * 24; + + ret = (ret + end.wHour - start.wHour) * 60; + ret = (ret + end.wMinute - start.wMinute) * 60; + ret = (ret + end.wSecond - start.wSecond); + ret += (end.wMilliseconds - start.wMilliseconds) / 1000.0; + + BIO_printf(bio_stdout, "win32 threads done - %.3f seconds\n", ret); +} + +#endif /* OPENSSL_SYS_WIN32 */ + + +#ifdef PTHREADS + +static pthread_mutex_t *lock_cs; +static long *lock_count; + +void thread_setup(void) +{ + int i; + + lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); + lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); + for (i = 0; i < CRYPTO_num_locks(); i++) { + lock_count[i] = 0; + pthread_mutex_init(&(lock_cs[i]), NULL); + } + + CRYPTO_THREADID_set_callback(pthreads_thread_id); + CRYPTO_set_locking_callback(pthreads_locking_callback); +} + +void thread_cleanup(void) +{ + int i; + + CRYPTO_set_locking_callback(NULL); + BIO_printf(bio_err, "cleanup\n"); + for (i = 0; i < CRYPTO_num_locks(); i++) { + pthread_mutex_destroy(&(lock_cs[i])); + BIO_printf(bio_err, "%8ld:%s\n", lock_count[i], CRYPTO_get_lock_name(i)); + } + OPENSSL_free(lock_cs); + OPENSSL_free(lock_count); + + BIO_printf(bio_err, "done cleanup\n"); +} + +void pthreads_locking_callback(int mode, int type, const char *file, int line) +{ + if (mode & CRYPTO_LOCK) { + pthread_mutex_lock(&(lock_cs[type])); + lock_count[type]++; + } else { + pthread_mutex_unlock(&(lock_cs[type])); + } +} + +void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) +{ + SSL_CTX *ssl_ctx[2]; + pthread_t thread_ctx[MAX_THREAD_NUMBER]; + int i; + + ssl_ctx[0] = s_ctx; + ssl_ctx[1] = c_ctx; + + for (i = 0; i < thread_number; i++) { + pthread_create(&(thread_ctx[i]), NULL, + (void *(*)())ndoit, (void *)ssl_ctx); + } + + BIO_printf(bio_stdout, "reaping\n"); + for (i = 0; i < thread_number; i++) { + pthread_join(thread_ctx[i], NULL); + } + +#if 0 /* We can't currently find out the reference amount */ + BIO_printf(bio_stdout, "pthreads threads done (%d,%d)\n", + s_ctx->references, c_ctx->references); +#else + BIO_printf(bio_stdout, "pthreads threads done\n"); +#endif +} + +void pthreads_thread_id(CRYPTO_THREADID *tid) +{ + CRYPTO_THREADID_set_numeric(tid, (unsigned long)pthread_self()); +} + +#endif /* PTHREADS */ diff --git a/demos/threads/pthread.sh b/demos/threads/pthread.sh new file mode 100644 index 0000000..ec945c4 --- /dev/null +++ b/demos/threads/pthread.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# +# build using pthreads where it's already built into the system +# +/bin/rm -f mttest +gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread -ldl diff --git a/crypto/asn1/a_digest.c b/demos/threads/th-lock.c similarity index 52% copy from crypto/asn1/a_digest.c copy to demos/threads/th-lock.c index 57adccc..dc58cb2 100644 --- a/crypto/asn1/a_digest.c +++ b/demos/threads/th-lock.c @@ -1,4 +1,3 @@ -/* crypto/asn1/a_digest.c */ /* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) * All rights reserved. * @@ -57,55 +56,139 @@ */ #include -#include - -#include "internal/cryptlib.h" - -#ifndef NO_SYS_TYPES_H -# include +#include +#include +#include +#ifdef LINUX +# include #endif - -#include -#include +#ifdef OPENSSL_SYS_WIN32 +# include +#endif +#ifdef PTHREADS +# include +#endif +#include +#include #include +#include "../../e_os.h" #include +#include +#include + +void CRYPTO_thread_setup(void); +void CRYPTO_thread_cleanup(void); + +static void win32_locking_callback(int mode, int type, char *file, int line); +static void pthreads_locking_callback(int mode, int type, char *file, int line); +static unsigned long pthreads_thread_id(void); + +/*- + * usage: + * CRYPTO_thread_setup(); + * application code + * CRYPTO_thread_cleanup(); + */ -#ifndef NO_ASN1_OLD +#ifdef OPENSSL_SYS_WIN32 -int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, - unsigned char *md, unsigned int *len) +static HANDLE *lock_cs; + +void CRYPTO_thread_setup(void) { int i; - unsigned char *str, *p; - i = i2d(data, NULL); - if ((str = OPENSSL_malloc(i)) == NULL) { - ASN1err(ASN1_F_ASN1_DIGEST, ERR_R_MALLOC_FAILURE); - return (0); + lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE)); + if (!lock_cs) { + /* Nothing we can do about this...void function! */ + return; + } + for (i = 0; i < CRYPTO_num_locks(); i++) { + lock_cs[i] = CreateMutex(NULL, FALSE, NULL); } - p = str; - i2d(data, &p); - if (!EVP_Digest(str, i, md, len, type, NULL)) - return 0; - OPENSSL_free(str); + CRYPTO_set_locking_callback((void (*)(int, int, char *, int)) + win32_locking_callback); + /* id callback defined */ return (1); } -#endif +static void CRYPTO_thread_cleanup(void) +{ + int i; -int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *asn, - unsigned char *md, unsigned int *len) + CRYPTO_set_locking_callback(NULL); + for (i = 0; i < CRYPTO_num_locks(); i++) + CloseHandle(lock_cs[i]); + OPENSSL_free(lock_cs); +} + +void win32_locking_callback(int mode, int type, char *file, int line) +{ + if (mode & CRYPTO_LOCK) { + WaitForSingleObject(lock_cs[type], INFINITE); + } else { + ReleaseMutex(lock_cs[type]); + } +} + +#endif /* OPENSSL_SYS_WIN32 */ + +/* Linux and a few others */ +#ifdef PTHREADS + +static pthread_mutex_t *lock_cs; +static long *lock_count; + +void CRYPTO_thread_setup(void) { int i; - unsigned char *str = NULL; - i = ASN1_item_i2d(asn, &str, it); - if (!str) - return (0); + lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); + lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); + if (!lock_cs || !lock_count) { + /* Nothing we can do about this...void function! */ + OPENSSL_free(lock_cs); + OPENSSL_free(lock_count); + return; + } + for (i = 0; i < CRYPTO_num_locks(); i++) { + lock_count[i] = 0; + pthread_mutex_init(&(lock_cs[i]), NULL); + } - if (!EVP_Digest(str, i, md, len, type, NULL)) - return 0; - OPENSSL_free(str); - return (1); + CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id); + CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback); } + +void thread_cleanup(void) +{ + int i; + + CRYPTO_set_locking_callback(NULL); + for (i = 0; i < CRYPTO_num_locks(); i++) { + pthread_mutex_destroy(&(lock_cs[i])); + } + OPENSSL_free(lock_cs); + OPENSSL_free(lock_count); +} + +void pthreads_locking_callback(int mode, int type, char *file, int line) +{ + if (mode & CRYPTO_LOCK) { + pthread_mutex_lock(&(lock_cs[type])); + lock_count[type]++; + } else { + pthread_mutex_unlock(&(lock_cs[type])); + } +} + +unsigned long pthreads_thread_id(void) +{ + unsigned long ret; + + ret = (unsigned long)pthread_self(); + return (ret); +} + +#endif /* PTHREADS */ diff --git a/demos/threads/win32.bat b/demos/threads/win32.bat new file mode 100644 index 0000000..ee6da80 --- /dev/null +++ b/demos/threads/win32.bat @@ -0,0 +1,4 @@ +del mttest.exe + +cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssleay32.lib ..\..\out\libeay32.lib + From rsalz at openssl.org Tue Oct 27 20:08:13 2015 From: rsalz at openssl.org (Rich Salz) Date: Tue, 27 Oct 2015 20:08:13 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1445976493.955134.2309.nullmailer@dev.openssl.org> The branch master has been updated via 6f5c03032080aa35e2ad5765b7243b8c75305611 (commit) from 0e56b4b42439d0842956a6730dec904ed70bbef7 (commit) - Log ----------------------------------------------------------------- commit 6f5c03032080aa35e2ad5765b7243b8c75305611 Author: Rich Salz Date: Tue Oct 27 15:44:15 2015 -0400 Remove HAMC_cleanup Old API for use with OpenSSL-0.9.6. Remove it. Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: doc/crypto/hmac.pod | 7 +------ include/openssl/hmac.h | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/doc/crypto/hmac.pod b/doc/crypto/hmac.pod index 372a0f4..88f5abc 100644 --- a/doc/crypto/hmac.pod +++ b/doc/crypto/hmac.pod @@ -2,8 +2,7 @@ =head1 NAME -HMAC, HMAC_CTX_init, HMAC_Init, HMAC_Init_ex, HMAC_Update, HMAC_Final, HMAC_CTX_cleanup, -HMAC_cleanup - HMAC message authentication code +HMAC, HMAC_CTX_init, HMAC_Init, HMAC_Init_ex, HMAC_Update, HMAC_Final, HMAC_CTX_cleanup - HMAC message authentication code =head1 SYNOPSIS @@ -23,7 +22,6 @@ HMAC_cleanup - HMAC message authentication code int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); void HMAC_CTX_cleanup(HMAC_CTX *ctx); - void HMAC_cleanup(HMAC_CTX *ctx); =head1 DESCRIPTION @@ -49,9 +47,6 @@ HMAC_CTX_cleanup() erases the key and other data from the B and releases any associated resources. It must be called when an B is no longer required. -HMAC_cleanup() is an alias for HMAC_CTX_cleanup() included for back -compatibility with 0.9.6b, it is deprecated. - The following functions may be used if the message is not completely stored in memory: diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h index 81aa49d..011e2ae 100644 --- a/include/openssl/hmac.h +++ b/include/openssl/hmac.h @@ -83,8 +83,6 @@ void HMAC_CTX_init(HMAC_CTX *ctx); void HMAC_CTX_cleanup(HMAC_CTX *ctx); #ifdef OPENSSL_USE_DEPRECATED -/* deprecated */ -# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ DECLARE_DEPRECATED(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, From rsalz at openssl.org Wed Oct 28 15:32:25 2015 From: rsalz at openssl.org (Rich Salz) Date: Wed, 28 Oct 2015 15:32:25 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1446046345.356841.16238.nullmailer@dev.openssl.org> The branch master has been updated via 304acb9ffcf84803ae4069b93922d2e03830b8d6 (commit) from b18bb5d816a762968429b29d6787728aa4afb6f1 (commit) - Log ----------------------------------------------------------------- commit 304acb9ffcf84803ae4069b93922d2e03830b8d6 Author: Rich Salz Date: Wed Oct 28 11:32:21 2015 -0400 Add GitHub URL ----------------------------------------------------------------------- Summary of changes: source/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/index.html b/source/index.html index e8eb2f6..47e7a7d 100644 --- a/source/index.html +++ b/source/index.html @@ -13,7 +13,9 @@

Our development is maintained in a git repository, which is - accessible over the network and cloned on GitHub. + accessible over the network and cloned on GitHub, + at https://github.com/openssl/openssl. Please familiarize yourself with the license.

From rsalz at openssl.org Wed Oct 28 18:15:10 2015 From: rsalz at openssl.org (Rich Salz) Date: Wed, 28 Oct 2015 18:15:10 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1446056110.309453.17598.nullmailer@dev.openssl.org> The branch master has been updated via 3a08552ec30c8cb318ad32afd219c41c1314038d (commit) from 304acb9ffcf84803ae4069b93922d2e03830b8d6 (commit) - Log ----------------------------------------------------------------- commit 3a08552ec30c8cb318ad32afd219c41c1314038d Author: Rich Salz Date: Wed Oct 28 14:15:02 2015 -0400 add conduct; after vote. ----------------------------------------------------------------------- Summary of changes: community/conduct.html | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 community/conduct.html diff --git a/community/conduct.html b/community/conduct.html new file mode 100644 index 0000000..9b8c2d0 --- /dev/null +++ b/community/conduct.html @@ -0,0 +1,52 @@ + + + + + + + +
+
+
+
+

Code of Conduct

+
+ + +

The OpenSSL community consists primarily, although not solely, of + its online presence in mailing lists and activities such as the blog + postings and comments, the GitHub repository, and so on. These + outlets are managed by the OpenSSL development team, whose members + are listed here: + https://www.openssl.org/community/team.html +

+ +

We strive to be an open and inclusive community where anyone can + contribute. Contributions should be judged on their own merits; we + don't care about your gender identity, race, political beliefs, age, + or similar attributes.

+ +

If we see that one or more members of the community are generally + abusive, harassing others, or seem to be trying to intimidate them + into leaving the community, we will first ask those who are doing so + to take a break from participation for a while. If you see any + evidence of such activity, please let us know by sending email to + conduct at openssl.org.

+
+ +
+
+ +
+
+ + + + + + From rsalz at openssl.org Wed Oct 28 18:17:27 2015 From: rsalz at openssl.org (Rich Salz) Date: Wed, 28 Oct 2015 18:17:27 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1446056247.674598.18543.nullmailer@dev.openssl.org> The branch master has been updated via 98dd590bb12c298a62e39a175b2b66511c3fb9bd (commit) from 3a08552ec30c8cb318ad32afd219c41c1314038d (commit) - Log ----------------------------------------------------------------- commit 98dd590bb12c298a62e39a175b2b66511c3fb9bd Author: Rich Salz Date: Wed Oct 28 14:17:16 2015 -0400 Add code of conduct reference. ----------------------------------------------------------------------- Summary of changes: community/index.html | 4 +++- community/sidebar.inc | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/community/index.html b/community/index.html index 498cfb9..5202e92 100644 --- a/community/index.html +++ b/community/index.html @@ -13,7 +13,9 @@

OpenSSL is a a collaborative effort of a worldwide community of - volunteers. Here are some of the ways you can join the + volunteers that has a code of conduct. +

+

Here are some of the ways you can join the community and contribute. The list of development team members is available, as is a description of how to diff --git a/community/sidebar.inc b/community/sidebar.inc index f975066..0990933 100644 --- a/community/sidebar.inc +++ b/community/sidebar.inc @@ -4,6 +4,9 @@

Community

  • + Code of Conduct +
  • +
  • Team
  • From rsalz at openssl.org Wed Oct 28 21:24:13 2015 From: rsalz at openssl.org (Rich Salz) Date: Wed, 28 Oct 2015 21:24:13 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1446067453.892685.30924.nullmailer@dev.openssl.org> The branch master has been updated via a528d4f0a9a71405f3ca06e20cbd27aa1b8c0df9 (commit) from 6f5c03032080aa35e2ad5765b7243b8c75305611 (commit) - Log ----------------------------------------------------------------- commit a528d4f0a9a71405f3ca06e20cbd27aa1b8c0df9 Author: Rich Salz Date: Tue Oct 27 13:40:11 2015 -0400 Remove SSLeay history, etc., from docs If something was "present in all versions" of SSLeay, or if it was added to a version of SSLeay (and therefore predates OpenSSL), remove mention of it. Documentation history now starts with OpenSSL. Remove mention of all history before OpenSSL 0.9.8, inclusive. Remove all AUTHOR sections. Reviewed-by: Tim Hudson ----------------------------------------------------------------------- Summary of changes: doc/apps/ciphers.pod | 6 +- doc/apps/config.pod | 4 +- doc/apps/dhparam.pod | 5 -- doc/apps/ec.pod | 8 -- doc/apps/ecparam.pod | 8 -- doc/apps/genpkey.pod | 12 ++- doc/apps/openssl.pod | 3 - doc/apps/pkcs12.pod | 24 ------ doc/apps/ts.pod | 4 - doc/apps/tsget.pod | 4 - doc/apps/verify.pod | 5 +- doc/apps/version.pod | 4 - doc/apps/x509.pod | 7 -- doc/apps/x509v3_config.pod | 10 --- doc/crypto/ASN1_OBJECT_new.pod | 4 - doc/crypto/ASN1_generate_nconf.pod | 4 - doc/crypto/BIO_f_md.pod | 13 +++- doc/crypto/BIO_f_ssl.pod | 2 +- doc/crypto/BIO_find_type.pod | 13 ---- doc/crypto/BN_BLINDING_new.pod | 12 +-- doc/crypto/BN_CTX_new.pod | 4 +- doc/crypto/BN_CTX_start.pod | 4 - doc/crypto/BN_add.pod | 9 --- doc/crypto/BN_add_word.pod | 9 --- doc/crypto/BN_bn2bin.pod | 8 -- doc/crypto/BN_cmp.pod | 6 -- doc/crypto/BN_copy.pod | 4 - doc/crypto/BN_generate_prime.pod | 7 +- doc/crypto/BN_mod_inverse.pod | 4 - doc/crypto/BN_mod_mul_montgomery.pod | 7 +- doc/crypto/BN_mod_mul_reciprocal.pod | 4 +- doc/crypto/BN_new.pod | 4 +- doc/crypto/BN_num_bytes.pod | 5 -- doc/crypto/BN_rand.pod | 7 -- doc/crypto/BN_set_bit.pod | 6 -- doc/crypto/BN_swap.pod | 4 - doc/crypto/BN_zero.pod | 9 --- doc/crypto/CMS_add0_cert.pod | 5 -- doc/crypto/CMS_add1_recipient_cert.pod | 5 -- doc/crypto/CMS_add1_signer.pod | 4 - doc/crypto/CMS_compress.pod | 3 +- doc/crypto/CMS_decrypt.pod | 4 - doc/crypto/CMS_encrypt.pod | 1 - doc/crypto/CMS_final.pod | 4 - doc/crypto/CMS_get0_RecipientInfos.pod | 4 - doc/crypto/CMS_get0_SignerInfos.pod | 4 - doc/crypto/CMS_get0_type.pod | 5 -- doc/crypto/CMS_get1_ReceiptRequest.pod | 6 -- doc/crypto/CMS_sign.pod | 2 - doc/crypto/CMS_sign_receipt.pod | 4 - doc/crypto/CMS_uncompress.pod | 4 - doc/crypto/CMS_verify.pod | 4 - doc/crypto/CMS_verify_receipt.pod | 4 - doc/crypto/CONF_modules_free.pod | 5 -- doc/crypto/CONF_modules_load_file.pod | 4 - doc/crypto/CRYPTO_set_ex_data.pod | 4 - doc/crypto/DH_generate_key.pod | 5 -- doc/crypto/DH_generate_parameters.pod | 8 -- doc/crypto/DH_get_ex_new_index.pod | 5 -- doc/crypto/DH_new.pod | 4 - doc/crypto/DH_set_method.pod | 25 ------ doc/crypto/DH_size.pod | 1 - doc/crypto/DSA_SIG_new.pod | 4 - doc/crypto/DSA_do_sign.pod | 4 - doc/crypto/DSA_dup_DH.pod | 4 - doc/crypto/DSA_generate_key.pod | 4 - doc/crypto/DSA_generate_parameters.pod | 9 --- doc/crypto/DSA_get_ex_new_index.pod | 5 -- doc/crypto/DSA_new.pod | 4 - doc/crypto/DSA_set_method.pod | 25 ------ doc/crypto/DSA_sign.pod | 5 -- doc/crypto/DSA_size.pod | 4 - doc/crypto/ERR_GET_LIB.pod | 2 +- doc/crypto/ERR_clear_error.pod | 4 - doc/crypto/ERR_error_string.pod | 5 -- doc/crypto/ERR_get_error.pod | 9 --- doc/crypto/ERR_load_crypto_strings.pod | 6 -- doc/crypto/ERR_load_strings.pod | 6 -- doc/crypto/ERR_print_errors.pod | 5 -- doc/crypto/ERR_put_error.pod | 5 -- doc/crypto/ERR_remove_state.pod | 4 +- doc/crypto/ERR_set_mark.pod | 4 - doc/crypto/EVP_DigestInit.pod | 16 +--- doc/crypto/EVP_EncryptInit.pod | 9 +-- doc/crypto/EVP_PKEY_CTX_ctrl.pod | 6 +- doc/crypto/EVP_SealInit.pod | 4 - doc/crypto/EVP_SignInit.pod | 7 -- doc/crypto/EVP_VerifyInit.pod | 7 -- doc/crypto/OPENSSL_VERSION_NUMBER.pod | 31 +++----- doc/crypto/OPENSSL_config.pod | 8 +- doc/crypto/OPENSSL_load_builtin_modules.pod | 4 - doc/crypto/PKCS12_create.pod | 9 --- doc/crypto/PKCS12_parse.pod | 4 - doc/crypto/PKCS7_decrypt.pod | 4 - doc/crypto/PKCS7_encrypt.pod | 3 +- doc/crypto/PKCS7_sign.pod | 9 +-- doc/crypto/PKCS7_verify.pod | 4 - doc/crypto/RAND_add.pod | 6 -- doc/crypto/RAND_bytes.pod | 6 -- doc/crypto/RAND_cleanup.pod | 4 - doc/crypto/RAND_egd.pod | 10 --- doc/crypto/RAND_load_file.pod | 7 +- doc/crypto/RAND_set_rand_method.pod | 13 +--- doc/crypto/RSA_blinding_on.pod | 4 - doc/crypto/RSA_check_key.pod | 1 - doc/crypto/RSA_generate_key.pod | 4 - doc/crypto/RSA_get_ex_new_index.pod | 5 -- doc/crypto/RSA_new.pod | 4 - doc/crypto/RSA_padding_add_PKCS1_type_1.pod | 11 --- doc/crypto/RSA_print.pod | 6 -- doc/crypto/RSA_private_encrypt.pod | 5 -- doc/crypto/RSA_public_encrypt.pod | 5 -- doc/crypto/RSA_set_method.pod | 28 ------- doc/crypto/RSA_sign.pod | 10 --- doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod | 5 -- doc/crypto/RSA_size.pod | 1 - doc/crypto/SMIME_read_CMS.pod | 4 - doc/crypto/SMIME_read_PKCS7.pod | 4 - doc/crypto/SMIME_write_CMS.pod | 4 - doc/crypto/SMIME_write_PKCS7.pod | 4 - doc/crypto/SSLeay_version.pod | 4 - doc/crypto/X509_STORE_CTX_get_ex_new_index.pod | 5 -- doc/crypto/X509_STORE_CTX_set_verify_cb.pod | 5 -- doc/crypto/X509_STORE_set_verify_cb_func.pod | 3 - doc/crypto/X509_get_subject_name.pod | 4 - doc/crypto/X509_get_version.pod | 4 - doc/crypto/X509_new.pod | 4 - doc/crypto/X509_verify_cert.pod | 4 - doc/crypto/buffer.pod | 6 +- doc/crypto/d2i_CMS_ContentInfo.pod | 4 - doc/crypto/d2i_X509.pod | 45 +---------- doc/crypto/des.pod | 5 -- doc/crypto/ecdsa.pod | 8 -- doc/crypto/engine.pod | 10 --- doc/crypto/hmac.pod | 6 -- doc/crypto/lh_stats.pod | 6 -- doc/crypto/lhash.pod | 58 +------------- doc/crypto/rand.pod | 104 +------------------------ doc/crypto/rc4.pod | 4 - doc/crypto/rsa.pod | 2 +- doc/crypto/threads.pod | 4 - doc/crypto/ui.pod | 9 --- doc/ssl/DTLSv1_listen.pod | 3 +- doc/ssl/SSL_CTX_set_cert_verify_callback.pod | 8 -- doc/ssl/SSL_CTX_set_generate_session_id.pod | 6 -- doc/ssl/SSL_CTX_set_max_cert_list.pod | 4 - doc/ssl/SSL_CTX_set_mode.pod | 4 - doc/ssl/SSL_CTX_set_msg_callback.pod | 5 -- doc/ssl/SSL_CTX_set_options.pod | 43 +--------- doc/ssl/SSL_CTX_set_session_cache_mode.pod | 5 -- doc/ssl/SSL_CTX_set_tlsext_ticket_key_cb.pod | 4 - doc/ssl/SSL_CTX_use_certificate.pod | 6 -- doc/ssl/SSL_get_error.pod | 4 - doc/ssl/SSL_library_init.pod | 6 -- doc/ssl/SSL_pending.pod | 3 - doc/ssl/ssl.pod | 2 - 156 files changed, 68 insertions(+), 1110 deletions(-) diff --git a/doc/apps/ciphers.pod b/doc/apps/ciphers.pod index 7598276..389b07c 100644 --- a/doc/apps/ciphers.pod +++ b/doc/apps/ciphers.pod @@ -162,9 +162,7 @@ export encryption algorithms. Including 40 and 56 bits algorithms. =item B -56 bit export encryption algorithms. In OpenSSL 0.9.8c and later the set of -56 bit export ciphers is empty unless OpenSSL has been explicitly configured -with support for experimental ciphers. +56 bit export encryption algorithms. This list is empty. =item B, B @@ -726,8 +724,6 @@ L, L, L =head1 HISTORY -The B and B selection options -for cipherlist strings were added in OpenSSL 0.9.7. The B<-V> option for the B command was added in OpenSSL 1.0.0. =cut diff --git a/doc/apps/config.pod b/doc/apps/config.pod index 22bb6c5..e238e15 100644 --- a/doc/apps/config.pod +++ b/doc/apps/config.pod @@ -56,7 +56,7 @@ the sequences B<\n>, B<\r>, B<\b> and B<\t> are recognized. =head1 OPENSSL LIBRARY CONFIGURATION -In OpenSSL 0.9.7 and later applications can automatically configure certain +Applications can automatically configure certain aspects of OpenSSL using the master OpenSSL configuration file, or optionally an alternative configuration file. The B utility includes this functionality: any sub command uses the master OpenSSL configuration file @@ -106,7 +106,7 @@ as any compliant applications. For example: some_new_oid = 1.2.3.4 some_other_oid = 1.2.3.5 -In OpenSSL 0.9.8 it is also possible to set the value to the long name followed +It is also possible to set the value to the long name followed by a comma and the numerical OID form. For example: shortName = some object long name, 1.2.3.4 diff --git a/doc/apps/dhparam.pod b/doc/apps/dhparam.pod index 8bb196d..b0a9802 100644 --- a/doc/apps/dhparam.pod +++ b/doc/apps/dhparam.pod @@ -141,9 +141,4 @@ There should be a way to generate and manipulate DH keys. L -=head1 HISTORY - -The B command was added in OpenSSL 0.9.5. -The B<-dsaparam> option was added in OpenSSL 0.9.6. - =cut diff --git a/doc/apps/ec.pod b/doc/apps/ec.pod index ebc49ea..379d0a8 100644 --- a/doc/apps/ec.pod +++ b/doc/apps/ec.pod @@ -179,12 +179,4 @@ To change the point conversion form to B: L, L, L -=head1 HISTORY - -The ec command was first introduced in OpenSSL 0.9.8. - -=head1 AUTHOR - -Nils Larsch for the OpenSSL project (http://www.openssl.org). - =cut diff --git a/doc/apps/ecparam.pod b/doc/apps/ecparam.pod index bfb155a..56962ab 100644 --- a/doc/apps/ecparam.pod +++ b/doc/apps/ecparam.pod @@ -168,12 +168,4 @@ To print out the EC parameters to standard output: L, L -=head1 HISTORY - -The ecparam command was first introduced in OpenSSL 0.9.8. - -=head1 AUTHOR - -Nils Larsch for the OpenSSL project (http://www.openssl.org) - =cut diff --git a/doc/apps/genpkey.pod b/doc/apps/genpkey.pod index d574caa..dee9722 100644 --- a/doc/apps/genpkey.pod +++ b/doc/apps/genpkey.pod @@ -141,7 +141,7 @@ and 2048 bit group with 256 bit subgroup as mentioned in RFC5114 sections =head1 EC PARAMETER GENERATION OPTIONS -In OpenSSL 1.0.2 and later the EC parameter generation options below can also +The EC parameter generation options below can also be supplied as EC key generation options. This can (for example) generate a key from a named curve without the need to use an explicit parameter file. @@ -149,8 +149,7 @@ key from a named curve without the need to use an explicit parameter file. =item B -the EC curve to use. OpenSSL 1.0.2 and later supports NIST curve names -such as "P-256". +the EC curve to use. OpenSSL supports NIST curve names such as "P-256". =item B @@ -243,11 +242,16 @@ Generate EC key from parameters: openssl genpkey -paramfile ecp.pem -out eckey.pem -Generate EC key directly (OpenSSL 1.0.2+ only): +Generate EC key directly: openssl genpkey -algorithm EC -out eckey.pem \ -pkeyopt ec_paramgen_curve:P-384 \ -pkeyopt ec_param_enc:named_curve +=head1 HISTORY + +The ability to use NIST curve names, and to generate an EC key directly, +were added in OpenSSL 1.0.2. + =cut diff --git a/doc/apps/openssl.pod b/doc/apps/openssl.pod index 30ea9bd..f148404 100644 --- a/doc/apps/openssl.pod +++ b/doc/apps/openssl.pod @@ -412,10 +412,7 @@ L, L, L =head1 HISTORY -The openssl(1) document appeared in OpenSSL 0.9.2. -The BIB<-commands> pseudo-commands were added in OpenSSL 0.9.3; The BIB<-algorithms> pseudo-commands were added in OpenSSL 1.0.0; -the BI pseudo-commands were added in OpenSSL 0.9.5a. For notes on the availability of other commands, see their individual manual pages. diff --git a/doc/apps/pkcs12.pod b/doc/apps/pkcs12.pod index f8162d0..811b822 100644 --- a/doc/apps/pkcs12.pod +++ b/doc/apps/pkcs12.pod @@ -348,30 +348,6 @@ Include some extra certificates: openssl pkcs12 -export -in file.pem -out file.p12 -name "My Certificate" \ -certfile othercerts.pem -=head1 BUGS - -Some would argue that the PKCS#12 standard is one big bug :-) - -Versions of OpenSSL before 0.9.6a had a bug in the PKCS#12 key generation -routines. Under rare circumstances this could produce a PKCS#12 file encrypted -with an invalid key. As a result some PKCS#12 files which triggered this bug -from other implementations (MSIE or Netscape) could not be decrypted -by OpenSSL and similarly OpenSSL could produce PKCS#12 files which could -not be decrypted by other implementations. The chances of producing such -a file are relatively small: less than 1 in 256. - -A side effect of fixing this bug is that any old invalidly encrypted PKCS#12 -files cannot no longer be parsed by the fixed version. Under such circumstances -the B utility will report that the MAC is OK but fail with a decryption -error when extracting private keys. - -This problem can be resolved by extracting the private keys and certificates -from the PKCS#12 file using an older version of OpenSSL and recreating the PKCS#12 -file from the keys and certificates using a newer version of OpenSSL. For example: - - old-openssl -in bad.p12 -out keycerts.pem - openssl -in keycerts.pem -export -name "My PKCS#12 file" -out fixed.p12 - =head1 SEE ALSO L diff --git a/doc/apps/ts.pod b/doc/apps/ts.pod index 7a55b61..e2b555a 100644 --- a/doc/apps/ts.pod +++ b/doc/apps/ts.pod @@ -581,10 +581,6 @@ test/testtsa). =cut -=head1 AUTHOR - -Zoltan Glozik , OpenTSA project (http://www.opentsa.org) - =head1 SEE ALSO L, L, L, diff --git a/doc/apps/tsget.pod b/doc/apps/tsget.pod index 3452c63..34187eb 100644 --- a/doc/apps/tsget.pod +++ b/doc/apps/tsget.pod @@ -182,10 +182,6 @@ example: export TSGET tsget file1.tsq -=head1 AUTHOR - -Zoltan Glozik , OpenTSA project (http://www.opentsa.org) - =head1 SEE ALSO L, L, L, diff --git a/doc/apps/verify.pod b/doc/apps/verify.pod index afd1b95..c935269 100644 --- a/doc/apps/verify.pod +++ b/doc/apps/verify.pod @@ -283,9 +283,8 @@ certificate. If a certificate is found which is its own issuer it is assumed to be the root CA. The process of 'looking up the issuers certificate' itself involves a number -of steps. In versions of OpenSSL before 0.9.5a the first certificate whose -subject name matched the issuer of the current certificate was assumed to be -the issuers certificate. In OpenSSL 0.9.6 and later all certificates +of steps. +Ater all certificates whose subject name matches the issuer name of the current certificate are subject to further tests. The relevant authority key identifier components of the current certificate (if present) must match the subject key identifier diff --git a/doc/apps/version.pod b/doc/apps/version.pod index 58f543b..61a364b 100644 --- a/doc/apps/version.pod +++ b/doc/apps/version.pod @@ -58,8 +58,4 @@ OPENSSLDIR setting. The output of B would typically be used when sending in a bug report. -=head1 HISTORY - -The B<-d> option was added in OpenSSL 0.9.7. - =cut diff --git a/doc/apps/x509.pod b/doc/apps/x509.pod index d479060..1c98e9d 100644 --- a/doc/apps/x509.pod +++ b/doc/apps/x509.pod @@ -869,11 +869,6 @@ be checked. There should be options to explicitly set such things as start and end dates rather than an offset from the current time. -The code to implement the verify behaviour described in the B -is currently being developed. It thus describes the intended behaviour rather -than the current behaviour. It is hoped that it will represent reality in -OpenSSL 0.9.5 and later. - =head1 SEE ALSO L, L, L, @@ -882,8 +877,6 @@ L =head1 HISTORY -Before OpenSSL 0.9.8, the default digest for RSA keys was MD5. - The hash algorithm used in the B<-subject_hash> and B<-issuer_hash> options before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding of the distinguished name. In OpenSSL 1.0.0 and later it is based on a diff --git a/doc/apps/x509v3_config.pod b/doc/apps/x509v3_config.pod index 297cbaa..e965be6 100644 --- a/doc/apps/x509v3_config.pod +++ b/doc/apps/x509v3_config.pod @@ -508,16 +508,6 @@ will only recognize the last value. This can be worked around by using the form: email.1=steve at here email.2=steve at there -=head1 HISTORY - -The X509v3 extension code was first added to OpenSSL 0.9.2. - -Policy mappings, inhibit any policy and name constraints support was added in -OpenSSL 0.9.8 - -The B and B option as well as the B option -for arbitrary extensions was added in OpenSSL 0.9.8 - =head1 SEE ALSO L, L, L, diff --git a/doc/crypto/ASN1_OBJECT_new.pod b/doc/crypto/ASN1_OBJECT_new.pod index 4bdfe02..486ccc9 100644 --- a/doc/crypto/ASN1_OBJECT_new.pod +++ b/doc/crypto/ASN1_OBJECT_new.pod @@ -39,8 +39,4 @@ ASN1_OBJECT_free() returns no value. L, L -=head1 HISTORY - -ASN1_OBJECT_new() and ASN1_OBJECT_free() are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/ASN1_generate_nconf.pod b/doc/crypto/ASN1_generate_nconf.pod index 8c845ac..a95b2c8 100644 --- a/doc/crypto/ASN1_generate_nconf.pod +++ b/doc/crypto/ASN1_generate_nconf.pod @@ -258,8 +258,4 @@ The error codes that can be obtained by L. L -=head1 HISTORY - -ASN1_generate_nconf() and ASN1_generate_v3() were added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/BIO_f_md.pod b/doc/crypto/BIO_f_md.pod index 2cc41f8..d9aec08 100644 --- a/doc/crypto/BIO_f_md.pod +++ b/doc/crypto/BIO_f_md.pod @@ -58,10 +58,8 @@ If an application needs to call BIO_gets() or BIO_puts() through a chain containing digest BIOs then this can be done by prepending a buffering BIO. -Before OpenSSL 1.0.0 the call to BIO_get_md_ctx() would only work if the BIO -had been initialized for example by calling BIO_set_md() ). In OpenSSL -1.0.0 and later the context is always returned and the BIO is state is set -to initialized. This allows applications to initialize the context externally +Calling BIO_get_md_ctx() will return the context and initialize the BIO +state. This allows applications to initialize the context externally if the standard calls such as BIO_set_md() are not sufficiently flexible. =head1 RETURN VALUES @@ -139,6 +137,13 @@ and BIO_puts() should be passed to the next BIO in the chain and digest the data passed through and that digests should be retrieved using a separate BIO_ctrl() call. +=head1 HISTORY + +Before OpenSSL 1.0.0., the call to BIO_get_md_ctx() would only work if the +BIO was initialized first. + =head1 SEE ALSO TBA + +=cut diff --git a/doc/crypto/BIO_f_ssl.pod b/doc/crypto/BIO_f_ssl.pod index 00b29bd..bf3151f 100644 --- a/doc/crypto/BIO_f_ssl.pod +++ b/doc/crypto/BIO_f_ssl.pod @@ -110,7 +110,7 @@ circumstances. Specifically this will happen if a session renegotiation takes place during a BIO_read() operation, one case where this happens is when step up occurs. -In OpenSSL 0.9.6 and later the SSL flag SSL_AUTO_RETRY can be +The SSL flag SSL_AUTO_RETRY can be set to disable this behaviour. That is when this flag is set an SSL BIO using a blocking transport will never request a retry. diff --git a/doc/crypto/BIO_find_type.pod b/doc/crypto/BIO_find_type.pod index 2595200..6e65668 100644 --- a/doc/crypto/BIO_find_type.pod +++ b/doc/crypto/BIO_find_type.pod @@ -63,19 +63,6 @@ BIO_next() returns the next BIO in a chain. BIO_method_type() returns the type of the BIO B. -=head1 NOTES - -BIO_next() was added to OpenSSL 0.9.6 to provide a 'clean' way to traverse a BIO -chain or find multiple matches using BIO_find_type(). Previous versions had to -use: - - next = bio->next_bio; - -=head1 BUGS - -BIO_find_type() in OpenSSL 0.9.5a and earlier could not be safely passed a -NULL pointer for the B argument. - =head1 EXAMPLE Traverse a chain looking for digest BIOs: diff --git a/doc/crypto/BN_BLINDING_new.pod b/doc/crypto/BN_BLINDING_new.pod index 65c6eab..2e575c6 100644 --- a/doc/crypto/BN_BLINDING_new.pod +++ b/doc/crypto/BN_BLINDING_new.pod @@ -102,15 +102,7 @@ L =head1 HISTORY -BN_BLINDING_thread_id was first introduced in OpenSSL 1.0.0, and it -deprecates BN_BLINDING_set_thread_id and BN_BLINDING_get_thread_id. - -BN_BLINDING_convert_ex, BN_BLINDIND_invert_ex, BN_BLINDING_get_thread_id, -BN_BLINDING_set_thread_id, BN_BLINDING_set_flags, BN_BLINDING_get_flags -and BN_BLINDING_create_param were first introduced in OpenSSL 0.9.8 - -=head1 AUTHOR - -Nils Larsch for the OpenSSL project (http://www.openssl.org). +BN_BLINDING_thread_id() was first introduced in OpenSSL 1.0.0, and it +deprecates BN_BLINDING_set_thread_id() and BN_BLINDING_get_thread_id(). =cut diff --git a/doc/crypto/BN_CTX_new.pod b/doc/crypto/BN_CTX_new.pod index 005c9f8..df432c7 100644 --- a/doc/crypto/BN_CTX_new.pod +++ b/doc/crypto/BN_CTX_new.pod @@ -62,8 +62,6 @@ L =head1 HISTORY -BN_CTX_new() and BN_CTX_free() are available in all versions on SSLeay -and OpenSSL. BN_CTX_init() was added in SSLeay 0.9.1b and removed in OpenSSL -1.1.0. +BN_CTX_init() was removed in OpenSSL 1.1.0. =cut diff --git a/doc/crypto/BN_CTX_start.pod b/doc/crypto/BN_CTX_start.pod index 57ddff6..2e23be2 100644 --- a/doc/crypto/BN_CTX_start.pod +++ b/doc/crypto/BN_CTX_start.pod @@ -45,8 +45,4 @@ can be obtained by L. L -=head1 HISTORY - -BN_CTX_start(), BN_CTX_get() and BN_CTX_end() were added in OpenSSL 0.9.5. - =cut diff --git a/doc/crypto/BN_add.pod b/doc/crypto/BN_add.pod index 38eeb3c..942048c 100644 --- a/doc/crypto/BN_add.pod +++ b/doc/crypto/BN_add.pod @@ -114,13 +114,4 @@ The error codes can be obtained by L. L, L, L, L, L -=head1 HISTORY - -BN_add(), BN_sub(), BN_sqr(), BN_div(), BN_mod(), BN_mod_mul(), -BN_mod_exp() and BN_gcd() are available in all versions of SSLeay and -OpenSSL. The I argument to BN_mul() was added in SSLeay -0.9.1b. BN_exp() appeared in SSLeay 0.9.0. -BN_nnmod(), BN_mod_add(), BN_mod_sub(), and BN_mod_sqr() were added in -OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/BN_add_word.pod b/doc/crypto/BN_add_word.pod index 4f472ad..1bbe31b 100644 --- a/doc/crypto/BN_add_word.pod +++ b/doc/crypto/BN_add_word.pod @@ -49,13 +49,4 @@ B<(BN_ULONG)-1> if an error occurred. L, L, L -=head1 HISTORY - -BN_add_word() and BN_mod_word() are available in all versions of -SSLeay and OpenSSL. BN_div_word() was added in SSLeay 0.8, and -BN_sub_word() and BN_mul_word() in SSLeay 0.9.0. - -Before 0.9.8a the return value for BN_div_word() and BN_mod_word() -in case of an error was 0. - =cut diff --git a/doc/crypto/BN_bn2bin.pod b/doc/crypto/BN_bn2bin.pod index dbcd11f..dd1007d 100644 --- a/doc/crypto/BN_bn2bin.pod +++ b/doc/crypto/BN_bn2bin.pod @@ -84,12 +84,4 @@ L, L, L, L, L -=head1 HISTORY - -BN_bn2bin(), BN_bin2bn(), BN_print_fp() and BN_print() are available -in all versions of SSLeay and OpenSSL. - -BN_bn2hex(), BN_bn2dec(), BN_hex2bn(), BN_dec2bn(), BN_bn2mpi() and -BN_mpi2bn() were added in SSLeay 0.9.0. - =cut diff --git a/doc/crypto/BN_cmp.pod b/doc/crypto/BN_cmp.pod index 6a9e341..6c33314 100644 --- a/doc/crypto/BN_cmp.pod +++ b/doc/crypto/BN_cmp.pod @@ -39,10 +39,4 @@ the condition is true, 0 otherwise. L -=head1 HISTORY - -BN_cmp(), BN_ucmp(), BN_is_zero(), BN_is_one() and BN_is_word() are -available in all versions of SSLeay and OpenSSL. -BN_is_odd() was added in SSLeay 0.8. - =cut diff --git a/doc/crypto/BN_copy.pod b/doc/crypto/BN_copy.pod index 834440f..4de9c1a 100644 --- a/doc/crypto/BN_copy.pod +++ b/doc/crypto/BN_copy.pod @@ -27,8 +27,4 @@ by L. L, L -=head1 HISTORY - -BN_copy() and BN_dup() are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/BN_generate_prime.pod b/doc/crypto/BN_generate_prime.pod index 316d12f..90f399d 100644 --- a/doc/crypto/BN_generate_prime.pod +++ b/doc/crypto/BN_generate_prime.pod @@ -177,10 +177,7 @@ L, L, L =head1 HISTORY -The B arguments to BN_generate_prime() and to BN_is_prime() -were added in SSLeay 0.9.0. The B argument to BN_generate_prime() -was added in SSLeay 0.9.1. -BN_is_prime_fasttest() was added in OpenSSL 0.9.5. BN_GENCB_new, BN_GENCB_free -and BN_GENCB_get_arg were added in OpenSSL 1.1.0 +BN_GENCB_new(), BN_GENCB_free(), +and BN_GENCB_get_arg() were added in OpenSSL 1.1.0 =cut diff --git a/doc/crypto/BN_mod_inverse.pod b/doc/crypto/BN_mod_inverse.pod index 97bb378..e54bccf 100644 --- a/doc/crypto/BN_mod_inverse.pod +++ b/doc/crypto/BN_mod_inverse.pod @@ -29,8 +29,4 @@ NULL on error. The error codes can be obtained by L. L, L, L -=head1 HISTORY - -BN_mod_inverse() is available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/BN_mod_mul_montgomery.pod b/doc/crypto/BN_mod_mul_montgomery.pod index 9a18a09..b4a09a2 100644 --- a/doc/crypto/BN_mod_mul_montgomery.pod +++ b/doc/crypto/BN_mod_mul_montgomery.pod @@ -96,11 +96,6 @@ L =head1 HISTORY -BN_MONT_CTX_new(), BN_MONT_CTX_free(), BN_MONT_CTX_set(), -BN_mod_mul_montgomery(), BN_from_montgomery() and BN_to_montgomery() -are available in all versions of SSLeay and OpenSSL. - -BN_MONT_CTX_init() and BN_MONT_CTX_copy() were added in SSLeay 0.9.1b. -BN_MONT_CTX_init was removed in OpenSSL 1.1.0 +BN_MONT_CTX_init() was removed in OpenSSL 1.1.0 =cut diff --git a/doc/crypto/BN_mod_mul_reciprocal.pod b/doc/crypto/BN_mod_mul_reciprocal.pod index 20357dc..f03feb2 100644 --- a/doc/crypto/BN_mod_mul_reciprocal.pod +++ b/doc/crypto/BN_mod_mul_reciprocal.pod @@ -83,8 +83,6 @@ L =head1 HISTORY -B was added in SSLeay 0.9.0. Before that, the function -BN_reciprocal() was used instead, and the BN_mod_mul_reciprocal() -arguments were different. BN_RECP_CTX_init was removed in OpenSSL 1.1.0 +BN_RECP_CTX_init was removed in OpenSSL 1.1.0 =cut diff --git a/doc/crypto/BN_new.pod b/doc/crypto/BN_new.pod index f5b5100..0629b19 100644 --- a/doc/crypto/BN_new.pod +++ b/doc/crypto/BN_new.pod @@ -61,8 +61,6 @@ L, L =head1 HISTORY -BN_new(), BN_clear(), BN_free() and BN_clear_free() are available in -all versions on SSLeay and OpenSSL. BN_init() was added in SSLeay -0.9.1b and removed in OpenSSL 1.1.0. +BN_init() was removed in OpenSSL 1.1.0. =cut diff --git a/doc/crypto/BN_num_bytes.pod b/doc/crypto/BN_num_bytes.pod index 54f200b..30ee3e5 100644 --- a/doc/crypto/BN_num_bytes.pod +++ b/doc/crypto/BN_num_bytes.pod @@ -49,9 +49,4 @@ more probability). L, L, L, L -=head1 HISTORY - -BN_num_bytes(), BN_num_bits() and BN_num_bits_word() are available in -all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/BN_rand.pod b/doc/crypto/BN_rand.pod index 1abcdd4..c4f98b6 100644 --- a/doc/crypto/BN_rand.pod +++ b/doc/crypto/BN_rand.pod @@ -49,11 +49,4 @@ The error codes can be obtained by L. L, L, L, L, L -=head1 HISTORY - -BN_rand() is available in all versions of SSLeay and OpenSSL. -BN_pseudo_rand() was added in OpenSSL 0.9.5. The B == -1 case -and the function BN_rand_range() were added in OpenSSL 0.9.6a. -BN_pseudo_rand_range() was added in OpenSSL 0.9.6c. - =cut diff --git a/doc/crypto/BN_set_bit.pod b/doc/crypto/BN_set_bit.pod index 20c24f0..13bf231 100644 --- a/doc/crypto/BN_set_bit.pod +++ b/doc/crypto/BN_set_bit.pod @@ -57,10 +57,4 @@ can be obtained by L. L, L, L -=head1 HISTORY - -BN_set_bit(), BN_clear_bit(), BN_is_bit_set(), BN_mask_bits(), -BN_lshift(), BN_lshift1(), BN_rshift(), and BN_rshift1() are available -in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/BN_swap.pod b/doc/crypto/BN_swap.pod index 8e764e3..04582e9 100644 --- a/doc/crypto/BN_swap.pod +++ b/doc/crypto/BN_swap.pod @@ -16,8 +16,4 @@ BN_swap() exchanges the values of I and I. L -=head1 HISTORY - -BN_swap was added in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/BN_zero.pod b/doc/crypto/BN_zero.pod index 6b0c639..e0f653f 100644 --- a/doc/crypto/BN_zero.pod +++ b/doc/crypto/BN_zero.pod @@ -47,13 +47,4 @@ unsigned long but this value is also returned on error. L, L -=head1 HISTORY - -BN_zero(), BN_one() and BN_set_word() are available in all versions of -SSLeay and OpenSSL. BN_value_one() and BN_get_word() were added in -SSLeay 0.8. - -BN_value_one() was changed to return a true const BIGNUM * in OpenSSL -0.9.7. - =cut diff --git a/doc/crypto/CMS_add0_cert.pod b/doc/crypto/CMS_add0_cert.pod index ec12801..dc2cf46 100644 --- a/doc/crypto/CMS_add0_cert.pod +++ b/doc/crypto/CMS_add0_cert.pod @@ -58,9 +58,4 @@ L, L, L -=head1 HISTORY - -CMS_add0_cert(), CMS_add1_cert(), CMS_get1_certs(), CMS_add0_crl() -and CMS_get1_crls() were all first added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_add1_recipient_cert.pod b/doc/crypto/CMS_add1_recipient_cert.pod index 4f94703..4efe086 100644 --- a/doc/crypto/CMS_add1_recipient_cert.pod +++ b/doc/crypto/CMS_add1_recipient_cert.pod @@ -54,9 +54,4 @@ occurs. L, L, L, -=head1 HISTORY - -CMS_add1_recipient_cert() and CMS_add0_recipient_key() were added to OpenSSL -0.9.8 - =cut diff --git a/doc/crypto/CMS_add1_signer.pod b/doc/crypto/CMS_add1_signer.pod index 2bcac66..0f43ea7 100644 --- a/doc/crypto/CMS_add1_signer.pod +++ b/doc/crypto/CMS_add1_signer.pod @@ -94,8 +94,4 @@ structure just added or NULL if an error occurs. L, L, L, -=head1 HISTORY - -CMS_add1_signer() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_compress.pod b/doc/crypto/CMS_compress.pod index 583b1ec..e2ead0e 100644 --- a/doc/crypto/CMS_compress.pod +++ b/doc/crypto/CMS_compress.pod @@ -67,7 +67,6 @@ L, L =head1 HISTORY -CMS_compress() was added to OpenSSL 0.9.8 -The B flag was first supported in OpenSSL 1.0.0. +The B flag was added in OpenSSL 1.0.0. =cut diff --git a/doc/crypto/CMS_decrypt.pod b/doc/crypto/CMS_decrypt.pod index 99e4811..06bc106 100644 --- a/doc/crypto/CMS_decrypt.pod +++ b/doc/crypto/CMS_decrypt.pod @@ -72,8 +72,4 @@ mentioned in CMS_verify() also applies to CMS_decrypt(). L, L -=head1 HISTORY - -CMS_decrypt() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_encrypt.pod b/doc/crypto/CMS_encrypt.pod index 4750942..b58b0fc 100644 --- a/doc/crypto/CMS_encrypt.pod +++ b/doc/crypto/CMS_encrypt.pod @@ -90,7 +90,6 @@ L, L =head1 HISTORY -CMS_decrypt() was added to OpenSSL 0.9.8 The B flag was first supported in OpenSSL 1.0.0. =cut diff --git a/doc/crypto/CMS_final.pod b/doc/crypto/CMS_final.pod index 227ca83..c0f4ef9 100644 --- a/doc/crypto/CMS_final.pod +++ b/doc/crypto/CMS_final.pod @@ -34,8 +34,4 @@ CMS_final() returns 1 for success or 0 for failure. L, L, L -=head1 HISTORY - -CMS_final() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_get0_RecipientInfos.pod b/doc/crypto/CMS_get0_RecipientInfos.pod index cc14af7..93bebb7 100644 --- a/doc/crypto/CMS_get0_RecipientInfos.pod +++ b/doc/crypto/CMS_get0_RecipientInfos.pod @@ -113,8 +113,4 @@ Any error can be obtained from L. L, L -=head1 HISTORY - -These functions were first was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_get0_SignerInfos.pod b/doc/crypto/CMS_get0_SignerInfos.pod index 531c338..e636532 100644 --- a/doc/crypto/CMS_get0_SignerInfos.pod +++ b/doc/crypto/CMS_get0_SignerInfos.pod @@ -74,8 +74,4 @@ Any error can be obtained from L L, L -=head1 HISTORY - -These functions were first was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_get0_type.pod b/doc/crypto/CMS_get0_type.pod index 75ef40a..80fc303 100644 --- a/doc/crypto/CMS_get0_type.pod +++ b/doc/crypto/CMS_get0_type.pod @@ -69,9 +69,4 @@ error can be obtained from ERR_get_error(3). L -=head1 HISTORY - -CMS_get0_type(), CMS_set1_eContentType() and CMS_get0_eContentType() were all -first added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_get1_ReceiptRequest.pod b/doc/crypto/CMS_get1_ReceiptRequest.pod index f94baac..81206eb 100644 --- a/doc/crypto/CMS_get1_ReceiptRequest.pod +++ b/doc/crypto/CMS_get1_ReceiptRequest.pod @@ -60,10 +60,4 @@ L, L, L, L L -=head1 HISTORY - -CMS_ReceiptRequest_create0(), CMS_add1_ReceiptRequest(), -CMS_get1_ReceiptRequest() and CMS_ReceiptRequest_get0_values() were added to -OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_sign.pod b/doc/crypto/CMS_sign.pod index e05f854..108b13e 100644 --- a/doc/crypto/CMS_sign.pod +++ b/doc/crypto/CMS_sign.pod @@ -113,8 +113,6 @@ L, L =head1 HISTORY -CMS_sign() was added to OpenSSL 0.9.8 - The B flag is only supported for detached data in OpenSSL 0.9.8, it is supported for embedded data in OpenSSL 1.0.0 and later. diff --git a/doc/crypto/CMS_sign_receipt.pod b/doc/crypto/CMS_sign_receipt.pod index 2083c88..99a0b14 100644 --- a/doc/crypto/CMS_sign_receipt.pod +++ b/doc/crypto/CMS_sign_receipt.pod @@ -38,8 +38,4 @@ L, L, L -=head1 HISTORY - -CMS_sign_receipt() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_uncompress.pod b/doc/crypto/CMS_uncompress.pod index c6943ac..44512a4 100644 --- a/doc/crypto/CMS_uncompress.pod +++ b/doc/crypto/CMS_uncompress.pod @@ -47,8 +47,4 @@ mentioned in CMS_verify() also applies to CMS_decompress(). L, L -=head1 HISTORY - -CMS_uncompress() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_verify.pod b/doc/crypto/CMS_verify.pod index 47ca32b..d4baffe 100644 --- a/doc/crypto/CMS_verify.pod +++ b/doc/crypto/CMS_verify.pod @@ -119,8 +119,4 @@ be held in memory if it is not detached. L, L -=head1 HISTORY - -CMS_verify() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CMS_verify_receipt.pod b/doc/crypto/CMS_verify_receipt.pod index 1dcc3b8..15ec54c 100644 --- a/doc/crypto/CMS_verify_receipt.pod +++ b/doc/crypto/CMS_verify_receipt.pod @@ -40,8 +40,4 @@ L, L, L, -=head1 HISTORY - -CMS_verify_receipt() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/CONF_modules_free.pod b/doc/crypto/CONF_modules_free.pod index 866bd3f..37a7b16 100644 --- a/doc/crypto/CONF_modules_free.pod +++ b/doc/crypto/CONF_modules_free.pod @@ -39,9 +39,4 @@ None of the functions return a value. L, L, L -=head1 HISTORY - -CONF_modules_free(), CONF_modules_unload(), and CONF_modules_finish() -first appeared in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/CONF_modules_load_file.pod b/doc/crypto/CONF_modules_load_file.pod index e9930fe..53202a7 100644 --- a/doc/crypto/CONF_modules_load_file.pod +++ b/doc/crypto/CONF_modules_load_file.pod @@ -130,8 +130,4 @@ return value of the failing module (this will always be zero or negative). L, L, L, L -=head1 HISTORY - -CONF_modules_load_file and CONF_modules_load first appeared in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/CRYPTO_set_ex_data.pod b/doc/crypto/CRYPTO_set_ex_data.pod index 8b6c3de..9ba3fb7 100644 --- a/doc/crypto/CRYPTO_set_ex_data.pod +++ b/doc/crypto/CRYPTO_set_ex_data.pod @@ -46,8 +46,4 @@ L, L, L -=head1 HISTORY - -CRYPTO_set_ex_data() and CRYPTO_get_ex_data() have been available since SSLeay 0.9.0. - =cut diff --git a/doc/crypto/DH_generate_key.pod b/doc/crypto/DH_generate_key.pod index d787704..b37decc 100644 --- a/doc/crypto/DH_generate_key.pod +++ b/doc/crypto/DH_generate_key.pod @@ -42,9 +42,4 @@ The error codes can be obtained by L. L, L, L, L -=head1 HISTORY - -DH_generate_key() and DH_compute_key() are available in all versions -of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/DH_generate_parameters.pod b/doc/crypto/DH_generate_parameters.pod index ebbb184..1491d9f 100644 --- a/doc/crypto/DH_generate_parameters.pod +++ b/doc/crypto/DH_generate_parameters.pod @@ -71,12 +71,4 @@ a usable generator. L, L, L, L -=head1 HISTORY - -DH_check() is available in all versions of SSLeay and OpenSSL. -The B argument to DH_generate_parameters() was added in SSLeay 0.9.0. - -In versions before OpenSSL 0.9.5, DH_CHECK_P_NOT_STRONG_PRIME is used -instead of DH_CHECK_P_NOT_SAFE_PRIME. - =cut diff --git a/doc/crypto/DH_get_ex_new_index.pod b/doc/crypto/DH_get_ex_new_index.pod index 1871463..0c113c7 100644 --- a/doc/crypto/DH_get_ex_new_index.pod +++ b/doc/crypto/DH_get_ex_new_index.pod @@ -28,9 +28,4 @@ as described in L. L, L -=head1 HISTORY - -DH_get_ex_new_index(), DH_set_ex_data() and DH_get_ex_data() are -available since OpenSSL 0.9.5. - =cut diff --git a/doc/crypto/DH_new.pod b/doc/crypto/DH_new.pod index 2d9fecd..450039c 100644 --- a/doc/crypto/DH_new.pod +++ b/doc/crypto/DH_new.pod @@ -34,8 +34,4 @@ L, L, L, L -=head1 HISTORY - -DH_new() and DH_free() are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/DH_set_method.pod b/doc/crypto/DH_set_method.pod index 8b80f5c..62d1ee1 100644 --- a/doc/crypto/DH_set_method.pod +++ b/doc/crypto/DH_set_method.pod @@ -97,33 +97,8 @@ DH_new_method() returns NULL and sets an error code that can be obtained by L if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. -=head1 NOTES - -As of version 0.9.7, DH_METHOD implementations are grouped together with other -algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B modules. If a -default ENGINE is specified for DH functionality using an ENGINE API function, -that will override any DH defaults set using the DH API (ie. -DH_set_default_method()). For this reason, the ENGINE API is the recommended way -to control default implementations for use in DH and other cryptographic -algorithms. - =head1 SEE ALSO L, L -=head1 HISTORY - -DH_set_default_method(), DH_get_default_method(), DH_set_method(), -DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4. - -DH_set_default_openssl_method() and DH_get_default_openssl_method() replaced -DH_set_default_method() and DH_get_default_method() respectively, and -DH_set_method() and DH_new_method() were altered to use Bs rather than -Bs during development of the engine version of OpenSSL 0.9.6. For -0.9.7, the handling of defaults in the ENGINE API was restructured so that this -change was reversed, and behaviour of the other functions resembled more closely -the previous behaviour. The behaviour of defaults in the ENGINE API now -transparently overrides the behaviour of defaults in the DH API without -requiring changing these function prototypes. - =cut diff --git a/doc/crypto/DH_size.pod b/doc/crypto/DH_size.pod index ab28072..f961eaa 100644 --- a/doc/crypto/DH_size.pod +++ b/doc/crypto/DH_size.pod @@ -33,7 +33,6 @@ L =head1 HISTORY -DH_size() is available in all versions of SSLeay and OpenSSL. DH_bits() was added in OpenSSL 1.1.0. =cut diff --git a/doc/crypto/DSA_SIG_new.pod b/doc/crypto/DSA_SIG_new.pod index aa2cb7d..91bb513 100644 --- a/doc/crypto/DSA_SIG_new.pod +++ b/doc/crypto/DSA_SIG_new.pod @@ -33,8 +33,4 @@ DSA_SIG_free() returns no value. L, L, L -=head1 HISTORY - -DSA_SIG_new() and DSA_SIG_free() were added in OpenSSL 0.9.3. - =cut diff --git a/doc/crypto/DSA_do_sign.pod b/doc/crypto/DSA_do_sign.pod index 7a1970b..6c7cb3c 100644 --- a/doc/crypto/DSA_do_sign.pod +++ b/doc/crypto/DSA_do_sign.pod @@ -40,8 +40,4 @@ L, L, L, L, L -=head1 HISTORY - -DSA_do_sign() and DSA_do_verify() were added in OpenSSL 0.9.3. - =cut diff --git a/doc/crypto/DSA_dup_DH.pod b/doc/crypto/DSA_dup_DH.pod index b2e5325..350e8aa 100644 --- a/doc/crypto/DSA_dup_DH.pod +++ b/doc/crypto/DSA_dup_DH.pod @@ -29,8 +29,4 @@ Be careful to avoid small subgroup attacks when using this. L, L, L -=head1 HISTORY - -DSA_dup_DH() was added in OpenSSL 0.9.4. - =cut diff --git a/doc/crypto/DSA_generate_key.pod b/doc/crypto/DSA_generate_key.pod index 34a9efb..bf396ed 100644 --- a/doc/crypto/DSA_generate_key.pod +++ b/doc/crypto/DSA_generate_key.pod @@ -27,8 +27,4 @@ The error codes can be obtained by L. L, L, L, L -=head1 HISTORY - -DSA_generate_key() is available since SSLeay 0.8. - =cut diff --git a/doc/crypto/DSA_generate_parameters.pod b/doc/crypto/DSA_generate_parameters.pod index ae13023..efe46eb 100644 --- a/doc/crypto/DSA_generate_parameters.pod +++ b/doc/crypto/DSA_generate_parameters.pod @@ -108,13 +108,4 @@ Seed lengths E 20 are not supported. L, L, L, L, L -=head1 HISTORY - -DSA_generate_parameters() appeared in SSLeay 0.8. The B -argument was added in SSLeay 0.9.0. -In versions up to OpenSSL 0.9.4, B was called -in the inner loop of the Miller-Rabin test whenever it reached the -squaring step (the parameters to B did not reveal how many -witnesses had been tested); since OpenSSL 0.9.5, B -is called as in BN_is_prime(3), i.e. once for each witness. =cut diff --git a/doc/crypto/DSA_get_ex_new_index.pod b/doc/crypto/DSA_get_ex_new_index.pod index 43b29b3..b9ed01b 100644 --- a/doc/crypto/DSA_get_ex_new_index.pod +++ b/doc/crypto/DSA_get_ex_new_index.pod @@ -28,9 +28,4 @@ as described in L. L, L -=head1 HISTORY - -DSA_get_ex_new_index(), DSA_set_ex_data() and DSA_get_ex_data() are -available since OpenSSL 0.9.5. - =cut diff --git a/doc/crypto/DSA_new.pod b/doc/crypto/DSA_new.pod index 766cfd3..320839c 100644 --- a/doc/crypto/DSA_new.pod +++ b/doc/crypto/DSA_new.pod @@ -36,8 +36,4 @@ L, L, L, L -=head1 HISTORY - -DSA_new() and DSA_free() are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/DSA_set_method.pod b/doc/crypto/DSA_set_method.pod index fe0d6e3..632aadb 100644 --- a/doc/crypto/DSA_set_method.pod +++ b/doc/crypto/DSA_set_method.pod @@ -111,33 +111,8 @@ DSA_new_method() returns NULL and sets an error code that can be obtained by L if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. -=head1 NOTES - -As of version 0.9.7, DSA_METHOD implementations are grouped together with other -algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B modules. If a -default ENGINE is specified for DSA functionality using an ENGINE API function, -that will override any DSA defaults set using the DSA API (ie. -DSA_set_default_method()). For this reason, the ENGINE API is the recommended way -to control default implementations for use in DSA and other cryptographic -algorithms. - =head1 SEE ALSO L, L -=head1 HISTORY - -DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(), -DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4. - -DSA_set_default_openssl_method() and DSA_get_default_openssl_method() replaced -DSA_set_default_method() and DSA_get_default_method() respectively, and -DSA_set_method() and DSA_new_method() were altered to use Bs rather than -Bs during development of the engine version of OpenSSL 0.9.6. For -0.9.7, the handling of defaults in the ENGINE API was restructured so that this -change was reversed, and behaviour of the other functions resembled more closely -the previous behaviour. The behaviour of defaults in the ENGINE API now -transparently overrides the behaviour of defaults in the DSA API without -requiring changing these function prototypes. - =cut diff --git a/doc/crypto/DSA_sign.pod b/doc/crypto/DSA_sign.pod index da923ab..1071cca 100644 --- a/doc/crypto/DSA_sign.pod +++ b/doc/crypto/DSA_sign.pod @@ -58,9 +58,4 @@ Standard, DSS), ANSI X9.30 L, L, L, L -=head1 HISTORY - -DSA_sign() and DSA_verify() are available in all versions of SSLeay. -DSA_sign_setup() was added in SSLeay 0.8. - =cut diff --git a/doc/crypto/DSA_size.pod b/doc/crypto/DSA_size.pod index bc96cbd..4333d6d 100644 --- a/doc/crypto/DSA_size.pod +++ b/doc/crypto/DSA_size.pod @@ -26,8 +26,4 @@ The size in bytes. L, L -=head1 HISTORY - -DSA_size() is available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/ERR_GET_LIB.pod b/doc/crypto/ERR_GET_LIB.pod index fe31f03..3f0e36a 100644 --- a/doc/crypto/ERR_GET_LIB.pod +++ b/doc/crypto/ERR_GET_LIB.pod @@ -46,6 +46,6 @@ L, L =head1 HISTORY ERR_GET_LIB(), ERR_GET_FUNC() and ERR_GET_REASON() are available in -all versions of SSLeay and OpenSSL. +all versions of OpenSSL. =cut diff --git a/doc/crypto/ERR_clear_error.pod b/doc/crypto/ERR_clear_error.pod index d1da2b6..e54e34c 100644 --- a/doc/crypto/ERR_clear_error.pod +++ b/doc/crypto/ERR_clear_error.pod @@ -22,8 +22,4 @@ ERR_clear_error() has no return value. L, L -=head1 HISTORY - -ERR_clear_error() is available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/ERR_error_string.pod b/doc/crypto/ERR_error_string.pod index b3f9a43..60df430 100644 --- a/doc/crypto/ERR_error_string.pod +++ b/doc/crypto/ERR_error_string.pod @@ -65,9 +65,4 @@ L, L L -=head1 HISTORY - -ERR_error_string() is available in all versions of SSLeay and OpenSSL. -ERR_error_string_n() was added in OpenSSL 0.9.6. - =cut diff --git a/doc/crypto/ERR_get_error.pod b/doc/crypto/ERR_get_error.pod index 90b620c..aa5047e 100644 --- a/doc/crypto/ERR_get_error.pod +++ b/doc/crypto/ERR_get_error.pod @@ -67,13 +67,4 @@ The error code, or 0 if there is no error in the queue. L, L, L -=head1 HISTORY - -ERR_get_error(), ERR_peek_error(), ERR_get_error_line() and -ERR_peek_error_line() are available in all versions of SSLeay and -OpenSSL. ERR_get_error_line_data() and ERR_peek_error_line_data() -were added in SSLeay 0.9.0. -ERR_peek_last_error(), ERR_peek_last_error_line() and -ERR_peek_last_error_line_data() were added in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/ERR_load_crypto_strings.pod b/doc/crypto/ERR_load_crypto_strings.pod index b5ff885..b4af1fc 100644 --- a/doc/crypto/ERR_load_crypto_strings.pod +++ b/doc/crypto/ERR_load_crypto_strings.pod @@ -37,10 +37,4 @@ ERR_free_strings() return no values. L, L -=head1 HISTORY - -ERR_load_error_strings(), SSL_load_error_strings() and -ERR_free_strings() are available in all versions of SSLeay and -OpenSSL. - =cut diff --git a/doc/crypto/ERR_load_strings.pod b/doc/crypto/ERR_load_strings.pod index 9edf7a3..0e212a0 100644 --- a/doc/crypto/ERR_load_strings.pod +++ b/doc/crypto/ERR_load_strings.pod @@ -45,10 +45,4 @@ ERR_get_next_error_library() returns a new library number. L, L -=head1 HISTORY - -ERR_load_error_strings() and ERR_PACK() are available in all versions -of SSLeay and OpenSSL. ERR_get_next_error_library() was added in -SSLeay 0.9.0. - =cut diff --git a/doc/crypto/ERR_print_errors.pod b/doc/crypto/ERR_print_errors.pod index db890a9..3b0defe 100644 --- a/doc/crypto/ERR_print_errors.pod +++ b/doc/crypto/ERR_print_errors.pod @@ -43,9 +43,4 @@ L, L, L -=head1 HISTORY - -ERR_print_errors() and ERR_print_errors_fp() -are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/ERR_put_error.pod b/doc/crypto/ERR_put_error.pod index a87dcae..f0a82f6 100644 --- a/doc/crypto/ERR_put_error.pod +++ b/doc/crypto/ERR_put_error.pod @@ -36,9 +36,4 @@ no values. L, L -=head1 HISTORY - -ERR_put_error() is available in all versions of SSLeay and OpenSSL. -ERR_add_error_data() was added in SSLeay 0.9.0. - =cut diff --git a/doc/crypto/ERR_remove_state.pod b/doc/crypto/ERR_remove_state.pod index 236aeb4..1d20fc2 100644 --- a/doc/crypto/ERR_remove_state.pod +++ b/doc/crypto/ERR_remove_state.pod @@ -38,8 +38,8 @@ L =head1 HISTORY -ERR_remove_state() is available in all versions of SSLeay and OpenSSL. It -was deprecated in OpenSSL 1.0.0 when ERR_remove_thread_state was introduced +ERR_remove_state() +was deprecated in OpenSSL 1.0.0 when ERR_remove_thread_state() was introduced and thread IDs were introduced to identify threads instead of 'unsigned long'. =cut diff --git a/doc/crypto/ERR_set_mark.pod b/doc/crypto/ERR_set_mark.pod index 122a81b..d30f1c0 100644 --- a/doc/crypto/ERR_set_mark.pod +++ b/doc/crypto/ERR_set_mark.pod @@ -31,8 +31,4 @@ implies that the stack became empty, otherwise 1. L -=head1 HISTORY - -ERR_set_mark() and ERR_pop_to_mark() were added in OpenSSL 0.9.8. - =cut diff --git a/doc/crypto/EVP_DigestInit.pod b/doc/crypto/EVP_DigestInit.pod index 2d7f0dc..1616309 100644 --- a/doc/crypto/EVP_DigestInit.pod +++ b/doc/crypto/EVP_DigestInit.pod @@ -189,7 +189,7 @@ EVP_MD_CTX_copy_ex() because they can efficiently reuse a digest context instead of initializing and cleaning it up on each call and allow non default implementations of digests to be specified. -In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use +If digest contexts are not cleaned up after use memory leaks will occur. Stack allocation of EVP_MD_CTX structures is common, for example: @@ -260,22 +260,8 @@ L =head1 HISTORY -EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() are -available in all versions of SSLeay and OpenSSL. - -EVP_MD_CTX_init(), EVP_MD_CTX_create(), EVP_MD_CTX_copy_ex(), -EVP_MD_CTX_cleanup(), EVP_MD_CTX_destroy(), EVP_DigestInit_ex() -and EVP_DigestFinal_ex() were added in OpenSSL 0.9.7. - -EVP_md_null(), EVP_md2(), EVP_md5(), EVP_sha1(), -EVP_dss1(), EVP_mdc2() and EVP_ripemd160() were -changed to return truly const EVP_MD * in OpenSSL 0.9.7. - The link between digests and signing algorithms was fixed in OpenSSL 1.0 and later, so now EVP_sha1() can be used with RSA and DSA; there is no need to use EVP_dss1() any more. -OpenSSL 1.0 and later does not include the MD2 digest algorithm in the -default configuration due to its security weaknesses. - =cut diff --git a/doc/crypto/EVP_EncryptInit.pod b/doc/crypto/EVP_EncryptInit.pod index 9a1bdef..8f3216b 100644 --- a/doc/crypto/EVP_EncryptInit.pod +++ b/doc/crypto/EVP_EncryptInit.pod @@ -614,13 +614,6 @@ L =head1 HISTORY -EVP_CIPHER_CTX_init(), EVP_EncryptInit_ex(), EVP_EncryptFinal_ex(), -EVP_DecryptInit_ex(), EVP_DecryptFinal_ex(), EVP_CipherInit_ex(), -EVP_CipherFinal_ex() and EVP_CIPHER_CTX_set_padding() appeared in -OpenSSL 0.9.7. - -IDEA appeared in OpenSSL 0.9.7 but was often disabled due to -patent concerns; the last patents expired in 2012. - Support for OCB mode was added in OpenSSL 1.1.0 + =cut diff --git a/doc/crypto/EVP_PKEY_CTX_ctrl.pod b/doc/crypto/EVP_PKEY_CTX_ctrl.pod index 5710cfb..cc27e54 100644 --- a/doc/crypto/EVP_PKEY_CTX_ctrl.pod +++ b/doc/crypto/EVP_PKEY_CTX_ctrl.pod @@ -108,8 +108,8 @@ for DH parameter generation. If not specified 2 is used. The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC parameter generation to B. For EC parameter generation this macro must be called -or an error occurs because there is no default curve. In OpenSSL 1.0.2 and -later this function can also be called to set the curve explicitly when +or an error occurs because there is no default curve. +This function can also be called to set the curve explicitly when generating an EC key. The EVP_PKEY_CTX_set_ec_param_enc() sets the EC parameter encoding to @@ -117,7 +117,7 @@ B when generating EC parameters or an EC key. The encoding can be B for explicit parameters (the default in versions of OpenSSL before 1.1.0) or B to use named curve form. For maximum compatibility the named curve form should be used. Note: the -B value was only added to OpenSSL 1.1.0: previous +B value was only added to OpenSSL 1.1.0; previous versions should use 0 instead. =head1 RETURN VALUES diff --git a/doc/crypto/EVP_SealInit.pod b/doc/crypto/EVP_SealInit.pod index 50271be..e920e3e 100644 --- a/doc/crypto/EVP_SealInit.pod +++ b/doc/crypto/EVP_SealInit.pod @@ -78,8 +78,4 @@ L, L, L, L -=head1 HISTORY - -EVP_SealFinal() did not return a value before OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/EVP_SignInit.pod b/doc/crypto/EVP_SignInit.pod index 9a91b91..51d49c8 100644 --- a/doc/crypto/EVP_SignInit.pod +++ b/doc/crypto/EVP_SignInit.pod @@ -96,11 +96,4 @@ L, L, L, L, L, L, L, L -=head1 HISTORY - -EVP_SignInit(), EVP_SignUpdate() and EVP_SignFinal() are -available in all versions of SSLeay and OpenSSL. - -EVP_SignInit_ex() was added in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/EVP_VerifyInit.pod b/doc/crypto/EVP_VerifyInit.pod index ee27de1..1a1d980 100644 --- a/doc/crypto/EVP_VerifyInit.pod +++ b/doc/crypto/EVP_VerifyInit.pod @@ -85,11 +85,4 @@ L, L, L, L, L, L, L, L -=head1 HISTORY - -EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are -available in all versions of SSLeay and OpenSSL. - -EVP_VerifyInit_ex() was added in OpenSSL 0.9.7 - =cut diff --git a/doc/crypto/OPENSSL_VERSION_NUMBER.pod b/doc/crypto/OPENSSL_VERSION_NUMBER.pod index f76a9d3..c8fed0f 100644 --- a/doc/crypto/OPENSSL_VERSION_NUMBER.pod +++ b/doc/crypto/OPENSSL_VERSION_NUMBER.pod @@ -2,7 +2,7 @@ =head1 NAME -OPENSSL_VERSION_NUMBER, SSLeay, SSLeay_version - get OpenSSL version number +OPENSSL_VERSION_NUMBER, OpenSSL_version - get OpenSSL version number =head1 SYNOPSIS @@ -10,8 +10,7 @@ OPENSSL_VERSION_NUMBER, SSLeay, SSLeay_version - get OpenSSL version number #define OPENSSL_VERSION_NUMBER 0xnnnnnnnnnL #include - long SSLeay(void); - const char *SSLeay_version(int t); + const char *OpenSSL_version(int t); =head1 DESCRIPTION @@ -44,38 +43,34 @@ except the patch level got the highest bit set, to keep continuity. The number was therefore 0x0090581f. -For backward compatibility, SSLEAY_VERSION_NUMBER is also defined. +For backward compatibility, OPENSSL_VERSION_NUMBER is also defined. -SSLeay() returns this number. The return value can be compared to the -macro to make sure that the correct version of the library has been -loaded, especially when using DLLs on Windows systems. - -SSLeay_version() returns different strings depending on B: +OpenSSL_version() returns different strings depending on B: =over 4 -=item SSLEAY_VERSION +=item OPENSSL_VERSION The text variant of the version number and the release date. For example, -"OpenSSL 0.9.5a 1 Apr 2000". +"OpenSSL 1.0.1a 15 Oct 2015". -=item SSLEAY_CFLAGS +=item OPENSSL_CFLAGS The compiler flags set for the compilation process in the form "compiler: ..." if available or "compiler: information not available" otherwise. -=item SSLEAY_BUILT_ON +=item OPENSSL_BUILT_ON The date of the build process in the form "built on: ..." if available or "built on: date not available" otherwise. -=item SSLEAY_PLATFORM +=item OPENSSL_PLATFORM The "Configure" target of the library build in the form "platform: ..." if available or "platform: information not available" otherwise. -=item SSLEAY_DIR +=item OPENSSL_DIR The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "..."" if available or "OPENSSLDIR: N/A" otherwise. @@ -92,10 +87,4 @@ The version number. L -=head1 HISTORY - -SSLeay() and SSLEAY_VERSION_NUMBER are available in all versions of SSLeay and OpenSSL. -OPENSSL_VERSION_NUMBER is available in all versions of OpenSSL. -B was added in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/OPENSSL_config.pod b/doc/crypto/OPENSSL_config.pod index cc86f24..fbf8b6d 100644 --- a/doc/crypto/OPENSSL_config.pod +++ b/doc/crypto/OPENSSL_config.pod @@ -42,9 +42,7 @@ Applications should instead call CONF_modules_load() during initialization (that is before starting any threads). There are several reasons why calling the OpenSSL configuration routines is -advisable. For example new ENGINE functionality was added to OpenSSL 0.9.7. -In OpenSSL 0.9.7 control functions can be supported by ENGINEs, this can be -used (among other things) to load dynamic ENGINEs from shared libraries (DSOs). +advisable. For example, to load dynamic ENGINEs from shared libraries (DSOs). However very few applications currently support the control interface and so very few can load and use dynamic ENGINEs. Equally in future more sophisticated ENGINEs will require certain control operations to customize them. If an @@ -62,8 +60,4 @@ L, L, L -=head1 HISTORY - -OPENSSL_config() and OPENSSL_no_config() first appeared in OpenSSL 0.9.7 - =cut diff --git a/doc/crypto/OPENSSL_load_builtin_modules.pod b/doc/crypto/OPENSSL_load_builtin_modules.pod index 8ff3d79..20ca44c 100644 --- a/doc/crypto/OPENSSL_load_builtin_modules.pod +++ b/doc/crypto/OPENSSL_load_builtin_modules.pod @@ -44,8 +44,4 @@ None of the functions return a value. L, L -=head1 HISTORY - -These functions first appeared in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/PKCS12_create.pod b/doc/crypto/PKCS12_create.pod index 76edc48..46b24c5 100644 --- a/doc/crypto/PKCS12_create.pod +++ b/doc/crypto/PKCS12_create.pod @@ -46,11 +46,6 @@ export grade software which could use signing only keys of arbitrary size but had restrictions on the permissible sizes of keys which could be used for encryption. -=head1 NEW FUNCTIONALITY IN OPENSSL 0.9.8 - -Some additional functionality was added to PKCS12_create() in OpenSSL -0.9.8. These extensions are detailed below. - If a certificate contains an B or B then this will be used for the corresponding B or B in the PKCS12 structure. @@ -68,8 +63,4 @@ B can be set to -1 and the MAC will then be omitted entirely. L -=head1 HISTORY - -PKCS12_create was added in OpenSSL 0.9.3 - =cut diff --git a/doc/crypto/PKCS12_parse.pod b/doc/crypto/PKCS12_parse.pod index 3691a9b..f02220e 100644 --- a/doc/crypto/PKCS12_parse.pod +++ b/doc/crypto/PKCS12_parse.pod @@ -50,8 +50,4 @@ Attributes currently cannot be stored in the private key B structure. L -=head1 HISTORY - -PKCS12_parse was added in OpenSSL 0.9.3 - =cut diff --git a/doc/crypto/PKCS7_decrypt.pod b/doc/crypto/PKCS7_decrypt.pod index 9bb367d..71313b8 100644 --- a/doc/crypto/PKCS7_decrypt.pod +++ b/doc/crypto/PKCS7_decrypt.pod @@ -48,8 +48,4 @@ mentioned in PKCS7_sign() also applies to PKCS7_verify(). L, L -=head1 HISTORY - -PKCS7_decrypt() was added to OpenSSL 0.9.5 - =cut diff --git a/doc/crypto/PKCS7_encrypt.pod b/doc/crypto/PKCS7_encrypt.pod index 71618d9..12475cf 100644 --- a/doc/crypto/PKCS7_encrypt.pod +++ b/doc/crypto/PKCS7_encrypt.pod @@ -74,7 +74,6 @@ L, L =head1 HISTORY -PKCS7_decrypt() was added to OpenSSL 0.9.5 -The B flag was first supported in OpenSSL 1.0.0. +The B flag was added in OpenSSL 1.0.0. =cut diff --git a/doc/crypto/PKCS7_sign.pod b/doc/crypto/PKCS7_sign.pod index f6fe3b6..07d4dc4 100644 --- a/doc/crypto/PKCS7_sign.pod +++ b/doc/crypto/PKCS7_sign.pod @@ -80,13 +80,13 @@ BIO_new_PKCS7(). If a signer is specified it will use the default digest for the signing algorithm. This is B for both RSA and DSA keys. -In OpenSSL 1.0.0 the B, B and B parameters can all be +The B, B and B parameters can all be B if the B flag is set. One or more signers can be added using the function B. B must also be called to finalize the structure if streaming is not enabled. Alternative signing digests can also be specified using this method. -In OpenSSL 1.0.0 if B and B are NULL then a certificates only +If B and B are NULL then a certificates only PKCS#7 structure is output. In versions of OpenSSL before 1.0.0 the B and B parameters must @@ -107,9 +107,8 @@ L, L =head1 HISTORY -PKCS7_sign() was added to OpenSSL 0.9.5 - -The B flag was added in OpenSSL 1.0.0 +The B flag, and the ability for B, B, +and B parameters to be B to be was added in OpenSSL 1.0.0 The B flag was added in OpenSSL 1.0.0 diff --git a/doc/crypto/PKCS7_verify.pod b/doc/crypto/PKCS7_verify.pod index b440f4d..3a5300a 100644 --- a/doc/crypto/PKCS7_verify.pod +++ b/doc/crypto/PKCS7_verify.pod @@ -111,8 +111,4 @@ mentioned in PKCS7_sign() also applies to PKCS7_verify(). L, L -=head1 HISTORY - -PKCS7_verify() was added to OpenSSL 0.9.5 - =cut diff --git a/doc/crypto/RAND_add.pod b/doc/crypto/RAND_add.pod index b160eeb..d54e1f5 100644 --- a/doc/crypto/RAND_add.pod +++ b/doc/crypto/RAND_add.pod @@ -68,10 +68,4 @@ The other functions do not return values. L, L, L, L -=head1 HISTORY - -RAND_seed() and RAND_screen() are available in all versions of SSLeay -and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL -0.9.5, RAND_event() in OpenSSL 0.9.5a. - =cut diff --git a/doc/crypto/RAND_bytes.pod b/doc/crypto/RAND_bytes.pod index 6a41c37..d57618d 100644 --- a/doc/crypto/RAND_bytes.pod +++ b/doc/crypto/RAND_bytes.pod @@ -44,10 +44,4 @@ method. L, L, L -=head1 HISTORY - -RAND_bytes() is available in all versions of SSLeay and OpenSSL. It -has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added -in OpenSSL 0.9.5. - =cut diff --git a/doc/crypto/RAND_cleanup.pod b/doc/crypto/RAND_cleanup.pod index e9b3af9..88efb9a 100644 --- a/doc/crypto/RAND_cleanup.pod +++ b/doc/crypto/RAND_cleanup.pod @@ -22,8 +22,4 @@ RAND_cleanup() returns no value. L -=head1 HISTORY - -RAND_cleanup() is available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/RAND_egd.pod b/doc/crypto/RAND_egd.pod index 5a28545..4c68113 100644 --- a/doc/crypto/RAND_egd.pod +++ b/doc/crypto/RAND_egd.pod @@ -75,14 +75,4 @@ success, and -1 if the connection failed. The PRNG state is not considered. L, L, L -=head1 HISTORY - -RAND_egd() is available since OpenSSL 0.9.5. - -RAND_egd_bytes() is available since OpenSSL 0.9.6. - -RAND_query_egd_bytes() is available since OpenSSL 0.9.7. - -The automatic query of /var/run/egd-pool et al was added in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/RAND_load_file.pod b/doc/crypto/RAND_load_file.pod index e19757e..debf06f 100644 --- a/doc/crypto/RAND_load_file.pod +++ b/doc/crypto/RAND_load_file.pod @@ -24,7 +24,7 @@ too small for the path name, an error occurs. RAND_load_file() reads a number of bytes from file B and adds them to the PRNG. If B is non-negative, -up to to B are read; starting with OpenSSL 0.9.5, +up to to B are read; if B is -1, the complete file is read. RAND_write_file() writes a number of random bytes (currently 1024) to @@ -45,9 +45,4 @@ error. L, L, L -=head1 HISTORY - -RAND_load_file(), RAND_write_file() and RAND_file_name() are available in -all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/RAND_set_rand_method.pod b/doc/crypto/RAND_set_rand_method.pod index a2828e3..fe7f441 100644 --- a/doc/crypto/RAND_set_rand_method.pod +++ b/doc/crypto/RAND_set_rand_method.pod @@ -57,7 +57,7 @@ RAND_SSLeay() return pointers to the respective methods. =head1 NOTES -As of version 0.9.7, RAND_METHOD implementations are grouped together with other +RAND_METHOD implementations are grouped together with other algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B modules. If a default ENGINE is specified for RAND functionality using an ENGINE API function, that will override any RAND defaults set using the RAND API (ie. @@ -69,15 +69,4 @@ algorithms. L, L -=head1 HISTORY - -RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are -available in all versions of OpenSSL. - -In the engine version of version 0.9.6, RAND_set_rand_method() was altered to -take an ENGINE pointer as its argument. As of version 0.9.7, that has been -reverted as the ENGINE API transparently overrides RAND defaults if used, -otherwise RAND API functions work as before. RAND_set_rand_engine() was also -introduced in version 0.9.7. - =cut diff --git a/doc/crypto/RSA_blinding_on.pod b/doc/crypto/RSA_blinding_on.pod index e512bbf..a323949 100644 --- a/doc/crypto/RSA_blinding_on.pod +++ b/doc/crypto/RSA_blinding_on.pod @@ -36,8 +36,4 @@ RSA_blinding_off() returns no value. L, L -=head1 HISTORY - -RSA_blinding_on() and RSA_blinding_off() appeared in SSLeay 0.9.0. - =cut diff --git a/doc/crypto/RSA_check_key.pod b/doc/crypto/RSA_check_key.pod index ec02063..8fd7d1f 100644 --- a/doc/crypto/RSA_check_key.pod +++ b/doc/crypto/RSA_check_key.pod @@ -71,7 +71,6 @@ L =head1 HISTORY -RSA_check_key() appeared in OpenSSL 0.9.4. RSA_check_key_ex() appeared after OpenSSL 1.0.2. =cut diff --git a/doc/crypto/RSA_generate_key.pod b/doc/crypto/RSA_generate_key.pod index 130acf9..7f6a157 100644 --- a/doc/crypto/RSA_generate_key.pod +++ b/doc/crypto/RSA_generate_key.pod @@ -73,8 +73,4 @@ RSA_generate_key() goes into an infinite loop for illegal input values. L, L, L, L, L -=head1 HISTORY - -The B argument was added in SSLeay 0.9.0. - =cut diff --git a/doc/crypto/RSA_get_ex_new_index.pod b/doc/crypto/RSA_get_ex_new_index.pod index 9b52559..a0f6750 100644 --- a/doc/crypto/RSA_get_ex_new_index.pod +++ b/doc/crypto/RSA_get_ex_new_index.pod @@ -112,9 +112,4 @@ present in the parent RSA structure when it is called. L, L -=head1 HISTORY - -RSA_get_ex_new_index(), RSA_set_ex_data() and RSA_get_ex_data() are -available since SSLeay 0.9.0. - =cut diff --git a/doc/crypto/RSA_new.pod b/doc/crypto/RSA_new.pod index 0ce325d..4910557 100644 --- a/doc/crypto/RSA_new.pod +++ b/doc/crypto/RSA_new.pod @@ -35,8 +35,4 @@ L, L, L, L -=head1 HISTORY - -RSA_new() and RSA_free() are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/RSA_padding_add_PKCS1_type_1.pod b/doc/crypto/RSA_padding_add_PKCS1_type_1.pod index 9389254..fe81e5f 100644 --- a/doc/crypto/RSA_padding_add_PKCS1_type_1.pod +++ b/doc/crypto/RSA_padding_add_PKCS1_type_1.pod @@ -110,15 +110,4 @@ L, L, L, L -=head1 HISTORY - -RSA_padding_add_PKCS1_type_1(), RSA_padding_check_PKCS1_type_1(), -RSA_padding_add_PKCS1_type_2(), RSA_padding_check_PKCS1_type_2(), -RSA_padding_add_SSLv23(), RSA_padding_check_SSLv23(), -RSA_padding_add_none() and RSA_padding_check_none() appeared in -SSLeay 0.9.0. - -RSA_padding_add_PKCS1_OAEP() and RSA_padding_check_PKCS1_OAEP() were -added in OpenSSL 0.9.2b. - =cut diff --git a/doc/crypto/RSA_print.pod b/doc/crypto/RSA_print.pod index 7690f31..df09726 100644 --- a/doc/crypto/RSA_print.pod +++ b/doc/crypto/RSA_print.pod @@ -40,10 +40,4 @@ These functions return 1 on success, 0 on error. L, L, L, L -=head1 HISTORY - -RSA_print(), RSA_print_fp(), DSA_print(), DSA_print_fp(), DH_print(), -DH_print_fp() are available in all versions of SSLeay and OpenSSL. -DSAparams_print() and DSAparams_print_fp() were added in SSLeay 0.8. - =cut diff --git a/doc/crypto/RSA_private_encrypt.pod b/doc/crypto/RSA_private_encrypt.pod index 8e4425c..fa4830c 100644 --- a/doc/crypto/RSA_private_encrypt.pod +++ b/doc/crypto/RSA_private_encrypt.pod @@ -62,9 +62,4 @@ obtained by L. L, L, L, L -=head1 HISTORY - -The B argument was added in SSLeay 0.8. RSA_NO_PADDING is -available since SSLeay 0.9.0. - =cut diff --git a/doc/crypto/RSA_public_encrypt.pod b/doc/crypto/RSA_public_encrypt.pod index 35a0fb5..57f1f18 100644 --- a/doc/crypto/RSA_public_encrypt.pod +++ b/doc/crypto/RSA_public_encrypt.pod @@ -76,9 +76,4 @@ SSL, PKCS #1 v2.0 L, L, L, L -=head1 HISTORY - -The B argument was added in SSLeay 0.8. RSA_NO_PADDING is -available since SSLeay 0.9.0, OAEP was added in OpenSSL 0.9.2b. - =cut diff --git a/doc/crypto/RSA_set_method.pod b/doc/crypto/RSA_set_method.pod index 7ccb216..5191844 100644 --- a/doc/crypto/RSA_set_method.pod +++ b/doc/crypto/RSA_set_method.pod @@ -159,16 +159,6 @@ RSA_new_method() returns NULL and sets an error code that can be obtained by L if the allocation fails. Otherwise it returns a pointer to the newly allocated structure. -=head1 NOTES - -As of version 0.9.7, RSA_METHOD implementations are grouped together with -other algorithmic APIs (eg. DSA_METHOD, EVP_CIPHER, etc) into B -modules. If a default ENGINE is specified for RSA functionality using an -ENGINE API function, that will override any RSA defaults set using the RSA -API (ie. RSA_set_default_method()). For this reason, the ENGINE API is the -recommended way to control default implementations for use in RSA and other -cryptographic algorithms. - =head1 BUGS The behaviour of RSA_flags() is a mis-feature that is left as-is for now @@ -185,22 +175,4 @@ not currently exist). L, L -=head1 HISTORY - -RSA_new_method() and RSA_set_default_method() appeared in SSLeay 0.8. -RSA_get_default_method(), RSA_set_method() and RSA_get_method() as -well as the rsa_sign and rsa_verify components of RSA_METHOD were -added in OpenSSL 0.9.4. - -RSA_set_default_openssl_method() and RSA_get_default_openssl_method() -replaced RSA_set_default_method() and RSA_get_default_method() -respectively, and RSA_set_method() and RSA_new_method() were altered to use -Bs rather than Bs during development of the engine -version of OpenSSL 0.9.6. For 0.9.7, the handling of defaults in the ENGINE -API was restructured so that this change was reversed, and behaviour of the -other functions resembled more closely the previous behaviour. The -behaviour of defaults in the ENGINE API now transparently overrides the -behaviour of defaults in the RSA API without requiring changing these -function prototypes. - =cut diff --git a/doc/crypto/RSA_sign.pod b/doc/crypto/RSA_sign.pod index a526eaf..94fae37 100644 --- a/doc/crypto/RSA_sign.pod +++ b/doc/crypto/RSA_sign.pod @@ -43,11 +43,6 @@ RSA_verify() returns 1 on successful verification. The error codes can be obtained by L. -=head1 BUGS - -Certain signatures with an improper algorithm identifier are accepted -for compatibility with SSLeay 0.4.5 :-) - =head1 CONFORMING TO SSL, PKCS #1 v2.0 @@ -58,9 +53,4 @@ L, L, L, L -=head1 HISTORY - -RSA_sign() and RSA_verify() are available in all versions of SSLeay -and OpenSSL. - =cut diff --git a/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod b/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod index 7b9ecfc..2ba2b47 100644 --- a/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod +++ b/doc/crypto/RSA_sign_ASN1_OCTET_STRING.pod @@ -51,9 +51,4 @@ L, L, L, L, L -=head1 HISTORY - -RSA_sign_ASN1_OCTET_STRING() and RSA_verify_ASN1_OCTET_STRING() were -added in SSLeay 0.8. - =cut diff --git a/doc/crypto/RSA_size.pod b/doc/crypto/RSA_size.pod index dc57bd1..eff8cdc 100644 --- a/doc/crypto/RSA_size.pod +++ b/doc/crypto/RSA_size.pod @@ -32,7 +32,6 @@ L, L =head1 HISTORY -RSA_size() is available in all versions of SSLeay and OpenSSL. RSA_bits() was added in OpenSSL 1.1.0. =cut diff --git a/doc/crypto/SMIME_read_CMS.pod b/doc/crypto/SMIME_read_CMS.pod index 15bec59..4b7c14d 100644 --- a/doc/crypto/SMIME_read_CMS.pod +++ b/doc/crypto/SMIME_read_CMS.pod @@ -63,8 +63,4 @@ L, L, L, L L -=head1 HISTORY - -SMIME_read_CMS() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/SMIME_read_PKCS7.pod b/doc/crypto/SMIME_read_PKCS7.pod index 40f950f..e96038b 100644 --- a/doc/crypto/SMIME_read_PKCS7.pod +++ b/doc/crypto/SMIME_read_PKCS7.pod @@ -66,8 +66,4 @@ L, L, L, L L -=head1 HISTORY - -SMIME_read_PKCS7() was added to OpenSSL 0.9.5 - =cut diff --git a/doc/crypto/SMIME_write_CMS.pod b/doc/crypto/SMIME_write_CMS.pod index 1cd1baa..0895825 100644 --- a/doc/crypto/SMIME_write_CMS.pod +++ b/doc/crypto/SMIME_write_CMS.pod @@ -57,8 +57,4 @@ L, L, L, L L -=head1 HISTORY - -SMIME_write_CMS() was added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/SMIME_write_PKCS7.pod b/doc/crypto/SMIME_write_PKCS7.pod index 85bc478..3ba3fe6 100644 --- a/doc/crypto/SMIME_write_PKCS7.pod +++ b/doc/crypto/SMIME_write_PKCS7.pod @@ -58,8 +58,4 @@ L, L, L, L L -=head1 HISTORY - -SMIME_write_PKCS7() was added to OpenSSL 0.9.5 - =cut diff --git a/doc/crypto/SSLeay_version.pod b/doc/crypto/SSLeay_version.pod index c54c3fe..4862cd4 100644 --- a/doc/crypto/SSLeay_version.pod +++ b/doc/crypto/SSLeay_version.pod @@ -67,8 +67,4 @@ Textual description. L -=head1 HISTORY - -B was added in OpenSSL 0.9.7. - =cut diff --git a/doc/crypto/X509_STORE_CTX_get_ex_new_index.pod b/doc/crypto/X509_STORE_CTX_get_ex_new_index.pod index 58368fd..f708329 100644 --- a/doc/crypto/X509_STORE_CTX_get_ex_new_index.pod +++ b/doc/crypto/X509_STORE_CTX_get_ex_new_index.pod @@ -33,9 +33,4 @@ structure. L -=head1 HISTORY - -X509_STORE_CTX_get_ex_new_index(), X509_STORE_CTX_set_ex_data() and -X509_STORE_CTX_get_ex_data() are available since OpenSSL 0.9.5. - =cut diff --git a/doc/crypto/X509_STORE_CTX_set_verify_cb.pod b/doc/crypto/X509_STORE_CTX_set_verify_cb.pod index 8ff47f6..ba35a38 100644 --- a/doc/crypto/X509_STORE_CTX_set_verify_cb.pod +++ b/doc/crypto/X509_STORE_CTX_set_verify_cb.pod @@ -153,9 +153,4 @@ L L L -=head1 HISTORY - -X509_STORE_CTX_set_verify_cb() is available in all versions of SSLeay and -OpenSSL. - =cut diff --git a/doc/crypto/X509_STORE_set_verify_cb_func.pod b/doc/crypto/X509_STORE_set_verify_cb_func.pod index b5bc1ea..67092db 100644 --- a/doc/crypto/X509_STORE_set_verify_cb_func.pod +++ b/doc/crypto/X509_STORE_set_verify_cb_func.pod @@ -46,9 +46,6 @@ L =head1 HISTORY -X509_STORE_set_verify_cb_func() is available in all versions of SSLeay and -OpenSSL. - X509_STORE_set_verify_cb() was added to OpenSSL 1.0.0. =cut diff --git a/doc/crypto/X509_get_subject_name.pod b/doc/crypto/X509_get_subject_name.pod index 12b3dfe..dcbf969 100644 --- a/doc/crypto/X509_get_subject_name.pod +++ b/doc/crypto/X509_get_subject_name.pod @@ -50,10 +50,6 @@ and X509_CRL_set_issuer_name() return 1 for success and 0 for failure. =head1 HISTORY -X509_get_subject_name(), X509_set_subject_name() and X509_get_issuer_name(), -X509_set_issuer_name(), X509_REQ_set_subject_name() and -X509_CRL_set_issuer_name() are avaiable in all versions of OpenSSL. - X509_REQ_get_subject_name() is a function in OpenSSL 1.1.0 and a macro in earlier versions. diff --git a/doc/crypto/X509_get_version.pod b/doc/crypto/X509_get_version.pod index 49b99bf..b02f12b 100644 --- a/doc/crypto/X509_get_version.pod +++ b/doc/crypto/X509_get_version.pod @@ -68,10 +68,6 @@ L =head1 HISTORY -X509_get_version(), X509_set_version() X509_REQ_get_version(), -X509_REQ_set_version(), X509_REQ_get_version() and X509_REQ_set_version() -are available in all versions of OpenSSL. - X509_get_version(), X509_REQ_get_version() and X509_CRL_get_version() are functions in OpenSSL 1.1.0, in previous versions they were macros. diff --git a/doc/crypto/X509_new.pod b/doc/crypto/X509_new.pod index 2b20af5..8e2ac98 100644 --- a/doc/crypto/X509_new.pod +++ b/doc/crypto/X509_new.pod @@ -48,8 +48,4 @@ L, L, L -=head1 HISTORY - -X509_new() and X509_free() are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/X509_verify_cert.pod b/doc/crypto/X509_verify_cert.pod index 1780bfe..1d0f1e2 100644 --- a/doc/crypto/X509_verify_cert.pod +++ b/doc/crypto/X509_verify_cert.pod @@ -47,8 +47,4 @@ functiosn which use B. L -=head1 HISTORY - -X509_verify_cert() is available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/buffer.pod b/doc/crypto/buffer.pod index d43518a..1351635 100644 --- a/doc/crypto/buffer.pod +++ b/doc/crypto/buffer.pod @@ -79,10 +79,6 @@ L. =head1 HISTORY -BUF_MEM_new(), BUF_MEM_free() and BUF_MEM_grow() are available in all -versions of SSLeay and OpenSSL. BUF_strdup() was added in SSLeay 0.8. - -BUF_MEM_new_ex() was contributed to OpenSSL by Akamai Technologies -in May, 2014. +BUF_MEM_new_ex() was added in OpenSSL 1.1.0. =cut diff --git a/doc/crypto/d2i_CMS_ContentInfo.pod b/doc/crypto/d2i_CMS_ContentInfo.pod index 463f617..e3142cb 100644 --- a/doc/crypto/d2i_CMS_ContentInfo.pod +++ b/doc/crypto/d2i_CMS_ContentInfo.pod @@ -22,8 +22,4 @@ described in the L manual page. L -=head1 HISTORY - -These functions were first added to OpenSSL 0.9.8 - =cut diff --git a/doc/crypto/d2i_X509.pod b/doc/crypto/d2i_X509.pod index af29829..435ca1f 100644 --- a/doc/crypto/d2i_X509.pod +++ b/doc/crypto/d2i_X509.pod @@ -43,7 +43,7 @@ at B<*out>, and increments it to point after the data just written. If the return value is negative an error occurred, otherwise it returns the length of the encoded data. -For OpenSSL 0.9.7 and later if B<*out> is B memory will be +If B<*out> is B memory will be allocated for a buffer and the encoded data written to it. In this case B<*out> is not incremented and it points to the start of the data just written. @@ -98,45 +98,21 @@ another will processed after it. Allocate and encode the DER encoding of an X509 structure: int len; - unsigned char *buf, *p; - - len = i2d_X509(x, NULL); - - buf = OPENSSL_malloc(len); - - if (buf == NULL) - /* error */ - - p = buf; - - i2d_X509(x, &p); - -If you are using OpenSSL 0.9.7 or later then this can be -simplified to: - - - int len; unsigned char *buf; buf = NULL; - len = i2d_X509(x, &buf); - if (len < 0) /* error */ Attempt to decode a buffer: X509 *x; - unsigned char *buf, *p; - int len; /* Something to setup buf and len */ - p = buf; - x = d2i_X509(NULL, &p, len); if (x == NULL) @@ -145,18 +121,14 @@ Attempt to decode a buffer: Alternative technique: X509 *x; - unsigned char *buf, *p; - int len; /* Something to setup buf and len */ - p = buf; - x = NULL; - if(!d2i_X509(&x, &p, len)) + if (!d2i_X509(&x, &p, len)) /* Some error */ @@ -169,16 +141,12 @@ mistake is to attempt to use a buffer directly as follows: unsigned char *buf; len = i2d_X509(x, NULL); - buf = OPENSSL_malloc(len); - if (buf == NULL) /* error */ i2d_X509(x, &buf); - /* Other stuff ... */ - OPENSSL_free(buf); This code will result in B apparently containing garbage because @@ -186,10 +154,6 @@ it was incremented after the call to point after the data just written. Also B will no longer contain the pointer allocated by B and the subsequent call to B may well crash. -The auto allocation feature (setting buf to NULL) only works on OpenSSL -0.9.7 and later. Attempts to use it on earlier versions will typically -cause a segmentation violation. - Another trap to avoid is misuse of the B argument to B: X509 *x; @@ -267,9 +231,4 @@ L, L, L -=head1 HISTORY - -d2i_X509, i2d_X509, d2i_X509_bio, d2i_X509_fp, i2d_X509_bio and i2d_X509_fp -are available in all versions of SSLeay and OpenSSL. - =cut diff --git a/doc/crypto/des.pod b/doc/crypto/des.pod index a6938aa..19b6662 100644 --- a/doc/crypto/des.pod +++ b/doc/crypto/des.pod @@ -312,11 +312,6 @@ functions directly. Single-key DES is insecure due to its short key size. ECB mode is not suitable for most applications; see L. -=head1 AUTHOR - -Eric Young (eay at cryptsoft.com). Modified for the OpenSSL project -(http://www.openssl.org). - =head1 SEE ALSO L, diff --git a/doc/crypto/ecdsa.pod b/doc/crypto/ecdsa.pod index f49d2ce..1af4feb 100644 --- a/doc/crypto/ecdsa.pod +++ b/doc/crypto/ecdsa.pod @@ -195,12 +195,4 @@ ANSI X9.62, US Federal Information Processing Standard FIPS 186-2 L, L -=head1 HISTORY - -The ecdsa implementation was first introduced in OpenSSL 0.9.8 - -=head1 AUTHOR - -Nils Larsch for the OpenSSL project (http://www.openssl.org). - =cut diff --git a/doc/crypto/engine.pod b/doc/crypto/engine.pod index 9424a7c..4d11b4a 100644 --- a/doc/crypto/engine.pod +++ b/doc/crypto/engine.pod @@ -576,16 +576,6 @@ might query various ENGINEs to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and ENGINE could therefore decide whether or not to support this "foo"-specific extension). -=head2 Future developments - -The ENGINE API and internal architecture is currently being reviewed. Slated for -possible release in 0.9.8 is support for transparent loading of "dynamic" -ENGINEs (built as self-contained shared-libraries). This would allow ENGINE -implementations to be provided independently of OpenSSL libraries and/or -OpenSSL-based applications, and would also remove any requirement for -applications to explicitly use the "dynamic" ENGINE to bind to shared-library -implementations. - =head1 SEE ALSO L, L, L, L diff --git a/doc/crypto/hmac.pod b/doc/crypto/hmac.pod index 88f5abc..753617a 100644 --- a/doc/crypto/hmac.pod +++ b/doc/crypto/hmac.pod @@ -89,12 +89,6 @@ L, L =head1 HISTORY -HMAC(), HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() -are available since SSLeay 0.9.0. - -HMAC_CTX_init(), HMAC_Init_ex() and HMAC_CTX_cleanup() are available -since OpenSSL 0.9.7. - HMAC_Init_ex(), HMAC_Update() and HMAC_Final() did not return values in versions of OpenSSL before 1.0.0. diff --git a/doc/crypto/lh_stats.pod b/doc/crypto/lh_stats.pod index 2a78c14..fa7bd9d 100644 --- a/doc/crypto/lh_stats.pod +++ b/doc/crypto/lh_stats.pod @@ -51,10 +51,4 @@ These functions do not return values. L, L -=head1 HISTORY - -These functions are available in all versions of SSLeay and OpenSSL. - -This manpage is derived from the SSLeay documentation. - =cut diff --git a/doc/crypto/lhash.pod b/doc/crypto/lhash.pod index 25410fa..7d39a67 100644 --- a/doc/crypto/lhash.pod +++ b/doc/crypto/lhash.pod @@ -234,69 +234,13 @@ without any "const" qualifiers. lh__insert() returns B both for success and error. -=head1 INTERNALS - -The following description is based on the SSLeay documentation: - -The B library implements a hash table described in the -I in 1991. What makes this hash table -different is that as the table fills, the hash table is increased (or -decreased) in size via OPENSSL_realloc(). When a 'resize' is done, instead of -all hashes being redistributed over twice as many 'buckets', one -bucket is split. So when an 'expand' is done, there is only a minimal -cost to redistribute some values. Subsequent inserts will cause more -single 'bucket' redistributions but there will never be a sudden large -cost due to redistributing all the 'buckets'. - -The state for a particular hash table is kept in the B structure. -The decision to increase or decrease the hash table size is made -depending on the 'load' of the hash table. The load is the number of -items in the hash table divided by the size of the hash table. The -default values are as follows. If (hash->up_load E load) =E -expand. if (hash-Edown_load E load) =E contract. The -B has a default value of 1 and B has a default value -of 2. These numbers can be modified by the application by just -playing with the B and B variables. The 'load' is -kept in a form which is multiplied by 256. So -hash-Eup_load=8*256; will cause a load of 8 to be set. - -If you are interested in performance the field to watch is -num_comp_calls. The hash library keeps track of the 'hash' value for -each item so when a lookup is done, the 'hashes' are compared, if -there is a match, then a full compare is done, and -hash-Enum_comp_calls is incremented. If num_comp_calls is not equal -to num_delete plus num_retrieve it means that your hash function is -generating hashes that are the same for different values. It is -probably worth changing your hash function if this is the case because -even if your hash table has 10 items in a 'bucket', it can be searched -with 10 B compares and 10 linked list traverses. This -will be much less expensive that 10 calls to your compare function. - -lh_strhash() is a demo string hashing function: - - unsigned long lh_strhash(const char *c); - -Since the B routines would normally be passed structures, this -routine would not normally be passed to lh__new(), rather it would be -used in the function passed to lh__new(). - =head1 SEE ALSO L =head1 HISTORY -The B library is available in all versions of SSLeay and OpenSSL. -lh_error() was added in SSLeay 0.9.1b. - -This manpage is derived from the SSLeay documentation. - -In OpenSSL 0.9.7, all lhash functions that were passed function pointers -were changed for better type safety, and the function types LHASH_COMP_FN_TYPE, -LHASH_HASH_FN_TYPE, LHASH_DOALL_FN_TYPE and LHASH_DOALL_ARG_FN_TYPE -became available. - -In OpenSSL 1.0.0, the lhash interface was revamped for even better +In OpenSSL 1.0.0, the lhash interface was revamped for better type checking. =cut diff --git a/doc/crypto/rand.pod b/doc/crypto/rand.pod index 25172d9..27a6787 100644 --- a/doc/crypto/rand.pod +++ b/doc/crypto/rand.pod @@ -25,7 +25,7 @@ rand - pseudo-random number generator void RAND_set_rand_method(const RAND_METHOD *meth); const RAND_METHOD *RAND_get_rand_method(void); - RAND_METHOD *RAND_SSLeay(void); + RAND_METHOD *RAND_OpenSSL(void); void RAND_cleanup(void); @@ -62,108 +62,6 @@ seeding process whenever the application is started. L describes how to obtain random data from the PRNG. -=head1 INTERNALS - -The RAND_SSLeay() method implements a PRNG based on a cryptographic -hash function. - -The following description of its design is based on the SSLeay -documentation: - -First up I will state the things I believe I need for a good RNG. - -=over 4 - -=item 1 - -A good hashing algorithm to mix things up and to convert the RNG 'state' -to random numbers. - -=item 2 - -An initial source of random 'state'. - -=item 3 - -The state should be very large. If the RNG is being used to generate -4096 bit RSA keys, 2 2048 bit random strings are required (at a minimum). -If your RNG state only has 128 bits, you are obviously limiting the -search space to 128 bits, not 2048. I'm probably getting a little -carried away on this last point but it does indicate that it may not be -a bad idea to keep quite a lot of RNG state. It should be easier to -break a cipher than guess the RNG seed data. - -=item 4 - -Any RNG seed data should influence all subsequent random numbers -generated. This implies that any random seed data entered will have -an influence on all subsequent random numbers generated. - -=item 5 - -When using data to seed the RNG state, the data used should not be -extractable from the RNG state. I believe this should be a -requirement because one possible source of 'secret' semi random -data would be a private key or a password. This data must -not be disclosed by either subsequent random numbers or a -'core' dump left by a program crash. - -=item 6 - -Given the same initial 'state', 2 systems should deviate in their RNG state -(and hence the random numbers generated) over time if at all possible. - -=item 7 - -Given the random number output stream, it should not be possible to determine -the RNG state or the next random number. - -=back - -The algorithm is as follows. - -There is global state made up of a 1023 byte buffer (the 'state'), a -working hash value ('md'), and a counter ('count'). - -Whenever seed data is added, it is inserted into the 'state' as -follows. - -The input is chopped up into units of 20 bytes (or less for -the last block). Each of these blocks is run through the hash -function as follows: The data passed to the hash function -is the current 'md', the same number of bytes from the 'state' -(the location determined by in incremented looping index) as -the current 'block', the new key data 'block', and 'count' -(which is incremented after each use). -The result of this is kept in 'md' and also xored into the -'state' at the same locations that were used as input into the -hash function. I -believe this system addresses points 1 (hash function; currently -SHA-1), 3 (the 'state'), 4 (via the 'md'), 5 (by the use of a hash -function and xor). - -When bytes are extracted from the RNG, the following process is used. -For each group of 10 bytes (or less), we do the following: - -Input into the hash function the local 'md' (which is initialized from -the global 'md' before any bytes are generated), the bytes that are to -be overwritten by the random bytes, and bytes from the 'state' -(incrementing looping index). From this digest output (which is kept -in 'md'), the top (up to) 10 bytes are returned to the caller and the -bottom 10 bytes are xored into the 'state'. - -Finally, after we have finished 'num' random bytes for the caller, -'count' (which is incremented) and the local and global 'md' are fed -into the hash function and the results are kept in the global 'md'. - -I believe the above addressed points 1 (use of SHA-1), 6 (by hashing -into the 'state' the 'old' data from the caller that is about to be -overwritten) and 7 (by not using the 10 bytes given to the caller to -update the 'state', but they are used to update 'md'). - -So of the points raised, only 2 is not addressed (but see -L). - =head1 SEE ALSO L, L, diff --git a/doc/crypto/rc4.pod b/doc/crypto/rc4.pod index cbbf5de..af2a609 100644 --- a/doc/crypto/rc4.pod +++ b/doc/crypto/rc4.pod @@ -50,10 +50,6 @@ functions directly. It is difficult to securely use stream ciphers. For example, do not perform multiple encryptions using the same key stream. -=head1 HISTORY - -RC4_set_key() and RC4() are available in all versions of SSLeay and OpenSSL. - =head1 SEE ALSO L diff --git a/doc/crypto/rsa.pod b/doc/crypto/rsa.pod index a1cec7f..ac32415 100644 --- a/doc/crypto/rsa.pod +++ b/doc/crypto/rsa.pod @@ -38,7 +38,7 @@ rsa - RSA public key cryptosystem const RSA_METHOD *RSA_get_default_method(void); int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); const RSA_METHOD *RSA_get_method(const RSA *rsa); - RSA_METHOD *RSA_PKCS1_SSLeay(void); + RSA_METHOD *RSA_PKCS1_OpenSSL(void); RSA_METHOD *RSA_null_method(void); int RSA_flags(const RSA *rsa); RSA *RSA_new_method(ENGINE *engine); diff --git a/doc/crypto/threads.pod b/doc/crypto/threads.pod index fd43a2c..d98b200 100644 --- a/doc/crypto/threads.pod +++ b/doc/crypto/threads.pod @@ -194,10 +194,6 @@ Solaris, Irix and Win32. =head1 HISTORY -CRYPTO_set_locking_callback() is -available in all versions of SSLeay and OpenSSL. -CRYPTO_num_locks() was added in OpenSSL 0.9.4. -All functions dealing with dynamic locks were added in OpenSSL 0.9.5b-dev. B and associated functions were introduced in OpenSSL 1.0.0 to replace (actually, deprecate) the previous CRYPTO_set_id_callback(), CRYPTO_get_id_callback(), and CRYPTO_thread_id() functions which assumed diff --git a/doc/crypto/ui.pod b/doc/crypto/ui.pod index bb4a8a5..f03e989 100644 --- a/doc/crypto/ui.pod +++ b/doc/crypto/ui.pod @@ -183,13 +183,4 @@ UI_set_method() changes the UI method associated with a given UI. L, L -=head1 HISTORY - -The UI section was first introduced in OpenSSL 0.9.7. - -=head1 AUTHOR - -Richard Levitte (richard at levitte.org) for the OpenSSL project -(http://www.openssl.org). - =cut diff --git a/doc/ssl/DTLSv1_listen.pod b/doc/ssl/DTLSv1_listen.pod index d5f5a52..1977916 100644 --- a/doc/ssl/DTLSv1_listen.pod +++ b/doc/ssl/DTLSv1_listen.pod @@ -89,7 +89,6 @@ L, L =head1 HISTORY -DTLSv1_listen() was added in OpenSSL 0.9.8. Its return codes were clarified in -OpenSSL 1.1.0. +DTLSv1_listen() return codes were clarified in OpenSSL 1.1.0. =cut diff --git a/doc/ssl/SSL_CTX_set_cert_verify_callback.pod b/doc/ssl/SSL_CTX_set_cert_verify_callback.pod index 8b802ab..6f6fe56 100644 --- a/doc/ssl/SSL_CTX_set_cert_verify_callback.pod +++ b/doc/ssl/SSL_CTX_set_cert_verify_callback.pod @@ -64,12 +64,4 @@ L, L, L, L -=head1 HISTORY - -Previous to OpenSSL 0.9.7, the I argument to B -was ignored, and I was called simply as - int (*callback)(X509_STORE_CTX *) -To compile software written for previous versions of OpenSSL, a dummy -argument will have to be added to I. - =cut diff --git a/doc/ssl/SSL_CTX_set_generate_session_id.pod b/doc/ssl/SSL_CTX_set_generate_session_id.pod index f66e314..e8459c9 100644 --- a/doc/ssl/SSL_CTX_set_generate_session_id.pod +++ b/doc/ssl/SSL_CTX_set_generate_session_id.pod @@ -123,10 +123,4 @@ same id is already in the cache. L, L -=head1 HISTORY - -SSL_CTX_set_generate_session_id(), SSL_set_generate_session_id() -and SSL_has_matching_session_id() have been introduced in -OpenSSL 0.9.7. - =cut diff --git a/doc/ssl/SSL_CTX_set_max_cert_list.pod b/doc/ssl/SSL_CTX_set_max_cert_list.pod index 1f66b82..080400c 100644 --- a/doc/ssl/SSL_CTX_set_max_cert_list.pod +++ b/doc/ssl/SSL_CTX_set_max_cert_list.pod @@ -70,8 +70,4 @@ set value. L, L, L -=head1 HISTORY - -SSL*_set/get_max_cert_list() have been introduced in OpenSSL 0.9.7. - =cut diff --git a/doc/ssl/SSL_CTX_set_mode.pod b/doc/ssl/SSL_CTX_set_mode.pod index 92706e5e..56f732f 100644 --- a/doc/ssl/SSL_CTX_set_mode.pod +++ b/doc/ssl/SSL_CTX_set_mode.pod @@ -92,8 +92,4 @@ SSL_CTX_get_mode() and SSL_get_mode() return the current bitmask. L, L, L -=head1 HISTORY - -SSL_MODE_AUTO_RETRY as been added in OpenSSL 0.9.6. - =cut diff --git a/doc/ssl/SSL_CTX_set_msg_callback.pod b/doc/ssl/SSL_CTX_set_msg_callback.pod index 07498e3..bcc2a4d 100644 --- a/doc/ssl/SSL_CTX_set_msg_callback.pod +++ b/doc/ssl/SSL_CTX_set_msg_callback.pod @@ -91,9 +91,4 @@ I will be B. L, L -=head1 HISTORY - -SSL_CTX_set_msg_callback(), SSL_CTX_set_msg_callback_arg(), -SSL_set_msg_callback() and SSL_get_msg_callback_arg() were added in OpenSSL 0.9.7. - =cut diff --git a/doc/ssl/SSL_CTX_set_options.pod b/doc/ssl/SSL_CTX_set_options.pod index 519d01f..3a75cda 100644 --- a/doc/ssl/SSL_CTX_set_options.pod +++ b/doc/ssl/SSL_CTX_set_options.pod @@ -61,18 +61,6 @@ The following B options are available: =over 4 -=item SSL_OP_MICROSOFT_SESS_ID_BUG - -As of OpenSSL 1.0.0 this option has no effect. - -=item SSL_OP_NETSCAPE_CHALLENGE_BUG - -As of OpenSSL 1.0.0 this option has no effect. - -=item SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG - -As of OpenSSL 0.9.8q and 1.0.0c, this option has no effect. - =item SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG ... @@ -208,7 +196,7 @@ B section for more details. =head1 SECURE RENEGOTIATION -OpenSSL 0.9.8m and later always attempts to use secure renegotiation as +OpenSSL always attempts to use secure renegotiation as described in RFC5746. This counters the prefix attack described in CVE-2009-3555 and elsewhere. @@ -240,14 +228,6 @@ unaware of the unpatched nature of the client. If the option B is set then renegotiation B succeeds. -B a bug in OpenSSL clients earlier than 0.9.8m (all of which are -unpatched) will result in the connection hanging if it receives a -B alert. OpenSSL versions 0.9.8m and later will regard -a B alert as fatal and respond with a fatal -B alert. This is because the OpenSSL API currently has -no provision to indicate to an application that a renegotiation attempt -was refused. - =head2 Patched OpenSSL client and unpatched server. If the option B or @@ -303,24 +283,7 @@ L =head1 HISTORY -B and -B have been added in -OpenSSL 0.9.7. - -B has been added in OpenSSL 0.9.6 and was automatically -enabled with B. As of 0.9.7, it is no longer included in B -and must be explicitly set. - -B has been added in OpenSSL 0.9.6e. -Versions up to OpenSSL 0.9.6c do not include the countermeasure that -can be disabled with this option (in OpenSSL 0.9.6d, it was always -enabled). - -SSL_CTX_clear_options() and SSL_clear_options() were first added in OpenSSL -0.9.8m. - -B, B -and the function SSL_get_secure_renegotiation_support() were first added in -OpenSSL 0.9.8m. +The attempt to always try to use secure renegotiation was added in +Openssl 0.9.8m. =cut diff --git a/doc/ssl/SSL_CTX_set_session_cache_mode.pod b/doc/ssl/SSL_CTX_set_session_cache_mode.pod index 0e0ea3c..4be9e24 100644 --- a/doc/ssl/SSL_CTX_set_session_cache_mode.pod +++ b/doc/ssl/SSL_CTX_set_session_cache_mode.pod @@ -129,9 +129,4 @@ L, L, L -=head1 HISTORY - -SSL_SESS_CACHE_NO_INTERNAL_STORE and SSL_SESS_CACHE_NO_INTERNAL -were introduced in OpenSSL 0.9.6h. - =cut diff --git a/doc/ssl/SSL_CTX_set_tlsext_ticket_key_cb.pod b/doc/ssl/SSL_CTX_set_tlsext_ticket_key_cb.pod index 1169e9b..e8b973f 100644 --- a/doc/ssl/SSL_CTX_set_tlsext_ticket_key_cb.pod +++ b/doc/ssl/SSL_CTX_set_tlsext_ticket_key_cb.pod @@ -185,8 +185,4 @@ L, L, L, -=head1 HISTORY - -This function was introduced in OpenSSL 0.9.8h - =cut diff --git a/doc/ssl/SSL_CTX_use_certificate.pod b/doc/ssl/SSL_CTX_use_certificate.pod index 76c4883..2bb0ea6 100644 --- a/doc/ssl/SSL_CTX_use_certificate.pod +++ b/doc/ssl/SSL_CTX_use_certificate.pod @@ -157,10 +157,4 @@ L, L, L -=head1 HISTORY - -Support for DER encoded private keys (SSL_FILETYPE_ASN1) in -SSL_CTX_use_PrivateKey_file() and SSL_use_PrivateKey_file() was added -in 0.9.8 . - =cut diff --git a/doc/ssl/SSL_get_error.pod b/doc/ssl/SSL_get_error.pod index 015f2c7..d52c27d 100644 --- a/doc/ssl/SSL_get_error.pod +++ b/doc/ssl/SSL_get_error.pod @@ -107,8 +107,4 @@ OpenSSL error queue contains more information on the error. L, L -=head1 HISTORY - -SSL_get_error() was added in SSLeay 0.8. - =cut diff --git a/doc/ssl/SSL_library_init.pod b/doc/ssl/SSL_library_init.pod index 1c99e76..ab9d05d 100644 --- a/doc/ssl/SSL_library_init.pod +++ b/doc/ssl/SSL_library_init.pod @@ -43,12 +43,6 @@ and provide readable error messages. SSL_library_init() always returns "1", so it is safe to discard the return value. -=head1 NOTES - -OpenSSL 0.9.8o and 1.0.0a and later added SHA2 algorithms to SSL_library_init(). -Applications which need to use SHA2 in earlier versions of OpenSSL should call -OpenSSL_add_all_algorithms() as well. - =head1 SEE ALSO L, L, diff --git a/doc/ssl/SSL_pending.pod b/doc/ssl/SSL_pending.pod index a263241..c6a79dc 100644 --- a/doc/ssl/SSL_pending.pod +++ b/doc/ssl/SSL_pending.pod @@ -34,9 +34,6 @@ L), additional protocol bytes may have been read containing more TLS/SSL records; these are ignored by SSL_pending(). -Up to OpenSSL 0.9.6, SSL_pending() does not check if the record type -of pending data is application data. - =head1 SEE ALSO L, diff --git a/doc/ssl/ssl.pod b/doc/ssl/ssl.pod index 3466ee4..37046c1 100644 --- a/doc/ssl/ssl.pod +++ b/doc/ssl/ssl.pod @@ -759,8 +759,6 @@ L =head1 HISTORY -The L document appeared in OpenSSL 0.9.2 - B, B and B where removed in OpenSSL 1.1.0. From rsalz at openssl.org Thu Oct 29 19:26:13 2015 From: rsalz at openssl.org (Rich Salz) Date: Thu, 29 Oct 2015 19:26:13 +0000 Subject: [openssl-commits] [web] master update Message-ID: <1446146773.062039.2702.nullmailer@dev.openssl.org> The branch master has been updated via 85a91384a31f8ca359dae220bf4d2cc63f0d1f18 (commit) from 98dd590bb12c298a62e39a175b2b66511c3fb9bd (commit) - Log ----------------------------------------------------------------- commit 85a91384a31f8ca359dae220bf4d2cc63f0d1f18 Author: Viktor Szakats Date: Thu Oct 29 20:15:25 2015 +0100 use secure URLs in secadv docs Also remove some trailing whitespace. Signed-off-by: Rich Salz ----------------------------------------------------------------------- Summary of changes: docs/faq.txt | 16 ++++++++-------- news/secadv/20020730.txt | 16 ++++++++-------- news/secadv/20030219.txt | 6 +++--- news/secadv/20030319.txt | 8 ++++---- news/secadv/20030930.txt | 8 ++++---- news/secadv/20031104.txt | 8 ++++---- news/secadv/20040317.txt | 8 ++++---- news/secadv/20051011.txt | 10 +++++----- news/secadv/20060905.txt | 10 +++++----- news/secadv/20060928.txt | 6 +++--- news/secadv/20071129.txt | 8 ++++---- news/secadv/20090107.txt | 2 +- news/secadv/20090325.txt | 2 +- news/secadv/20091111.txt | 4 ++-- news/secadv/20100324.txt | 2 +- news/secadv/20100601.txt | 2 +- news/secadv/20101116-2.txt | 2 +- news/secadv/20101116.txt | 2 +- news/secadv/20101202.txt | 4 ++-- news/secadv/20110208.txt | 2 +- news/secadv/20110906.txt | 2 +- news/secadv/20120104.txt | 2 +- news/secadv/20120118.txt | 2 +- news/secadv/20120312.txt | 2 +- news/secadv/20120419.txt | 2 +- news/secadv/20120424.txt | 4 ++-- news/secadv/20120510.txt | 2 +- news/secadv/20130205.txt | 2 +- news/secadv/20140605.txt | 2 +- news/secadv/20140806.txt | 2 +- news/secadv/20150108.txt | 3 +-- news/secadv/prng.txt | 4 ++-- support/acks.html | 2 +- 33 files changed, 78 insertions(+), 79 deletions(-) mode change 100644 => 100755 news/secadv/20020730.txt mode change 100644 => 100755 news/secadv/20030219.txt mode change 100644 => 100755 news/secadv/20030319.txt mode change 100644 => 100755 news/secadv/20030930.txt mode change 100644 => 100755 news/secadv/20031104.txt mode change 100644 => 100755 news/secadv/20040317.txt mode change 100644 => 100755 news/secadv/20051011.txt mode change 100644 => 100755 news/secadv/20060905.txt mode change 100644 => 100755 news/secadv/20060928.txt mode change 100644 => 100755 news/secadv/20071129.txt mode change 100644 => 100755 news/secadv/20090107.txt mode change 100644 => 100755 news/secadv/20090325.txt mode change 100644 => 100755 news/secadv/20091111.txt mode change 100644 => 100755 news/secadv/20100324.txt mode change 100644 => 100755 news/secadv/20100601.txt mode change 100644 => 100755 news/secadv/20101116-2.txt mode change 100644 => 100755 news/secadv/20101116.txt mode change 100644 => 100755 news/secadv/20101202.txt mode change 100644 => 100755 news/secadv/20110208.txt mode change 100644 => 100755 news/secadv/20110906.txt mode change 100644 => 100755 news/secadv/20120104.txt mode change 100644 => 100755 news/secadv/20120118.txt mode change 100644 => 100755 news/secadv/20120312.txt mode change 100644 => 100755 news/secadv/20120419.txt mode change 100644 => 100755 news/secadv/20120424.txt mode change 100644 => 100755 news/secadv/20120510.txt mode change 100644 => 100755 news/secadv/20130205.txt mode change 100644 => 100755 news/secadv/20140605.txt mode change 100644 => 100755 news/secadv/20140806.txt mode change 100644 => 100755 news/secadv/prng.txt diff --git a/docs/faq.txt b/docs/faq.txt index 85b8092..dde39c0 100644 --- a/docs/faq.txt +++ b/docs/faq.txt @@ -15,7 +15,7 @@ OpenSSL - Frequently Asked Questions [LEGAL] Legal questions * Do I need patent licenses to use OpenSSL? -* Can I use OpenSSL with GPL software? +* Can I use OpenSSL with GPL software? [USER] Questions on using the OpenSSL applications @@ -174,9 +174,9 @@ just do: * How does the versioning scheme work? -After the release of OpenSSL 1.0.0 the versioning scheme changed. Letter +After the release of OpenSSL 1.0.0 the versioning scheme changed. Letter releases (e.g. 1.0.1a) can only contain bug and security fixes and no -new features. Minor releases change the last number (e.g. 1.0.2) and +new features. Minor releases change the last number (e.g. 1.0.2) and can contain new features that retain binary compatibility. Changes to the middle number are considered major releases and neither source nor binary compatibility is guaranteed. @@ -543,7 +543,7 @@ that the OpenSSL bntest throws at it. This gets triggered when you run the test suite (using "make test"). The message returned is "bc: stack empty". The best way to deal with this is to find another implementation of bc -and compile/install it. GNU bc (see +and compile/install it. GNU bc (see for download instructions) can be safely used, for example. @@ -582,7 +582,7 @@ This will only compile sha_dgst.c with -O0, the rest with the optimization level chosen by the configuration process. When the above is done, do the test and installation and you're set. -3. Reconfigure the toolkit with no-sha0 option to leave out SHA0. It +3. Reconfigure the toolkit with no-sha0 option to leave out SHA0. It should not be used and is not used in SSL/TLS nor any other recognized protocol in either case. @@ -774,14 +774,14 @@ See also * I've found a security issue, how do I report it? If you think your bug has security implications then please send it to -openssl-security at openssl.org if you don't get a prompt reply at least +openssl-security at openssl.org if you don't get a prompt reply at least acknowledging receipt then resend or mail it directly to one of the more active team members (e.g. Steve). If you wish to use PGP to send in a report please use one or more of the keys of the team members listed at Note that bugs only present in the openssl utility are not in general -considered to be security issues. +considered to be security issues. [PROG] ======================================================================== @@ -931,7 +931,7 @@ macros with a C++ compiler. There is hardly ever any need to use the PKCS#12 macros in a program, it is much easier to parse and create PKCS#12 files using the PKCS12_parse() and PKCS12_create() functions documented in doc/openssl.txt and with examples in demos/pkcs12. The -'pkcs12' application has to use the macros because it prints out +'pkcs12' application has to use the macros because it prints out debugging information. diff --git a/news/secadv/20020730.txt b/news/secadv/20020730.txt old mode 100644 new mode 100755 index 918b764..464307c --- a/news/secadv/20020730.txt +++ b/news/secadv/20020730.txt @@ -56,7 +56,7 @@ Apply the attached patch to OpenSSL 0.9.6d, or upgrade to OpenSSL TLS. A patch for 0.9.7 is available from the OpenSSL website -(http://www.openssl.org/). +(https://www.openssl.org/). Servers can disable SSL2, alternatively disable all applications using SSL or TLS until the patches are applied. Users of 0.9.7 pre-release @@ -74,9 +74,9 @@ possible, but have not released the exploit code. References ---------- -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0655 -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0656 -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0657 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0655 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0656 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0657 Acknowledgements ---------------- @@ -126,7 +126,7 @@ There are no known exploits for this vulnerability. References ---------- -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0659 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2002-0659 Acknowledgements ---------------- @@ -141,10 +141,10 @@ The patch and advisory were prepared by Dr. Stephen Henson. Combined patches for OpenSSL 0.9.6d: -http://www.openssl.org/news/patch_20020730_0_9_6d.txt +https://www.openssl.org/news/patch_20020730_0_9_6d.txt Combined patches for OpenSSL 0.9.7 beta 2: -http://www.openssl.org/news/patch_20020730_0_9_7.txt +https://www.openssl.org/news/patch_20020730_0_9_7.txt URL for this Security Advisory: -http://www.openssl.org/news/secadv_20020730.txt +https://www.openssl.org/news/secadv_20020730.txt diff --git a/news/secadv/20030219.txt b/news/secadv/20030219.txt old mode 100644 new mode 100755 index 647373a..d8266ba --- a/news/secadv/20030219.txt +++ b/news/secadv/20030219.txt @@ -48,7 +48,7 @@ plaintext block. OpenSSL version since 0.9.6c supposedly treat block cipher padding errors like MAC verification errors during record decryption -(see http://www.openssl.org/~bodo/tls-cbc.txt), but MAC verification +(see https://www.openssl.org/~bodo/tls-cbc.txt), but MAC verification was still skipped after detection of a padding error, which allowed the timing attack. (Note that it is likely that other SSL/TLS implementations will have similar problems.) @@ -208,7 +208,7 @@ http://lasecwww.epfl.ch/memo_ssl.shtml The Common Vulnerabilities and Exposures project (cve.mitre.org) has assigned the name CAN-2003-0078 to this issue: -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0078 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0078 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20030219.txt +https://www.openssl.org/news/secadv_20030219.txt diff --git a/news/secadv/20030319.txt b/news/secadv/20030319.txt old mode 100644 new mode 100755 index f868198..778f9e2 --- a/news/secadv/20030319.txt +++ b/news/secadv/20030319.txt @@ -44,7 +44,7 @@ The following patch can be applied to OpenSSL releases 0.9.6b up to 0.9.6i, + /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ + + /* The Klima-Pokorny-Rosa extension of Bleichenbacher's attack -+ * (http://eprint.iacr.org/2003/052/) exploits the version ++ * (https://eprint.iacr.org/2003/052/) exploits the version + * number check as a "bad version oracle" -- an alert would + * reveal that the plaintext corresponding to some ciphertext + * made up by the adversary is properly formatted except @@ -84,11 +84,11 @@ References Report "Attacking RSA-based Sessions in SSL/TLS" by V. Klima, O. Pokorny, and T. Rosa: -http://eprint.iacr.org/2003/052/ +https://eprint.iacr.org/2003/052/ The Common Vulnerabilities and Exposures project (cve.mitre.org) has assigned the name CAN-2003-0131 to this issue. -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0131 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0131 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20030319.txt +https://www.openssl.org/news/secadv_20030319.txt diff --git a/news/secadv/20030930.txt b/news/secadv/20030930.txt old mode 100644 new mode 100755 index 72aee84..ad0b90e --- a/news/secadv/20030930.txt +++ b/news/secadv/20030930.txt @@ -61,12 +61,12 @@ References The Common Vulnerabilities and Exposures project (cve.mitre.org) has assigned the name CAN-2003-0545 for issue 1: -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0545 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0545 and CAN-2003-0543 and CAN-2003-0544 for issue 2: -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0543 -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0544 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0543 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0544 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20030930.txt +https://www.openssl.org/news/secadv_20030930.txt diff --git a/news/secadv/20031104.txt b/news/secadv/20031104.txt old mode 100644 new mode 100755 index 2cd2fb8..31b332c --- a/news/secadv/20031104.txt +++ b/news/secadv/20031104.txt @@ -42,9 +42,9 @@ applications statically linked to OpenSSL libraries. OpenSSL 0.9.6l is available for download via HTTP and FTP from the following master locations (you can find the various FTP mirrors under -http://www.openssl.org/source/mirror.html): +https://www.openssl.org/source/mirror.html): - o http://www.openssl.org/source/ + o https://www.openssl.org/source/ o ftp://ftp.openssl.org/source/ The distribution file name is: @@ -65,7 +65,7 @@ References The Common Vulnerabilities and Exposures project (cve.mitre.org) has assigned the name CAN-2003-0851 to this issue. -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0851 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2003-0851 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20031104.txt +https://www.openssl.org/news/secadv_20031104.txt diff --git a/news/secadv/20040317.txt b/news/secadv/20040317.txt old mode 100644 new mode 100755 index daf0b67..15879c6 --- a/news/secadv/20040317.txt +++ b/news/secadv/20040317.txt @@ -48,7 +48,7 @@ statically linked to OpenSSL libraries. OpenSSL 0.9.7d and OpenSSL 0.9.6m are available for download via HTTP and FTP from the following master locations (you can find the various FTP -mirrors under http://www.openssl.org/source/mirror.html): +mirrors under https://www.openssl.org/source/mirror.html): ftp://ftp.openssl.org/source/ @@ -79,10 +79,10 @@ References ---------- http://www.codenomicon.com/testtools/tls/ -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0079 -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0112 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0079 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0112 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20040317.txt +https://www.openssl.org/news/secadv_20040317.txt diff --git a/news/secadv/20051011.txt b/news/secadv/20051011.txt old mode 100644 new mode 100755 index c4fd001..1fadb6f --- a/news/secadv/20051011.txt +++ b/news/secadv/20051011.txt @@ -63,9 +63,9 @@ following measures is sufficient. OpenSSL 0.9.8a and OpenSSL 0.9.7h are available for download via HTTP and FTP from the following master locations (you can find the - various FTP mirrors under http://www.openssl.org/source/mirror.html): + various FTP mirrors under https://www.openssl.org/source/mirror.html): - o http://www.openssl.org/source/ + o https://www.openssl.org/source/ o ftp://ftp.openssl.org/source/ The distribution file names are: @@ -88,7 +88,7 @@ following measures is sufficient. source code to resolve the problem. The patch is compatible with the 0.9.6, 0.9.7, and 0.9.8 branches of OpenSSL. - o http://www.openssl.org/news/patch-CAN-2005-2969.txt + o https://www.openssl.org/news/patch-CAN-2005-2969.txt Whether you choose to upgrade to a new version or to apply the patch, make sure to recompile any applications statically linked @@ -108,7 +108,7 @@ problem. References ---------- -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-2969 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-2969 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20051011.txt +https://www.openssl.org/news/secadv_20051011.txt diff --git a/news/secadv/20060905.txt b/news/secadv/20060905.txt old mode 100644 new mode 100755 index 45c9e7f..9865eee --- a/news/secadv/20060905.txt +++ b/news/secadv/20060905.txt @@ -38,9 +38,9 @@ following measures is sufficient. OpenSSL 0.9.8c and OpenSSL 0.9.7k are available for download via HTTP and FTP from the following master locations (you can find the - various FTP mirrors under http://www.openssl.org/source/mirror.html): + various FTP mirrors under https://www.openssl.org/source/mirror.html): - o http://www.openssl.org/source/ + o https://www.openssl.org/source/ o ftp://ftp.openssl.org/source/ The distribution file names are: @@ -63,7 +63,7 @@ following measures is sufficient. source code to resolve the problem. The patch is compatible with the 0.9.6, 0.9.7, 0.9.8, and 0.9.9 branches of OpenSSL. - o http://www.openssl.org/news/patch-CVE-2006-4339.txt + o https://www.openssl.org/news/patch-CVE-2006-4339.txt Whether you choose to upgrade to a new version or to apply the patch, make sure to recompile any applications statically linked to OpenSSL @@ -82,9 +82,9 @@ to fix the problems. References ---------- -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-4339 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-4339 http://www.imc.org/ietf-openpgp/mail-archive/msg14307.html URL for this Security Advisory: -http://www.openssl.org/news/secadv_20060905.txt +https://www.openssl.org/news/secadv_20060905.txt diff --git a/news/secadv/20060928.txt b/news/secadv/20060928.txt old mode 100644 new mode 100755 index 9c2c1e1..50a2f09 --- a/news/secadv/20060928.txt +++ b/news/secadv/20060928.txt @@ -79,9 +79,9 @@ These vulnerabilities are resolved in the following versions of OpenSSL: OpenSSL 0.9.8d and OpenSSL 0.9.7l are available for download via HTTP and FTP from the following master locations (you can find the -various FTP mirrors under http://www.openssl.org/source/mirror.html): +various FTP mirrors under https://www.openssl.org/source/mirror.html): - o http://www.openssl.org/source/ + o https://www.openssl.org/source/ o ftp://ftp.openssl.org/source/ The distribution file names are: @@ -108,4 +108,4 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20060928.txt +https://www.openssl.org/news/secadv_20060928.txt diff --git a/news/secadv/20071129.txt b/news/secadv/20071129.txt old mode 100644 new mode 100755 index 52e7c5f..d3f0be3 --- a/news/secadv/20071129.txt +++ b/news/secadv/20071129.txt @@ -4,7 +4,7 @@ OpenSSL FIPS Object Module Vulnerabilities ------------------------------------------ A significant flaw in the PRNG implementation for the OpenSSL FIPS Object -Module v1.1.1 (http://openssl.org/source/openssl-fips-1.1.1.tar.gz, FIPS +Module v1.1.1 (https://www.openssl.org/source/openssl-fips-1.1.1.tar.gz, FIPS 140-2 validation certificate #733, http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140val-all.htm#733) has been reported by Geoff Lowe of Secure Computing Corporation. Due to a coding @@ -32,11 +32,11 @@ Wait for official approval of a patched distribution. For reference purposes the patches - http://www.openssl.org/news/patch-CVE-2007-5502-1.txt + https://www.openssl.org/news/patch-CVE-2007-5502-1.txt (the simplest direct fix) and: - http://www.openssl.org/news/patch-CVE-2007-5502-2.txt + https://www.openssl.org/news/patch-CVE-2007-5502-2.txt (a workaround which avoids touching the PRNG code directly) demonstrate two different fixes that independently address the vulnerability. However, for @@ -49,7 +49,7 @@ Institute (OSSI), has supplied the information needed for a "letter change" update request based on the latter of these two patches to the FIPS 140-2 test lab to be submitted for official approval. Once (and if) approved the new distribution containing this patch will be posted as -http://openssl.org/source/openssl-fips-1.1.2.tar.gz. The timeline for this +https://www.openssl.org/source/openssl-fips-1.1.2.tar.gz. The timeline for this approval is presently unknown. diff --git a/news/secadv/20090107.txt b/news/secadv/20090107.txt old mode 100644 new mode 100755 index b2816c9..4e06b88 --- a/news/secadv/20090107.txt +++ b/news/secadv/20090107.txt @@ -63,7 +63,7 @@ References =========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20090107.txt +https://www.openssl.org/news/secadv_20090107.txt diff -ur openssl-0.9.8i-ORIG/apps/speed.c openssl-0.9.8i/apps/speed.c diff --git a/news/secadv/20090325.txt b/news/secadv/20090325.txt old mode 100644 new mode 100755 index 4e90a20..de84b65 --- a/news/secadv/20090325.txt +++ b/news/secadv/20090325.txt @@ -60,5 +60,5 @@ References =========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20090325.txt +https://www.openssl.org/news/secadv_20090325.txt diff --git a/news/secadv/20091111.txt b/news/secadv/20091111.txt old mode 100644 new mode 100755 index 62af9e9..b21eec9 --- a/news/secadv/20091111.txt +++ b/news/secadv/20091111.txt @@ -83,11 +83,11 @@ References =========== CVE-2009-3555: -http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-3555 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-3555 TLS extension: https://svn.resiprocate.org/rep/ietf-drafts/ekr/draft-rescorla-tls-renegotiate.txt URL for this Security Advisory: -http://www.openssl.org/news/secadv_20091111.txt +https://www.openssl.org/news/secadv_20091111.txt diff --git a/news/secadv/20100324.txt b/news/secadv/20100324.txt old mode 100644 new mode 100755 index aabb4d3..0127494 --- a/news/secadv/20100324.txt +++ b/news/secadv/20100324.txt @@ -45,4 +45,4 @@ References This vulnerability is tracked as CVE-2010-0740. URL for this Security Advisory: -http://www.openssl.org/news/secadv_20100324.txt +https://www.openssl.org/news/secadv_20100324.txt diff --git a/news/secadv/20100601.txt b/news/secadv/20100601.txt old mode 100644 new mode 100755 index 6d874e3..709370c --- a/news/secadv/20100601.txt +++ b/news/secadv/20100601.txt @@ -41,5 +41,5 @@ References =========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20100601.txt +https://www.openssl.org/news/secadv_20100601.txt diff --git a/news/secadv/20101116-2.txt b/news/secadv/20101116-2.txt old mode 100644 new mode 100755 index e624bb3..4d6e0bf --- a/news/secadv/20101116-2.txt +++ b/news/secadv/20101116-2.txt @@ -203,6 +203,6 @@ References =========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20101116-2.txt +https://www.openssl.org/news/secadv_20101116-2.txt diff --git a/news/secadv/20101116.txt b/news/secadv/20101116.txt old mode 100644 new mode 100755 index 7273c81..bc392f1 --- a/news/secadv/20101116.txt +++ b/news/secadv/20101116.txt @@ -199,6 +199,6 @@ References =========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20101116.txt +https://www.openssl.org/news/secadv_20101116.txt diff --git a/news/secadv/20101202.txt b/news/secadv/20101202.txt old mode 100644 new mode 100755 index 22a31c6..0d4d91a --- a/news/secadv/20101202.txt +++ b/news/secadv/20101202.txt @@ -119,9 +119,9 @@ References =========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20101202.txt +https://www.openssl.org/news/secadv_20101202.txt URL for updated CVS-2010-3864 Security Advisory: -http://www.openssl.org/news/secadv_20101116-2.txt +https://www.openssl.org/news/secadv_20101116-2.txt diff --git a/news/secadv/20110208.txt b/news/secadv/20110208.txt old mode 100644 new mode 100755 index 9c1e951..ee46181 --- a/news/secadv/20110208.txt +++ b/news/secadv/20110208.txt @@ -72,7 +72,7 @@ References This vulnerability is tracked as CVE-2011-0014. URL for this Security Advisory: -http://www.openssl.org/news/secadv_20110208.txt +https://www.openssl.org/news/secadv_20110208.txt OCSP stapling is defined in RFC 6066 (previously RFC 3546), section "Certificate Status Request". diff --git a/news/secadv/20110906.txt b/news/secadv/20110906.txt old mode 100644 new mode 100755 index f95aa02..db8cba1 --- a/news/secadv/20110906.txt +++ b/news/secadv/20110906.txt @@ -58,5 +58,5 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20110906.txt +https://www.openssl.org/news/secadv_20110906.txt diff --git a/news/secadv/20120104.txt b/news/secadv/20120104.txt old mode 100644 new mode 100755 index 6763fb4..d015463 --- a/news/secadv/20120104.txt +++ b/news/secadv/20120104.txt @@ -105,5 +105,5 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20120104.txt +https://www.openssl.org/news/secadv_20120104.txt diff --git a/news/secadv/20120118.txt b/news/secadv/20120118.txt old mode 100644 new mode 100755 index 64d3502..4ac82c3 --- a/news/secadv/20120118.txt +++ b/news/secadv/20120118.txt @@ -19,5 +19,5 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20120118.txt +https://www.openssl.org/news/secadv_20120118.txt diff --git a/news/secadv/20120312.txt b/news/secadv/20120312.txt old mode 100644 new mode 100755 index d584f62..1ee42d9 --- a/news/secadv/20120312.txt +++ b/news/secadv/20120312.txt @@ -29,5 +29,5 @@ References RFC3218 URL for this Security Advisory: -http://www.openssl.org/news/secadv_20120312.txt +https://www.openssl.org/news/secadv_20120312.txt diff --git a/news/secadv/20120419.txt b/news/secadv/20120419.txt old mode 100644 new mode 100755 index ca9bd34..617f8d7 --- a/news/secadv/20120419.txt +++ b/news/secadv/20120419.txt @@ -35,6 +35,6 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20120419.txt +https://www.openssl.org/news/secadv_20120419.txt diff --git a/news/secadv/20120424.txt b/news/secadv/20120424.txt old mode 100644 new mode 100755 index 5929329..21ff332 --- a/news/secadv/20120424.txt +++ b/news/secadv/20120424.txt @@ -7,7 +7,7 @@ ASN1 BIO incomplete fix (CVE-2012-2131) It was discovered that the fix for CVE-2012-2110 released on 19 Apr 2012 was not sufficient to correct the issue for OpenSSL 0.9.8. -Please see http://www.openssl.org/news/secadv_20120419.txt for details +Please see https://www.openssl.org/news/secadv_20120419.txt for details of that vulnerability. This issue only affects OpenSSL 0.9.8v. OpenSSL 1.0.1a and 1.0.0i @@ -21,4 +21,4 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20120424.txt +https://www.openssl.org/news/secadv_20120424.txt diff --git a/news/secadv/20120510.txt b/news/secadv/20120510.txt old mode 100644 new mode 100755 index 441b835..be085ed --- a/news/secadv/20120510.txt +++ b/news/secadv/20120510.txt @@ -22,6 +22,6 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20120510.txt +https://www.openssl.org/news/secadv_20120510.txt diff --git a/news/secadv/20130205.txt b/news/secadv/20130205.txt old mode 100644 new mode 100755 index 4d4a610..1a278f6 --- a/news/secadv/20130205.txt +++ b/news/secadv/20130205.txt @@ -57,7 +57,7 @@ Affected users should upgrade to OpenSSL 1.0.1d, 1.0.0k or 0.9.8y. References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20130204.txt +https://www.openssl.org/news/secadv_20130204.txt Wikipedia AES-NI description: https://en.wikipedia.org/wiki/AES-NI diff --git a/news/secadv/20140605.txt b/news/secadv/20140605.txt old mode 100644 new mode 100755 index a86051d..514929e --- a/news/secadv/20140605.txt +++ b/news/secadv/20140605.txt @@ -117,7 +117,7 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20140605.txt +https://www.openssl.org/news/secadv_20140605.txt Note: the online version of the advisory may be updated with additional details over time. diff --git a/news/secadv/20140806.txt b/news/secadv/20140806.txt old mode 100644 new mode 100755 index d2e7e53..0146712 --- a/news/secadv/20140806.txt +++ b/news/secadv/20140806.txt @@ -157,7 +157,7 @@ References ========== URL for this Security Advisory: -http://www.openssl.org/news/secadv_20140806.txt +https://www.openssl.org/news/secadv_20140806.txt Note: the online version of the advisory may be updated with additional details over time. diff --git a/news/secadv/20150108.txt b/news/secadv/20150108.txt index a4e68a8..c3fe15f 100644 --- a/news/secadv/20150108.txt +++ b/news/secadv/20150108.txt @@ -193,7 +193,7 @@ conducted by the OpenSSL development team and Adam Langley of Google. The final fix was developed by Andy Polyakov of the OpenSSL core team. -[1] http://css.csail.mit.edu/6.858/2013/readings/rsa-bug-attacks.pdf +[1] https://css.csail.mit.edu/6.858/2013/readings/rsa-bug-attacks.pdf Note ==== @@ -215,4 +215,3 @@ details over time. For details of OpenSSL severity classifications please see: https://www.openssl.org/about/secpolicy.html - diff --git a/news/secadv/prng.txt b/news/secadv/prng.txt old mode 100644 new mode 100755 index a923174..981b062 --- a/news/secadv/prng.txt +++ b/news/secadv/prng.txt @@ -23,7 +23,7 @@ MD5 checksums: openssl-engine-0.9.6b.tar.gz ab5ca5b157459c49bdab06a7db8a5a47 OpenSSL source code can also be obtained from a number of mirror sites. -For a list, see . +For a list, see . If you are using a pre-compiled OpenSSL package, please look for update information from the respective software distributor. The OpenSSL @@ -216,4 +216,4 @@ for discovering the PRNG problem and bringing it to our attention. URL for this Security Advisory: -http://www.openssl.org/news/secadv_prng.txt +https://www.openssl.org/news/secadv_prng.txt diff --git a/support/acks.html b/support/acks.html index 0118b3e..29bb761 100644 --- a/support/acks.html +++ b/support/acks.html @@ -25,7 +25,7 @@

    Exceptional support:

    -
    + From kurt at openssl.org Thu Oct 29 19:36:00 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Thu, 29 Oct 2015 19:36:00 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1446147360.054705.3975.nullmailer@dev.openssl.org> The branch master has been updated via 94b3664a528258df5ebcaae213d19bf6568cc47d (commit) from a528d4f0a9a71405f3ca06e20cbd27aa1b8c0df9 (commit) - Log ----------------------------------------------------------------- commit 94b3664a528258df5ebcaae213d19bf6568cc47d Author: Pascal Cuoq Date: Mon Oct 12 12:19:19 2015 +0200 BN_GF2m_mod_inv(): check bn_wexpand return value Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1276, RT #4107 ----------------------------------------------------------------------- Summary of changes: crypto/bn/bn_gf2m.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 3b6c883..11d00c6 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -697,18 +697,21 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int top = p->top; BN_ULONG *udp, *bdp, *vdp, *cdp; - bn_wexpand(u, top); + if (!bn_wexpand(u, top)) + goto err; udp = u->d; for (i = u->top; i < top; i++) udp[i] = 0; u->top = top; - bn_wexpand(b, top); + if (!bn_wexpand(b, top)) + goto err; bdp = b->d; bdp[0] = 1; for (i = 1; i < top; i++) bdp[i] = 0; b->top = top; - bn_wexpand(c, top); + if (!bn_wexpand(c, top)) + goto err; cdp = c->d; for (i = 0; i < top; i++) cdp[i] = 0; From kurt at openssl.org Thu Oct 29 19:41:07 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Thu, 29 Oct 2015 19:41:07 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_2-stable update Message-ID: <1446147667.359998.5595.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_2-stable has been updated via dfb23a5ac80bb9a74bd1f44a90ccff54bc3a8c31 (commit) from b62a2f8a373d1889672599834acf95161f2883ce (commit) - Log ----------------------------------------------------------------- commit dfb23a5ac80bb9a74bd1f44a90ccff54bc3a8c31 Author: Pascal Cuoq Date: Mon Oct 12 12:19:19 2015 +0200 BN_GF2m_mod_inv(): check bn_wexpand return value Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1276, RT #4107 (cherry picked from commit 94b3664a528258df5ebcaae213d19bf6568cc47d) ----------------------------------------------------------------------- Summary of changes: crypto/bn/bn_gf2m.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index e48ca95..2c61da1 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -699,18 +699,21 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int top = p->top; BN_ULONG *udp, *bdp, *vdp, *cdp; - bn_wexpand(u, top); + if (!bn_wexpand(u, top)) + goto err; udp = u->d; for (i = u->top; i < top; i++) udp[i] = 0; u->top = top; - bn_wexpand(b, top); + if (!bn_wexpand(b, top)) + goto err; bdp = b->d; bdp[0] = 1; for (i = 1; i < top; i++) bdp[i] = 0; b->top = top; - bn_wexpand(c, top); + if (!bn_wexpand(c, top)) + goto err; cdp = c->d; for (i = 0; i < top; i++) cdp[i] = 0; From kurt at openssl.org Thu Oct 29 19:44:11 2015 From: kurt at openssl.org (Kurt Roeckx) Date: Thu, 29 Oct 2015 19:44:11 +0000 Subject: [openssl-commits] [openssl] OpenSSL_1_0_1-stable update Message-ID: <1446147851.430271.6477.nullmailer@dev.openssl.org> The branch OpenSSL_1_0_1-stable has been updated via 9f82c7b3aa125b8a91905f61836d79d96d62d5c6 (commit) from 200c8ed4f5dd5fce21a3688c2f41d474a3aceca4 (commit) - Log ----------------------------------------------------------------- commit 9f82c7b3aa125b8a91905f61836d79d96d62d5c6 Author: Pascal Cuoq Date: Mon Oct 12 12:19:19 2015 +0200 BN_GF2m_mod_inv(): check bn_wexpand return value Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1276, RT #4107 (cherry picked from commit 94b3664a528258df5ebcaae213d19bf6568cc47d) ----------------------------------------------------------------------- Summary of changes: crypto/bn/bn_gf2m.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index a7a04f8..8ad44b4 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -700,18 +700,21 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int top = p->top; BN_ULONG *udp, *bdp, *vdp, *cdp; - bn_wexpand(u, top); + if (!bn_wexpand(u, top)) + goto err; udp = u->d; for (i = u->top; i < top; i++) udp[i] = 0; u->top = top; - bn_wexpand(b, top); + if (!bn_wexpand(b, top)) + goto err; bdp = b->d; bdp[0] = 1; for (i = 1; i < top; i++) bdp[i] = 0; b->top = top; - bn_wexpand(c, top); + if (!bn_wexpand(c, top)) + goto err; cdp = c->d; for (i = 0; i < top; i++) cdp[i] = 0; From matt at openssl.org Fri Oct 30 09:06:18 2015 From: matt at openssl.org (Matt Caswell) Date: Fri, 30 Oct 2015 09:06:18 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1446195978.545860.3672.nullmailer@dev.openssl.org> The branch master has been updated via b7fa1f989d0059ad7b992c11797f37f095d61204 (commit) via bb3e20cf8c5e733c16fe68ce41f67eea5a2a520e (commit) via 956de7b2873e0dde61b287049cd0eb35756b6207 (commit) via fed1767436f626bc43140182442567340bd8bd34 (commit) via 141eb8c679a316278651d1e50b2259a989e030c9 (commit) via 8481f583d3aebd7383ba5824bfbe854242231e1b (commit) via be3583fa40a2658cbbcf73320f75e9d674bb39f4 (commit) via 3616bb63586df04b22de00f49bc92d92dff1b8b6 (commit) via 006207d1bc39335b9cb474e6c9a4ca96a33bae46 (commit) via c9de4a20fa21101208cf311c5437d9c358ba1f07 (commit) via d13dd4beb4674689c7a46450dbb8bae9af24d510 (commit) via 9b67c0d810a4842096cb73702c59a1320805f912 (commit) via f0659bdb0014afda3585a837607331133b7bc6b1 (commit) via 024f543c15e70acb57a80067c3b32227f87bfe5f (commit) via 20dbe585772a18952b730b71cd6722ce62dfe88b (commit) via 31fd10e60d12ae2e955de8651fa84aff016d719a (commit) via 91eac8d567c2717ef7bfd7a5997f8e73057ce780 (commit) via f3ae986218ad2269758f4994ffe137b8233dc0b8 (commit) via d78052cf4f3b8def0ebbd89d3ecc0098190ee20f (commit) via d6f1a6e931beccd75b4e77c8ea99ca6699d052b4 (commit) via 5998e2903589e7b19e102ebff06521f2dcb60409 (commit) via a71a4966a31b31df72db42c130544462fd6ad624 (commit) via c874def60a756df57d1069f48852632a0690f856 (commit) via fe3a329117dbb04a17ca2cb9fc9e3493dc7f03ab (commit) via 7c8b53571698f32219a912e05bc71df4017094c1 (commit) via 35bf6e05371de3aebd83dc630125a108ec4a5e70 (commit) via a455d0f6fff7bdac2b991715e7bf5b000e2274af (commit) via f3b9257f8239e06cc30cea47558d37fc540853ee (commit) via 264ab6b1cd3dae59d98cbead70fd76677a409592 (commit) via 075c8795857de6746ee662e50ebe44055a494f51 (commit) via e0a51488c335e0c61e929e71828fab1252335062 (commit) via 9d671ad1cf6d48c3249c73e2e0ad5aa0f3768a86 (commit) via f0de39595013e4b3af2fd8c76740e52c1a87c2cf (commit) via 82c1aa93c955736e21746593c3e434ae046641ae (commit) via 61ae935a9831d2b132e50508ccc37f879c17a5c4 (commit) via 8ba708e5166b02ab61f2762d36b3e7b7455e9c06 (commit) via 1aeaa7ec06ccd4c819a3ca94139c3ab79463fada (commit) via 73999b62a27d9ac7c10ff27d79fd2bab97f97670 (commit) via 0131df49ee1f98918e958c05b0d4f56b7d441f83 (commit) via 23a635c0ec895f9876d4d7633e7e2923b5bbfc17 (commit) via 5e41ba031edd91bfbac6a614664f83b22fb48207 (commit) via c64359db8af1bf759f4496a01c93bac658decc7e (commit) via 49ae742398aecd81551d59f421e4116a5b8a4ea9 (commit) via c130dd8ea4d09cb708aac9e41bd25c2f5fa7ea38 (commit) via 94836de2aeab65869caf2aa9a260114a309aaf0a (commit) via e27f234a4147a7bd621d2a439c2cc2cc9a6a8382 (commit) via 4e3458a565da5bccf30fe598e87ad7da1ee9daa7 (commit) via 473483d42db5d176946323ac390fcd3c80ea40e6 (commit) via 76af303761670cd54a93f1b196bcd7b2eaf7c29c (commit) via f6a2f2da58d6ba0042a9e94cf7281e5db23e9333 (commit) via 8723588e1b9a13511ffd7b806c73293120bc1f44 (commit) via b9908bf9b8d6d609736b537f4ecda720ff5dc078 (commit) via f8e0a5573820bd7318782d4954c6643ff7e58102 (commit) via 9ab930b27d51a13362e6647074f13589a8ac004d (commit) from 94b3664a528258df5ebcaae213d19bf6568cc47d (commit) - Log ----------------------------------------------------------------- commit b7fa1f989d0059ad7b992c11797f37f095d61204 Author: Matt Caswell Date: Mon Oct 26 23:11:44 2015 +0000 Add SRP and PSK to disallowed CertificateRequest ciphersuites There was a discrepancy between what ciphersuites we allowed to send a CertificateRequest, and what ciphersuites we allowed to receive one. So add PSK and SRP to the disallowed ones. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit bb3e20cf8c5e733c16fe68ce41f67eea5a2a520e Author: Matt Caswell Date: Mon Oct 26 14:08:22 2015 +0000 Remove the inline keyword Some functions were marked as inline in statem_srvr.c where they probably didn't need to be, so remove it. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 956de7b2873e0dde61b287049cd0eb35756b6207 Author: Matt Caswell Date: Mon Oct 26 14:05:43 2015 +0000 Remove superfluous check |tls_process_finished| was checking that |peer_finish_md_len| was non-negative. However neither |tls1_final_finish_mac| or |ssl3_final_finish_mac| can ever return a negative value, so the check is superfluous. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit fed1767436f626bc43140182442567340bd8bd34 Author: Matt Caswell Date: Mon Oct 26 12:21:40 2015 +0000 Change SSL_state_string return strings to start with a T Due the rest of the state machine changes it makes sense to change the SSL_state_string return strings from 3* to T*. They are not SSL3 specific Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 141eb8c679a316278651d1e50b2259a989e030c9 Author: Matt Caswell Date: Mon Oct 26 12:00:00 2015 +0000 Change snprintf to memcpy There was a few uses of snprintf in the DTLS SCTP code which made more sense to be a memcpy. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 8481f583d3aebd7383ba5824bfbe854242231e1b Author: Matt Caswell Date: Mon Oct 26 11:54:17 2015 +0000 Add ossl_statem prefix to various functions Add the ossl_statem prefix to various funtions to avoid name clashes. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit be3583fa40a2658cbbcf73320f75e9d674bb39f4 Author: Matt Caswell Date: Mon Oct 26 11:46:33 2015 +0000 Convert enums to typedefs Various enums were introduced as part of the state machine rewrite. As a matter of style it is preferred for these to be typedefs. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 3616bb63586df04b22de00f49bc92d92dff1b8b6 Author: Matt Caswell Date: Mon Oct 26 11:13:56 2015 +0000 Make dtls1_link_min_mtu static The function dtls1_link_min_mtu() was only used within d1_lib.c so make it static. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 006207d1bc39335b9cb474e6c9a4ca96a33bae46 Author: Matt Caswell Date: Thu Oct 22 15:13:20 2015 +0100 Fix a bogus clang warning Clang with --strict-warnings was complaining about an uninitalised variable. In reality it will never be used uninitialised but clang can't figure out the logic, so just init it anyway to silence the warning. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit c9de4a20fa21101208cf311c5437d9c358ba1f07 Author: Matt Caswell Date: Thu Oct 22 15:02:14 2015 +0100 Fix empty NewSessionTicket processing Rebasing the state machine code introduced a problem with empty NewSessionTicket processing. The return value from the tls_process_new_session_ticket() is supposed to be an enum, but a bare integer was being used. Unfortunately this is valid C so the compiler doesn't pick it up. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit d13dd4beb4674689c7a46450dbb8bae9af24d510 Author: Matt Caswell Date: Thu Oct 22 14:34:33 2015 +0100 Fix uninitialised variable Fix another instance of |al| being unitialised in certain error scenarios. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 9b67c0d810a4842096cb73702c59a1320805f912 Author: Matt Caswell Date: Thu Oct 22 14:13:40 2015 +0100 make update Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit f0659bdb0014afda3585a837607331133b7bc6b1 Author: Matt Caswell Date: Thu Oct 22 14:02:46 2015 +0100 Fix various error codes A number of error codes were wrong due to a rebase of the state machine code. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 024f543c15e70acb57a80067c3b32227f87bfe5f Author: Matt Caswell Date: Thu Oct 22 13:57:18 2015 +0100 Move in_handshake into STATEM The SSL variable |in_handshake| seems misplaced. It would be better to have it in the STATEM structure. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 20dbe585772a18952b730b71cd6722ce62dfe88b Author: Matt Caswell Date: Thu Oct 22 13:31:20 2015 +0100 Fix unitialised variable problem tls_process_client_hello() failed to initialise the |al| variable in some (error) scenarios. This could cause issues with creating the alert. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 31fd10e60d12ae2e955de8651fa84aff016d719a Author: Matt Caswell Date: Thu Oct 22 12:18:45 2015 +0100 Fix DTLSv1_listen following state machine changes Adding the new state machine broke the DTLSv1_listen code because calling SSL_in_before() was erroneously returning true after DTLSv1_listen had successfully completed. This change ensures that SSL_in_before returns false. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 91eac8d567c2717ef7bfd7a5997f8e73057ce780 Author: Matt Caswell Date: Mon Oct 5 11:28:51 2015 +0100 Add a function to get the info_callback Remove repeated blocks of checking SSL and then SSL_CTX for the info_callback. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit f3ae986218ad2269758f4994ffe137b8233dc0b8 Author: Matt Caswell Date: Mon Oct 5 11:17:08 2015 +0100 Remove the old state defines Remove all the defines for the old state machines states. Mapping old to new is probably going to cause more problems than it solves so it is probably better to just remove them. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit d78052cf4f3b8def0ebbd89d3ecc0098190ee20f Author: Matt Caswell Date: Mon Oct 5 11:03:27 2015 +0100 Change SUB_STATE_RETURN into a typedef Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit d6f1a6e931beccd75b4e77c8ea99ca6699d052b4 Author: Matt Caswell Date: Mon Oct 5 10:58:52 2015 +0100 Rename STATEM to OSSL_STATEM Add an OSSL_ prefix onto STATEM Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 5998e2903589e7b19e102ebff06521f2dcb60409 Author: Matt Caswell Date: Mon Oct 5 10:49:15 2015 +0100 Remove SSL_state and SSL_set_state SSL_state has been replaced by SSL_get_state and SSL_set_state is no longer supported. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit a71a4966a31b31df72db42c130544462fd6ad624 Author: Matt Caswell Date: Mon Oct 5 10:44:41 2015 +0100 Move |no_cert_verify| into state machine The |no_cert_verify| should be in the state machine structure not in SSL Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit c874def60a756df57d1069f48852632a0690f856 Author: Matt Caswell Date: Mon Oct 5 10:41:13 2015 +0100 Remove extraneous parens Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit fe3a329117dbb04a17ca2cb9fc9e3493dc7f03ab Author: Matt Caswell Date: Mon Oct 5 10:39:54 2015 +0100 Change statem prefix to ossl_statem Change various state machine functions to use the prefix ossl_statem instead. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 7c8b53571698f32219a912e05bc71df4017094c1 Author: Matt Caswell Date: Mon Oct 5 10:21:11 2015 +0100 Don't depend on SSL structure internals The macros SSL_in_connect_init() and SSL_in_accept_init() inadvertently depended on SSL structure internals. This fixes it to use public API calls instead. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 35bf6e05371de3aebd83dc630125a108ec4a5e70 Author: Matt Caswell Date: Mon Oct 5 10:18:06 2015 +0100 Change HANDSHAKE_STATE to OSSL_HANDSHAKE_STATE Rename the enum HANDSHAKE_STATE to OSSL_HANDSHAKE_STATE to ensure there are no namespace clashes, and convert it into a typedef. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit a455d0f6fff7bdac2b991715e7bf5b000e2274af Author: Matt Caswell Date: Mon Sep 14 15:06:37 2015 +0100 Fix some client side transition logic Fixed some issues in the logic for determining whether an SKE should be expected or not. In particular only allow an SKE for RSA if its export and the key size is not allowed. Also fix the ephemeral ciphersuite checks and add in a missing call to ssl3_check_cert_and_algorithm(). Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit f3b9257f8239e06cc30cea47558d37fc540853ee Author: Matt Caswell Date: Fri Sep 11 13:39:04 2015 +0100 Minor documentation tweak Update the return type for SSL_state in the documentation. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 264ab6b1cd3dae59d98cbead70fd76677a409592 Author: Matt Caswell Date: Fri Sep 11 13:36:42 2015 +0100 Update CHANGES Update the CHANGES file for the state machine rewrite Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 075c8795857de6746ee662e50ebe44055a494f51 Author: Matt Caswell Date: Fri Sep 11 13:11:37 2015 +0100 Remove a call to SSL_set_state from s_server s_server was (ab)using SSL_set_state to force a renegotiation. This is a bad way to do things and does not work with the new state machine code, so we need to do it a different way. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit e0a51488c335e0c61e929e71828fab1252335062 Author: Matt Caswell Date: Fri Sep 11 12:11:39 2015 +0100 Fix a comment Fix an out of date reference to old state machine code in a comment Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 9d671ad1cf6d48c3249c73e2e0ad5aa0f3768a86 Author: Matt Caswell Date: Fri Sep 11 11:56:48 2015 +0100 Remove some unused variables The next_state variable is no longer needed in the new state machine. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit f0de39595013e4b3af2fd8c76740e52c1a87c2cf Author: Matt Caswell Date: Fri Sep 11 11:51:20 2015 +0100 Add a state machine README Add some documentation on the thinking behind the state machine. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 82c1aa93c955736e21746593c3e434ae046641ae Author: Matt Caswell Date: Fri Sep 11 11:28:24 2015 +0100 make update Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 61ae935a9831d2b132e50508ccc37f879c17a5c4 Author: Matt Caswell Date: Fri Sep 11 11:23:20 2015 +0100 More state machine reorg Move some function definitions around within the state machine to make sure they are in the correct files. Also create a statem_locl.h header for stuff entirely local to the state machine code and move various definitions into it. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 8ba708e5166b02ab61f2762d36b3e7b7455e9c06 Author: Matt Caswell Date: Fri Sep 11 10:48:59 2015 +0100 Reorganise state machine files Pull out the state machine into a separate sub directory. Also moved some functions which were nothing to do with the state machine but were in state machine files. Pulled all the SSL_METHOD definitions into one place...most of those files had very little left in them any more. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 1aeaa7ec06ccd4c819a3ca94139c3ab79463fada Author: Matt Caswell Date: Thu Sep 10 10:43:22 2015 +0100 Remove ssl_get_message from ssl_method_st ssl_get_message is no longer used so it should be removed from ssl_method_st Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 73999b62a27d9ac7c10ff27d79fd2bab97f97670 Author: Matt Caswell Date: Thu Sep 10 10:22:30 2015 +0100 Move PACKET creation into the state machine Previously each message specific process function would create its own PACKET structure. Rather than duplicate all of this code lots of times we should create it in the state machine itself. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 0131df49ee1f98918e958c05b0d4f56b7d441f83 Author: Matt Caswell Date: Thu Sep 10 09:23:34 2015 +0100 Remove the SSL state variable The SSL structure contained a "state" variable that kept track of the state machine in the old code. The new state machine does not use this so it can be removed. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 23a635c0ec895f9876d4d7633e7e2923b5bbfc17 Author: Matt Caswell Date: Thu Sep 10 09:19:53 2015 +0100 Remove the type variable The SSL structure contained a "type" variable that was set to either SSL_ST_ACCEPT or SSL_ST_CONNECT depending on whether we are the server or the client. This duplicates the capability of the "server" variable and was actually rarely used. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 5e41ba031edd91bfbac6a614664f83b22fb48207 Author: Matt Caswell Date: Thu Oct 22 10:45:29 2015 +0100 Convert DTLSv1_listen to use new state machine code The DTLSv1_listen code set the state value explicitly to move into init. Change to use state_set_in_init() instead. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit c64359db8af1bf759f4496a01c93bac658decc7e Author: Matt Caswell Date: Thu Sep 10 09:11:41 2015 +0100 Redefine old state values ssl.h and ssl3.h have a number of defines for the various states in the old state machine code. Since this is public API it is not desirable to just remove them. Instead redefine them to the closest equivalent state in the new state machine code. If an application calls SSL_state then the return value can still be compared against these old values if necessary. However not all values have an equivalent state in the new code, so these are just redefined to a dummy value. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 49ae742398aecd81551d59f421e4116a5b8a4ea9 Author: Matt Caswell Date: Tue Sep 8 09:13:50 2015 +0100 Remove redundant code Clean up and remove lots of code that is now no longer needed due to the move to the new state machine. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit c130dd8ea4d09cb708aac9e41bd25c2f5fa7ea38 Author: Matt Caswell Date: Fri Sep 4 13:51:49 2015 +0100 Move server side DTLS to new state machine Implement all of the necessary changes to make DTLS on the server work with the new state machine code. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 94836de2aeab65869caf2aa9a260114a309aaf0a Author: Matt Caswell Date: Tue Sep 8 09:19:22 2015 +0100 Move server side TLS to new state machine Implement all of the necessary changes for moving TLS server side processing into the new state machine code. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit e27f234a4147a7bd621d2a439c2cc2cc9a6a8382 Author: Matt Caswell Date: Tue Sep 8 09:38:08 2015 +0100 Split TLS server functions Split the TLS server ssl3_get_* and ssl3_send_* functions into two ready for the migration to the new state machine code. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 4e3458a565da5bccf30fe598e87ad7da1ee9daa7 Author: Matt Caswell Date: Wed Aug 12 19:58:29 2015 +0100 Delete unused functions Remove all the functions and dead code that is now no longer required as a result of the DTLS client move into the new state machine code. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 473483d42db5d176946323ac390fcd3c80ea40e6 Author: Matt Caswell Date: Mon Sep 7 22:00:36 2015 +0100 Implement DTLS client move to new state machine Move all DTLS client side processing into the new state machine code. A subsequent commit will clean up the old dead code. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 76af303761670cd54a93f1b196bcd7b2eaf7c29c Author: Matt Caswell Date: Tue Aug 11 11:41:03 2015 +0100 dtls_get_message changes for state machine move Create a dtls_get_message function similar to the old dtls1_get_message but in the format required for the new state machine code. The old function will eventually be deleted in later commits. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit f6a2f2da58d6ba0042a9e94cf7281e5db23e9333 Author: Matt Caswell Date: Thu Jul 30 13:45:50 2015 +0100 Client TLS state machine rewrite cleanup Remove redundant code following moving client side TLS handling to the new state machine implementation. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 8723588e1b9a13511ffd7b806c73293120bc1f44 Author: Matt Caswell Date: Mon Sep 7 16:36:53 2015 +0100 Implement Client TLS state machine This swaps the implementation of the client TLS state machine to use the new state machine code instead. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit b9908bf9b8d6d609736b537f4ecda720ff5dc078 Author: Matt Caswell Date: Wed Jul 29 14:08:49 2015 +0100 Split client message reading and writing functions The new state machine code will split up the reading and writing of hanshake messages into discrete phases. In order to facilitate that the existing "get" type functions will be split into two halves: one to get the message and one to process it. The "send" type functions will also have all work relating to constructing the message split out into a separate function just for that. For some functions there will also be separate pre and post "work" phases to prepare or update state. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit f8e0a5573820bd7318782d4954c6643ff7e58102 Author: Matt Caswell Date: Wed Jul 29 14:23:56 2015 +0100 Add initial state machine rewrite code This is the first drop of the new state machine code. The rewrite has the following objectives: - Remove duplication of state code between client and server - Remove duplication of state code between TLS and DTLS - Simplify transitions and bring the logic together in a single location so that it is easier to validate - Remove duplication of code between each of the message handling functions - Receive a message first and then work out whether that is a valid transition - not the other way around (the other way causes lots of issues where we are expecting one type of message next but actually get something else) - Separate message flow state from handshake state (in order to better understand each) - message flow state = when to flush buffers; handling restarts in the event of NBIO events; handling the common flow of steps for reading a message and the common flow of steps for writing a message etc - handshake state = what handshake message are we working on now - Control complexity: only the state machine can change state: keep all the state changes local to a file This builds on previous state machine related work: - Surface CCS processing in the state machine - Version negotiation rewrite Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte commit 9ab930b27d51a13362e6647074f13589a8ac004d Author: Matt Caswell Date: Wed Jul 29 14:20:05 2015 +0100 Split ssl3_get_message The function ssl3_get_message gets a whole message from the underlying bio and returns it to the state machine code. The new state machine code will split this into two discrete steps: get the message header and get the message body. This commit splits the existing function into these two sub steps to facilitate the state machine implementation. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: CHANGES | 11 + apps/s_server.c | 28 +- crypto/ct/Makefile | 3 +- doc/ssl/ssl.pod | 4 +- include/openssl/ssl.h | 121 +- include/openssl/ssl3.h | 107 - ssl/Makefile | 460 ++-- ssl/d1_clnt.c | 830 ------- ssl/d1_lib.c | 248 ++- ssl/d1_meth.c | 88 - ssl/d1_msg.c | 7 +- ssl/d1_srvr.c | 914 -------- ssl/methods.c | 351 +++ ssl/record/rec_layer_d1.c | 37 +- ssl/record/rec_layer_s3.c | 28 +- ssl/record/ssl3_record.c | 2 +- ssl/s3_lib.c | 12 +- ssl/s3_msg.c | 4 +- ssl/s3_srvr.c | 3534 ------------------------------ ssl/ssl_cert.c | 2 +- ssl/ssl_err.c | 58 + ssl/ssl_lib.c | 28 +- ssl/ssl_locl.h | 81 +- ssl/ssl_stat.c | 479 ++-- ssl/statem/README | 63 + ssl/statem/statem.c | 891 ++++++++ ssl/statem/statem.h | 176 ++ ssl/{s3_clnt.c => statem/statem_clnt.c} | 3213 +++++++++++++-------------- ssl/{d1_both.c => statem/statem_dtls.c} | 482 +--- ssl/{s3_both.c => statem/statem_lib.c} | 476 ++-- ssl/statem/statem_locl.h | 171 ++ ssl/statem/statem_srvr.c | 3652 +++++++++++++++++++++++++++++++ ssl/t1_clnt.c | 107 - ssl/t1_lib.c | 2 +- ssl/t1_meth.c | 100 - ssl/t1_srvr.c | 109 - test/Makefile | 5 +- util/ssleay.num | 8 +- 38 files changed, 8109 insertions(+), 8783 deletions(-) delete mode 100644 ssl/d1_clnt.c delete mode 100644 ssl/d1_meth.c delete mode 100644 ssl/d1_srvr.c create mode 100644 ssl/methods.c delete mode 100644 ssl/s3_srvr.c create mode 100644 ssl/statem/README create mode 100644 ssl/statem/statem.c create mode 100644 ssl/statem/statem.h rename ssl/{s3_clnt.c => statem/statem_clnt.c} (50%) rename ssl/{d1_both.c => statem/statem_dtls.c} (76%) rename ssl/{s3_both.c => statem/statem_lib.c} (64%) create mode 100644 ssl/statem/statem_locl.h create mode 100644 ssl/statem/statem_srvr.c delete mode 100644 ssl/t1_clnt.c delete mode 100644 ssl/t1_meth.c delete mode 100644 ssl/t1_srvr.c diff --git a/CHANGES b/CHANGES index 7f33901..a8629d8 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,16 @@ Changes between 1.0.2 and 1.1.0 [xx XXX xxxx] + *) State machine rewrite. The state machine code has been significantly + refactored in order to remove much duplication of code and solve issues + with the old code (see ssl/statem/README for further details). This change + does have some associated API changes. Notably the SSL_state() function + has been removed and replaced by SSL_get_state which now returns an + "OSSL_HANDSHAKE_STATE" instead of an int. SSL_set_state() has been removed + altogether. The previous handshake states defined in ssl.h and ssl3.h have + also been removed. + [Matt Caswell] + *) The demo files in crypto/threads were moved to demo/threads. [Rich Salz] @@ -47,6 +57,7 @@ *) Fix no-stdio build. [ David Woodhouse and also Ivan Nestlerode ] + *) New testing framework The testing framework has been largely rewritten and is now using perl and the perl modules Test::Harness and an extended variant of diff --git a/apps/s_server.c b/apps/s_server.c index bfc8b1f..aa01d43 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -2428,7 +2428,7 @@ static int init_ssl_connection(SSL *con) #ifdef CERT_CB_TEST_RETRY { while (i <= 0 && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP - && SSL_state(con) == SSL3_ST_SR_CLNT_HELLO_C) { + && SSL_get_state(con) == TLS_ST_SR_CLNT_HELLO) { BIO_printf(bio_err, "LOOKUP from certificate callback during accept\n"); i = SSL_accept(con); @@ -2567,6 +2567,11 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context) #ifdef RENEG int total_bytes = 0; #endif + int width; + fd_set readfds; + + /* Set width for a select call if needed */ + width = s + 1; buf = app_malloc(bufsize, "server www buffer"); io = BIO_new(BIO_f_buffer()); @@ -2684,6 +2689,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context) NULL); i = SSL_renegotiate(con); BIO_printf(bio_s_out, "SSL_renegotiate -> %d\n", i); + /* Send the HelloRequest */ i = SSL_do_handshake(con); if (i <= 0) { BIO_printf(bio_s_out, "SSL_do_handshake() Retval %d\n", @@ -2691,16 +2697,22 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context) ERR_print_errors(bio_err); goto err; } - /* EVIL HACK! */ - SSL_set_state(con, SSL_ST_ACCEPT); - i = SSL_do_handshake(con); - BIO_printf(bio_s_out, "SSL_do_handshake -> %d\n", i); - if (i <= 0) { - BIO_printf(bio_s_out, "SSL_do_handshake() Retval %d\n", - SSL_get_error(con, i)); + /* Wait for a ClientHello to come back */ + FD_ZERO(&readfds); + openssl_fdset(s, &readfds); + i = select(width, (void *)&readfds, NULL, NULL, NULL); + if (i <= 0 || !FD_ISSET(s, &readfds)) { + BIO_printf(bio_s_out, "Error waiting for client response\n"); ERR_print_errors(bio_err); goto err; } + /* + * We're not acutally expecting any data here and we ignore + * any that is sent. This is just to force the handshake that + * we're expecting to come from the client. If they haven't + * sent one there's not much we can do. + */ + BIO_gets(io, buf, bufsize - 1); } BIO_puts(io, diff --git a/crypto/ct/Makefile b/crypto/ct/Makefile index 2f55a2d..dfb0839 100644 --- a/crypto/ct/Makefile +++ b/crypto/ct/Makefile @@ -90,4 +90,5 @@ ct_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h ct_lib.o: ../../include/openssl/tls1.h ../../include/openssl/x509.h ct_lib.o: ../../include/openssl/x509_vfy.h ../../ssl/packet_locl.h ct_lib.o: ../../ssl/record/record.h ../../ssl/ssl_locl.h -ct_lib.o: ../include/internal/cryptlib.h ../include/internal/ct_int.h ct_lib.c +ct_lib.o: ../../ssl/statem/statem.h ../include/internal/cryptlib.h +ct_lib.o: ../include/internal/ct_int.h ct_lib.c diff --git a/doc/ssl/ssl.pod b/doc/ssl/ssl.pod index 37046c1..9413907 100644 --- a/doc/ssl/ssl.pod +++ b/doc/ssl/ssl.pod @@ -624,7 +624,9 @@ success or 0 on failure. =item int B(SSL *ssl); -=item int B(const SSL *ssl); +=item OSSL_HANDSHAKE_STATE B(const SSL *ssl); + +Returns the current handshake state. =item char *B(const SSL *ssl); diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 25ceca8..2e899cd 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -920,22 +920,71 @@ extern "C" { # define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) # define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) + +/* + * The valid handshake states (one for each type message sent and one for each + * type of message received). There are also two "special" states: + * TLS = TLS or DTLS state + * DTLS = DTLS specific state + * CR/SR = Client Read/Server Read + * CW/SW = Client Write/Server Write + * + * The "special" states are: + * TLS_ST_BEFORE = No handshake has been initiated yet + * TLS_ST_OK = A handshake has been successfully completed + */ +typedef enum { + TLS_ST_BEFORE, + TLS_ST_OK, + DTLS_ST_CR_HELLO_VERIFY_REQUEST, + TLS_ST_CR_SRVR_HELLO, + TLS_ST_CR_CERT, + TLS_ST_CR_CERT_STATUS, + TLS_ST_CR_KEY_EXCH, + TLS_ST_CR_CERT_REQ, + TLS_ST_CR_SRVR_DONE, + TLS_ST_CR_SESSION_TICKET, + TLS_ST_CR_CHANGE, + TLS_ST_CR_FINISHED, + TLS_ST_CW_CLNT_HELLO, + TLS_ST_CW_CERT, + TLS_ST_CW_KEY_EXCH, + TLS_ST_CW_CERT_VRFY, + TLS_ST_CW_CHANGE, + TLS_ST_CW_NEXT_PROTO, + TLS_ST_CW_FINISHED, + TLS_ST_SW_HELLO_REQ, + TLS_ST_SR_CLNT_HELLO, + DTLS_ST_SW_HELLO_VERIFY_REQUEST, + TLS_ST_SW_SRVR_HELLO, + TLS_ST_SW_CERT, + TLS_ST_SW_KEY_EXCH, + TLS_ST_SW_CERT_REQ, + TLS_ST_SW_SRVR_DONE, + TLS_ST_SR_CERT, + TLS_ST_SR_KEY_EXCH, + TLS_ST_SR_CERT_VRFY, + TLS_ST_SR_NEXT_PROTO, + TLS_ST_SR_CHANGE, + TLS_ST_SR_FINISHED, + TLS_ST_SW_SESSION_TICKET, + TLS_ST_SW_CERT_STATUS, + TLS_ST_SW_CHANGE, + TLS_ST_SW_FINISHED +} OSSL_HANDSHAKE_STATE; + /* - * The following are the possible values for ssl->state are are used to - * indicate where we are up to in the SSL connection establishment. The - * macros that follow are about the only things you should need to use and - * even then, only when using non-blocking IO. It can also be useful to work - * out where you were when the connection failed + * Most of the following state values are no longer used and are defined to be + * the closest equivalent value in the current state machine code. Not all + * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT + * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP, + * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT. */ # define SSL_ST_CONNECT 0x1000 # define SSL_ST_ACCEPT 0x2000 + # define SSL_ST_MASK 0x0FFF -# define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT) -# define SSL_ST_BEFORE 0x4000 -# define SSL_ST_OK 0x03 -# define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT) -# define SSL_ST_ERR 0x05 # define SSL_CB_LOOP 0x01 # define SSL_CB_EXIT 0x02 @@ -952,12 +1001,11 @@ extern "C" { # define SSL_CB_HANDSHAKE_DONE 0x20 /* Is the SSL_connection established? */ -# define SSL_get_state(a) SSL_state(a) -# define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK) -# define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT) -# define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE) -# define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT) -# define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT) +# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a)) +# define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a)) +int SSL_in_init(SSL *s); +int SSL_in_before(SSL *s); +int SSL_is_init_finished(SSL *s); /* * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you @@ -1646,8 +1694,7 @@ void SSL_set_info_callback(SSL *ssl, void (*cb) (const SSL *ssl, int type, int val)); void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type, int val); -__owur int SSL_state(const SSL *ssl); -void SSL_set_state(SSL *ssl, int state); +__owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl); void SSL_set_verify_result(SSL *ssl, long v); __owur long SSL_get_verify_result(const SSL *ssl); @@ -1928,6 +1975,11 @@ void ERR_load_SSL_strings(void); # define SSL_F_DTLS1_SEND_SERVER_HELLO 266 # define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE 267 # define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 +# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC 371 +# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 385 +# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 370 +# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 386 +# define SSL_F_READ_STATE_MACHINE 352 # define SSL_F_SSL3_ACCEPT 128 # define SSL_F_SSL3_ADD_CERT_TO_BUF 296 # define SSL_F_SSL3_CALLBACK_CTRL 233 @@ -2085,6 +2137,7 @@ void ERR_load_SSL_strings(void); # define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 # define SSL_F_SSL_VERIFY_CERT_CHAIN 207 # define SSL_F_SSL_WRITE 208 +# define SSL_F_STATE_MACHINE 353 # define SSL_F_TLS12_CHECK_PEER_SIGALG 333 # define SSL_F_TLS1_CERT_VERIFY_MAC 286 # define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 @@ -2099,6 +2152,37 @@ void ERR_load_SSL_strings(void); # define SSL_F_TLS1_PROCESS_HEARTBEAT 341 # define SSL_F_TLS1_SETUP_KEY_BLOCK 211 # define SSL_F_TLS1_SET_SERVER_SIGALGS 335 +# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK 354 +# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST 372 +# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 355 +# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 356 +# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 357 +# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY 358 +# define SSL_F_TLS_CONSTRUCT_FINISHED 359 +# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST 373 +# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE 374 +# define SSL_F_TLS_CONSTRUCT_SERVER_DONE 375 +# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO 376 +# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE 377 +# define SSL_F_TLS_GET_MESSAGE_BODY 351 +# define SSL_F_TLS_GET_MESSAGE_HEADER 387 +# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 378 +# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 384 +# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE 360 +# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST 361 +# define SSL_F_TLS_PROCESS_CERT_STATUS 362 +# define SSL_F_TLS_PROCESS_CERT_VERIFY 379 +# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC 363 +# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE 380 +# define SSL_F_TLS_PROCESS_CLIENT_HELLO 381 +# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE 382 +# define SSL_F_TLS_PROCESS_FINISHED 364 +# define SSL_F_TLS_PROCESS_KEY_EXCHANGE 365 +# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET 366 +# define SSL_F_TLS_PROCESS_NEXT_PROTO 383 +# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 367 +# define SSL_F_TLS_PROCESS_SERVER_DONE 368 +# define SSL_F_TLS_PROCESS_SERVER_HELLO 369 # define SSL_F_USE_CERTIFICATE_CHAIN_FILE 220 /* Reason codes. */ @@ -2211,6 +2295,7 @@ void ERR_load_SSL_strings(void); # define SSL_R_INVALID_TRUST 279 # define SSL_R_LENGTH_MISMATCH 159 # define SSL_R_LENGTH_TOO_SHORT 160 +# define SSL_R_LENGTH_TOO_LONG 404 # define SSL_R_LIBRARY_BUG 274 # define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 # define SSL_R_MISSING_DH_DSA_CERT 162 diff --git a/include/openssl/ssl3.h b/include/openssl/ssl3.h index ec339de..ef93c08 100644 --- a/include/openssl/ssl3.h +++ b/include/openssl/ssl3.h @@ -370,113 +370,6 @@ extern "C" { # define TLS1_FLAGS_ENCRYPT_THEN_MAC 0x0100 -/* SSLv3 */ -/* - * client - */ -/* extra state */ -# define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) -# ifndef OPENSSL_NO_SCTP -# define DTLS1_SCTP_ST_CW_WRITE_SOCK (0x310|SSL_ST_CONNECT) -# define DTLS1_SCTP_ST_CR_READ_SOCK (0x320|SSL_ST_CONNECT) -# endif -/* write to server */ -# define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) -# define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) -/* read from server */ -# define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) -# define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) -# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT) -# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT) -# define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) -# define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) -# define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) -# define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) -# define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) -# define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) -# define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) -# define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) -/* write to server */ -# define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) -# define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) -# define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) -# define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) -# define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) -# define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) -# define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) -# define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) -# define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) -# define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) -# ifndef OPENSSL_NO_NEXTPROTONEG -# define SSL3_ST_CW_NEXT_PROTO_A (0x200|SSL_ST_CONNECT) -# define SSL3_ST_CW_NEXT_PROTO_B (0x201|SSL_ST_CONNECT) -# endif -# define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) -# define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) -/* read from server */ -# define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) -# define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) -# define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) -# define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) -# define SSL3_ST_CR_SESSION_TICKET_A (0x1E0|SSL_ST_CONNECT) -# define SSL3_ST_CR_SESSION_TICKET_B (0x1E1|SSL_ST_CONNECT) -# define SSL3_ST_CR_CERT_STATUS_A (0x1F0|SSL_ST_CONNECT) -# define SSL3_ST_CR_CERT_STATUS_B (0x1F1|SSL_ST_CONNECT) - -/* server */ -/* extra state */ -# define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) -# ifndef OPENSSL_NO_SCTP -# define DTLS1_SCTP_ST_SW_WRITE_SOCK (0x310|SSL_ST_ACCEPT) -# define DTLS1_SCTP_ST_SR_READ_SOCK (0x320|SSL_ST_ACCEPT) -# endif -/* read from client */ -/* Do not change the number values, they do matter */ -# define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CLNT_HELLO_D (0x115|SSL_ST_ACCEPT) -/* write to client */ -# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT) -# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT) -# define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) -# define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) -# define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) -# define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) -# define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) -# define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) -# define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) -# define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) -# define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) -/* read from client */ -# define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) -# define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) -# define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) -# define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) -# ifndef OPENSSL_NO_NEXTPROTONEG -# define SSL3_ST_SR_NEXT_PROTO_A (0x210|SSL_ST_ACCEPT) -# define SSL3_ST_SR_NEXT_PROTO_B (0x211|SSL_ST_ACCEPT) -# endif -# define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) -# define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) -/* write to client */ -# define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) -# define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) -# define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) -# define SSL3_ST_SW_SESSION_TICKET_A (0x1F0|SSL_ST_ACCEPT) -# define SSL3_ST_SW_SESSION_TICKET_B (0x1F1|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CERT_STATUS_A (0x200|SSL_ST_ACCEPT) -# define SSL3_ST_SW_CERT_STATUS_B (0x201|SSL_ST_ACCEPT) - # define SSL3_MT_HELLO_REQUEST 0 # define SSL3_MT_CLIENT_HELLO 1 # define SSL3_MT_SERVER_HELLO 2 diff --git a/ssl/Makefile b/ssl/Makefile index 7953da4..0865631 100644 --- a/ssl/Makefile +++ b/ssl/Makefile @@ -17,31 +17,33 @@ GENERAL=Makefile README ssl-lib.com install.com LIB=$(TOP)/libssl.a SHARED_LIB= libssl$(SHLIB_EXT) LIBSRC= \ - s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c record/rec_layer_s3.c \ - s3_both.c s3_cbc.c s3_msg.c \ - t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c t1_ext.c \ - d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c record/rec_layer_d1.c d1_msg.c \ - d1_both.c d1_srtp.c \ + statem/statem_srvr.c statem/statem_clnt.c s3_lib.c s3_enc.c record/rec_layer_s3.c \ + statem/statem_lib.c s3_cbc.c s3_msg.c \ + methods.c t1_lib.c t1_enc.c t1_ext.c \ + d1_lib.c record/rec_layer_d1.c d1_msg.c \ + statem/statem_dtls.c d1_srtp.c \ ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \ ssl_ciph.c ssl_stat.c ssl_rsa.c \ ssl_asn1.c ssl_txt.c ssl_algs.c ssl_conf.c \ bio_ssl.c ssl_err.c t1_reneg.c tls_srp.c t1_trce.c ssl_utst.c \ - record/ssl3_buffer.c record/ssl3_record.c record/dtls1_bitmap.c + record/ssl3_buffer.c record/ssl3_record.c record/dtls1_bitmap.c \ + statem/statem.c LIBOBJ= \ - s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o record/rec_layer_s3.o \ - s3_both.o s3_cbc.o s3_msg.o \ - t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o t1_ext.o \ - d1_meth.o d1_srvr.o d1_clnt.o d1_lib.o record/rec_layer_d1.o d1_msg.o \ - d1_both.o d1_srtp.o\ + statem/statem_srvr.o statem/statem_clnt.o s3_lib.o s3_enc.o record/rec_layer_s3.o \ + statem/statem_lib.o s3_cbc.o s3_msg.o \ + methods.o t1_lib.o t1_enc.o t1_ext.o \ + d1_lib.o record/rec_layer_d1.o d1_msg.o \ + statem/statem_dtls.o d1_srtp.o\ ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \ ssl_ciph.o ssl_stat.o ssl_rsa.o \ ssl_asn1.o ssl_txt.o ssl_algs.o ssl_conf.o \ bio_ssl.o ssl_err.o t1_reneg.o tls_srp.o t1_trce.o ssl_utst.o \ - record/ssl3_buffer.o record/ssl3_record.o record/dtls1_bitmap.o + record/ssl3_buffer.o record/ssl3_record.o record/dtls1_bitmap.o \ + statem/statem.o SRC= $(LIBSRC) -HEADER= ssl_locl.h record/record_locl.h record/record.h +HEADER= ssl_locl.h record/record_locl.h record/record.h statem/statem.h ALL= $(GENERAL) $(SRC) $(HEADER) @@ -91,7 +93,9 @@ clean: rm -f $(LIBOBJ) *.obj lib tags core .pure .nfs* *.old *.bak fluff rm -f record/*.obj record/lib record/retags record/core \ record/.pure record/.nfs* record/*.old record/*.bak record/fluff - + rm -f statem/*.obj statem/lib statem/retags statem/core \ + statem/.pure statem/.nfs* statem/*.old statem/*.bak statem/fluff + # DO NOT DELETE THIS LINE -- make depend depends on it. bio_ssl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h @@ -113,48 +117,7 @@ bio_ssl.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h bio_ssl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h bio_ssl.o: ../include/openssl/tls1.h ../include/openssl/x509.h bio_ssl.o: ../include/openssl/x509_vfy.h bio_ssl.c packet_locl.h -bio_ssl.o: record/record.h ssl_locl.h -d1_both.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -d1_both.o: ../include/openssl/bn.h ../include/openssl/buffer.h -d1_both.o: ../include/openssl/comp.h ../include/openssl/crypto.h -d1_both.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -d1_both.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -d1_both.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -d1_both.o: ../include/openssl/err.h ../include/openssl/evp.h -d1_both.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -d1_both.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -d1_both.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -d1_both.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -d1_both.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -d1_both.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -d1_both.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -d1_both.o: ../include/openssl/sha.h ../include/openssl/srtp.h -d1_both.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -d1_both.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -d1_both.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -d1_both.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h d1_both.c -d1_both.o: packet_locl.h record/record.h ssl_locl.h -d1_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -d1_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h -d1_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h -d1_clnt.o: ../include/openssl/dh.h ../include/openssl/dsa.h -d1_clnt.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h -d1_clnt.o: ../include/openssl/ec.h ../include/openssl/ecdh.h -d1_clnt.o: ../include/openssl/ecdsa.h ../include/openssl/err.h -d1_clnt.o: ../include/openssl/evp.h ../include/openssl/hmac.h -d1_clnt.o: ../include/openssl/lhash.h ../include/openssl/md5.h -d1_clnt.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -d1_clnt.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -d1_clnt.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -d1_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -d1_clnt.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -d1_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -d1_clnt.o: ../include/openssl/sha.h ../include/openssl/srtp.h -d1_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -d1_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -d1_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -d1_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h d1_clnt.c -d1_clnt.o: packet_locl.h record/record.h ssl_locl.h +bio_ssl.o: record/record.h ssl_locl.h statem/statem.h d1_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h d1_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h d1_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -167,34 +130,14 @@ d1_lib.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h d1_lib.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h d1_lib.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h d1_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -d1_lib.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h -d1_lib.o: ../include/openssl/safestack.h ../include/openssl/sha.h -d1_lib.o: ../include/openssl/srtp.h ../include/openssl/ssl.h -d1_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h -d1_lib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -d1_lib.o: ../include/openssl/tls1.h ../include/openssl/x509.h -d1_lib.o: ../include/openssl/x509_vfy.h d1_lib.c packet_locl.h record/record.h -d1_lib.o: ssl_locl.h -d1_meth.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -d1_meth.o: ../include/openssl/bn.h ../include/openssl/buffer.h -d1_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h -d1_meth.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -d1_meth.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -d1_meth.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -d1_meth.o: ../include/openssl/err.h ../include/openssl/evp.h -d1_meth.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -d1_meth.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -d1_meth.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -d1_meth.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -d1_meth.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -d1_meth.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h -d1_meth.o: ../include/openssl/safestack.h ../include/openssl/sha.h -d1_meth.o: ../include/openssl/srtp.h ../include/openssl/ssl.h -d1_meth.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h -d1_meth.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -d1_meth.o: ../include/openssl/tls1.h ../include/openssl/x509.h -d1_meth.o: ../include/openssl/x509_vfy.h d1_meth.c packet_locl.h -d1_meth.o: record/record.h ssl_locl.h +d1_lib.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +d1_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +d1_lib.o: ../include/openssl/sha.h ../include/openssl/srtp.h +d1_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +d1_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +d1_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +d1_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h d1_lib.c +d1_lib.o: packet_locl.h record/record.h ssl_locl.h statem/statem.h d1_msg.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h d1_msg.o: ../include/openssl/bn.h ../include/openssl/buffer.h d1_msg.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -214,7 +157,7 @@ d1_msg.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h d1_msg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h d1_msg.o: ../include/openssl/tls1.h ../include/openssl/x509.h d1_msg.o: ../include/openssl/x509_vfy.h d1_msg.c packet_locl.h record/record.h -d1_msg.o: ssl_locl.h +d1_msg.o: ssl_locl.h statem/statem.h d1_srtp.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h d1_srtp.o: ../include/openssl/bn.h ../include/openssl/buffer.h d1_srtp.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -234,28 +177,27 @@ d1_srtp.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h d1_srtp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h d1_srtp.o: ../include/openssl/tls1.h ../include/openssl/x509.h d1_srtp.o: ../include/openssl/x509_vfy.h d1_srtp.c packet_locl.h -d1_srtp.o: record/record.h ssl_locl.h -d1_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -d1_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h -d1_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h -d1_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h -d1_srvr.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h -d1_srvr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h -d1_srvr.o: ../include/openssl/ecdsa.h ../include/openssl/err.h -d1_srvr.o: ../include/openssl/evp.h ../include/openssl/hmac.h -d1_srvr.o: ../include/openssl/lhash.h ../include/openssl/md5.h -d1_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -d1_srvr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -d1_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -d1_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -d1_srvr.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -d1_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -d1_srvr.o: ../include/openssl/sha.h ../include/openssl/srtp.h -d1_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -d1_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -d1_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -d1_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h d1_srvr.c -d1_srvr.o: packet_locl.h record/record.h ssl_locl.h +d1_srtp.o: record/record.h ssl_locl.h statem/statem.h +methods.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h +methods.o: ../include/openssl/bn.h ../include/openssl/buffer.h +methods.o: ../include/openssl/comp.h ../include/openssl/crypto.h +methods.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h +methods.o: ../include/openssl/e_os2.h ../include/openssl/ec.h +methods.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h +methods.o: ../include/openssl/err.h ../include/openssl/evp.h +methods.o: ../include/openssl/hmac.h ../include/openssl/lhash.h +methods.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +methods.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +methods.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +methods.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +methods.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h +methods.o: ../include/openssl/safestack.h ../include/openssl/sha.h +methods.o: ../include/openssl/srtp.h ../include/openssl/ssl.h +methods.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h +methods.o: ../include/openssl/stack.h ../include/openssl/symhacks.h +methods.o: ../include/openssl/tls1.h ../include/openssl/x509.h +methods.o: ../include/openssl/x509_vfy.h methods.c packet_locl.h +methods.o: record/record.h ssl_locl.h statem/statem.h record/dtls1_bitmap.o: ../e_os.h ../include/openssl/asn1.h record/dtls1_bitmap.o: ../include/openssl/bio.h ../include/openssl/bn.h record/dtls1_bitmap.o: ../include/openssl/buffer.h ../include/openssl/comp.h @@ -278,7 +220,8 @@ record/dtls1_bitmap.o: ../include/openssl/stack.h ../include/openssl/symhacks.h record/dtls1_bitmap.o: ../include/openssl/tls1.h ../include/openssl/x509.h record/dtls1_bitmap.o: ../include/openssl/x509_vfy.h record/../packet_locl.h record/dtls1_bitmap.o: record/../record/record.h record/../ssl_locl.h -record/dtls1_bitmap.o: record/dtls1_bitmap.c record/record_locl.h +record/dtls1_bitmap.o: record/../statem/statem.h record/dtls1_bitmap.c +record/dtls1_bitmap.o: record/record_locl.h record/rec_layer_d1.o: ../e_os.h ../include/openssl/asn1.h record/rec_layer_d1.o: ../include/openssl/bio.h ../include/openssl/bn.h record/rec_layer_d1.o: ../include/openssl/buffer.h ../include/openssl/comp.h @@ -301,8 +244,8 @@ record/rec_layer_d1.o: ../include/openssl/ssl3.h ../include/openssl/stack.h record/rec_layer_d1.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h record/rec_layer_d1.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h record/rec_layer_d1.o: record/../packet_locl.h record/../record/record.h -record/rec_layer_d1.o: record/../ssl_locl.h record/rec_layer_d1.c -record/rec_layer_d1.o: record/record_locl.h +record/rec_layer_d1.o: record/../ssl_locl.h record/../statem/statem.h +record/rec_layer_d1.o: record/rec_layer_d1.c record/record_locl.h record/rec_layer_s3.o: ../e_os.h ../include/openssl/asn1.h record/rec_layer_s3.o: ../include/openssl/bio.h ../include/openssl/bn.h record/rec_layer_s3.o: ../include/openssl/buffer.h ../include/openssl/comp.h @@ -325,8 +268,8 @@ record/rec_layer_s3.o: ../include/openssl/ssl3.h ../include/openssl/stack.h record/rec_layer_s3.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h record/rec_layer_s3.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h record/rec_layer_s3.o: record/../packet_locl.h record/../record/record.h -record/rec_layer_s3.o: record/../ssl_locl.h record/rec_layer_s3.c -record/rec_layer_s3.o: record/record_locl.h +record/rec_layer_s3.o: record/../ssl_locl.h record/../statem/statem.h +record/rec_layer_s3.o: record/rec_layer_s3.c record/record_locl.h record/ssl3_buffer.o: ../e_os.h ../include/openssl/asn1.h record/ssl3_buffer.o: ../include/openssl/bio.h ../include/openssl/bn.h record/ssl3_buffer.o: ../include/openssl/buffer.h ../include/openssl/comp.h @@ -349,7 +292,8 @@ record/ssl3_buffer.o: ../include/openssl/stack.h ../include/openssl/symhacks.h record/ssl3_buffer.o: ../include/openssl/tls1.h ../include/openssl/x509.h record/ssl3_buffer.o: ../include/openssl/x509_vfy.h record/../packet_locl.h record/ssl3_buffer.o: record/../record/record.h record/../ssl_locl.h -record/ssl3_buffer.o: record/record_locl.h record/ssl3_buffer.c +record/ssl3_buffer.o: record/../statem/statem.h record/record_locl.h +record/ssl3_buffer.o: record/ssl3_buffer.c record/ssl3_record.o: ../e_os.h ../include/internal/constant_time_locl.h record/ssl3_record.o: ../include/openssl/asn1.h ../include/openssl/bio.h record/ssl3_record.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -372,28 +316,8 @@ record/ssl3_record.o: ../include/openssl/ssl3.h ../include/openssl/stack.h record/ssl3_record.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h record/ssl3_record.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h record/ssl3_record.o: record/../packet_locl.h record/../record/record.h -record/ssl3_record.o: record/../ssl_locl.h record/record_locl.h -record/ssl3_record.o: record/ssl3_record.c -s3_both.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -s3_both.o: ../include/openssl/bn.h ../include/openssl/buffer.h -s3_both.o: ../include/openssl/comp.h ../include/openssl/crypto.h -s3_both.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -s3_both.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -s3_both.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -s3_both.o: ../include/openssl/err.h ../include/openssl/evp.h -s3_both.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -s3_both.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -s3_both.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -s3_both.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -s3_both.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -s3_both.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -s3_both.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -s3_both.o: ../include/openssl/sha.h ../include/openssl/srtp.h -s3_both.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -s3_both.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -s3_both.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -s3_both.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -s3_both.o: packet_locl.h record/record.h s3_both.c ssl_locl.h +record/ssl3_record.o: record/../ssl_locl.h record/../statem/statem.h +record/ssl3_record.o: record/record_locl.h record/ssl3_record.c s3_cbc.o: ../e_os.h ../include/internal/constant_time_locl.h s3_cbc.o: ../include/openssl/asn1.h ../include/openssl/bio.h s3_cbc.o: ../include/openssl/bn.h ../include/openssl/buffer.h @@ -414,29 +338,7 @@ s3_cbc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h s3_cbc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h s3_cbc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h s3_cbc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h packet_locl.h -s3_cbc.o: record/record.h s3_cbc.c ssl_locl.h -s3_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -s3_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h -s3_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h -s3_clnt.o: ../include/openssl/dh.h ../include/openssl/dsa.h -s3_clnt.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h -s3_clnt.o: ../include/openssl/ec.h ../include/openssl/ecdh.h -s3_clnt.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h -s3_clnt.o: ../include/openssl/err.h ../include/openssl/evp.h -s3_clnt.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -s3_clnt.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h -s3_clnt.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h -s3_clnt.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h -s3_clnt.o: ../include/openssl/pem.h ../include/openssl/pem2.h -s3_clnt.o: ../include/openssl/pkcs7.h ../include/openssl/pqueue.h -s3_clnt.o: ../include/openssl/rand.h ../include/openssl/rsa.h -s3_clnt.o: ../include/openssl/safestack.h ../include/openssl/sha.h -s3_clnt.o: ../include/openssl/srtp.h ../include/openssl/ssl.h -s3_clnt.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h -s3_clnt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -s3_clnt.o: ../include/openssl/tls1.h ../include/openssl/x509.h -s3_clnt.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -s3_clnt.o: s3_clnt.c ssl_locl.h +s3_cbc.o: record/record.h s3_cbc.c ssl_locl.h statem/statem.h s3_enc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h s3_enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h s3_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -456,7 +358,7 @@ s3_enc.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h s3_enc.o: ../include/openssl/ssl3.h ../include/openssl/stack.h s3_enc.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h s3_enc.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h packet_locl.h -s3_enc.o: record/record.h s3_enc.c ssl_locl.h +s3_enc.o: record/record.h s3_enc.c ssl_locl.h statem/statem.h s3_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h s3_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h s3_lib.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -477,7 +379,7 @@ s3_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h s3_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h s3_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h s3_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h packet_locl.h -s3_lib.o: record/record.h s3_lib.c ssl_locl.h +s3_lib.o: record/record.h s3_lib.c ssl_locl.h statem/statem.h s3_msg.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h s3_msg.o: ../include/openssl/bn.h ../include/openssl/buffer.h s3_msg.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -497,29 +399,7 @@ s3_msg.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h s3_msg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h s3_msg.o: ../include/openssl/tls1.h ../include/openssl/x509.h s3_msg.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h s3_msg.c -s3_msg.o: ssl_locl.h -s3_srvr.o: ../e_os.h ../include/internal/constant_time_locl.h -s3_srvr.o: ../include/openssl/asn1.h ../include/openssl/bio.h -s3_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h -s3_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h -s3_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h -s3_srvr.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h -s3_srvr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h -s3_srvr.o: ../include/openssl/ecdsa.h ../include/openssl/err.h -s3_srvr.o: ../include/openssl/evp.h ../include/openssl/hmac.h -s3_srvr.o: ../include/openssl/lhash.h ../include/openssl/md5.h -s3_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -s3_srvr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -s3_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -s3_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -s3_srvr.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -s3_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -s3_srvr.o: ../include/openssl/sha.h ../include/openssl/srtp.h -s3_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -s3_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -s3_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -s3_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -s3_srvr.o: packet_locl.h record/record.h s3_srvr.c ssl_locl.h +s3_msg.o: ssl_locl.h statem/statem.h ssl_algs.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_algs.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_algs.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -539,7 +419,7 @@ ssl_algs.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_algs.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_algs.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_algs.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_algs.o: ssl_algs.c ssl_locl.h +ssl_algs.o: ssl_algs.c ssl_locl.h statem/statem.h ssl_asn1.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/asn1t.h ssl_asn1.o: ../include/openssl/bio.h ../include/openssl/bn.h ssl_asn1.o: ../include/openssl/buffer.h ../include/openssl/comp.h @@ -559,7 +439,7 @@ ssl_asn1.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h ssl_asn1.o: ../include/openssl/ssl3.h ../include/openssl/stack.h ssl_asn1.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssl_asn1.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -ssl_asn1.o: packet_locl.h record/record.h ssl_asn1.c ssl_locl.h +ssl_asn1.o: packet_locl.h record/record.h ssl_asn1.c ssl_locl.h statem/statem.h ssl_cert.o: ../e_os.h ../include/internal/o_dir.h ../include/openssl/asn1.h ssl_cert.o: ../include/openssl/bio.h ../include/openssl/bn.h ssl_cert.o: ../include/openssl/buffer.h ../include/openssl/comp.h @@ -581,7 +461,7 @@ ssl_cert.o: ../include/openssl/ssl3.h ../include/openssl/stack.h ssl_cert.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssl_cert.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_cert.o: ../include/openssl/x509v3.h packet_locl.h record/record.h -ssl_cert.o: ssl_cert.c ssl_locl.h +ssl_cert.o: ssl_cert.c ssl_locl.h statem/statem.h ssl_ciph.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_ciph.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_ciph.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -601,7 +481,7 @@ ssl_ciph.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h ssl_ciph.o: ../include/openssl/ssl3.h ../include/openssl/stack.h ssl_ciph.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssl_ciph.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -ssl_ciph.o: packet_locl.h record/record.h ssl_ciph.c ssl_locl.h +ssl_ciph.o: packet_locl.h record/record.h ssl_ciph.c ssl_locl.h statem/statem.h ssl_conf.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_conf.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_conf.o: ../include/openssl/comp.h ../include/openssl/conf.h @@ -622,7 +502,7 @@ ssl_conf.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_conf.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_conf.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_conf.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_conf.o: ssl_conf.c ssl_locl.h +ssl_conf.o: ssl_conf.c ssl_locl.h statem/statem.h ssl_err.o: ../include/openssl/asn1.h ../include/openssl/bio.h ssl_err.o: ../include/openssl/buffer.h ../include/openssl/comp.h ssl_err.o: ../include/openssl/crypto.h ../include/openssl/dtls1.h @@ -679,7 +559,7 @@ ssl_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h ssl_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssl_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssl_lib.o: ../include/openssl/x509v3.h packet_locl.h record/record.h ssl_lib.c -ssl_lib.o: ssl_locl.h +ssl_lib.o: ssl_locl.h statem/statem.h ssl_rsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_rsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_rsa.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -699,7 +579,7 @@ ssl_rsa.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_rsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_rsa.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_rsa.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_rsa.o: ssl_locl.h ssl_rsa.c +ssl_rsa.o: ssl_locl.h ssl_rsa.c statem/statem.h ssl_sess.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_sess.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_sess.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -720,7 +600,7 @@ ssl_sess.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_sess.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_sess.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_sess.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_sess.o: ssl_locl.h ssl_sess.c +ssl_sess.o: ssl_locl.h ssl_sess.c statem/statem.h ssl_stat.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_stat.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_stat.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -740,7 +620,7 @@ ssl_stat.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_stat.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_stat.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_stat.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_stat.o: ssl_locl.h ssl_stat.c +ssl_stat.o: ssl_locl.h ssl_stat.c statem/statem.h ssl_txt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_txt.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_txt.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -760,7 +640,7 @@ ssl_txt.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_txt.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_txt.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_txt.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_txt.o: ssl_locl.h ssl_txt.c +ssl_txt.o: ssl_locl.h ssl_txt.c statem/statem.h ssl_utst.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h ssl_utst.o: ../include/openssl/bn.h ../include/openssl/buffer.h ssl_utst.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -780,27 +660,127 @@ ssl_utst.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h ssl_utst.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ssl_utst.o: ../include/openssl/tls1.h ../include/openssl/x509.h ssl_utst.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -ssl_utst.o: ssl_locl.h ssl_utst.c -t1_clnt.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -t1_clnt.o: ../include/openssl/bn.h ../include/openssl/buffer.h -t1_clnt.o: ../include/openssl/comp.h ../include/openssl/crypto.h -t1_clnt.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -t1_clnt.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -t1_clnt.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -t1_clnt.o: ../include/openssl/err.h ../include/openssl/evp.h -t1_clnt.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -t1_clnt.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -t1_clnt.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -t1_clnt.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -t1_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -t1_clnt.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -t1_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -t1_clnt.o: ../include/openssl/sha.h ../include/openssl/srtp.h -t1_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -t1_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -t1_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -t1_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -t1_clnt.o: packet_locl.h record/record.h ssl_locl.h t1_clnt.c +ssl_utst.o: ssl_locl.h ssl_utst.c statem/statem.h +statem/statem.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h +statem/statem.o: ../include/openssl/bn.h ../include/openssl/buffer.h +statem/statem.o: ../include/openssl/comp.h ../include/openssl/crypto.h +statem/statem.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h +statem/statem.o: ../include/openssl/e_os2.h ../include/openssl/ec.h +statem/statem.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h +statem/statem.o: ../include/openssl/err.h ../include/openssl/evp.h +statem/statem.o: ../include/openssl/hmac.h ../include/openssl/lhash.h +statem/statem.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +statem/statem.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h +statem/statem.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +statem/statem.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +statem/statem.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +statem/statem.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +statem/statem.o: ../include/openssl/sha.h ../include/openssl/srtp.h +statem/statem.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +statem/statem.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +statem/statem.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +statem/statem.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +statem/statem.o: statem/../packet_locl.h statem/../record/record.h +statem/statem.o: statem/../ssl_locl.h statem/../statem/statem.h statem/statem.c +statem/statem.o: statem/statem_locl.h +statem/statem_clnt.o: ../e_os.h ../include/openssl/asn1.h +statem/statem_clnt.o: ../include/openssl/bio.h ../include/openssl/bn.h +statem/statem_clnt.o: ../include/openssl/buffer.h ../include/openssl/comp.h +statem/statem_clnt.o: ../include/openssl/crypto.h ../include/openssl/dh.h +statem/statem_clnt.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h +statem/statem_clnt.o: ../include/openssl/e_os2.h ../include/openssl/ec.h +statem/statem_clnt.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h +statem/statem_clnt.o: ../include/openssl/engine.h ../include/openssl/err.h +statem/statem_clnt.o: ../include/openssl/evp.h ../include/openssl/hmac.h +statem/statem_clnt.o: ../include/openssl/lhash.h ../include/openssl/md5.h +statem/statem_clnt.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +statem/statem_clnt.o: ../include/openssl/opensslconf.h +statem/statem_clnt.o: ../include/openssl/opensslv.h +statem/statem_clnt.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +statem/statem_clnt.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +statem/statem_clnt.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +statem/statem_clnt.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +statem/statem_clnt.o: ../include/openssl/sha.h ../include/openssl/srtp.h +statem/statem_clnt.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +statem/statem_clnt.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +statem/statem_clnt.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +statem/statem_clnt.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +statem/statem_clnt.o: statem/../packet_locl.h statem/../record/record.h +statem/statem_clnt.o: statem/../ssl_locl.h statem/../statem/statem.h +statem/statem_clnt.o: statem/statem_clnt.c statem/statem_locl.h +statem/statem_dtls.o: ../e_os.h ../include/openssl/asn1.h +statem/statem_dtls.o: ../include/openssl/bio.h ../include/openssl/bn.h +statem/statem_dtls.o: ../include/openssl/buffer.h ../include/openssl/comp.h +statem/statem_dtls.o: ../include/openssl/crypto.h ../include/openssl/dsa.h +statem/statem_dtls.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +statem/statem_dtls.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +statem/statem_dtls.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +statem/statem_dtls.o: ../include/openssl/evp.h ../include/openssl/hmac.h +statem/statem_dtls.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h +statem/statem_dtls.o: ../include/openssl/objects.h +statem/statem_dtls.o: ../include/openssl/opensslconf.h +statem/statem_dtls.o: ../include/openssl/opensslv.h +statem/statem_dtls.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +statem/statem_dtls.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +statem/statem_dtls.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +statem/statem_dtls.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +statem/statem_dtls.o: ../include/openssl/sha.h ../include/openssl/srtp.h +statem/statem_dtls.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +statem/statem_dtls.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +statem/statem_dtls.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +statem/statem_dtls.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +statem/statem_dtls.o: statem/../packet_locl.h statem/../record/record.h +statem/statem_dtls.o: statem/../ssl_locl.h statem/../statem/statem.h +statem/statem_dtls.o: statem/statem_dtls.c statem/statem_locl.h +statem/statem_lib.o: ../e_os.h ../include/openssl/asn1.h +statem/statem_lib.o: ../include/openssl/bio.h ../include/openssl/bn.h +statem/statem_lib.o: ../include/openssl/buffer.h ../include/openssl/comp.h +statem/statem_lib.o: ../include/openssl/crypto.h ../include/openssl/dsa.h +statem/statem_lib.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +statem/statem_lib.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +statem/statem_lib.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +statem/statem_lib.o: ../include/openssl/evp.h ../include/openssl/hmac.h +statem/statem_lib.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h +statem/statem_lib.o: ../include/openssl/objects.h +statem/statem_lib.o: ../include/openssl/opensslconf.h +statem/statem_lib.o: ../include/openssl/opensslv.h +statem/statem_lib.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +statem/statem_lib.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +statem/statem_lib.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +statem/statem_lib.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +statem/statem_lib.o: ../include/openssl/sha.h ../include/openssl/srtp.h +statem/statem_lib.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +statem/statem_lib.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +statem/statem_lib.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +statem/statem_lib.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +statem/statem_lib.o: statem/../packet_locl.h statem/../record/record.h +statem/statem_lib.o: statem/../ssl_locl.h statem/../statem/statem.h +statem/statem_lib.o: statem/statem_lib.c statem/statem_locl.h +statem/statem_srvr.o: ../e_os.h ../include/internal/constant_time_locl.h +statem/statem_srvr.o: ../include/openssl/asn1.h ../include/openssl/bio.h +statem/statem_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h +statem/statem_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h +statem/statem_srvr.o: ../include/openssl/dh.h ../include/openssl/dsa.h +statem/statem_srvr.o: ../include/openssl/dtls1.h ../include/openssl/e_os2.h +statem/statem_srvr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h +statem/statem_srvr.o: ../include/openssl/ecdsa.h ../include/openssl/err.h +statem/statem_srvr.o: ../include/openssl/evp.h ../include/openssl/hmac.h +statem/statem_srvr.o: ../include/openssl/lhash.h ../include/openssl/md5.h +statem/statem_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h +statem/statem_srvr.o: ../include/openssl/opensslconf.h +statem/statem_srvr.o: ../include/openssl/opensslv.h +statem/statem_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h +statem/statem_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h +statem/statem_srvr.o: ../include/openssl/pqueue.h ../include/openssl/rand.h +statem/statem_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h +statem/statem_srvr.o: ../include/openssl/sha.h ../include/openssl/srtp.h +statem/statem_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h +statem/statem_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h +statem/statem_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h +statem/statem_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h +statem/statem_srvr.o: statem/../packet_locl.h statem/../record/record.h +statem/statem_srvr.o: statem/../ssl_locl.h statem/../statem/statem.h +statem/statem_srvr.o: statem/statem_locl.h statem/statem_srvr.c t1_enc.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h t1_enc.o: ../include/openssl/bn.h ../include/openssl/buffer.h t1_enc.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -821,7 +801,7 @@ t1_enc.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h t1_enc.o: ../include/openssl/stack.h ../include/openssl/symhacks.h t1_enc.o: ../include/openssl/tls1.h ../include/openssl/x509.h t1_enc.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -t1_enc.o: ssl_locl.h t1_enc.c +t1_enc.o: ssl_locl.h statem/statem.h t1_enc.c t1_ext.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h t1_ext.o: ../include/openssl/bn.h ../include/openssl/buffer.h t1_ext.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -841,7 +821,7 @@ t1_ext.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h t1_ext.o: ../include/openssl/stack.h ../include/openssl/symhacks.h t1_ext.o: ../include/openssl/tls1.h ../include/openssl/x509.h t1_ext.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -t1_ext.o: ssl_locl.h t1_ext.c +t1_ext.o: ssl_locl.h statem/statem.h t1_ext.c t1_lib.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h t1_lib.o: ../include/openssl/bn.h ../include/openssl/buffer.h t1_lib.o: ../include/openssl/comp.h ../include/openssl/conf.h @@ -863,27 +843,7 @@ t1_lib.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h t1_lib.o: ../include/openssl/stack.h ../include/openssl/symhacks.h t1_lib.o: ../include/openssl/tls1.h ../include/openssl/x509.h t1_lib.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h -t1_lib.o: packet_locl.h record/record.h ssl_locl.h t1_lib.c -t1_meth.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -t1_meth.o: ../include/openssl/bn.h ../include/openssl/buffer.h -t1_meth.o: ../include/openssl/comp.h ../include/openssl/crypto.h -t1_meth.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -t1_meth.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -t1_meth.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -t1_meth.o: ../include/openssl/err.h ../include/openssl/evp.h -t1_meth.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -t1_meth.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -t1_meth.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -t1_meth.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -t1_meth.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -t1_meth.o: ../include/openssl/pqueue.h ../include/openssl/rsa.h -t1_meth.o: ../include/openssl/safestack.h ../include/openssl/sha.h -t1_meth.o: ../include/openssl/srtp.h ../include/openssl/ssl.h -t1_meth.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h -t1_meth.o: ../include/openssl/stack.h ../include/openssl/symhacks.h -t1_meth.o: ../include/openssl/tls1.h ../include/openssl/x509.h -t1_meth.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -t1_meth.o: ssl_locl.h t1_meth.c +t1_lib.o: packet_locl.h record/record.h ssl_locl.h statem/statem.h t1_lib.c t1_reneg.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h t1_reneg.o: ../include/openssl/bn.h ../include/openssl/buffer.h t1_reneg.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -903,27 +863,7 @@ t1_reneg.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h t1_reneg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h t1_reneg.o: ../include/openssl/tls1.h ../include/openssl/x509.h t1_reneg.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -t1_reneg.o: ssl_locl.h t1_reneg.c -t1_srvr.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h -t1_srvr.o: ../include/openssl/bn.h ../include/openssl/buffer.h -t1_srvr.o: ../include/openssl/comp.h ../include/openssl/crypto.h -t1_srvr.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h -t1_srvr.o: ../include/openssl/e_os2.h ../include/openssl/ec.h -t1_srvr.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h -t1_srvr.o: ../include/openssl/err.h ../include/openssl/evp.h -t1_srvr.o: ../include/openssl/hmac.h ../include/openssl/lhash.h -t1_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h -t1_srvr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h -t1_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h -t1_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h -t1_srvr.o: ../include/openssl/pqueue.h ../include/openssl/rand.h -t1_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h -t1_srvr.o: ../include/openssl/sha.h ../include/openssl/srtp.h -t1_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h -t1_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h -t1_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h -t1_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h -t1_srvr.o: packet_locl.h record/record.h ssl_locl.h t1_srvr.c +t1_reneg.o: ssl_locl.h statem/statem.h t1_reneg.c t1_trce.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h t1_trce.o: ../include/openssl/bn.h ../include/openssl/buffer.h t1_trce.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -943,7 +883,7 @@ t1_trce.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h t1_trce.o: ../include/openssl/stack.h ../include/openssl/symhacks.h t1_trce.o: ../include/openssl/tls1.h ../include/openssl/x509.h t1_trce.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -t1_trce.o: ssl_locl.h t1_trce.c +t1_trce.o: ssl_locl.h statem/statem.h t1_trce.c tls_srp.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h tls_srp.o: ../include/openssl/bn.h ../include/openssl/buffer.h tls_srp.o: ../include/openssl/comp.h ../include/openssl/crypto.h @@ -964,4 +904,4 @@ tls_srp.o: ../include/openssl/ssl2.h ../include/openssl/ssl3.h tls_srp.o: ../include/openssl/stack.h ../include/openssl/symhacks.h tls_srp.o: ../include/openssl/tls1.h ../include/openssl/x509.h tls_srp.o: ../include/openssl/x509_vfy.h packet_locl.h record/record.h -tls_srp.o: ssl_locl.h tls_srp.c +tls_srp.o: ssl_locl.h statem/statem.h tls_srp.c diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c deleted file mode 100644 index 083333e..0000000 --- a/ssl/d1_clnt.c +++ /dev/null @@ -1,830 +0,0 @@ -/* ssl/d1_clnt.c */ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra at cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include "ssl_locl.h" -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_DH -# include -#endif - -static const SSL_METHOD *dtls1_get_client_method(int ver); -static int dtls1_get_hello_verify(SSL *s); - -static const SSL_METHOD *dtls1_get_client_method(int ver) -{ - if (ver == DTLS1_VERSION || ver == DTLS1_BAD_VER) - return (DTLSv1_client_method()); - else if (ver == DTLS1_2_VERSION) - return (DTLSv1_2_client_method()); - else - return (NULL); -} - -IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, - DTLSv1_client_method, - ssl_undefined_function, - dtls1_connect, - dtls1_get_client_method, DTLSv1_enc_data) - - IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, - DTLSv1_2_client_method, - ssl_undefined_function, - dtls1_connect, - dtls1_get_client_method, DTLSv1_2_enc_data) - - IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, - DTLS_client_method, - ssl_undefined_function, - dtls1_connect, - dtls1_get_client_method, DTLSv1_2_enc_data) - -int dtls1_connect(SSL *s) -{ - BUF_MEM *buf = NULL; - unsigned long Time = (unsigned long)time(NULL); - void (*cb) (const SSL *ssl, int type, int val) = NULL; - int ret = -1; - int new_state, state, skip = 0; -#ifndef OPENSSL_NO_SCTP - unsigned char sctpauthkey[64]; - char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; -#endif - - RAND_add(&Time, sizeof(Time), 0); - ERR_clear_error(); - clear_sys_error(); - - if (s->info_callback != NULL) - cb = s->info_callback; - else if (s->ctx->info_callback != NULL) - cb = s->ctx->info_callback; - - s->in_handshake++; - if (!SSL_in_init(s) || SSL_in_before(s)) { - if (!SSL_clear(s)) - return -1; - } - -#ifndef OPENSSL_NO_SCTP - /* - * Notify SCTP BIO socket to enter handshake mode and prevent stream - * identifier other than 0. Will be ignored if no SCTP is used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, - s->in_handshake, NULL); -#endif - -#ifndef OPENSSL_NO_HEARTBEATS - /* - * If we're awaiting a HeartbeatResponse, pretend we already got and - * don't await it anymore, because Heartbeats don't make sense during - * handshakes anyway. - */ - if (s->tlsext_hb_pending) { - dtls1_stop_timer(s); - s->tlsext_hb_pending = 0; - s->tlsext_hb_seq++; - } -#endif - - for (;;) { - state = s->state; - - switch (s->state) { - case SSL_ST_RENEGOTIATE: - s->renegotiate = 1; - s->state = SSL_ST_CONNECT; - s->ctx->stats.sess_connect_renegotiate++; - /* break */ - case SSL_ST_BEFORE: - case SSL_ST_CONNECT: - case SSL_ST_BEFORE | SSL_ST_CONNECT: - case SSL_ST_OK | SSL_ST_CONNECT: - - s->server = 0; - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_START, 1); - - if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00) && - (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00)) { - SSLerr(SSL_F_DTLS1_CONNECT, ERR_R_INTERNAL_ERROR); - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - /* s->version=SSL3_VERSION; */ - s->type = SSL_ST_CONNECT; - - if (s->init_buf == NULL) { - if ((buf = BUF_MEM_new()) == NULL) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - s->init_buf = buf; - buf = NULL; - } - - if (!ssl3_setup_buffers(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - /* setup buffing BIO */ - if (!ssl_init_wbio_buffer(s, 0)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - /* don't push the buffering BIO quite yet */ - - s->state = SSL3_ST_CW_CLNT_HELLO_A; - s->ctx->stats.sess_connect++; - s->init_num = 0; - /* mark client_random uninitialized */ - memset(s->s3->client_random, 0, sizeof(s->s3->client_random)); - s->d1->send_cookie = 0; - s->hit = 0; - /* - * Should have been reset by ssl3_get_finished, too. - */ - s->s3->change_cipher_spec = 0; - break; - -#ifndef OPENSSL_NO_SCTP - case DTLS1_SCTP_ST_CR_READ_SOCK: - - if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { - s->s3->in_read_app_data = 2; - s->rwstate = SSL_READING; - BIO_clear_retry_flags(SSL_get_rbio(s)); - BIO_set_retry_read(SSL_get_rbio(s)); - ret = -1; - goto end; - } - - s->state = s->s3->tmp.next_state; - break; - - case DTLS1_SCTP_ST_CW_WRITE_SOCK: - /* read app data until dry event */ - - ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); - if (ret < 0) - goto end; - - if (ret == 0) { - s->s3->in_read_app_data = 2; - s->rwstate = SSL_READING; - BIO_clear_retry_flags(SSL_get_rbio(s)); - BIO_set_retry_read(SSL_get_rbio(s)); - ret = -1; - goto end; - } - - s->state = s->d1->next_state; - break; -#endif - - case SSL3_ST_CW_CLNT_HELLO_A: - case SSL3_ST_CW_CLNT_HELLO_B: - - s->shutdown = 0; - - /* every DTLS ClientHello resets Finished MAC */ - ssl3_init_finished_mac(s); - - dtls1_start_timer(s); - ret = ssl3_client_hello(s); - if (ret <= 0) - goto end; - - if (s->d1->send_cookie) { - s->state = SSL3_ST_CW_FLUSH; - s->s3->tmp.next_state = SSL3_ST_CR_SRVR_HELLO_A; - } else - s->state = SSL3_ST_CR_SRVR_HELLO_A; - - s->init_num = 0; - -#ifndef OPENSSL_NO_SCTP - /* Disable buffering for SCTP */ - if (!BIO_dgram_is_sctp(SSL_get_wbio(s))) { -#endif - /* - * turn on buffering for the next lot of output - */ - if (s->bbio != s->wbio) - s->wbio = BIO_push(s->bbio, s->wbio); -#ifndef OPENSSL_NO_SCTP - } -#endif - - break; - - case SSL3_ST_CR_SRVR_HELLO_A: - case SSL3_ST_CR_SRVR_HELLO_B: - ret = ssl3_get_server_hello(s); - if (ret <= 0) - goto end; - else { - if (s->hit) { -#ifndef OPENSSL_NO_SCTP - /* - * Add new shared key for SCTP-Auth, will be ignored if - * no SCTP used. - */ - snprintf((char *)labelbuffer, - sizeof(DTLS1_SCTP_AUTH_LABEL), - DTLS1_SCTP_AUTH_LABEL); - - if (SSL_export_keying_material(s, sctpauthkey, - sizeof(sctpauthkey), - labelbuffer, - sizeof(labelbuffer), NULL, 0, - 0) <= 0) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - BIO_ctrl(SSL_get_wbio(s), - BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, - sizeof(sctpauthkey), sctpauthkey); -#endif - - s->state = SSL3_ST_CR_CHANGE_A; - if (s->tlsext_ticket_expected) { - /* receive renewed session ticket */ - s->state = SSL3_ST_CR_SESSION_TICKET_A; - } - } else - s->state = DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A; - } - s->init_num = 0; - break; - - case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: - case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: - - ret = dtls1_get_hello_verify(s); - if (ret <= 0) - goto end; - dtls1_stop_timer(s); - if (s->d1->send_cookie) /* start again, with a cookie */ - s->state = SSL3_ST_CW_CLNT_HELLO_A; - else - s->state = SSL3_ST_CR_CERT_A; - s->init_num = 0; - break; - - case SSL3_ST_CR_CERT_A: - case SSL3_ST_CR_CERT_B: - /* Check if it is anon DH or PSK */ - if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && - !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { - ret = ssl3_get_server_certificate(s); - if (ret <= 0) - goto end; - - if (s->tlsext_status_expected) - s->state = SSL3_ST_CR_CERT_STATUS_A; - else - s->state = SSL3_ST_CR_KEY_EXCH_A; - } else { - skip = 1; - s->state = SSL3_ST_CR_KEY_EXCH_A; - } - - s->init_num = 0; - break; - - case SSL3_ST_CR_KEY_EXCH_A: - case SSL3_ST_CR_KEY_EXCH_B: - ret = ssl3_get_key_exchange(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_CERT_REQ_A; - s->init_num = 0; - - /* - * at this point we check that we have the required stuff from - * the server - */ - if (!ssl3_check_cert_and_algorithm(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - break; - - case SSL3_ST_CR_CERT_REQ_A: - case SSL3_ST_CR_CERT_REQ_B: - ret = ssl3_get_certificate_request(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_SRVR_DONE_A; - s->init_num = 0; - break; - - case SSL3_ST_CR_SRVR_DONE_A: - case SSL3_ST_CR_SRVR_DONE_B: - ret = ssl3_get_server_done(s); - if (ret <= 0) - goto end; - dtls1_stop_timer(s); - if (s->s3->tmp.cert_req) - s->s3->tmp.next_state = SSL3_ST_CW_CERT_A; - else - s->s3->tmp.next_state = SSL3_ST_CW_KEY_EXCH_A; - s->init_num = 0; - -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && - state == SSL_ST_RENEGOTIATE) - s->state = DTLS1_SCTP_ST_CR_READ_SOCK; - else -#endif - s->state = s->s3->tmp.next_state; - break; - - case SSL3_ST_CW_CERT_A: - case SSL3_ST_CW_CERT_B: - case SSL3_ST_CW_CERT_C: - case SSL3_ST_CW_CERT_D: - dtls1_start_timer(s); - ret = ssl3_send_client_certificate(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CW_KEY_EXCH_A; - s->init_num = 0; - break; - - case SSL3_ST_CW_KEY_EXCH_A: - case SSL3_ST_CW_KEY_EXCH_B: - dtls1_start_timer(s); - ret = ssl3_send_client_key_exchange(s); - if (ret <= 0) - goto end; - -#ifndef OPENSSL_NO_SCTP - /* - * Add new shared key for SCTP-Auth, will be ignored if no SCTP - * used. - */ - snprintf((char *)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), - DTLS1_SCTP_AUTH_LABEL); - - if (SSL_export_keying_material(s, sctpauthkey, - sizeof(sctpauthkey), labelbuffer, - sizeof(labelbuffer), NULL, 0, 0) <= 0) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, - sizeof(sctpauthkey), sctpauthkey); -#endif - - /* - * EAY EAY EAY need to check for DH fix cert sent back - */ - /* - * For TLS, cert_req is set to 2, so a cert chain of nothing is - * sent, but no verify packet is sent - */ - if (s->s3->tmp.cert_req == 1) { - s->state = SSL3_ST_CW_CERT_VRFY_A; - } else { -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { - s->d1->next_state = SSL3_ST_CW_CHANGE_A; - s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; - } else -#endif - s->state = SSL3_ST_CW_CHANGE_A; - } - - s->init_num = 0; - break; - - case SSL3_ST_CW_CERT_VRFY_A: - case SSL3_ST_CW_CERT_VRFY_B: - dtls1_start_timer(s); - ret = ssl3_send_client_verify(s); - if (ret <= 0) - goto end; -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { - s->d1->next_state = SSL3_ST_CW_CHANGE_A; - s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; - } else -#endif - s->state = SSL3_ST_CW_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_CW_CHANGE_A: - case SSL3_ST_CW_CHANGE_B: - if (!s->hit) - dtls1_start_timer(s); - ret = dtls1_send_change_cipher_spec(s, - SSL3_ST_CW_CHANGE_A, - SSL3_ST_CW_CHANGE_B); - if (ret <= 0) - goto end; - - s->state = SSL3_ST_CW_FINISHED_A; - s->init_num = 0; - - s->session->cipher = s->s3->tmp.new_cipher; -#ifdef OPENSSL_NO_COMP - s->session->compress_meth = 0; -#else - if (s->s3->tmp.new_compression == NULL) - s->session->compress_meth = 0; - else - s->session->compress_meth = s->s3->tmp.new_compression->id; -#endif - if (!s->method->ssl3_enc->setup_key_block(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - if (!s->method->ssl3_enc->change_cipher_state(s, - SSL3_CHANGE_CIPHER_CLIENT_WRITE)) - { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } -#ifndef OPENSSL_NO_SCTP - if (s->hit) { - /* - * Change to new shared key of SCTP-Auth, will be ignored if - * no SCTP used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, - 0, NULL); - } -#endif - - dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); - break; - - case SSL3_ST_CW_FINISHED_A: - case SSL3_ST_CW_FINISHED_B: - if (!s->hit) - dtls1_start_timer(s); - ret = ssl3_send_finished(s, - SSL3_ST_CW_FINISHED_A, - SSL3_ST_CW_FINISHED_B, - s->method-> - ssl3_enc->client_finished_label, - s->method-> - ssl3_enc->client_finished_label_len); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CW_FLUSH; - - if (s->hit) { - s->s3->tmp.next_state = SSL_ST_OK; -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { - s->d1->next_state = s->s3->tmp.next_state; - s->s3->tmp.next_state = DTLS1_SCTP_ST_CW_WRITE_SOCK; - } -#endif - } else { -#ifndef OPENSSL_NO_SCTP - /* - * Change to new shared key of SCTP-Auth, will be ignored if - * no SCTP used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, - 0, NULL); -#endif - - /* - * Allow NewSessionTicket if ticket expected - */ - if (s->tlsext_ticket_expected) - s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A; - else - s->s3->tmp.next_state = SSL3_ST_CR_CHANGE_A; - } - s->init_num = 0; - break; - - case SSL3_ST_CR_SESSION_TICKET_A: - case SSL3_ST_CR_SESSION_TICKET_B: - ret = ssl3_get_new_session_ticket(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_CR_CERT_STATUS_A: - case SSL3_ST_CR_CERT_STATUS_B: - ret = ssl3_get_cert_status(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_KEY_EXCH_A; - s->init_num = 0; - break; - - case SSL3_ST_CR_CHANGE_A: - case SSL3_ST_CR_CHANGE_B: - ret = ssl3_get_change_cipher_spec(s, SSL3_ST_CR_CHANGE_A, - SSL3_ST_CR_CHANGE_B); - if (ret <= 0) - goto end; - - s->state = SSL3_ST_CR_FINISHED_A; - s->init_num = 0; - break; - - case SSL3_ST_CR_FINISHED_A: - case SSL3_ST_CR_FINISHED_B: - ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A, - SSL3_ST_CR_FINISHED_B); - if (ret <= 0) - goto end; - dtls1_stop_timer(s); - - if (s->hit) - s->state = SSL3_ST_CW_CHANGE_A; - else - s->state = SSL_ST_OK; - -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && - state == SSL_ST_RENEGOTIATE) { - s->d1->next_state = s->state; - s->state = DTLS1_SCTP_ST_CW_WRITE_SOCK; - } -#endif - - s->init_num = 0; - break; - - case SSL3_ST_CW_FLUSH: - s->rwstate = SSL_WRITING; - if (BIO_flush(s->wbio) <= 0) { - /* - * If the write error was fatal, stop trying - */ - if (!BIO_should_retry(s->wbio)) { - s->rwstate = SSL_NOTHING; - s->state = s->s3->tmp.next_state; - } - - ret = -1; - goto end; - } - s->rwstate = SSL_NOTHING; - s->state = s->s3->tmp.next_state; - break; - - case SSL_ST_OK: - /* clean a few things up */ - ssl3_cleanup_key_block(s); - - /* Remove the buffering */ - ssl_free_wbio_buffer(s); - - s->init_num = 0; - s->renegotiate = 0; - s->new_session = 0; - - ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); - if (s->hit) - s->ctx->stats.sess_hit++; - - ret = 1; - /* s->server=0; */ - s->handshake_func = dtls1_connect; - s->ctx->stats.sess_connect_good++; - - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_DONE, 1); - - /* done with handshaking */ - s->d1->handshake_read_seq = 0; - s->d1->next_handshake_write_seq = 0; - goto end; - /* break; */ - - case SSL_ST_ERR: - default: - SSLerr(SSL_F_DTLS1_CONNECT, SSL_R_UNKNOWN_STATE); - ret = -1; - goto end; - /* break; */ - } - - /* did we do anything */ - if (!s->s3->tmp.reuse_message && !skip) { - if (s->debug) { - if ((ret = BIO_flush(s->wbio)) <= 0) - goto end; - } - - if ((cb != NULL) && (s->state != state)) { - new_state = s->state; - s->state = state; - cb(s, SSL_CB_CONNECT_LOOP, 1); - s->state = new_state; - } - } - skip = 0; - } - end: - s->in_handshake--; - -#ifndef OPENSSL_NO_SCTP - /* - * Notify SCTP BIO socket to leave handshake mode and allow stream - * identifier other than 0. Will be ignored if no SCTP is used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, - s->in_handshake, NULL); -#endif - - BUF_MEM_free(buf); - if (cb != NULL) - cb(s, SSL_CB_CONNECT_EXIT, ret); - return (ret); -} - -static int dtls1_get_hello_verify(SSL *s) -{ - int n, al, ok = 0; - unsigned char *data; - unsigned int cookie_len; - - s->first_packet = 1; - n = s->method->ssl_get_message(s, - DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A, - DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B, - -1, s->max_cert_list, &ok); - s->first_packet = 0; - - if (!ok) - return ((int)n); - - if (s->s3->tmp.message_type != DTLS1_MT_HELLO_VERIFY_REQUEST) { - s->d1->send_cookie = 0; - s->s3->tmp.reuse_message = 1; - return (1); - } - - data = (unsigned char *)s->init_msg; - data += 2; - - cookie_len = *(data++); - if (cookie_len > sizeof(s->d1->cookie)) { - al = SSL_AD_ILLEGAL_PARAMETER; - goto f_err; - } - - memcpy(s->d1->cookie, data, cookie_len); - s->d1->cookie_len = cookie_len; - - s->d1->send_cookie = 1; - return 1; - - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - s->state = SSL_ST_ERR; - return -1; -} diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index 3a0a4cf..733973b 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -60,6 +60,7 @@ #include #define USE_SOCKETS #include +#include #include "ssl_locl.h" #if defined(OPENSSL_SYS_VMS) @@ -76,6 +77,10 @@ static void get_current_time(struct timeval *t); static int dtls1_set_handshake_header(SSL *s, int type, unsigned long len); static int dtls1_handshake_write(SSL *s); int dtls1_listen(SSL *s, struct sockaddr *client); +static unsigned int dtls1_link_min_mtu(void); + +/* XDTLS: figure out the right values */ +static const unsigned int g_probable_mtu[] = { 1500, 512, 256 }; const SSL3_ENC_METHOD DTLSv1_enc_data = { tls1_enc, @@ -762,8 +767,8 @@ int dtls1_listen(SSL *s, struct sockaddr *client) } p = &buf[DTLS1_RT_HEADER_LENGTH]; - msglen = dtls1_raw_hello_verify_request(p + DTLS1_HM_HEADER_LENGTH, - cookie, cookielen); + msglen = dtls_raw_hello_verify_request(p + DTLS1_HM_HEADER_LENGTH, + cookie, cookielen); *p++ = DTLS1_MT_HELLO_VERIFY_REQUEST; @@ -869,10 +874,10 @@ int dtls1_listen(SSL *s, struct sockaddr *client) SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE); /* - * Put us into the "init" state so that dtls1_accept doesn't clear our - * state + * Tell the state machine that we've done the initial hello verify + * exchange */ - s->state = SSL_ST_ACCEPT; + ossl_statem_set_hello_verify_done(s); if(BIO_dgram_get_peer(rbio, client) <= 0) { SSLerr(SSL_F_DTLS1_LISTEN, ERR_R_INTERNAL_ERROR); @@ -908,3 +913,236 @@ static int dtls1_handshake_write(SSL *s) { return dtls1_do_write(s, SSL3_RT_HANDSHAKE); } + +#ifndef OPENSSL_NO_HEARTBEATS +int dtls1_process_heartbeat(SSL *s, unsigned char *p, unsigned int length) +{ + unsigned char *pl; + unsigned short hbtype; + unsigned int payload; + unsigned int padding = 16; /* Use minimum padding */ + + if (s->msg_callback) + s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT, + p, length, s, s->msg_callback_arg); + + /* Read type and payload length first */ + if (1 + 2 + 16 > length) + return 0; /* silently discard */ + if (length > SSL3_RT_MAX_PLAIN_LENGTH) + return 0; /* silently discard per RFC 6520 sec. 4 */ + + hbtype = *p++; + n2s(p, payload); + if (1 + 2 + payload + 16 > length) + return 0; /* silently discard per RFC 6520 sec. 4 */ + pl = p; + + if (hbtype == TLS1_HB_REQUEST) { + unsigned char *buffer, *bp; + unsigned int write_length = 1 /* heartbeat type */ + + 2 /* heartbeat length */ + + payload + padding; + int r; + + if (write_length > SSL3_RT_MAX_PLAIN_LENGTH) + return 0; + + /* + * Allocate memory for the response, size is 1 byte message type, + * plus 2 bytes payload length, plus payload, plus padding + */ + buffer = OPENSSL_malloc(write_length); + if (buffer == NULL) + return -1; + bp = buffer; + + /* Enter response type, length and copy payload */ + *bp++ = TLS1_HB_RESPONSE; + s2n(payload, bp); + memcpy(bp, pl, payload); + bp += payload; + /* Random padding */ + if (RAND_bytes(bp, padding) <= 0) { + OPENSSL_free(buffer); + return -1; + } + + r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, write_length); + + if (r >= 0 && s->msg_callback) + s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT, + buffer, write_length, s, s->msg_callback_arg); + + OPENSSL_free(buffer); + + if (r < 0) + return r; + } else if (hbtype == TLS1_HB_RESPONSE) { + unsigned int seq; + + /* + * We only send sequence numbers (2 bytes unsigned int), and 16 + * random bytes, so we just try to read the sequence number + */ + n2s(pl, seq); + + if (payload == 18 && seq == s->tlsext_hb_seq) { + dtls1_stop_timer(s); + s->tlsext_hb_seq++; + s->tlsext_hb_pending = 0; + } + } + + return 0; +} + +int dtls1_heartbeat(SSL *s) +{ + unsigned char *buf, *p; + int ret = -1; + unsigned int payload = 18; /* Sequence number + random bytes */ + unsigned int padding = 16; /* Use minimum padding */ + + /* Only send if peer supports and accepts HB requests... */ + if (!(s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) || + s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_SEND_REQUESTS) { + SSLerr(SSL_F_DTLS1_HEARTBEAT, SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT); + return -1; + } + + /* ...and there is none in flight yet... */ + if (s->tlsext_hb_pending) { + SSLerr(SSL_F_DTLS1_HEARTBEAT, SSL_R_TLS_HEARTBEAT_PENDING); + return -1; + } + + /* ...and no handshake in progress. */ + if (SSL_in_init(s) || ossl_statem_get_in_handshake(s)) { + SSLerr(SSL_F_DTLS1_HEARTBEAT, SSL_R_UNEXPECTED_MESSAGE); + return -1; + } + + /* + * Check if padding is too long, payload and padding must not exceed 2^14 + * - 3 = 16381 bytes in total. + */ + OPENSSL_assert(payload + padding <= 16381); + + /*- + * Create HeartBeat message, we just use a sequence number + * as payload to distuingish different messages and add + * some random stuff. + * - Message Type, 1 byte + * - Payload Length, 2 bytes (unsigned int) + * - Payload, the sequence number (2 bytes uint) + * - Payload, random bytes (16 bytes uint) + * - Padding + */ + buf = OPENSSL_malloc(1 + 2 + payload + padding); + if (buf == NULL) { + SSLerr(SSL_F_DTLS1_HEARTBEAT, ERR_R_MALLOC_FAILURE); + return -1; + } + p = buf; + /* Message Type */ + *p++ = TLS1_HB_REQUEST; + /* Payload length (18 bytes here) */ + s2n(payload, p); + /* Sequence number */ + s2n(s->tlsext_hb_seq, p); + /* 16 random bytes */ + if (RAND_bytes(p, 16) <= 0) { + SSLerr(SSL_F_DTLS1_HEARTBEAT, ERR_R_INTERNAL_ERROR); + goto err; + } + p += 16; + /* Random padding */ + if (RAND_bytes(p, padding) <= 0) { + SSLerr(SSL_F_DTLS1_HEARTBEAT, ERR_R_INTERNAL_ERROR); + goto err; + } + + ret = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buf, 3 + payload + padding); + if (ret >= 0) { + if (s->msg_callback) + s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT, + buf, 3 + payload + padding, + s, s->msg_callback_arg); + + dtls1_start_timer(s); + s->tlsext_hb_pending = 1; + } + + err: + OPENSSL_free(buf); + + return ret; +} +#endif + +int dtls1_shutdown(SSL *s) +{ + int ret; +#ifndef OPENSSL_NO_SCTP + BIO *wbio; + + wbio = SSL_get_wbio(s); + if (wbio != NULL && BIO_dgram_is_sctp(wbio) && + !(s->shutdown & SSL_SENT_SHUTDOWN)) { + ret = BIO_dgram_sctp_wait_for_dry(wbio); + if (ret < 0) + return -1; + + if (ret == 0) + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN, 1, + NULL); + } +#endif + ret = ssl3_shutdown(s); +#ifndef OPENSSL_NO_SCTP + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN, 0, NULL); +#endif + return ret; +} + +int dtls1_query_mtu(SSL *s) +{ + if (s->d1->link_mtu) { + s->d1->mtu = + s->d1->link_mtu - BIO_dgram_get_mtu_overhead(SSL_get_wbio(s)); + s->d1->link_mtu = 0; + } + + /* AHA! Figure out the MTU, and stick to the right size */ + if (s->d1->mtu < dtls1_min_mtu(s)) { + if (!(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU)) { + s->d1->mtu = + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL); + + /* + * I've seen the kernel return bogus numbers when it doesn't know + * (initial write), so just make sure we have a reasonable number + */ + if (s->d1->mtu < dtls1_min_mtu(s)) { + /* Set to min mtu */ + s->d1->mtu = dtls1_min_mtu(s); + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SET_MTU, + s->d1->mtu, NULL); + } + } else + return 0; + } + return 1; +} + +static unsigned int dtls1_link_min_mtu(void) +{ + return (g_probable_mtu[(sizeof(g_probable_mtu) / + sizeof(g_probable_mtu[0])) - 1]); +} + +unsigned int dtls1_min_mtu(SSL *s) +{ + return dtls1_link_min_mtu() - BIO_dgram_get_mtu_overhead(SSL_get_wbio(s)); +} diff --git a/ssl/d1_meth.c b/ssl/d1_meth.c deleted file mode 100644 index 7340774..0000000 --- a/ssl/d1_meth.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ssl/d1_meth.h */ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra at cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ - -#include -#include -#include "ssl_locl.h" - -static const SSL_METHOD *dtls1_get_method(int ver); -static const SSL_METHOD *dtls1_get_method(int ver) -{ - if (ver == DTLS1_VERSION) - return (DTLSv1_method()); - else if (ver == DTLS1_2_VERSION) - return (DTLSv1_2_method()); - else - return (NULL); -} - -IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, - DTLSv1_method, - dtls1_accept, - dtls1_connect, dtls1_get_method, DTLSv1_enc_data) - - IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, - DTLSv1_2_method, - dtls1_accept, - dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data) - - IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, - DTLS_method, - dtls1_accept, - dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data) diff --git a/ssl/d1_msg.c b/ssl/d1_msg.c index 13bda46..4a2f0dc 100644 --- a/ssl/d1_msg.c +++ b/ssl/d1_msg.c @@ -125,12 +125,11 @@ int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, int len) * Check if we have to continue an interrupted handshake for reading * belated app data with SCTP. */ - if ((SSL_in_init(s) && !s->in_handshake) || + if ((SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) || (BIO_dgram_is_sctp(SSL_get_wbio(s)) && - (s->state == DTLS1_SCTP_ST_SR_READ_SOCK - || s->state == DTLS1_SCTP_ST_CR_READ_SOCK))) + ossl_statem_in_sctp_read_sock(s))) #else - if (SSL_in_init(s) && !s->in_handshake) + if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) #endif { i = s->handshake_func(s); diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c deleted file mode 100644 index e32c4c1..0000000 --- a/ssl/d1_srvr.c +++ /dev/null @@ -1,914 +0,0 @@ -/* ssl/d1_srvr.c */ -/* - * DTLS implementation written by Nagendra Modadugu - * (nagendra at cs.stanford.edu) for the OpenSSL project 2005. - */ -/* ==================================================================== - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include "ssl_locl.h" -#include -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_DH -# include -#endif - -static const SSL_METHOD *dtls1_get_server_method(int ver); -static int dtls1_send_hello_verify_request(SSL *s); - -static const SSL_METHOD *dtls1_get_server_method(int ver) -{ - if (ver == DTLS1_VERSION) - return (DTLSv1_server_method()); - else if (ver == DTLS1_2_VERSION) - return (DTLSv1_2_server_method()); - else - return (NULL); -} - -IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, - DTLSv1_server_method, - dtls1_accept, - ssl_undefined_function, - dtls1_get_server_method, DTLSv1_enc_data) - - IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, - DTLSv1_2_server_method, - dtls1_accept, - ssl_undefined_function, - dtls1_get_server_method, DTLSv1_2_enc_data) - - IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, - DTLS_server_method, - dtls1_accept, - ssl_undefined_function, - dtls1_get_server_method, DTLSv1_2_enc_data) - -int dtls1_accept(SSL *s) -{ - BUF_MEM *buf; - unsigned long Time = (unsigned long)time(NULL); - void (*cb) (const SSL *ssl, int type, int val) = NULL; - unsigned long alg_k; - int ret = -1; - int new_state, state, skip = 0; -#ifndef OPENSSL_NO_SCTP - unsigned char sctpauthkey[64]; - char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; -#endif - - RAND_add(&Time, sizeof(Time), 0); - ERR_clear_error(); - clear_sys_error(); - - if (s->info_callback != NULL) - cb = s->info_callback; - else if (s->ctx->info_callback != NULL) - cb = s->ctx->info_callback; - - /* init things to blank */ - s->in_handshake++; - if (!SSL_in_init(s) || SSL_in_before(s)) { - if (!SSL_clear(s)) - return -1; - } - -#ifndef OPENSSL_NO_SCTP - /* - * Notify SCTP BIO socket to enter handshake mode and prevent stream - * identifier other than 0. Will be ignored if no SCTP is used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, - s->in_handshake, NULL); -#endif - -#ifndef OPENSSL_NO_HEARTBEATS - /* - * If we're awaiting a HeartbeatResponse, pretend we already got and - * don't await it anymore, because Heartbeats don't make sense during - * handshakes anyway. - */ - if (s->tlsext_hb_pending) { - dtls1_stop_timer(s); - s->tlsext_hb_pending = 0; - s->tlsext_hb_seq++; - } -#endif - - for (;;) { - state = s->state; - - switch (s->state) { - case SSL_ST_RENEGOTIATE: - s->renegotiate = 1; - /* s->state=SSL_ST_ACCEPT; */ - - case SSL_ST_BEFORE: - case SSL_ST_ACCEPT: - case SSL_ST_BEFORE | SSL_ST_ACCEPT: - case SSL_ST_OK | SSL_ST_ACCEPT: - - s->server = 1; - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_START, 1); - - if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00)) { - SSLerr(SSL_F_DTLS1_ACCEPT, ERR_R_INTERNAL_ERROR); - return -1; - } - s->type = SSL_ST_ACCEPT; - - if (s->init_buf == NULL) { - if ((buf = BUF_MEM_new()) == NULL) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { - BUF_MEM_free(buf); - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - s->init_buf = buf; - } - - if (!ssl3_setup_buffers(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - s->init_num = 0; - /* - * Should have been reset by ssl3_get_finished, too. - */ - s->s3->change_cipher_spec = 0; - - if (s->state != SSL_ST_RENEGOTIATE) { - /* - * Ok, we now need to push on a buffering BIO so that the - * output is sent in a way that TCP likes :-) ...but not with - * SCTP :-) - */ -#ifndef OPENSSL_NO_SCTP - if (!BIO_dgram_is_sctp(SSL_get_wbio(s))) -#endif - if (!ssl_init_wbio_buffer(s, 1)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - ssl3_init_finished_mac(s); - s->state = SSL3_ST_SR_CLNT_HELLO_A; - s->ctx->stats.sess_accept++; - } else { - /* - * s->state == SSL_ST_RENEGOTIATE, we will just send a - * HelloRequest - */ - s->ctx->stats.sess_accept_renegotiate++; - s->state = SSL3_ST_SW_HELLO_REQ_A; - } - - break; - - case SSL3_ST_SW_HELLO_REQ_A: - case SSL3_ST_SW_HELLO_REQ_B: - - s->shutdown = 0; - dtls1_clear_record_buffer(s); - dtls1_start_timer(s); - ret = ssl3_send_hello_request(s); - if (ret <= 0) - goto end; - s->s3->tmp.next_state = SSL3_ST_SR_CLNT_HELLO_A; - s->state = SSL3_ST_SW_FLUSH; - s->init_num = 0; - - ssl3_init_finished_mac(s); - break; - - case SSL3_ST_SW_HELLO_REQ_C: - s->state = SSL_ST_OK; - break; - - case SSL3_ST_SR_CLNT_HELLO_A: - case SSL3_ST_SR_CLNT_HELLO_B: - case SSL3_ST_SR_CLNT_HELLO_C: - - s->shutdown = 0; - ret = ssl3_get_client_hello(s); - if (ret <= 0) - goto end; - dtls1_stop_timer(s); - - if (ret == 1 && (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE)) - s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A; - else - s->state = SSL3_ST_SW_SRVR_HELLO_A; - - s->init_num = 0; - break; - - case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: - case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: - - ret = dtls1_send_hello_verify_request(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_FLUSH; - s->s3->tmp.next_state = SSL3_ST_SR_CLNT_HELLO_A; - - /* HelloVerifyRequest resets Finished MAC */ - if (s->version != DTLS1_BAD_VER) - ssl3_init_finished_mac(s); - break; - -#ifndef OPENSSL_NO_SCTP - case DTLS1_SCTP_ST_SR_READ_SOCK: - - if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { - s->s3->in_read_app_data = 2; - s->rwstate = SSL_READING; - BIO_clear_retry_flags(SSL_get_rbio(s)); - BIO_set_retry_read(SSL_get_rbio(s)); - ret = -1; - goto end; - } - - s->state = SSL3_ST_SR_CHANGE_A; - break; - - case DTLS1_SCTP_ST_SW_WRITE_SOCK: - ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); - if (ret < 0) - goto end; - - if (ret == 0) { - if (s->d1->next_state != SSL_ST_OK) { - s->s3->in_read_app_data = 2; - s->rwstate = SSL_READING; - BIO_clear_retry_flags(SSL_get_rbio(s)); - BIO_set_retry_read(SSL_get_rbio(s)); - ret = -1; - goto end; - } - } - - s->state = s->d1->next_state; - break; -#endif - - case SSL3_ST_SW_SRVR_HELLO_A: - case SSL3_ST_SW_SRVR_HELLO_B: - s->renegotiate = 2; - dtls1_start_timer(s); - ret = ssl3_send_server_hello(s); - if (ret <= 0) - goto end; - - if (s->hit) { -#ifndef OPENSSL_NO_SCTP - /* - * Add new shared key for SCTP-Auth, will be ignored if no - * SCTP used. - */ - snprintf((char *)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), - DTLS1_SCTP_AUTH_LABEL); - - if (SSL_export_keying_material(s, sctpauthkey, - sizeof(sctpauthkey), labelbuffer, - sizeof(labelbuffer), NULL, 0, 0) <= 0) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, - sizeof(sctpauthkey), sctpauthkey); -#endif - if (s->tlsext_ticket_expected) - s->state = SSL3_ST_SW_SESSION_TICKET_A; - else - s->state = SSL3_ST_SW_CHANGE_A; - } else - s->state = SSL3_ST_SW_CERT_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CERT_A: - case SSL3_ST_SW_CERT_B: - /* Check if it is anon DH or normal PSK */ - if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) - && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { - dtls1_start_timer(s); - ret = ssl3_send_server_certificate(s); - if (ret <= 0) - goto end; - - if (s->tlsext_status_expected) - s->state = SSL3_ST_SW_CERT_STATUS_A; - else - s->state = SSL3_ST_SW_KEY_EXCH_A; - } else { - skip = 1; - s->state = SSL3_ST_SW_KEY_EXCH_A; - } - s->init_num = 0; - break; - - case SSL3_ST_SW_KEY_EXCH_A: - case SSL3_ST_SW_KEY_EXCH_B: - alg_k = s->s3->tmp.new_cipher->algorithm_mkey; - - /* - * clear this, it may get reset by - * send_server_key_exchange - */ - s->s3->tmp.use_rsa_tmp = 0; - - /* - * only send if a DH key exchange or RSA but we have a sign only - * certificate - */ - if (0 - /* - * PSK: send ServerKeyExchange if PSK identity hint if - * provided - */ -#ifndef OPENSSL_NO_PSK - || ((alg_k & SSL_kPSK) && s->cert->psk_identity_hint) -#endif - || (alg_k & SSL_kDHE) - || (alg_k & SSL_kECDHE) - || ((alg_k & SSL_kRSA) - && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL - || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) - && EVP_PKEY_size(s->cert->pkeys - [SSL_PKEY_RSA_ENC].privatekey) * - 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) - ) - ) - ) - ) { - dtls1_start_timer(s); - ret = ssl3_send_server_key_exchange(s); - if (ret <= 0) - goto end; - } else - skip = 1; - - s->state = SSL3_ST_SW_CERT_REQ_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CERT_REQ_A: - case SSL3_ST_SW_CERT_REQ_B: - if ( /* don't request cert unless asked for it: */ - !(s->verify_mode & SSL_VERIFY_PEER) || - /* - * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert - * during re-negotiation: - */ - ((s->session->peer != NULL) && - (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || - /* - * never request cert in anonymous ciphersuites (see - * section "Certificate request" in SSL 3 drafts and in - * RFC 2246): - */ - ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && - /* - * ... except when the application insists on - * verification (against the specs, but s3_clnt.c accepts - * this for SSL 3) - */ - !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) - /* - * With normal PSK Certificates and Certificate Requests - * are omitted - */ - || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { - /* no cert request */ - skip = 1; - s->s3->tmp.cert_request = 0; - s->state = SSL3_ST_SW_SRVR_DONE_A; -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { - s->d1->next_state = SSL3_ST_SW_SRVR_DONE_A; - s->state = DTLS1_SCTP_ST_SW_WRITE_SOCK; - } -#endif - } else { - s->s3->tmp.cert_request = 1; - dtls1_start_timer(s); - ret = ssl3_send_certificate_request(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_SRVR_DONE_A; -# ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { - s->d1->next_state = SSL3_ST_SW_SRVR_DONE_A; - s->state = DTLS1_SCTP_ST_SW_WRITE_SOCK; - } -# endif - s->init_num = 0; - } - break; - - case SSL3_ST_SW_SRVR_DONE_A: - case SSL3_ST_SW_SRVR_DONE_B: - dtls1_start_timer(s); - ret = ssl3_send_server_done(s); - if (ret <= 0) - goto end; - s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; - s->state = SSL3_ST_SW_FLUSH; - s->init_num = 0; - break; - - case SSL3_ST_SW_FLUSH: - s->rwstate = SSL_WRITING; - if (BIO_flush(s->wbio) <= 0) { - /* - * If the write error was fatal, stop trying - */ - if (!BIO_should_retry(s->wbio)) { - s->rwstate = SSL_NOTHING; - s->state = s->s3->tmp.next_state; - } - - ret = -1; - goto end; - } - s->rwstate = SSL_NOTHING; - s->state = s->s3->tmp.next_state; - break; - - case SSL3_ST_SR_CERT_A: - case SSL3_ST_SR_CERT_B: - if (s->s3->tmp.cert_request) { - ret = ssl3_get_client_certificate(s); - if (ret <= 0) - goto end; - } - s->init_num = 0; - s->state = SSL3_ST_SR_KEY_EXCH_A; - break; - - case SSL3_ST_SR_KEY_EXCH_A: - case SSL3_ST_SR_KEY_EXCH_B: - ret = ssl3_get_client_key_exchange(s); - if (ret <= 0) - goto end; -#ifndef OPENSSL_NO_SCTP - /* - * Add new shared key for SCTP-Auth, will be ignored if no SCTP - * used. - */ - snprintf((char *)labelbuffer, sizeof(DTLS1_SCTP_AUTH_LABEL), - DTLS1_SCTP_AUTH_LABEL); - - if (SSL_export_keying_material(s, sctpauthkey, - sizeof(sctpauthkey), labelbuffer, - sizeof(labelbuffer), NULL, 0, 0) <= 0) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, - sizeof(sctpauthkey), sctpauthkey); -#endif - - s->state = SSL3_ST_SR_CERT_VRFY_A; - s->init_num = 0; - - if (ret == 2) { - /* - * For the ECDH ciphersuites when the client sends its ECDH - * pub key in a certificate, the CertificateVerify message is - * not sent. - */ - s->state = SSL3_ST_SR_CHANGE_A; - s->init_num = 0; - } else if (SSL_USE_SIGALGS(s)) { - s->state = SSL3_ST_SR_CERT_VRFY_A; - s->init_num = 0; - if (!s->session->peer) - break; - if (!s->s3->handshake_buffer) { - SSLerr(SSL_F_DTLS1_ACCEPT, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return -1; - } - /* - * For sigalgs freeze the handshake buffer. If we support - * extms we've done this already. - */ - if (!ssl3_digest_cached_records(s, 1)) { - s->state = SSL_ST_ERR; - return -1; - } - } else { - s->state = SSL3_ST_SR_CERT_VRFY_A; - s->init_num = 0; - - /* - * We need to get hashes here so if there is a client cert, - * it can be verified - */ - s->method->ssl3_enc->cert_verify_mac(s, - NID_md5, - &(s->s3-> - tmp.cert_verify_md - [0])); - s->method->ssl3_enc->cert_verify_mac(s, NID_sha1, - &(s->s3-> - tmp.cert_verify_md - [MD5_DIGEST_LENGTH])); - } - break; - - case SSL3_ST_SR_CERT_VRFY_A: - case SSL3_ST_SR_CERT_VRFY_B: - ret = ssl3_get_cert_verify(s); - if (ret <= 0) - goto end; -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s)) && - state == SSL_ST_RENEGOTIATE) - s->state = DTLS1_SCTP_ST_SR_READ_SOCK; - else -#endif - s->state = SSL3_ST_SR_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_SR_CHANGE_A: - case SSL3_ST_SR_CHANGE_B: - ret = ssl3_get_change_cipher_spec(s, SSL3_ST_SR_CHANGE_A, - SSL3_ST_SR_CHANGE_B); - if (ret <= 0) - goto end; - - s->state = SSL3_ST_SR_FINISHED_A; - s->init_num = 0; - break; - - case SSL3_ST_SR_FINISHED_A: - case SSL3_ST_SR_FINISHED_B: - ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, - SSL3_ST_SR_FINISHED_B); - if (ret <= 0) - goto end; - dtls1_stop_timer(s); - if (s->hit) - s->state = SSL_ST_OK; - else if (s->tlsext_ticket_expected) - s->state = SSL3_ST_SW_SESSION_TICKET_A; - else - s->state = SSL3_ST_SW_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_SESSION_TICKET_A: - case SSL3_ST_SW_SESSION_TICKET_B: - ret = ssl3_send_newsession_ticket(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CERT_STATUS_A: - case SSL3_ST_SW_CERT_STATUS_B: - ret = ssl3_send_cert_status(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_KEY_EXCH_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CHANGE_A: - case SSL3_ST_SW_CHANGE_B: - - s->session->cipher = s->s3->tmp.new_cipher; - if (!s->method->ssl3_enc->setup_key_block(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - ret = dtls1_send_change_cipher_spec(s, - SSL3_ST_SW_CHANGE_A, - SSL3_ST_SW_CHANGE_B); - - if (ret <= 0) - goto end; - -#ifndef OPENSSL_NO_SCTP - if (!s->hit) { - /* - * Change to new shared key of SCTP-Auth, will be ignored if - * no SCTP used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, - 0, NULL); - } -#endif - - s->state = SSL3_ST_SW_FINISHED_A; - s->init_num = 0; - - if (!s->method->ssl3_enc->change_cipher_state(s, - SSL3_CHANGE_CIPHER_SERVER_WRITE)) - { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); - break; - - case SSL3_ST_SW_FINISHED_A: - case SSL3_ST_SW_FINISHED_B: - ret = ssl3_send_finished(s, - SSL3_ST_SW_FINISHED_A, - SSL3_ST_SW_FINISHED_B, - s->method-> - ssl3_enc->server_finished_label, - s->method-> - ssl3_enc->server_finished_label_len); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_FLUSH; - if (s->hit) { - s->s3->tmp.next_state = SSL3_ST_SR_CHANGE_A; - -#ifndef OPENSSL_NO_SCTP - /* - * Change to new shared key of SCTP-Auth, will be ignored if - * no SCTP used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, - 0, NULL); -#endif - } else { - s->s3->tmp.next_state = SSL_ST_OK; -#ifndef OPENSSL_NO_SCTP - if (BIO_dgram_is_sctp(SSL_get_wbio(s))) { - s->d1->next_state = s->s3->tmp.next_state; - s->s3->tmp.next_state = DTLS1_SCTP_ST_SW_WRITE_SOCK; - } -#endif - } - s->init_num = 0; - break; - - case SSL_ST_OK: - /* clean a few things up */ - ssl3_cleanup_key_block(s); - - /* remove buffering on output */ - ssl_free_wbio_buffer(s); - - s->init_num = 0; - - if (s->renegotiate == 2) { /* skipped if we just sent a - * HelloRequest */ - s->renegotiate = 0; - s->new_session = 0; - - ssl_update_cache(s, SSL_SESS_CACHE_SERVER); - - s->ctx->stats.sess_accept_good++; - /* s->server=1; */ - s->handshake_func = dtls1_accept; - - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_DONE, 1); - } - - ret = 1; - - /* done handshaking, next message is client hello */ - s->d1->handshake_read_seq = 0; - /* next message is server hello */ - s->d1->handshake_write_seq = 0; - s->d1->next_handshake_write_seq = 0; - goto end; - /* break; */ - - case SSL_ST_ERR: - default: - SSLerr(SSL_F_DTLS1_ACCEPT, SSL_R_UNKNOWN_STATE); - ret = -1; - goto end; - /* break; */ - } - - if (!s->s3->tmp.reuse_message && !skip) { - if (s->debug) { - if ((ret = BIO_flush(s->wbio)) <= 0) - goto end; - } - - if ((cb != NULL) && (s->state != state)) { - new_state = s->state; - s->state = state; - cb(s, SSL_CB_ACCEPT_LOOP, 1); - s->state = new_state; - } - } - skip = 0; - } - end: - /* BIO_flush(s->wbio); */ - - s->in_handshake--; -#ifndef OPENSSL_NO_SCTP - /* - * Notify SCTP BIO socket to leave handshake mode and prevent stream - * identifier other than 0. Will be ignored if no SCTP is used. - */ - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, - s->in_handshake, NULL); -#endif - - if (cb != NULL) - cb(s, SSL_CB_ACCEPT_EXIT, ret); - return (ret); -} - -unsigned int dtls1_raw_hello_verify_request(unsigned char *buf, - unsigned char *cookie, - unsigned char cookie_len) -{ - unsigned int msg_len; - unsigned char *p; - - p = buf; - /* Always use DTLS 1.0 version: see RFC 6347 */ - *(p++) = DTLS1_VERSION >> 8; - *(p++) = DTLS1_VERSION & 0xFF; - - *(p++) = (unsigned char)cookie_len; - memcpy(p, cookie, cookie_len); - p += cookie_len; - msg_len = p - buf; - - return msg_len; -} - - -int dtls1_send_hello_verify_request(SSL *s) -{ - unsigned int len; - unsigned char *buf; - - if (s->state == DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A) { - buf = (unsigned char *)s->init_buf->data; - - if (s->ctx->app_gen_cookie_cb == NULL || - s->ctx->app_gen_cookie_cb(s, s->d1->cookie, - &(s->d1->cookie_len)) == 0 || - s->d1->cookie_len > 255) { - SSLerr(SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST, - SSL_R_COOKIE_GEN_CALLBACK_FAILURE); - s->state = SSL_ST_ERR; - return 0; - } - - len = dtls1_raw_hello_verify_request(&buf[DTLS1_HM_HEADER_LENGTH], - s->d1->cookie, s->d1->cookie_len); - - dtls1_set_message_header(s, buf, DTLS1_MT_HELLO_VERIFY_REQUEST, len, 0, - len); - len += DTLS1_HM_HEADER_LENGTH; - - s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B; - /* number of bytes to write */ - s->init_num = len; - s->init_off = 0; - } - - /* s->state = DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B */ - return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); -} diff --git a/ssl/methods.c b/ssl/methods.c new file mode 100644 index 0000000..3319119 --- /dev/null +++ b/ssl/methods.c @@ -0,0 +1,351 @@ +/* ssl/t1_meth.c */ +/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay at cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh at cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay at cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core at openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay at cryptsoft.com). This product includes software written by Tim + * Hudson (tjh at cryptsoft.com). + * + */ + +#include +#include +#include "ssl_locl.h" + +/* + * TLS/SSLv3 methods + */ + +static const SSL_METHOD *tls1_get_method(int ver) +{ + if (ver == TLS_ANY_VERSION) + return TLS_method(); + if (ver == TLS1_2_VERSION) + return TLSv1_2_method(); + if (ver == TLS1_1_VERSION) + return TLSv1_1_method(); + if (ver == TLS1_VERSION) + return TLSv1_method(); +#ifndef OPENSSL_NO_SSL3 + if (ver == SSL3_VERSION) + return (SSLv3_method()); + else +#endif + return NULL; +} + +IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, TLS_method, + ossl_statem_accept, + ossl_statem_connect, tls1_get_method, TLSv1_2_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_2_VERSION, TLSv1_2_method, + ossl_statem_accept, + ossl_statem_connect, tls1_get_method, TLSv1_2_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_1_VERSION, TLSv1_1_method, + ossl_statem_accept, + ossl_statem_connect, tls1_get_method, TLSv1_1_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_VERSION, TLSv1_method, + ossl_statem_accept, + ossl_statem_connect, tls1_get_method, TLSv1_enc_data) + +#ifndef OPENSSL_NO_SSL3_METHOD +IMPLEMENT_ssl3_meth_func(SSLv3_method, ossl_statem_accept, ossl_statem_connect, + tls1_get_method) +#endif + + +/* + * TLS/SSLv3 server methods + */ + +static const SSL_METHOD *tls1_get_server_method(int ver) +{ + if (ver == TLS_ANY_VERSION) + return TLS_server_method(); + if (ver == TLS1_2_VERSION) + return TLSv1_2_server_method(); + if (ver == TLS1_1_VERSION) + return TLSv1_1_server_method(); + if (ver == TLS1_VERSION) + return TLSv1_server_method(); +#ifndef OPENSSL_NO_SSL3 + if (ver == SSL3_VERSION) + return (SSLv3_server_method()); +#endif + return NULL; +} + +IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, TLS_server_method, + ossl_statem_accept, + ssl_undefined_function, + tls1_get_server_method, TLSv1_2_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_2_VERSION, TLSv1_2_server_method, + ossl_statem_accept, + ssl_undefined_function, + tls1_get_server_method, TLSv1_2_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_1_VERSION, TLSv1_1_server_method, + ossl_statem_accept, + ssl_undefined_function, + tls1_get_server_method, TLSv1_1_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_VERSION, TLSv1_server_method, + ossl_statem_accept, + ssl_undefined_function, + tls1_get_server_method, TLSv1_enc_data) + +#ifndef OPENSSL_NO_SSL3_METHOD +IMPLEMENT_ssl3_meth_func(SSLv3_server_method, + ossl_statem_accept, + ssl_undefined_function, tls1_get_server_method) +#endif + + +/* + * TLS/SSLv3 client methods + */ + +static const SSL_METHOD *tls1_get_client_method(int ver) +{ + if (ver == TLS_ANY_VERSION) + return TLS_client_method(); + if (ver == TLS1_2_VERSION) + return TLSv1_2_client_method(); + if (ver == TLS1_1_VERSION) + return TLSv1_1_client_method(); + if (ver == TLS1_VERSION) + return TLSv1_client_method(); +#ifndef OPENSSL_NO_SSL3 + if (ver == SSL3_VERSION) + return (SSLv3_client_method()); +#endif + return NULL; +} + +IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, TLS_client_method, + ssl_undefined_function, + ossl_statem_connect, + tls1_get_client_method, TLSv1_2_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_2_VERSION, TLSv1_2_client_method, + ssl_undefined_function, + ossl_statem_connect, + tls1_get_client_method, TLSv1_2_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_1_VERSION, TLSv1_1_client_method, + ssl_undefined_function, + ossl_statem_connect, + tls1_get_client_method, TLSv1_1_enc_data) + +IMPLEMENT_tls_meth_func(TLS1_VERSION, TLSv1_client_method, + ssl_undefined_function, + ossl_statem_connect, + tls1_get_client_method, TLSv1_enc_data) + +#ifndef OPENSSL_NO_SSL3_METHOD +IMPLEMENT_ssl3_meth_func(SSLv3_client_method, + ssl_undefined_function, + ossl_statem_connect, tls1_get_client_method) +#endif + + +/* + * DTLS methods + */ +static const SSL_METHOD *dtls1_get_method(int ver) +{ + if (ver == DTLS1_VERSION) + return (DTLSv1_method()); + else if (ver == DTLS1_2_VERSION) + return (DTLSv1_2_method()); + else + return (NULL); +} + +IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, + DTLSv1_method, + ossl_statem_accept, + ossl_statem_connect, + dtls1_get_method, DTLSv1_enc_data) + +IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, + DTLSv1_2_method, + ossl_statem_accept, + ossl_statem_connect, + dtls1_get_method, DTLSv1_2_enc_data) + +IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, + DTLS_method, + ossl_statem_accept, + ossl_statem_connect, + dtls1_get_method, DTLSv1_2_enc_data) + + +/* + * DTLS server methods + */ + +static const SSL_METHOD *dtls1_get_server_method(int ver) +{ + if (ver == DTLS1_VERSION) + return (DTLSv1_server_method()); + else if (ver == DTLS1_2_VERSION) + return (DTLSv1_2_server_method()); + else + return (NULL); +} + +IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, + DTLSv1_server_method, + ossl_statem_accept, + ssl_undefined_function, + dtls1_get_server_method, DTLSv1_enc_data) + +IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, + DTLSv1_2_server_method, + ossl_statem_accept, + ssl_undefined_function, + dtls1_get_server_method, DTLSv1_2_enc_data) + +IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, + DTLS_server_method, + ossl_statem_accept, + ssl_undefined_function, + dtls1_get_server_method, DTLSv1_2_enc_data) + + +/* + * DTLS client methods + */ + +static const SSL_METHOD *dtls1_get_client_method(int ver) +{ + if (ver == DTLS1_VERSION || ver == DTLS1_BAD_VER) + return (DTLSv1_client_method()); + else if (ver == DTLS1_2_VERSION) + return (DTLSv1_2_client_method()); + else + return (NULL); +} + +IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, + DTLSv1_client_method, + ssl_undefined_function, + ossl_statem_connect, + dtls1_get_client_method, DTLSv1_enc_data) + +IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, + DTLSv1_2_client_method, + ssl_undefined_function, + ossl_statem_connect, + dtls1_get_client_method, DTLSv1_2_enc_data) + +IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, + DTLS_client_method, + ssl_undefined_function, + ossl_statem_connect, + dtls1_get_client_method, DTLSv1_2_enc_data) diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c index d7d0093..0133ae3 100644 --- a/ssl/record/rec_layer_d1.c +++ b/ssl/record/rec_layer_d1.c @@ -283,8 +283,8 @@ int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) #ifndef OPENSSL_NO_SCTP /* Store bio_dgram_sctp_rcvinfo struct */ if (BIO_dgram_is_sctp(SSL_get_rbio(s)) && - (s->state == SSL3_ST_SR_FINISHED_A - || s->state == SSL3_ST_CR_FINISHED_A)) { + (SSL_get_state(s) == TLS_ST_SR_FINISHED + || SSL_get_state(s) == TLS_ST_CR_FINISHED)) { BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_GET_RCVINFO, sizeof(rdata->recordinfo), &rdata->recordinfo); } @@ -439,13 +439,12 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, * Continue handshake if it had to be interrupted to read app data with * SCTP. */ - if ((!s->in_handshake && SSL_in_init(s)) || - (BIO_dgram_is_sctp(SSL_get_rbio(s)) && - (s->state == DTLS1_SCTP_ST_SR_READ_SOCK - || s->state == DTLS1_SCTP_ST_CR_READ_SOCK) + if ((!ossl_statem_get_in_handshake(s) && SSL_in_init(s)) || + (BIO_dgram_is_sctp(SSL_get_rbio(s)) + && ossl_statem_in_sctp_read_sock(s) && s->s3->in_read_app_data != 2)) #else - if (!s->in_handshake && SSL_in_init(s)) + if (!ossl_statem_get_in_handshake(s) && SSL_in_init(s)) #endif { /* type == SSL3_RT_APPLICATION_DATA */ @@ -473,7 +472,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, * We are not handshaking and have no data yet, so process data buffered * during the last handshake in advance, if any. */ - if (s->state == SSL_ST_OK && SSL3_RECORD_get_length(rr) == 0) { + if (SSL_is_init_finished(s) && SSL3_RECORD_get_length(rr) == 0) { pitem *item; item = pqueue_pop(s->rlayer.d->buffered_app_data.q); if (item) { @@ -586,8 +585,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, */ if (BIO_dgram_is_sctp(SSL_get_rbio(s)) && SSL3_RECORD_get_type(rr) == SSL3_RT_APPLICATION_DATA && - (s->state == DTLS1_SCTP_ST_SR_READ_SOCK - || s->state == DTLS1_SCTP_ST_CR_READ_SOCK)) { + ossl_statem_in_sctp_read_sock(s)) { s->rwstate = SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); @@ -880,7 +878,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, * Unexpected handshake message (Client Hello, or protocol violation) */ if ((s->rlayer.d->handshake_fragment_len >= DTLS1_HM_HEADER_LENGTH) && - !s->in_handshake) { + !ossl_statem_get_in_handshake(s)) { struct hm_header_st msg_hdr; /* this may just be a stale retransmit */ @@ -903,9 +901,9 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, goto start; } - if (((s->state & SSL_ST_MASK) == SSL_ST_OK) && + if (SSL_is_init_finished(s) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { - s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; + ossl_statem_set_in_init(s, 1); s->renegotiate = 1; s->new_session = 1; } @@ -952,8 +950,8 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, case SSL3_RT_HANDSHAKE: /* * we already handled all of these, with the possible exception of - * SSL3_RT_HANDSHAKE when s->in_handshake is set, but that should not - * happen when type != rr->type + * SSL3_RT_HANDSHAKE when ossl_statem_get_in_handshake(s) is true, but + * that should not happen when type != rr->type */ al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS1_READ_BYTES, ERR_R_INTERNAL_ERROR); @@ -968,14 +966,7 @@ int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, */ if (s->s3->in_read_app_data && (s->s3->total_renegotiations != 0) && - (((s->state & SSL_ST_CONNECT) && - (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && - (s->state <= SSL3_ST_CR_SRVR_HELLO_A) - ) || ((s->state & SSL_ST_ACCEPT) && - (s->state <= SSL3_ST_SW_HELLO_REQ_A) && - (s->state >= SSL3_ST_SR_CLNT_HELLO_A) - ) - )) { + ossl_statem_app_data_allowed(s)) { s->s3->in_read_app_data = 2; return (-1); } else { diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index f5dd27a..e59c203 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -459,7 +459,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) tot = s->rlayer.wnum; s->rlayer.wnum = 0; - if (SSL_in_init(s) && !s->in_handshake) { + if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) { i = s->handshake_func(s); if (i < 0) return (i); @@ -779,7 +779,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf, * Some servers hang if iniatial client hello is larger than 256 bytes * and record version number > TLS 1.0 */ - if (s->state == SSL3_ST_CW_CLNT_HELLO_B + if (SSL_get_state(s) == TLS_ST_CW_CLNT_HELLO && !s->renegotiate && TLS1_get_version(s) > TLS1_VERSION) *(p++) = 0x1; else @@ -1025,7 +1025,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, * Now s->rlayer.handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */ - if (!s->in_handshake && SSL_in_init(s)) { + if (!ossl_statem_get_in_handshake(s) && SSL_in_init(s)) { /* type == SSL3_RT_APPLICATION_DATA */ i = s->handshake_func(s); if (i < 0) @@ -1383,10 +1383,11 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, /* * Unexpected handshake message (Client Hello, or protocol violation) */ - if ((s->rlayer.handshake_fragment_len >= 4) && !s->in_handshake) { - if (((s->state & SSL_ST_MASK) == SSL_ST_OK) && + if ((s->rlayer.handshake_fragment_len >= 4) + && !ossl_statem_get_in_handshake(s)) { + if (SSL_is_init_finished(s) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { - s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; + ossl_statem_set_in_init(s, 1); s->renegotiate = 1; s->new_session = 1; } @@ -1436,8 +1437,8 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, case SSL3_RT_HANDSHAKE: /* * we already handled all of these, with the possible exception of - * SSL3_RT_HANDSHAKE when s->in_handshake is set, but that should not - * happen when type != rr->type + * SSL3_RT_HANDSHAKE when ossl_statem_get_in_handshake(s) is true, but + * that should not happen when type != rr->type */ al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); @@ -1450,16 +1451,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf, * application data at this point (session renegotiation not yet * started), we will indulge it. */ - if (s->s3->in_read_app_data && - (s->s3->total_renegotiations != 0) && - (((s->state & SSL_ST_CONNECT) && - (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && - (s->state <= SSL3_ST_CR_SRVR_HELLO_A) - ) || ((s->state & SSL_ST_ACCEPT) && - (s->state <= SSL3_ST_SW_HELLO_REQ_A) && - (s->state >= SSL3_ST_SR_CLNT_HELLO_A) - ) - )) { + if (ossl_statem_app_data_allowed(s)) { s->s3->in_read_app_data = 2; return (-1); } else { diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c index 7383f13..86aaf4f 100644 --- a/ssl/record/ssl3_record.c +++ b/ssl/record/ssl3_record.c @@ -1528,7 +1528,7 @@ int dtls1_get_record(SSL *s) * processed at this time. */ if (is_next_epoch) { - if ((SSL_in_init(s) || s->in_handshake)) { + if ((SSL_in_init(s) || ossl_statem_get_in_handshake(s))) { if (dtls1_buffer_record (s, &(DTLS_RECORD_LAYER_get_unprocessed_rcds(&s->rlayer)), rr->seq_num) < 0) diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 5e7b618..39d08a0 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -5014,7 +5014,7 @@ int ssl3_shutdown(SSL *s) * Don't do anything much if we have not done the handshake or we don't * want to send messages :-) */ - if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE)) { + if (s->quiet_shutdown || SSL_in_before(s)) { s->shutdown = (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); return (1); } @@ -5085,11 +5085,11 @@ static int ssl3_read_internal(SSL *s, void *buf, int len, int peek) * makes sense here; so disable handshake processing and try to read * application data again. */ - s->in_handshake++; + ossl_statem_set_in_handshake(s, 1); ret = s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf, len, peek); - s->in_handshake--; + ossl_statem_set_in_handshake(s, 0); } else s->s3->in_read_app_data = 0; @@ -5128,10 +5128,10 @@ int ssl3_renegotiate_check(SSL *s) && !SSL_in_init(s)) { /* * if we are the server, and we have sent a 'RENEGOTIATE' - * message, we need to go to SSL_ST_ACCEPT. + * message, we need to set the state machine into the renegotiate + * state. */ - /* SSL_ST_ACCEPT */ - s->state = SSL_ST_RENEGOTIATE; + ossl_statem_set_renegotiate(s); s->s3->renegotiate = 0; s->s3->num_renegotiations++; s->s3->total_renegotiations++; diff --git a/ssl/s3_msg.c b/ssl/s3_msg.c index fcf4744..8d7f042 100644 --- a/ssl/s3_msg.c +++ b/ssl/s3_msg.c @@ -118,7 +118,7 @@ int ssl3_do_change_cipher_spec(SSL *s) const char *sender; int slen; - if (s->state & SSL_ST_ACCEPT) + if (s->server) i = SSL3_CHANGE_CIPHER_SERVER_READ; else i = SSL3_CHANGE_CIPHER_CLIENT_READ; @@ -143,7 +143,7 @@ int ssl3_do_change_cipher_spec(SSL *s) * we have to record the message digest at this point so we can get it * before we read the finished message */ - if (s->state & SSL_ST_CONNECT) { + if (!s->server) { sender = s->method->ssl3_enc->server_finished_label; slen = s->method->ssl3_enc->server_finished_label_len; } else { diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c deleted file mode 100644 index 376ab71..0000000 --- a/ssl/s3_srvr.c +++ /dev/null @@ -1,3534 +0,0 @@ -/* ssl/s3_srvr.c -*- mode:C; c-file-style: "eay" -*- */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core at openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay at cryptsoft.com). This product includes software written by Tim - * Hudson (tjh at cryptsoft.com). - * - */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * ECC cipher suite support in OpenSSL originally written by - * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. - * - */ -/* ==================================================================== - * Copyright 2005 Nokia. All rights reserved. - * - * The portions of the attached software ("Contribution") is developed by - * Nokia Corporation and is licensed pursuant to the OpenSSL open source - * license. - * - * The Contribution, originally written by Mika Kousa and Pasi Eronen of - * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites - * support (see RFC 4279) to OpenSSL. - * - * No patent licenses or other rights except those expressly stated in - * the OpenSSL open source license shall be deemed granted or received - * expressly, by implication, estoppel, or otherwise. - * - * No assurances are provided by Nokia that the Contribution does not - * infringe the patent or other intellectual property rights of any third - * party or that the license provides you with all the necessary rights - * to make use of the Contribution. - * - * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN - * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA - * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY - * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR - * OTHERWISE. - */ - - -#include -#include "ssl_locl.h" -#include "internal/constant_time_locl.h" -#include -#include -#include -#include -#include -#include -#ifndef OPENSSL_NO_DH -# include -#endif -#include -#include - -static STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, - PACKET *cipher_suites, - STACK_OF(SSL_CIPHER) **skp, - int sslv2format, int *al); - - -#ifndef OPENSSL_NO_SRP -static int ssl_check_srp_ext_ClientHello(SSL *s, int *al) -{ - int ret = SSL_ERROR_NONE; - - *al = SSL_AD_UNRECOGNIZED_NAME; - - if ((s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) && - (s->srp_ctx.TLS_ext_srp_username_callback != NULL)) { - if (s->srp_ctx.login == NULL) { - /* - * RFC 5054 says SHOULD reject, we do so if There is no srp - * login name - */ - ret = SSL3_AL_FATAL; - *al = SSL_AD_UNKNOWN_PSK_IDENTITY; - } else { - ret = SSL_srp_server_param_with_username(s, al); - } - } - return ret; -} -#endif - -int ssl3_accept(SSL *s) -{ - BUF_MEM *buf; - unsigned long alg_k, Time = (unsigned long)time(NULL); - void (*cb) (const SSL *ssl, int type, int val) = NULL; - int ret = -1; - int new_state, state, skip = 0; - - RAND_add(&Time, sizeof(Time), 0); - ERR_clear_error(); - clear_sys_error(); - - if (s->info_callback != NULL) - cb = s->info_callback; - else if (s->ctx->info_callback != NULL) - cb = s->ctx->info_callback; - - /* init things to blank */ - s->in_handshake++; - if (!SSL_in_init(s) || SSL_in_before(s)) { - if (!SSL_clear(s)) - return -1; - } - -#ifndef OPENSSL_NO_HEARTBEATS - /* - * If we're awaiting a HeartbeatResponse, pretend we already got and - * don't await it anymore, because Heartbeats don't make sense during - * handshakes anyway. - */ - if (s->tlsext_hb_pending) { - s->tlsext_hb_pending = 0; - s->tlsext_hb_seq++; - } -#endif - - for (;;) { - state = s->state; - - switch (s->state) { - case SSL_ST_RENEGOTIATE: - s->renegotiate = 1; - /* s->state=SSL_ST_ACCEPT; */ - - case SSL_ST_BEFORE: - case SSL_ST_ACCEPT: - case SSL_ST_BEFORE | SSL_ST_ACCEPT: - case SSL_ST_OK | SSL_ST_ACCEPT: - - s->server = 1; - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_START, 1); - - if ((s->version >> 8 != 3) && s->version != TLS_ANY_VERSION) { - SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return -1; - } - - if (!ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) { - SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_VERSION_TOO_LOW); - return -1; - } - - s->type = SSL_ST_ACCEPT; - - if (s->init_buf == NULL) { - if ((buf = BUF_MEM_new()) == NULL) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { - BUF_MEM_free(buf); - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - s->init_buf = buf; - } - - if (!ssl3_setup_buffers(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - s->init_num = 0; - s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; - /* - * Should have been reset by ssl3_get_finished, too. - */ - s->s3->change_cipher_spec = 0; - - if (s->state != SSL_ST_RENEGOTIATE) { - /* - * Ok, we now need to push on a buffering BIO so that the - * output is sent in a way that TCP likes :-) - */ - if (!ssl_init_wbio_buffer(s, 1)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - ssl3_init_finished_mac(s); - s->state = SSL3_ST_SR_CLNT_HELLO_A; - s->ctx->stats.sess_accept++; - } else if (!s->s3->send_connection_binding && - !(s->options & - SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { - /* - * Server attempting to renegotiate with client that doesn't - * support secure renegotiation. - */ - SSLerr(SSL_F_SSL3_ACCEPT, - SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } else { - /* - * s->state == SSL_ST_RENEGOTIATE, we will just send a - * HelloRequest - */ - s->ctx->stats.sess_accept_renegotiate++; - s->state = SSL3_ST_SW_HELLO_REQ_A; - } - break; - - case SSL3_ST_SW_HELLO_REQ_A: - case SSL3_ST_SW_HELLO_REQ_B: - - s->shutdown = 0; - ret = ssl3_send_hello_request(s); - if (ret <= 0) - goto end; - s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; - s->state = SSL3_ST_SW_FLUSH; - s->init_num = 0; - - ssl3_init_finished_mac(s); - break; - - case SSL3_ST_SW_HELLO_REQ_C: - s->state = SSL_ST_OK; - break; - - case SSL3_ST_SR_CLNT_HELLO_A: - case SSL3_ST_SR_CLNT_HELLO_B: - case SSL3_ST_SR_CLNT_HELLO_C: - - ret = ssl3_get_client_hello(s); - if (ret <= 0) - goto end; -#ifndef OPENSSL_NO_SRP - s->state = SSL3_ST_SR_CLNT_HELLO_D; - case SSL3_ST_SR_CLNT_HELLO_D: - { - int al; - if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { - /* - * callback indicates firther work to be done - */ - s->rwstate = SSL_X509_LOOKUP; - goto end; - } - if (ret != SSL_ERROR_NONE) { - ssl3_send_alert(s, SSL3_AL_FATAL, al); - /* - * This is not really an error but the only means to for - * a client to detect whether srp is supported. - */ - if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) - SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - } -#endif - - s->renegotiate = 2; - s->state = SSL3_ST_SW_SRVR_HELLO_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_SRVR_HELLO_A: - case SSL3_ST_SW_SRVR_HELLO_B: - ret = ssl3_send_server_hello(s); - if (ret <= 0) - goto end; - - if (s->hit) { - if (s->tlsext_ticket_expected) - s->state = SSL3_ST_SW_SESSION_TICKET_A; - else - s->state = SSL3_ST_SW_CHANGE_A; - } else { - s->state = SSL3_ST_SW_CERT_A; - } - s->init_num = 0; - break; - - case SSL3_ST_SW_CERT_A: - case SSL3_ST_SW_CERT_B: - /* Check if it is anon DH or anon ECDH, */ - /* normal PSK or SRP */ - if (!(s->s3->tmp.new_cipher->algorithm_auth & - (SSL_aNULL | SSL_aSRP | SSL_aPSK))) { - ret = ssl3_send_server_certificate(s); - if (ret <= 0) - goto end; - - if (s->tlsext_status_expected) - s->state = SSL3_ST_SW_CERT_STATUS_A; - else - s->state = SSL3_ST_SW_KEY_EXCH_A; - } else { - skip = 1; - s->state = SSL3_ST_SW_KEY_EXCH_A; - } - s->init_num = 0; - break; - - case SSL3_ST_SW_KEY_EXCH_A: - case SSL3_ST_SW_KEY_EXCH_B: - alg_k = s->s3->tmp.new_cipher->algorithm_mkey; - - /* - * clear this, it may get reset by - * send_server_key_exchange - */ - s->s3->tmp.use_rsa_tmp = 0; - - /* - * only send if a DH key exchange, fortezza or RSA but we have a - * sign only certificate PSK: may send PSK identity hints For - * ECC ciphersuites, we send a serverKeyExchange message only if - * the cipher suite is either ECDH-anon or ECDHE. In other cases, - * the server certificate contains the server's public key for - * key exchange. - */ - if (0 - /* - * PSK: send ServerKeyExchange if PSK identity hint if - * provided - */ -#ifndef OPENSSL_NO_PSK - /* Only send SKE if we have identity hint for plain PSK */ - || ((alg_k & (SSL_kPSK | SSL_kRSAPSK)) && s->cert->psk_identity_hint) - /* For other PSK always send SKE */ - || (alg_k & (SSL_PSK & (SSL_kDHEPSK | SSL_kECDHEPSK))) -#endif -#ifndef OPENSSL_NO_SRP - /* SRP: send ServerKeyExchange */ - || (alg_k & SSL_kSRP) -#endif - || (alg_k & SSL_kDHE) - || (alg_k & SSL_kECDHE) - || ((alg_k & SSL_kRSA) - && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL - || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) - && EVP_PKEY_size(s->cert->pkeys - [SSL_PKEY_RSA_ENC].privatekey) * - 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) - ) - ) - ) - ) { - ret = ssl3_send_server_key_exchange(s); - if (ret <= 0) - goto end; - } else - skip = 1; - - s->state = SSL3_ST_SW_CERT_REQ_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CERT_REQ_A: - case SSL3_ST_SW_CERT_REQ_B: - if ( /* don't request cert unless asked for it: */ - !(s->verify_mode & SSL_VERIFY_PEER) || - /* - * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert - * during re-negotiation: - */ - ((s->session->peer != NULL) && - (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || - /* - * never request cert in anonymous ciphersuites (see - * section "Certificate request" in SSL 3 drafts and in - * RFC 2246): - */ - ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && - /* - * ... except when the application insists on - * verification (against the specs, but s3_clnt.c accepts - * this for SSL 3) - */ - !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || - /* don't request certificate for SRP auth */ - (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) - /* - * With normal PSK Certificates and Certificate Requests - * are omitted - */ - || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK)) { - /* no cert request */ - skip = 1; - s->s3->tmp.cert_request = 0; - s->state = SSL3_ST_SW_SRVR_DONE_A; - if (!ssl3_digest_cached_records(s, 0)) { - s->state = SSL_ST_ERR; - return -1; - } - } else { - s->s3->tmp.cert_request = 1; - ret = ssl3_send_certificate_request(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_SRVR_DONE_A; - s->init_num = 0; - } - break; - - case SSL3_ST_SW_SRVR_DONE_A: - case SSL3_ST_SW_SRVR_DONE_B: - ret = ssl3_send_server_done(s); - if (ret <= 0) - goto end; - s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; - s->state = SSL3_ST_SW_FLUSH; - s->init_num = 0; - break; - - case SSL3_ST_SW_FLUSH: - - /* - * This code originally checked to see if any data was pending - * using BIO_CTRL_INFO and then flushed. This caused problems as - * documented in PR#1939. The proposed fix doesn't completely - * resolve this issue as buggy implementations of - * BIO_CTRL_PENDING still exist. So instead we just flush - * unconditionally. - */ - - s->rwstate = SSL_WRITING; - if (BIO_flush(s->wbio) <= 0) { - ret = -1; - goto end; - } - s->rwstate = SSL_NOTHING; - - s->state = s->s3->tmp.next_state; - break; - - case SSL3_ST_SR_CERT_A: - case SSL3_ST_SR_CERT_B: - if (s->s3->tmp.cert_request) { - ret = ssl3_get_client_certificate(s); - if (ret <= 0) - goto end; - } - s->init_num = 0; - s->state = SSL3_ST_SR_KEY_EXCH_A; - break; - - case SSL3_ST_SR_KEY_EXCH_A: - case SSL3_ST_SR_KEY_EXCH_B: - ret = ssl3_get_client_key_exchange(s); - if (ret <= 0) - goto end; - if (ret == 2) { - /* - * For the ECDH ciphersuites when the client sends its ECDH - * pub key in a certificate, the CertificateVerify message is - * not sent. Also for GOST ciphersuites when the client uses - * its key from the certificate for key exchange. - */ - s->state = SSL3_ST_SR_CHANGE_A; - s->init_num = 0; - } else if (SSL_USE_SIGALGS(s)) { - s->state = SSL3_ST_SR_CERT_VRFY_A; - s->init_num = 0; - if (!s->session->peer) - break; - if (!s->s3->handshake_buffer) { - SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return -1; - } - /* - * For sigalgs freeze the handshake buffer. If we support - * extms we've done this already so this is a no-op - */ - if (!ssl3_digest_cached_records(s, 1)) { - s->state = SSL_ST_ERR; - return -1; - } - } else { - int offset = 0; - int dgst_num; - - s->state = SSL3_ST_SR_CERT_VRFY_A; - s->init_num = 0; - - /* - * We need to get hashes here so if there is a client cert, - * it can be verified FIXME - digest processing for - * CertificateVerify should be generalized. But it is next - * step - */ - if (!ssl3_digest_cached_records(s, 0)) { - s->state = SSL_ST_ERR; - return -1; - } - for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) - if (s->s3->handshake_dgst[dgst_num]) { - int dgst_size; - - s->method->ssl3_enc->cert_verify_mac(s, - EVP_MD_CTX_type - (s-> - s3->handshake_dgst - [dgst_num]), - &(s->s3-> - tmp.cert_verify_md - [offset])); - dgst_size = - EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); - if (dgst_size < 0) { - s->state = SSL_ST_ERR; - ret = -1; - goto end; - } - offset += dgst_size; - } - } - break; - - case SSL3_ST_SR_CERT_VRFY_A: - case SSL3_ST_SR_CERT_VRFY_B: - ret = ssl3_get_cert_verify(s); - if (ret <= 0) - goto end; - - s->state = SSL3_ST_SR_CHANGE_A; - s->init_num = 0; - break; - -#if !defined(OPENSSL_NO_NEXTPROTONEG) - case SSL3_ST_SR_NEXT_PROTO_A: - case SSL3_ST_SR_NEXT_PROTO_B: - ret = ssl3_get_next_proto(s); - if (ret <= 0) - goto end; - s->init_num = 0; - s->state = SSL3_ST_SR_FINISHED_A; - break; -#endif - - - case SSL3_ST_SR_CHANGE_A: - case SSL3_ST_SR_CHANGE_B: - ret = ssl3_get_change_cipher_spec(s, SSL3_ST_SR_CHANGE_A, - SSL3_ST_SR_CHANGE_B); - if (ret <= 0) - goto end; - -#if defined(OPENSSL_NO_NEXTPROTONEG) - s->state = SSL3_ST_SR_FINISHED_A; -#else - if (s->s3->next_proto_neg_seen) - s->state = SSL3_ST_SR_NEXT_PROTO_A; - else - s->state = SSL3_ST_SR_FINISHED_A; -#endif - s->init_num = 0; - break; - - case SSL3_ST_SR_FINISHED_A: - case SSL3_ST_SR_FINISHED_B: - ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, - SSL3_ST_SR_FINISHED_B); - if (ret <= 0) - goto end; - if (s->hit) - s->state = SSL_ST_OK; - else if (s->tlsext_ticket_expected) - s->state = SSL3_ST_SW_SESSION_TICKET_A; - else - s->state = SSL3_ST_SW_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_SESSION_TICKET_A: - case SSL3_ST_SW_SESSION_TICKET_B: - ret = ssl3_send_newsession_ticket(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CERT_STATUS_A: - case SSL3_ST_SW_CERT_STATUS_B: - ret = ssl3_send_cert_status(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_KEY_EXCH_A; - s->init_num = 0; - break; - - case SSL3_ST_SW_CHANGE_A: - case SSL3_ST_SW_CHANGE_B: - - s->session->cipher = s->s3->tmp.new_cipher; - if (!s->method->ssl3_enc->setup_key_block(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - ret = ssl3_send_change_cipher_spec(s, - SSL3_ST_SW_CHANGE_A, - SSL3_ST_SW_CHANGE_B); - - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_FINISHED_A; - s->init_num = 0; - - if (!s->method->ssl3_enc->change_cipher_state(s, - SSL3_CHANGE_CIPHER_SERVER_WRITE)) - { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - - break; - - case SSL3_ST_SW_FINISHED_A: - case SSL3_ST_SW_FINISHED_B: - ret = ssl3_send_finished(s, - SSL3_ST_SW_FINISHED_A, - SSL3_ST_SW_FINISHED_B, - s->method-> - ssl3_enc->server_finished_label, - s->method-> - ssl3_enc->server_finished_label_len); - if (ret <= 0) - goto end; - s->state = SSL3_ST_SW_FLUSH; - if (s->hit) { - s->s3->tmp.next_state = SSL3_ST_SR_CHANGE_A; - } else - s->s3->tmp.next_state = SSL_ST_OK; - s->init_num = 0; - break; - - case SSL_ST_OK: - /* clean a few things up */ - ssl3_cleanup_key_block(s); - - BUF_MEM_free(s->init_buf); - s->init_buf = NULL; - - /* remove buffering on output */ - ssl_free_wbio_buffer(s); - - s->init_num = 0; - - if (s->renegotiate == 2) { /* skipped if we just sent a - * HelloRequest */ - s->renegotiate = 0; - s->new_session = 0; - - ssl_update_cache(s, SSL_SESS_CACHE_SERVER); - - s->ctx->stats.sess_accept_good++; - /* s->server=1; */ - s->handshake_func = ssl3_accept; - - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_DONE, 1); - } - - ret = 1; - goto end; - /* break; */ - - case SSL_ST_ERR: - default: - SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); - ret = -1; - goto end; - /* break; */ - } - - if (!s->s3->tmp.reuse_message && !skip) { - if (s->debug) { - if ((ret = BIO_flush(s->wbio)) <= 0) - goto end; - } - - if ((cb != NULL) && (s->state != state)) { - new_state = s->state; - s->state = state; - cb(s, SSL_CB_ACCEPT_LOOP, 1); - s->state = new_state; - } - } - skip = 0; - } - end: - /* BIO_flush(s->wbio); */ - - s->in_handshake--; - if (cb != NULL) - cb(s, SSL_CB_ACCEPT_EXIT, ret); - return (ret); -} - -int ssl3_send_hello_request(SSL *s) -{ - - if (s->state == SSL3_ST_SW_HELLO_REQ_A) { - if (!ssl_set_handshake_header(s, SSL3_MT_HELLO_REQUEST, 0)) { - SSLerr(SSL_F_SSL3_SEND_HELLO_REQUEST, ERR_R_INTERNAL_ERROR); - return -1; - } - s->state = SSL3_ST_SW_HELLO_REQ_B; - } - - /* SSL3_ST_SW_HELLO_REQ_B */ - return ssl_do_write(s); -} - -int ssl3_get_client_hello(SSL *s) -{ - int i, ok, al = SSL_AD_INTERNAL_ERROR, ret = -1; - unsigned int j, complen = 0; - long n; - unsigned long id; - SSL_CIPHER *c; -#ifndef OPENSSL_NO_COMP - SSL_COMP *comp = NULL; -#endif - STACK_OF(SSL_CIPHER) *ciphers = NULL; - int protverr = 1; - /* |cookie| will only be initialized for DTLS. */ - PACKET pkt, session_id, cipher_suites, compression, extensions, cookie; - int is_v2_record; - - if (s->state == SSL3_ST_SR_CLNT_HELLO_C && !s->first_packet) - goto retry_cert; - - /* - * We do this so that we will respond with our native type. If we are - * TLSv1 and we get SSLv3, we will respond with TLSv1, This down - * switching should be handled by a different method. If we are SSLv3, we - * will respond with SSLv3, even if prompted with TLSv1. - */ - if (s->state == SSL3_ST_SR_CLNT_HELLO_A) { - s->state = SSL3_ST_SR_CLNT_HELLO_B; - } - s->first_packet = 1; - n = s->method->ssl_get_message(s, - SSL3_ST_SR_CLNT_HELLO_B, - SSL3_ST_SR_CLNT_HELLO_C, - SSL3_MT_CLIENT_HELLO, - SSL3_RT_MAX_PLAIN_LENGTH, &ok); - - if (!ok) - return ((int)n); - s->first_packet = 0; - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - - is_v2_record = RECORD_LAYER_is_sslv2_record(&s->rlayer); - - PACKET_null_init(&cookie); - /* First lets get s->client_version set correctly */ - if (is_v2_record) { - unsigned int version; - unsigned int mt; - /*- - * An SSLv3/TLSv1 backwards-compatible CLIENT-HELLO in an SSLv2 - * header is sent directly on the wire, not wrapped as a TLS - * record. Our record layer just processes the message length and passes - * the rest right through. Its format is: - * Byte Content - * 0-1 msg_length - decoded by the record layer - * 2 msg_type - s->init_msg points here - * 3-4 version - * 5-6 cipher_spec_length - * 7-8 session_id_length - * 9-10 challenge_length - * ... ... - */ - - if (!PACKET_get_1(&pkt, &mt) - || mt != SSL2_MT_CLIENT_HELLO) { - /* - * Should never happen. We should have tested this in the record - * layer in order to have determined that this is a SSLv2 record - * in the first place - */ - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto err; - } - - if (!PACKET_get_net_2(&pkt, &version)) { - /* No protocol version supplied! */ - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); - goto err; - } - if (version == 0x0002) { - /* This is real SSLv2. We don't support it. */ - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); - goto err; - } else if ((version & 0xff00) == (SSL3_VERSION_MAJOR << 8)) { - /* SSLv3/TLS */ - s->client_version = version; - } else { - /* No idea what protocol this is */ - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); - goto err; - } - } else { - /* - * use version from inside client hello, not from record header (may - * differ: see RFC 2246, Appendix E, second paragraph) - */ - if(!PACKET_get_net_2(&pkt, (unsigned int *)&s->client_version)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); - goto f_err; - } - } - - /* Do SSL/TLS version negotiation if applicable */ - if (!SSL_IS_DTLS(s)) { - if (s->version != TLS_ANY_VERSION) { - if (s->client_version >= s->version) { - protverr = 0; - } - } else if (s->client_version >= SSL3_VERSION) { - switch(s->client_version) { - default: - case TLS1_2_VERSION: - if(!(s->options & SSL_OP_NO_TLSv1_2)) { - s->version = TLS1_2_VERSION; - s->method = TLSv1_2_server_method(); - protverr = 0; - break; - } - /* Deliberately fall through */ - case TLS1_1_VERSION: - if(!(s->options & SSL_OP_NO_TLSv1_1)) { - s->version = TLS1_1_VERSION; - s->method = TLSv1_1_server_method(); - protverr = 0; - break; - } - /* Deliberately fall through */ - case TLS1_VERSION: - if(!(s->options & SSL_OP_NO_TLSv1)) { - s->version = TLS1_VERSION; - s->method = TLSv1_server_method(); - protverr = 0; - break; - } - /* Deliberately fall through */ - case SSL3_VERSION: -#ifndef OPENSSL_NO_SSL3 - if(!(s->options & SSL_OP_NO_SSLv3)) { - s->version = SSL3_VERSION; - s->method = SSLv3_server_method(); - protverr = 0; - break; - } -#else - break; -#endif - } - } - } else if (s->client_version <= s->version - || s->method->version == DTLS_ANY_VERSION) { - /* - * For DTLS we just check versions are potentially compatible. Version - * negotiation comes later. - */ - protverr = 0; - } - - if (protverr) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); - if ((!s->enc_write_ctx && !s->write_hash)) { - /* - * similar to ssl3_get_record, send alert using remote version - * number - */ - s->version = s->client_version; - } - al = SSL_AD_PROTOCOL_VERSION; - goto f_err; - } - - /* Parse the message and load client random. */ - if (is_v2_record) { - /* - * Handle an SSLv2 backwards compatible ClientHello - * Note, this is only for SSLv3+ using the backward compatible format. - * Real SSLv2 is not supported, and is rejected above. - */ - unsigned int cipher_len, session_id_len, challenge_len; - PACKET challenge; - - if (!PACKET_get_net_2(&pkt, &cipher_len) - || !PACKET_get_net_2(&pkt, &session_id_len) - || !PACKET_get_net_2(&pkt, &challenge_len)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH); - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - - if (!PACKET_get_sub_packet(&pkt, &cipher_suites, cipher_len) - || !PACKET_get_sub_packet(&pkt, &session_id, session_id_len) - || !PACKET_get_sub_packet(&pkt, &challenge, challenge_len) - /* No extensions. */ - || PACKET_remaining(&pkt) != 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH); - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - - /* Load the client random */ - challenge_len = challenge_len > SSL3_RANDOM_SIZE ? SSL3_RANDOM_SIZE : - challenge_len; - memset(s->s3->client_random, 0, SSL3_RANDOM_SIZE); - if (!PACKET_copy_bytes(&challenge, - s->s3->client_random + SSL3_RANDOM_SIZE - - challenge_len, challenge_len)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - - PACKET_null_init(&compression); - PACKET_null_init(&extensions); - } else { - /* Regular ClientHello. */ - if (!PACKET_copy_bytes(&pkt, s->s3->client_random, SSL3_RANDOM_SIZE) - || !PACKET_get_length_prefixed_1(&pkt, &session_id)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - - if (SSL_IS_DTLS(s)) { - if (!PACKET_get_length_prefixed_1(&pkt, &cookie)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - /* - * If we require cookies and this ClientHello doesn't contain one, - * just return since we do not want to allocate any memory yet. - * So check cookie length... - */ - if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { - if (PACKET_remaining(&cookie) == 0) - return 1; - } - } - - if (!PACKET_get_length_prefixed_2(&pkt, &cipher_suites) - || !PACKET_get_length_prefixed_1(&pkt, &compression)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - /* Could be empty. */ - extensions = pkt; - } - - s->hit = 0; - - /* - * We don't allow resumption in a backwards compatible ClientHello. - * TODO(openssl-team): in TLS1.1+, session_id MUST be empty. - * - * Versions before 0.9.7 always allow clients to resume sessions in - * renegotiation. 0.9.7 and later allow this by default, but optionally - * ignore resumption requests with flag - * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather - * than a change to default behavior so that applications relying on - * this for security won't even compile against older library versions). - * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to - * request renegotiation but not a new session (s->new_session remains - * unset): for servers, this essentially just means that the - * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be - * ignored. - */ - if (is_v2_record || - (s->new_session && - (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) { - if (!ssl_get_new_session(s, 1)) - goto err; - } else { - i = ssl_get_prev_session(s, &extensions, &session_id); - /* - * Only resume if the session's version matches the negotiated - * version. - * RFC 5246 does not provide much useful advice on resumption - * with a different protocol version. It doesn't forbid it but - * the sanity of such behaviour would be questionable. - * In practice, clients do not accept a version mismatch and - * will abort the handshake with an error. - */ - if (i == 1 && s->version == s->session->ssl_version) { - /* previous session */ - s->hit = 1; - } else if (i == -1) { - goto err; - } else { - /* i == 0 */ - if (!ssl_get_new_session(s, 1)) - goto err; - } - } - - if (SSL_IS_DTLS(s)) { - /* Empty cookie was already handled above by returning early. */ - if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { - if (s->ctx->app_verify_cookie_cb != NULL) { - if (s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookie), - PACKET_remaining(&cookie)) == 0) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_COOKIE_MISMATCH); - goto f_err; - /* else cookie verification succeeded */ - } - /* default verification */ - } else if (!PACKET_equal(&cookie, s->d1->cookie, - s->d1->cookie_len)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); - goto f_err; - } - /* Set to -2 so if successful we return 2 */ - ret = -2; - } - if (s->method->version == DTLS_ANY_VERSION) { - /* Select version to use */ - if (s->client_version <= DTLS1_2_VERSION && - !(s->options & SSL_OP_NO_DTLSv1_2)) { - s->version = DTLS1_2_VERSION; - s->method = DTLSv1_2_server_method(); - } else if (tls1_suiteb(s)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); - s->version = s->client_version; - al = SSL_AD_PROTOCOL_VERSION; - goto f_err; - } else if (s->client_version <= DTLS1_VERSION && - !(s->options & SSL_OP_NO_DTLSv1)) { - s->version = DTLS1_VERSION; - s->method = DTLSv1_server_method(); - } else { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_WRONG_VERSION_NUMBER); - s->version = s->client_version; - al = SSL_AD_PROTOCOL_VERSION; - goto f_err; - } - s->session->ssl_version = s->version; - } - } - - if (ssl_bytes_to_cipher_list(s, &cipher_suites, &(ciphers), - is_v2_record, &al) == NULL) { - goto f_err; - } - - /* If it is a hit, check that the cipher is in the list */ - if (s->hit) { - j = 0; - id = s->session->cipher->id; - -#ifdef CIPHER_DEBUG - fprintf(stderr, "client sent %d ciphers\n", - sk_SSL_CIPHER_num(ciphers)); -#endif - for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { - c = sk_SSL_CIPHER_value(ciphers, i); -#ifdef CIPHER_DEBUG - fprintf(stderr, "client [%2d of %2d]:%s\n", - i, sk_SSL_CIPHER_num(ciphers), SSL_CIPHER_get_name(c)); -#endif - if (c->id == id) { - j = 1; - break; - } - } - if (j == 0) { - /* - * we need to have the cipher in the cipher list if we are asked - * to reuse it - */ - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_REQUIRED_CIPHER_MISSING); - goto f_err; - } - } - - complen = PACKET_remaining(&compression); - for (j = 0; j < complen; j++) { - if (PACKET_data(&compression)[j] == 0) - break; - } - - if (j >= complen) { - /* no compress */ - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED); - goto f_err; - } - - /* TLS extensions */ - if (s->version >= SSL3_VERSION) { - if (!ssl_parse_clienthello_tlsext(s, &extensions)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT); - goto err; - } - } - - /* - * Check if we want to use external pre-shared secret for this handshake - * for not reused session only. We need to generate server_random before - * calling tls_session_secret_cb in order to allow SessionTicket - * processing to use it in key derivation. - */ - { - unsigned char *pos; - pos = s->s3->server_random; - if (ssl_fill_hello_random(s, 1, pos, SSL3_RANDOM_SIZE) <= 0) { - goto f_err; - } - } - - if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) { - SSL_CIPHER *pref_cipher = NULL; - - s->session->master_key_length = sizeof(s->session->master_key); - if (s->tls_session_secret_cb(s, s->session->master_key, - &s->session->master_key_length, ciphers, - &pref_cipher, - s->tls_session_secret_cb_arg)) { - s->hit = 1; - s->session->ciphers = ciphers; - s->session->verify_result = X509_V_OK; - - ciphers = NULL; - - /* check if some cipher was preferred by call back */ - pref_cipher = - pref_cipher ? pref_cipher : ssl3_choose_cipher(s, - s-> - session->ciphers, - SSL_get_ciphers - (s)); - if (pref_cipher == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER); - goto f_err; - } - - s->session->cipher = pref_cipher; - sk_SSL_CIPHER_free(s->cipher_list); - s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers); - sk_SSL_CIPHER_free(s->cipher_list_by_id); - s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers); - } - } - - /* - * Worst case, we will use the NULL compression, but if we have other - * options, we will now look for them. We have complen-1 compression - * algorithms from the client, starting at q. - */ - s->s3->tmp.new_compression = NULL; -#ifndef OPENSSL_NO_COMP - /* This only happens if we have a cache hit */ - if (s->session->compress_meth != 0) { - int m, comp_id = s->session->compress_meth; - unsigned int k; - /* Perform sanity checks on resumed compression algorithm */ - /* Can't disable compression */ - if (!ssl_allow_compression(s)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_INCONSISTENT_COMPRESSION); - goto f_err; - } - /* Look for resumed compression method */ - for (m = 0; m < sk_SSL_COMP_num(s->ctx->comp_methods); m++) { - comp = sk_SSL_COMP_value(s->ctx->comp_methods, m); - if (comp_id == comp->id) { - s->s3->tmp.new_compression = comp; - break; - } - } - if (s->s3->tmp.new_compression == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_INVALID_COMPRESSION_ALGORITHM); - goto f_err; - } - /* Look for resumed method in compression list */ - for (k = 0; k < complen; k++) { - if (PACKET_data(&compression)[k] == comp_id) - break; - } - if (k >= complen) { - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, - SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING); - goto f_err; - } - } else if (s->hit) - comp = NULL; - else if (ssl_allow_compression(s) && s->ctx->comp_methods) { - /* See if we have a match */ - int m, nn, v, done = 0; - unsigned int o; - - nn = sk_SSL_COMP_num(s->ctx->comp_methods); - for (m = 0; m < nn; m++) { - comp = sk_SSL_COMP_value(s->ctx->comp_methods, m); - v = comp->id; - for (o = 0; o < complen; o++) { - if (v == PACKET_data(&compression)[o]) { - done = 1; - break; - } - } - if (done) - break; - } - if (done) - s->s3->tmp.new_compression = comp; - else - comp = NULL; - } -#else - /* - * If compression is disabled we'd better not try to resume a session - * using compression. - */ - if (s->session->compress_meth != 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_INCONSISTENT_COMPRESSION); - goto f_err; - } -#endif - - /* - * Given s->session->ciphers and SSL_get_ciphers, we must pick a cipher - */ - - if (!s->hit) { -#ifdef OPENSSL_NO_COMP - s->session->compress_meth = 0; -#else - s->session->compress_meth = (comp == NULL) ? 0 : comp->id; -#endif - sk_SSL_CIPHER_free(s->session->ciphers); - s->session->ciphers = ciphers; - if (ciphers == NULL) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto f_err; - } - ciphers = NULL; - if (!tls1_set_server_sigalgs(s)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); - goto err; - } - /* Let cert callback update server certificates if required */ - retry_cert: - if (s->cert->cert_cb) { - int rv = s->cert->cert_cb(s, s->cert->cert_cb_arg); - if (rv == 0) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CERT_CB_ERROR); - goto f_err; - } - if (rv < 0) { - s->rwstate = SSL_X509_LOOKUP; - return -1; - } - s->rwstate = SSL_NOTHING; - } - c = ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s)); - - if (c == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER); - goto f_err; - } - s->s3->tmp.new_cipher = c; - /* check whether we should disable session resumption */ - if (s->not_resumable_session_cb != NULL) - s->session->not_resumable = s->not_resumable_session_cb(s, - ((c->algorithm_mkey & (SSL_kDHE | SSL_kECDHE)) - != 0)); - if (s->session->not_resumable) - /* do not send a session ticket */ - s->tlsext_ticket_expected = 0; - } else { - /* Session-id reuse */ - s->s3->tmp.new_cipher = s->session->cipher; - } - - if (!SSL_USE_SIGALGS(s) || !(s->verify_mode & SSL_VERIFY_PEER)) { - if (!ssl3_digest_cached_records(s, 0)) - goto f_err; - } - - /*- - * we now have the following setup. - * client_random - * cipher_list - our prefered list of ciphers - * ciphers - the clients prefered list of ciphers - * compression - basically ignored right now - * ssl version is set - sslv3 - * s->session - The ssl session has been setup. - * s->hit - session reuse flag - * s->s3->tmp.new_cipher- the new cipher to use. - */ - - /* Handles TLS extensions that we couldn't check earlier */ - if (s->version >= SSL3_VERSION) { - if (ssl_check_clienthello_tlsext_late(s) <= 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); - goto err; - } - } - - if (ret < 0) - ret = -ret; - if (0) { - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - err: - s->state = SSL_ST_ERR; - } - - sk_SSL_CIPHER_free(ciphers); - return ret < 0 ? -1 : ret; -} - -int ssl3_send_server_hello(SSL *s) -{ - unsigned char *buf; - unsigned char *p, *d; - int i, sl; - int al = 0; - unsigned long l; - - if (s->state == SSL3_ST_SW_SRVR_HELLO_A) { - buf = (unsigned char *)s->init_buf->data; - - /* Do the message type and length last */ - d = p = ssl_handshake_start(s); - - *(p++) = s->version >> 8; - *(p++) = s->version & 0xff; - - /* - * Random stuff. Filling of the server_random takes place in - * ssl3_get_client_hello() - */ - memcpy(p, s->s3->server_random, SSL3_RANDOM_SIZE); - p += SSL3_RANDOM_SIZE; - - /*- - * There are several cases for the session ID to send - * back in the server hello: - * - For session reuse from the session cache, - * we send back the old session ID. - * - If stateless session reuse (using a session ticket) - * is successful, we send back the client's "session ID" - * (which doesn't actually identify the session). - * - If it is a new session, we send back the new - * session ID. - * - However, if we want the new session to be single-use, - * we send back a 0-length session ID. - * s->hit is non-zero in either case of session reuse, - * so the following won't overwrite an ID that we're supposed - * to send back. - */ - if (s->session->not_resumable || - (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER) - && !s->hit)) - s->session->session_id_length = 0; - - sl = s->session->session_id_length; - if (sl > (int)sizeof(s->session->session_id)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return -1; - } - *(p++) = sl; - memcpy(p, s->session->session_id, sl); - p += sl; - - /* put the cipher */ - i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p); - p += i; - - /* put the compression method */ -#ifdef OPENSSL_NO_COMP - *(p++) = 0; -#else - if (s->s3->tmp.new_compression == NULL) - *(p++) = 0; - else - *(p++) = s->s3->tmp.new_compression->id; -#endif - - if (ssl_prepare_serverhello_tlsext(s) <= 0) { - SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, SSL_R_SERVERHELLO_TLSEXT); - s->state = SSL_ST_ERR; - return -1; - } - if ((p = - ssl_add_serverhello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH, - &al)) == NULL) { - ssl3_send_alert(s, SSL3_AL_FATAL, al); - SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return -1; - } - - /* do the header */ - l = (p - d); - if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_HELLO, l)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); - return -1; - } - s->state = SSL3_ST_SW_SRVR_HELLO_B; - } - - /* SSL3_ST_SW_SRVR_HELLO_B */ - return ssl_do_write(s); -} - -int ssl3_send_server_done(SSL *s) -{ - - if (s->state == SSL3_ST_SW_SRVR_DONE_A) { - if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_DONE, 0)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_DONE, ERR_R_INTERNAL_ERROR); - return -1; - } - s->state = SSL3_ST_SW_SRVR_DONE_B; - } - - /* SSL3_ST_SW_SRVR_DONE_B */ - return ssl_do_write(s); -} - -int ssl3_send_server_key_exchange(SSL *s) -{ -#ifndef OPENSSL_NO_RSA - unsigned char *q; - int j, num; - RSA *rsa; - unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; - unsigned int u; -#endif -#ifndef OPENSSL_NO_DH - DH *dh = NULL, *dhp; -#endif -#ifndef OPENSSL_NO_EC - EC_KEY *ecdh = NULL, *ecdhp; - unsigned char *encodedPoint = NULL; - int encodedlen = 0; - int curve_id = 0; - BN_CTX *bn_ctx = NULL; -#endif - EVP_PKEY *pkey; - const EVP_MD *md = NULL; - unsigned char *p, *d; - int al, i; - unsigned long type; - int n; - CERT *cert; - BIGNUM *r[4]; - int nr[4], kn; - BUF_MEM *buf; - EVP_MD_CTX md_ctx; - - EVP_MD_CTX_init(&md_ctx); - if (s->state == SSL3_ST_SW_KEY_EXCH_A) { - type = s->s3->tmp.new_cipher->algorithm_mkey; - cert = s->cert; - - buf = s->init_buf; - - r[0] = r[1] = r[2] = r[3] = NULL; - n = 0; -#ifndef OPENSSL_NO_PSK - if (type & SSL_PSK) { - /* - * reserve size for record length and PSK identity hint - */ - n += 2; - if (s->cert->psk_identity_hint) - n += strlen(s->cert->psk_identity_hint); - } - /* Plain PSK or RSAPSK nothing to do */ - if (type & (SSL_kPSK | SSL_kRSAPSK)) { - } else -#endif /* !OPENSSL_NO_PSK */ -#ifndef OPENSSL_NO_RSA - if (type & SSL_kRSA) { - rsa = cert->rsa_tmp; - if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) { - rsa = s->cert->rsa_tmp_cb(s, - SSL_C_IS_EXPORT(s->s3-> - tmp.new_cipher), - SSL_C_EXPORT_PKEYLENGTH(s->s3-> - tmp.new_cipher)); - if (rsa == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_ERROR_GENERATING_TMP_RSA_KEY); - goto f_err; - } - RSA_up_ref(rsa); - cert->rsa_tmp = rsa; - } - if (rsa == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_MISSING_TMP_RSA_KEY); - goto f_err; - } - r[0] = rsa->n; - r[1] = rsa->e; - s->s3->tmp.use_rsa_tmp = 1; - } else -#endif -#ifndef OPENSSL_NO_DH - if (type & (SSL_kDHE | SSL_kDHEPSK)) { - if (s->cert->dh_tmp_auto) { - dhp = ssl_get_auto_dh(s); - if (dhp == NULL) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto f_err; - } - } else - dhp = cert->dh_tmp; - if ((dhp == NULL) && (s->cert->dh_tmp_cb != NULL)) - dhp = s->cert->dh_tmp_cb(s, - SSL_C_IS_EXPORT(s->s3-> - tmp.new_cipher), - SSL_C_EXPORT_PKEYLENGTH(s->s3-> - tmp.new_cipher)); - if (dhp == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_MISSING_TMP_DH_KEY); - goto f_err; - } - if (!ssl_security(s, SSL_SECOP_TMP_DH, - DH_security_bits(dhp), 0, dhp)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_DH_KEY_TOO_SMALL); - goto f_err; - } - if (s->s3->tmp.dh != NULL) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } - - if (s->cert->dh_tmp_auto) - dh = dhp; - else if ((dh = DHparams_dup(dhp)) == NULL) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); - goto err; - } - - s->s3->tmp.dh = dh; - if ((dhp->pub_key == NULL || - dhp->priv_key == NULL || - (s->options & SSL_OP_SINGLE_DH_USE))) { - if (!DH_generate_key(dh)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); - goto err; - } - } else { - dh->pub_key = BN_dup(dhp->pub_key); - dh->priv_key = BN_dup(dhp->priv_key); - if ((dh->pub_key == NULL) || (dh->priv_key == NULL)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); - goto err; - } - } - r[0] = dh->p; - r[1] = dh->g; - r[2] = dh->pub_key; - } else -#endif -#ifndef OPENSSL_NO_EC - if (type & (SSL_kECDHE | SSL_kECDHEPSK)) { - const EC_GROUP *group; - - ecdhp = cert->ecdh_tmp; - if (s->cert->ecdh_tmp_auto) { - /* Get NID of appropriate shared curve */ - int nid = tls1_shared_curve(s, -2); - if (nid != NID_undef) - ecdhp = EC_KEY_new_by_curve_name(nid); - } else if ((ecdhp == NULL) && s->cert->ecdh_tmp_cb) { - ecdhp = s->cert->ecdh_tmp_cb(s, - SSL_C_IS_EXPORT(s->s3-> - tmp.new_cipher), - SSL_C_EXPORT_PKEYLENGTH(s-> - s3->tmp.new_cipher)); - } - if (ecdhp == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_MISSING_TMP_ECDH_KEY); - goto f_err; - } - - if (s->s3->tmp.ecdh != NULL) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } - - /* Duplicate the ECDH structure. */ - if (ecdhp == NULL) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); - goto err; - } - if (s->cert->ecdh_tmp_auto) - ecdh = ecdhp; - else if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); - goto err; - } - - s->s3->tmp.ecdh = ecdh; - if ((EC_KEY_get0_public_key(ecdh) == NULL) || - (EC_KEY_get0_private_key(ecdh) == NULL) || - (s->options & SSL_OP_SINGLE_ECDH_USE)) { - if (!EC_KEY_generate_key(ecdh)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - ERR_R_ECDH_LIB); - goto err; - } - } - - if (((group = EC_KEY_get0_group(ecdh)) == NULL) || - (EC_KEY_get0_public_key(ecdh) == NULL) || - (EC_KEY_get0_private_key(ecdh) == NULL)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); - goto err; - } - - if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && - (EC_GROUP_get_degree(group) > 163)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER); - goto err; - } - - /* - * XXX: For now, we only support ephemeral ECDH keys over named - * (not generic) curves. For supported named curves, curve_id is - * non-zero. - */ - if ((curve_id = - tls1_ec_nid2curve_id(EC_GROUP_get_curve_name(group))) - == 0) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_UNSUPPORTED_ELLIPTIC_CURVE); - goto err; - } - - /* - * Encode the public key. First check the size of encoding and - * allocate memory accordingly. - */ - encodedlen = EC_POINT_point2oct(group, - EC_KEY_get0_public_key(ecdh), - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, NULL); - - encodedPoint = (unsigned char *) - OPENSSL_malloc(encodedlen * sizeof(unsigned char)); - bn_ctx = BN_CTX_new(); - if ((encodedPoint == NULL) || (bn_ctx == NULL)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - ERR_R_MALLOC_FAILURE); - goto err; - } - - encodedlen = EC_POINT_point2oct(group, - EC_KEY_get0_public_key(ecdh), - POINT_CONVERSION_UNCOMPRESSED, - encodedPoint, encodedlen, bn_ctx); - - if (encodedlen == 0) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); - goto err; - } - - BN_CTX_free(bn_ctx); - bn_ctx = NULL; - - /* - * XXX: For now, we only support named (not generic) curves in - * ECDH ephemeral key exchanges. In this situation, we need four - * additional bytes to encode the entire ServerECDHParams - * structure. - */ - n += 4 + encodedlen; - - /* - * We'll generate the serverKeyExchange message explicitly so we - * can set these to NULLs - */ - r[0] = NULL; - r[1] = NULL; - r[2] = NULL; - r[3] = NULL; - } else -#endif /* !OPENSSL_NO_EC */ -#ifndef OPENSSL_NO_SRP - if (type & SSL_kSRP) { - if ((s->srp_ctx.N == NULL) || - (s->srp_ctx.g == NULL) || - (s->srp_ctx.s == NULL) || (s->srp_ctx.B == NULL)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_MISSING_SRP_PARAM); - goto err; - } - r[0] = s->srp_ctx.N; - r[1] = s->srp_ctx.g; - r[2] = s->srp_ctx.s; - r[3] = s->srp_ctx.B; - } else -#endif - { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); - goto f_err; - } - for (i = 0; i < 4 && r[i] != NULL; i++) { - nr[i] = BN_num_bytes(r[i]); -#ifndef OPENSSL_NO_SRP - if ((i == 2) && (type & SSL_kSRP)) - n += 1 + nr[i]; - else -#endif - n += 2 + nr[i]; - } - - if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aSRP)) - && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK)) { - if ((pkey = ssl_get_sign_pkey(s, s->s3->tmp.new_cipher, &md)) - == NULL) { - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - kn = EVP_PKEY_size(pkey); - } else { - pkey = NULL; - kn = 0; - } - - if (!BUF_MEM_grow_clean(buf, n + SSL_HM_HEADER_LENGTH(s) + kn)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_BUF); - goto err; - } - d = p = ssl_handshake_start(s); - -#ifndef OPENSSL_NO_PSK - if (type & SSL_PSK) { - /* copy PSK identity hint */ - if (s->cert->psk_identity_hint) { - s2n(strlen(s->cert->psk_identity_hint), p); - strncpy((char *)p, s->cert->psk_identity_hint, - strlen(s->cert->psk_identity_hint)); - p += strlen(s->cert->psk_identity_hint); - } else { - s2n(0, p); - } - } -#endif - - for (i = 0; i < 4 && r[i] != NULL; i++) { -#ifndef OPENSSL_NO_SRP - if ((i == 2) && (type & SSL_kSRP)) { - *p = nr[i]; - p++; - } else -#endif - s2n(nr[i], p); - BN_bn2bin(r[i], p); - p += nr[i]; - } - -#ifndef OPENSSL_NO_EC - if (type & (SSL_kECDHE | SSL_kECDHEPSK)) { - /* - * XXX: For now, we only support named (not generic) curves. In - * this situation, the serverKeyExchange message has: [1 byte - * CurveType], [2 byte CurveName] [1 byte length of encoded - * point], followed by the actual encoded point itself - */ - *p = NAMED_CURVE_TYPE; - p += 1; - *p = 0; - p += 1; - *p = curve_id; - p += 1; - *p = encodedlen; - p += 1; - memcpy(p, encodedPoint, encodedlen); - OPENSSL_free(encodedPoint); - encodedPoint = NULL; - p += encodedlen; - } -#endif - - /* not anonymous */ - if (pkey != NULL) { - /* - * n is the length of the params, they start at &(d[4]) and p - * points to the space at the end. - */ -#ifndef OPENSSL_NO_RSA - if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { - q = md_buf; - j = 0; - for (num = 2; num > 0; num--) { - EVP_MD_CTX_set_flags(&md_ctx, - EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); - EVP_DigestInit_ex(&md_ctx, (num == 2) - ? s->ctx->md5 : s->ctx->sha1, NULL); - EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]), - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]), - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(&md_ctx, d, n); - EVP_DigestFinal_ex(&md_ctx, q, (unsigned int *)&i); - q += i; - j += i; - } - if (RSA_sign(NID_md5_sha1, md_buf, j, - &(p[2]), &u, pkey->pkey.rsa) <= 0) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_RSA); - goto err; - } - s2n(u, p); - n += u + 2; - } else -#endif - if (md) { - /* send signature algorithm */ - if (SSL_USE_SIGALGS(s)) { - if (!tls12_get_sigandhash(p, pkey, md)) { - /* Should never happen */ - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto f_err; - } - p += 2; - } -#ifdef SSL_DEBUG - fprintf(stderr, "Using hash %s\n", EVP_MD_name(md)); -#endif - EVP_SignInit_ex(&md_ctx, md, NULL); - EVP_SignUpdate(&md_ctx, &(s->s3->client_random[0]), - SSL3_RANDOM_SIZE); - EVP_SignUpdate(&md_ctx, &(s->s3->server_random[0]), - SSL3_RANDOM_SIZE); - EVP_SignUpdate(&md_ctx, d, n); - if (!EVP_SignFinal(&md_ctx, &(p[2]), - (unsigned int *)&i, pkey)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_LIB_EVP); - goto err; - } - s2n(i, p); - n += i + 2; - if (SSL_USE_SIGALGS(s)) - n += 2; - } else { - /* Is this error check actually needed? */ - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, - SSL_R_UNKNOWN_PKEY_TYPE); - goto f_err; - } - } - - if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_KEY_EXCHANGE, n)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - } - - s->state = SSL3_ST_SW_KEY_EXCH_B; - EVP_MD_CTX_cleanup(&md_ctx); - return ssl_do_write(s); - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - err: -#ifndef OPENSSL_NO_EC - OPENSSL_free(encodedPoint); - BN_CTX_free(bn_ctx); -#endif - EVP_MD_CTX_cleanup(&md_ctx); - s->state = SSL_ST_ERR; - return (-1); -} - -int ssl3_send_certificate_request(SSL *s) -{ - unsigned char *p, *d; - int i, j, nl, off, n; - STACK_OF(X509_NAME) *sk = NULL; - X509_NAME *name; - BUF_MEM *buf; - - if (s->state == SSL3_ST_SW_CERT_REQ_A) { - buf = s->init_buf; - - d = p = ssl_handshake_start(s); - - /* get the list of acceptable cert types */ - p++; - n = ssl3_get_req_cert_type(s, p); - d[0] = n; - p += n; - n++; - - if (SSL_USE_SIGALGS(s)) { - const unsigned char *psigs; - unsigned char *etmp = p; - nl = tls12_get_psigalgs(s, &psigs); - /* Skip over length for now */ - p += 2; - nl = tls12_copy_sigalgs(s, p, psigs, nl); - /* Now fill in length */ - s2n(nl, etmp); - p += nl; - n += nl + 2; - } - - off = n; - p += 2; - n += 2; - - sk = SSL_get_client_CA_list(s); - nl = 0; - if (sk != NULL) { - for (i = 0; i < sk_X509_NAME_num(sk); i++) { - name = sk_X509_NAME_value(sk, i); - j = i2d_X509_NAME(name, NULL); - if (!BUF_MEM_grow_clean - (buf, SSL_HM_HEADER_LENGTH(s) + n + j + 2)) { - SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, - ERR_R_BUF_LIB); - goto err; - } - p = ssl_handshake_start(s) + n; - s2n(j, p); - i2d_X509_NAME(name, &p); - n += 2 + j; - nl += 2 + j; - } - } - /* else no CA names */ - p = ssl_handshake_start(s) + off; - s2n(nl, p); - - if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_REQUEST, n)) { - SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, ERR_R_INTERNAL_ERROR); - return -1; - } - - s->state = SSL3_ST_SW_CERT_REQ_B; - } - - /* SSL3_ST_SW_CERT_REQ_B */ - return ssl_do_write(s); - err: - s->state = SSL_ST_ERR; - return (-1); -} - -int ssl3_get_client_key_exchange(SSL *s) -{ - unsigned int i; - int al, ok; - long n; - unsigned long alg_k; -#ifndef OPENSSL_NO_RSA - RSA *rsa = NULL; - EVP_PKEY *pkey = NULL; -#endif -#ifndef OPENSSL_NO_DH - BIGNUM *pub = NULL; - DH *dh_srvr, *dh_clnt = NULL; -#endif -#ifndef OPENSSL_NO_EC - EC_KEY *srvr_ecdh = NULL; - EVP_PKEY *clnt_pub_pkey = NULL; - EC_POINT *clnt_ecpoint = NULL; - BN_CTX *bn_ctx = NULL; -#endif - PACKET pkt, enc_premaster; - unsigned char *data, *rsa_decrypt = NULL; - - n = s->method->ssl_get_message(s, - SSL3_ST_SR_KEY_EXCH_A, - SSL3_ST_SR_KEY_EXCH_B, - SSL3_MT_CLIENT_KEY_EXCHANGE, 2048, &ok); - - if (!ok) - return ((int)n); - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - - alg_k = s->s3->tmp.new_cipher->algorithm_mkey; - -#ifndef OPENSSL_NO_PSK - /* For PSK parse and retrieve identity, obtain PSK key */ - if (alg_k & SSL_PSK) { - unsigned char psk[PSK_MAX_PSK_LEN]; - size_t psklen; - PACKET psk_identity; - - if (!PACKET_get_length_prefixed_2(&pkt, &psk_identity)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - if (PACKET_remaining(&psk_identity) > PSK_MAX_IDENTITY_LEN) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_DATA_LENGTH_TOO_LONG); - goto f_err; - } - if (s->psk_server_callback == NULL) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_PSK_NO_SERVER_CB); - goto f_err; - } - - if (!PACKET_strndup(&psk_identity, &s->session->psk_identity)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - - psklen = s->psk_server_callback(s, s->session->psk_identity, - psk, sizeof(psk)); - - if (psklen > PSK_MAX_PSK_LEN) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } else if (psklen == 0) { - /* - * PSK related to the given identity not found - */ - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_PSK_IDENTITY_NOT_FOUND); - al = SSL_AD_UNKNOWN_PSK_IDENTITY; - goto f_err; - } - - OPENSSL_free(s->s3->tmp.psk); - s->s3->tmp.psk = BUF_memdup(psk, psklen); - OPENSSL_cleanse(psk, psklen); - - if (s->s3->tmp.psk == NULL) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto f_err; - } - - s->s3->tmp.psklen = psklen; - } - if (alg_k & SSL_kPSK) { - /* Identity extracted earlier: should be nothing left */ - if (PACKET_remaining(&pkt) != 0) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - /* PSK handled by ssl_generate_master_secret */ - if (!ssl_generate_master_secret(s, NULL, 0, 0)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - } else -#endif -#ifndef OPENSSL_NO_RSA - if (alg_k & (SSL_kRSA | SSL_kRSAPSK)) { - unsigned char rand_premaster_secret[SSL_MAX_MASTER_KEY_LENGTH]; - int decrypt_len; - unsigned char decrypt_good, version_good; - size_t j; - - /* FIX THIS UP EAY EAY EAY EAY */ - if (s->s3->tmp.use_rsa_tmp) { - if ((s->cert != NULL) && (s->cert->rsa_tmp != NULL)) - rsa = s->cert->rsa_tmp; - /* - * Don't do a callback because rsa_tmp should be sent already - */ - if (rsa == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_MISSING_TMP_RSA_PKEY); - goto f_err; - - } - } else { - pkey = s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey; - if ((pkey == NULL) || - (pkey->type != EVP_PKEY_RSA) || (pkey->pkey.rsa == NULL)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_MISSING_RSA_CERTIFICATE); - goto f_err; - } - rsa = pkey->pkey.rsa; - } - - /* SSLv3 and pre-standard DTLS omit the length bytes. */ - if (s->version == SSL3_VERSION || s->version == DTLS1_BAD_VER) { - enc_premaster = pkt; - } else { - PACKET orig = pkt; - if (!PACKET_get_length_prefixed_2(&pkt, &enc_premaster) - || PACKET_remaining(&pkt) != 0) { - /* Try SSLv3 behaviour for TLS. */ - if (s->options & SSL_OP_TLS_D5_BUG) { - enc_premaster = orig; - } else { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - } - } - - /* - * We want to be sure that the plaintext buffer size makes it safe to - * iterate over the entire size of a premaster secret - * (SSL_MAX_MASTER_KEY_LENGTH). Reject overly short RSA keys because - * their ciphertext cannot accommodate a premaster secret anyway. - */ - if (RSA_size(rsa) < SSL_MAX_MASTER_KEY_LENGTH) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - RSA_R_KEY_SIZE_TOO_SMALL); - goto f_err; - } - - rsa_decrypt = OPENSSL_malloc(RSA_size(rsa)); - if (rsa_decrypt == NULL) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto f_err; - } - - /* - * We must not leak whether a decryption failure occurs because of - * Bleichenbacher's attack on PKCS #1 v1.5 RSA padding (see RFC 2246, - * section 7.4.7.1). The code follows that advice of the TLS RFC and - * generates a random premaster secret for the case that the decrypt - * fails. See https://tools.ietf.org/html/rfc5246#section-7.4.7.1 - */ - - if (RAND_bytes(rand_premaster_secret, - sizeof(rand_premaster_secret)) <= 0) { - goto err; - } - - decrypt_len = RSA_private_decrypt(PACKET_remaining(&enc_premaster), - PACKET_data(&enc_premaster), - rsa_decrypt, rsa, RSA_PKCS1_PADDING); - ERR_clear_error(); - - /* - * decrypt_len should be SSL_MAX_MASTER_KEY_LENGTH. decrypt_good will - * be 0xff if so and zero otherwise. - */ - decrypt_good = - constant_time_eq_int_8(decrypt_len, SSL_MAX_MASTER_KEY_LENGTH); - - /* - * If the version in the decrypted pre-master secret is correct then - * version_good will be 0xff, otherwise it'll be zero. The - * Klima-Pokorny-Rosa extension of Bleichenbacher's attack - * (http://eprint.iacr.org/2003/052/) exploits the version number - * check as a "bad version oracle". Thus version checks are done in - * constant time and are treated like any other decryption error. - */ - version_good = - constant_time_eq_8(rsa_decrypt[0], - (unsigned)(s->client_version >> 8)); - version_good &= - constant_time_eq_8(rsa_decrypt[1], - (unsigned)(s->client_version & 0xff)); - - /* - * The premaster secret must contain the same version number as the - * ClientHello to detect version rollback attacks (strangely, the - * protocol does not offer such protection for DH ciphersuites). - * However, buggy clients exist that send the negotiated protocol - * version instead if the server does not support the requested - * protocol version. If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such - * clients. - */ - if (s->options & SSL_OP_TLS_ROLLBACK_BUG) { - unsigned char workaround_good; - workaround_good = - constant_time_eq_8(rsa_decrypt[0], (unsigned)(s->version >> 8)); - workaround_good &= - constant_time_eq_8(rsa_decrypt[1], - (unsigned)(s->version & 0xff)); - version_good |= workaround_good; - } - - /* - * Both decryption and version must be good for decrypt_good to - * remain non-zero (0xff). - */ - decrypt_good &= version_good; - - /* - * Now copy rand_premaster_secret over from p using - * decrypt_good_mask. If decryption failed, then p does not - * contain valid plaintext, however, a check above guarantees - * it is still sufficiently large to read from. - */ - for (j = 0; j < sizeof(rand_premaster_secret); j++) { - rsa_decrypt[j] = - constant_time_select_8(decrypt_good, rsa_decrypt[j], - rand_premaster_secret[j]); - } - - if (!ssl_generate_master_secret(s, rsa_decrypt, - sizeof(rand_premaster_secret), 0)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - OPENSSL_free(rsa_decrypt); - rsa_decrypt = NULL; - } else -#endif -#ifndef OPENSSL_NO_DH - if (alg_k & (SSL_kDHE | SSL_kDHr | SSL_kDHd | SSL_kDHEPSK)) { - int idx = -1; - EVP_PKEY *skey = NULL; - PACKET bookmark = pkt; - unsigned char shared[(OPENSSL_DH_MAX_MODULUS_BITS + 7) / 8]; - - if (!PACKET_get_net_2(&pkt, &i)) { - if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG); - goto f_err; - } - i = 0; - } - if (PACKET_remaining(&pkt) != i) { - if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG); - goto err; - } else { - pkt = bookmark; - i = PACKET_remaining(&pkt); - } - } - if (alg_k & SSL_kDHr) - idx = SSL_PKEY_DH_RSA; - else if (alg_k & SSL_kDHd) - idx = SSL_PKEY_DH_DSA; - if (idx >= 0) { - skey = s->cert->pkeys[idx].privatekey; - if ((skey == NULL) || - (skey->type != EVP_PKEY_DH) || (skey->pkey.dh == NULL)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_MISSING_RSA_CERTIFICATE); - goto f_err; - } - dh_srvr = skey->pkey.dh; - } else if (s->s3->tmp.dh == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_MISSING_TMP_DH_KEY); - goto f_err; - } else - dh_srvr = s->s3->tmp.dh; - - if (n == 0L) { - /* Get pubkey from cert */ - EVP_PKEY *clkey = X509_get_pubkey(s->session->peer); - if (clkey) { - if (EVP_PKEY_cmp_parameters(clkey, skey) == 1) - dh_clnt = EVP_PKEY_get1_DH(clkey); - } - if (dh_clnt == NULL) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_MISSING_TMP_DH_KEY); - goto f_err; - } - EVP_PKEY_free(clkey); - pub = dh_clnt->pub_key; - } else { - if (!PACKET_get_bytes(&pkt, &data, i)) { - /* We already checked we have enough data */ - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto f_err; - } - pub = BN_bin2bn(data, i, NULL); - } - if (pub == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_BN_LIB); - goto err; - } - - i = DH_compute_key(shared, pub, dh_srvr); - - if (i <= 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); - BN_clear_free(pub); - goto err; - } - - DH_free(s->s3->tmp.dh); - s->s3->tmp.dh = NULL; - if (dh_clnt) - DH_free(dh_clnt); - else - BN_clear_free(pub); - pub = NULL; - if (!ssl_generate_master_secret(s, shared, i, 0)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - if (dh_clnt) - return 2; - } else -#endif - -#ifndef OPENSSL_NO_EC - if (alg_k & (SSL_kECDHE | SSL_kECDHr | SSL_kECDHe | SSL_kECDHEPSK)) { - int ret = 1; - int field_size = 0; - const EC_KEY *tkey; - const EC_GROUP *group; - const BIGNUM *priv_key; - unsigned char *shared; - - /* initialize structures for server's ECDH key pair */ - if ((srvr_ecdh = EC_KEY_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto err; - } - - /* Let's get server private key and group information */ - if (alg_k & (SSL_kECDHr | SSL_kECDHe)) { - /* use the certificate */ - tkey = s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec; - } else { - /* - * use the ephermeral values we saved when generating the - * ServerKeyExchange msg. - */ - tkey = s->s3->tmp.ecdh; - } - - group = EC_KEY_get0_group(tkey); - priv_key = EC_KEY_get0_private_key(tkey); - - if (!EC_KEY_set_group(srvr_ecdh, group) || - !EC_KEY_set_private_key(srvr_ecdh, priv_key)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); - goto err; - } - - /* Let's get client's public key */ - if ((clnt_ecpoint = EC_POINT_new(group)) == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto err; - } - - if (n == 0L) { - /* Client Publickey was in Client Certificate */ - - if (alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_MISSING_TMP_ECDH_KEY); - goto f_err; - } - if (((clnt_pub_pkey = X509_get_pubkey(s->session->peer)) - == NULL) || (clnt_pub_pkey->type != EVP_PKEY_EC)) { - /* - * XXX: For now, we do not support client authentication - * using ECDH certificates so this branch (n == 0L) of the - * code is never executed. When that support is added, we - * ought to ensure the key received in the certificate is - * authorized for key agreement. ECDH_compute_key implicitly - * checks that the two ECDH shares are for the same group. - */ - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_UNABLE_TO_DECODE_ECDH_CERTS); - goto f_err; - } - - if (EC_POINT_copy(clnt_ecpoint, - EC_KEY_get0_public_key(clnt_pub_pkey-> - pkey.ec)) == 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); - goto err; - } - ret = 2; /* Skip certificate verify processing */ - } else { - /* - * Get client's public key from encoded point in the - * ClientKeyExchange message. - */ - if ((bn_ctx = BN_CTX_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - ERR_R_MALLOC_FAILURE); - goto err; - } - - /* Get encoded point length */ - if (!PACKET_get_1(&pkt, &i)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_LENGTH_MISMATCH); - goto f_err; - } - if (!PACKET_get_bytes(&pkt, &data, i) - || PACKET_remaining(&pkt) != 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); - goto err; - } - if (EC_POINT_oct2point(group, clnt_ecpoint, data, i, bn_ctx) == 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); - goto err; - } - } - - /* Compute the shared pre-master secret */ - field_size = EC_GROUP_get_degree(group); - if (field_size <= 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); - goto err; - } - shared = OPENSSL_malloc((field_size + 7) / 8); - if (shared == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto err; - } - i = ECDH_compute_key(shared, (field_size + 7) / 8, clnt_ecpoint, - srvr_ecdh, NULL); - if (i <= 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); - OPENSSL_free(shared); - goto err; - } - - EVP_PKEY_free(clnt_pub_pkey); - EC_POINT_free(clnt_ecpoint); - EC_KEY_free(srvr_ecdh); - BN_CTX_free(bn_ctx); - EC_KEY_free(s->s3->tmp.ecdh); - s->s3->tmp.ecdh = NULL; - - if (!ssl_generate_master_secret(s, shared, i, 1)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - return (ret); - } else -#endif -#ifndef OPENSSL_NO_SRP - if (alg_k & SSL_kSRP) { - if (!PACKET_get_net_2(&pkt, &i) - || !PACKET_get_bytes(&pkt, &data, i)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_BAD_SRP_A_LENGTH); - goto f_err; - } - if ((s->srp_ctx.A = BN_bin2bn(data, i, NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_BN_LIB); - goto err; - } - if (BN_ucmp(s->srp_ctx.A, s->srp_ctx.N) >= 0 - || BN_is_zero(s->srp_ctx.A)) { - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_BAD_SRP_PARAMETERS); - goto f_err; - } - OPENSSL_free(s->session->srp_username); - s->session->srp_username = BUF_strdup(s->srp_ctx.login); - if (s->session->srp_username == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); - goto err; - } - - if (!srp_generate_server_master_secret(s)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto err; - } - } else -#endif /* OPENSSL_NO_SRP */ - if (alg_k & SSL_kGOST) { - int ret = 0; - EVP_PKEY_CTX *pkey_ctx; - EVP_PKEY *client_pub_pkey = NULL, *pk = NULL; - unsigned char premaster_secret[32], *start; - size_t outlen = 32, inlen; - unsigned long alg_a; - int Ttag, Tclass; - long Tlen; - - /* Get our certificate private key */ - alg_a = s->s3->tmp.new_cipher->algorithm_auth; - if (alg_a & SSL_aGOST01) - pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; - - pkey_ctx = EVP_PKEY_CTX_new(pk, NULL); - EVP_PKEY_decrypt_init(pkey_ctx); - /* - * If client certificate is present and is of the same type, maybe - * use it for key exchange. Don't mind errors from - * EVP_PKEY_derive_set_peer, because it is completely valid to use a - * client certificate for authorization only. - */ - client_pub_pkey = X509_get_pubkey(s->session->peer); - if (client_pub_pkey) { - if (EVP_PKEY_derive_set_peer(pkey_ctx, client_pub_pkey) <= 0) - ERR_clear_error(); - } - /* Decrypt session key */ - if (!PACKET_get_bytes(&pkt, &data, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - if (ASN1_get_object - ((const unsigned char **)&data, &Tlen, &Ttag, &Tclass, - n) != V_ASN1_CONSTRUCTED || Ttag != V_ASN1_SEQUENCE - || Tclass != V_ASN1_UNIVERSAL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_DECRYPTION_FAILED); - goto gerr; - } - start = data; - inlen = Tlen; - if (EVP_PKEY_decrypt - (pkey_ctx, premaster_secret, &outlen, start, inlen) <= 0) { - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, - SSL_R_DECRYPTION_FAILED); - goto gerr; - } - /* Generate master secret */ - if (!ssl_generate_master_secret(s, premaster_secret, - sizeof(premaster_secret), 0)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - /* Check if pubkey from client certificate was used */ - if (EVP_PKEY_CTX_ctrl - (pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) - ret = 2; - else - ret = 1; - gerr: - EVP_PKEY_free(client_pub_pkey); - EVP_PKEY_CTX_free(pkey_ctx); - if (ret) - return ret; - goto err; - } else { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, SSL_R_UNKNOWN_CIPHER_TYPE); - goto f_err; - } - - return (1); - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); -#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_SRP) - err: -#endif -#ifndef OPENSSL_NO_EC - EVP_PKEY_free(clnt_pub_pkey); - EC_POINT_free(clnt_ecpoint); - EC_KEY_free(srvr_ecdh); - BN_CTX_free(bn_ctx); - OPENSSL_free(rsa_decrypt); -#endif -#ifndef OPENSSL_NO_PSK - OPENSSL_clear_free(s->s3->tmp.psk, s->s3->tmp.psklen); - s->s3->tmp.psk = NULL; -#endif - s->state = SSL_ST_ERR; - return (-1); -} - -int ssl3_get_cert_verify(SSL *s) -{ - EVP_PKEY *pkey = NULL; - unsigned char *sig, *data; - int al, ok, ret = 0; - long n; - int type = 0, i, j; - unsigned int len; - X509 *peer; - const EVP_MD *md = NULL; - EVP_MD_CTX mctx; - PACKET pkt; - EVP_MD_CTX_init(&mctx); - - /* - * We should only process a CertificateVerify message if we have received - * a Certificate from the client. If so then |s->session->peer| will be non - * NULL. In some instances a CertificateVerify message is not required even - * if the peer has sent a Certificate (e.g. such as in the case of static - * DH). In that case the ClientKeyExchange processing will skip the - * CertificateVerify state so we should not arrive here. - */ - if (s->session->peer == NULL) { - ret = 1; - goto end; - } - - n = s->method->ssl_get_message(s, - SSL3_ST_SR_CERT_VRFY_A, - SSL3_ST_SR_CERT_VRFY_B, - SSL3_MT_CERTIFICATE_VERIFY, - SSL3_RT_MAX_PLAIN_LENGTH, &ok); - - if (!ok) - return ((int)n); - - peer = s->session->peer; - pkey = X509_get_pubkey(peer); - type = X509_certificate_type(peer, pkey); - - if (!(type & EVP_PKT_SIGN)) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, - SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE); - al = SSL_AD_ILLEGAL_PARAMETER; - goto f_err; - } - - /* we now have a signature that we need to verify */ - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - /* Check for broken implementations of GOST ciphersuites */ - /* - * If key is GOST and n is exactly 64, it is bare signature without - * length field - */ - if (n == 64 && pkey->type == NID_id_GostR3410_2001) { - len = 64; - } else { - if (SSL_USE_SIGALGS(s)) { - int rv; - - if (!PACKET_get_bytes(&pkt, &sig, 2)) { - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - rv = tls12_check_peer_sigalg(&md, s, sig, pkey); - if (rv == -1) { - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } else if (rv == 0) { - al = SSL_AD_DECODE_ERROR; - goto f_err; - } -#ifdef SSL_DEBUG - fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); -#endif - } - if (!PACKET_get_net_2(&pkt, &len)) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_LENGTH_MISMATCH); - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - } - j = EVP_PKEY_size(pkey); - if (((int)len > j) || ((int)PACKET_remaining(&pkt) > j) || (n <= 0)) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_SIZE); - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - if (!PACKET_get_bytes(&pkt, &data, len)) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_LENGTH_MISMATCH); - al = SSL_AD_DECODE_ERROR; - goto f_err; - } - - if (SSL_USE_SIGALGS(s)) { - long hdatalen = 0; - void *hdata; - hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); - if (hdatalen <= 0) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } -#ifdef SSL_DEBUG - fprintf(stderr, "Using TLS 1.2 with client verify alg %s\n", - EVP_MD_name(md)); -#endif - if (!EVP_VerifyInit_ex(&mctx, md, NULL) - || !EVP_VerifyUpdate(&mctx, hdata, hdatalen)) { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_EVP_LIB); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - - if (EVP_VerifyFinal(&mctx, data, len, pkey) <= 0) { - al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_SIGNATURE); - goto f_err; - } - } else -#ifndef OPENSSL_NO_RSA - if (pkey->type == EVP_PKEY_RSA) { - i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, - MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, data, len, - pkey->pkey.rsa); - if (i < 0) { - al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_RSA_DECRYPT); - goto f_err; - } - if (i == 0) { - al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_RSA_SIGNATURE); - goto f_err; - } - } else -#endif -#ifndef OPENSSL_NO_DSA - if (pkey->type == EVP_PKEY_DSA) { - j = DSA_verify(pkey->save_type, - &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), - SHA_DIGEST_LENGTH, data, len, pkey->pkey.dsa); - if (j <= 0) { - /* bad signature */ - al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_DSA_SIGNATURE); - goto f_err; - } - } else -#endif -#ifndef OPENSSL_NO_EC - if (pkey->type == EVP_PKEY_EC) { - j = ECDSA_verify(pkey->save_type, - &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), - SHA_DIGEST_LENGTH, data, len, pkey->pkey.ec); - if (j <= 0) { - /* bad signature */ - al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); - goto f_err; - } - } else -#endif - if (pkey->type == NID_id_GostR3410_2001) { - unsigned char signature[64]; - int idx; - EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(pkey, NULL); - EVP_PKEY_verify_init(pctx); - if (len != 64) { - fprintf(stderr, "GOST signature length is %d", len); - } - for (idx = 0; idx < 64; idx++) { - signature[63 - idx] = data[idx]; - } - j = EVP_PKEY_verify(pctx, signature, 64, s->s3->tmp.cert_verify_md, - 32); - EVP_PKEY_CTX_free(pctx); - if (j <= 0) { - al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); - goto f_err; - } - } else { - SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); - al = SSL_AD_UNSUPPORTED_CERTIFICATE; - goto f_err; - } - - ret = 1; - if (0) { - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - s->state = SSL_ST_ERR; - } - end: - BIO_free(s->s3->handshake_buffer); - s->s3->handshake_buffer = NULL; - EVP_MD_CTX_cleanup(&mctx); - EVP_PKEY_free(pkey); - return (ret); -} - -int ssl3_get_client_certificate(SSL *s) -{ - int i, ok, al, ret = -1; - X509 *x = NULL; - unsigned long l, llen, n; - const unsigned char *certstart; - unsigned char *certbytes; - STACK_OF(X509) *sk = NULL; - PACKET pkt, spkt; - - n = s->method->ssl_get_message(s, - SSL3_ST_SR_CERT_A, - SSL3_ST_SR_CERT_B, - -1, s->max_cert_list, &ok); - - if (!ok) - return ((int)n); - - if (s->s3->tmp.message_type == SSL3_MT_CLIENT_KEY_EXCHANGE) { - if ((s->verify_mode & SSL_VERIFY_PEER) && - (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE); - al = SSL_AD_HANDSHAKE_FAILURE; - goto f_err; - } - /* - * If tls asked for a client cert, the client must return a 0 list - */ - if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST); - al = SSL_AD_UNEXPECTED_MESSAGE; - goto f_err; - } - s->s3->tmp.reuse_message = 1; - return (1); - } - - if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_WRONG_MESSAGE_TYPE); - goto f_err; - } - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_INTERNAL_ERROR); - goto f_err; - } - - if ((sk = sk_X509_new_null()) == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); - goto done; - } - - if (!PACKET_get_net_3(&pkt, &llen) - || !PACKET_get_sub_packet(&pkt, &spkt, llen) - || PACKET_remaining(&pkt) != 0) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_LENGTH_MISMATCH); - goto f_err; - } - - while (PACKET_remaining(&spkt) > 0) { - if (!PACKET_get_net_3(&spkt, &l) - || !PACKET_get_bytes(&spkt, &certbytes, l)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_CERT_LENGTH_MISMATCH); - goto f_err; - } - - certstart = certbytes; - x = d2i_X509(NULL, (const unsigned char **)&certbytes, l); - if (x == NULL) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_ASN1_LIB); - goto done; - } - if (certbytes != (certstart + l)) { - al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_CERT_LENGTH_MISMATCH); - goto f_err; - } - if (!sk_X509_push(sk, x)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); - goto done; - } - x = NULL; - } - - if (sk_X509_num(sk) <= 0) { - /* TLS does not mind 0 certs returned */ - if (s->version == SSL3_VERSION) { - al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_NO_CERTIFICATES_RETURNED); - goto f_err; - } - /* Fail for TLS only if we required a certificate */ - else if ((s->verify_mode & SSL_VERIFY_PEER) && - (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE); - al = SSL_AD_HANDSHAKE_FAILURE; - goto f_err; - } - /* No client certificate so digest cached records */ - if (s->s3->handshake_buffer && !ssl3_digest_cached_records(s, 0)) { - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - } else { - EVP_PKEY *pkey; - i = ssl_verify_cert_chain(s, sk); - if (i <= 0) { - al = ssl_verify_alarm_type(s->verify_result); - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_CERTIFICATE_VERIFY_FAILED); - goto f_err; - } - if (i > 1) { - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, i); - al = SSL_AD_HANDSHAKE_FAILURE; - goto f_err; - } - pkey = X509_get_pubkey(sk_X509_value(sk, 0)); - if (pkey == NULL) { - al = SSL3_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, - SSL_R_UNKNOWN_CERTIFICATE_TYPE); - goto f_err; - } - EVP_PKEY_free(pkey); - } - - X509_free(s->session->peer); - s->session->peer = sk_X509_shift(sk); - s->session->verify_result = s->verify_result; - - sk_X509_pop_free(s->session->peer_chain, X509_free); - s->session->peer_chain = sk; - /* - * Inconsistency alert: cert_chain does *not* include the peer's own - * certificate, while we do include it in s3_clnt.c - */ - sk = NULL; - ret = 1; - goto done; - - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - done: - s->state = SSL_ST_ERR; - X509_free(x); - sk_X509_pop_free(sk, X509_free); - return (ret); -} - -int ssl3_send_server_certificate(SSL *s) -{ - CERT_PKEY *cpk; - - if (s->state == SSL3_ST_SW_CERT_A) { - cpk = ssl_get_server_send_pkey(s); - if (cpk == NULL) { - SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return (0); - } - - if (!ssl3_output_cert_chain(s, cpk)) { - SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return (0); - } - s->state = SSL3_ST_SW_CERT_B; - } - - /* SSL3_ST_SW_CERT_B */ - return ssl_do_write(s); -} - -/* send a new session ticket (not necessarily for a new session) */ -int ssl3_send_newsession_ticket(SSL *s) -{ - unsigned char *senc = NULL; - EVP_CIPHER_CTX ctx; - HMAC_CTX hctx; - - if (s->state == SSL3_ST_SW_SESSION_TICKET_A) { - unsigned char *p, *macstart; - const unsigned char *const_p; - int len, slen_full, slen; - SSL_SESSION *sess; - unsigned int hlen; - SSL_CTX *tctx = s->initial_ctx; - unsigned char iv[EVP_MAX_IV_LENGTH]; - unsigned char key_name[16]; - - /* get session encoding length */ - slen_full = i2d_SSL_SESSION(s->session, NULL); - /* - * Some length values are 16 bits, so forget it if session is too - * long - */ - if (slen_full == 0 || slen_full > 0xFF00) { - s->state = SSL_ST_ERR; - return -1; - } - senc = OPENSSL_malloc(slen_full); - if (!senc) { - s->state = SSL_ST_ERR; - return -1; - } - - EVP_CIPHER_CTX_init(&ctx); - HMAC_CTX_init(&hctx); - - p = senc; - if (!i2d_SSL_SESSION(s->session, &p)) - goto err; - - /* - * create a fresh copy (not shared with other threads) to clean up - */ - const_p = senc; - sess = d2i_SSL_SESSION(NULL, &const_p, slen_full); - if (sess == NULL) - goto err; - sess->session_id_length = 0; /* ID is irrelevant for the ticket */ - - slen = i2d_SSL_SESSION(sess, NULL); - if (slen == 0 || slen > slen_full) { /* shouldn't ever happen */ - SSL_SESSION_free(sess); - goto err; - } - p = senc; - if (!i2d_SSL_SESSION(sess, &p)) { - SSL_SESSION_free(sess); - goto err; - } - SSL_SESSION_free(sess); - - /*- - * Grow buffer if need be: the length calculation is as - * follows handshake_header_length + - * 4 (ticket lifetime hint) + 2 (ticket length) + - * 16 (key name) + max_iv_len (iv length) + - * session_length + max_enc_block_size (max encrypted session - * length) + max_md_size (HMAC). - */ - if (!BUF_MEM_grow(s->init_buf, - SSL_HM_HEADER_LENGTH(s) + 22 + EVP_MAX_IV_LENGTH + - EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + slen)) - goto err; - - p = ssl_handshake_start(s); - /* - * Initialize HMAC and cipher contexts. If callback present it does - * all the work otherwise use generated values from parent ctx. - */ - if (tctx->tlsext_ticket_key_cb) { - if (tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx, - &hctx, 1) < 0) - goto err; - } else { - if (RAND_bytes(iv, 16) <= 0) - goto err; - if (!EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, - tctx->tlsext_tick_aes_key, iv)) - goto err; - if (!HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, - EVP_sha256(), NULL)) - goto err; - memcpy(key_name, tctx->tlsext_tick_key_name, 16); - } - - /* - * Ticket lifetime hint (advisory only): We leave this unspecified - * for resumed session (for simplicity), and guess that tickets for - * new sessions will live as long as their sessions. - */ - l2n(s->hit ? 0 : s->session->timeout, p); - - /* Skip ticket length for now */ - p += 2; - /* Output key name */ - macstart = p; - memcpy(p, key_name, 16); - p += 16; - /* output IV */ - memcpy(p, iv, EVP_CIPHER_CTX_iv_length(&ctx)); - p += EVP_CIPHER_CTX_iv_length(&ctx); - /* Encrypt session data */ - if (!EVP_EncryptUpdate(&ctx, p, &len, senc, slen)) - goto err; - p += len; - if (!EVP_EncryptFinal(&ctx, p, &len)) - goto err; - p += len; - - if (!HMAC_Update(&hctx, macstart, p - macstart)) - goto err; - if (!HMAC_Final(&hctx, p, &hlen)) - goto err; - - EVP_CIPHER_CTX_cleanup(&ctx); - HMAC_CTX_cleanup(&hctx); - - p += hlen; - /* Now write out lengths: p points to end of data written */ - /* Total length */ - len = p - ssl_handshake_start(s); - /* Skip ticket lifetime hint */ - p = ssl_handshake_start(s) + 4; - s2n(len - 6, p); - if (!ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len)) - goto err; - s->state = SSL3_ST_SW_SESSION_TICKET_B; - OPENSSL_free(senc); - } - - /* SSL3_ST_SW_SESSION_TICKET_B */ - return ssl_do_write(s); - err: - OPENSSL_free(senc); - EVP_CIPHER_CTX_cleanup(&ctx); - HMAC_CTX_cleanup(&hctx); - s->state = SSL_ST_ERR; - return -1; -} - -int ssl3_send_cert_status(SSL *s) -{ - if (s->state == SSL3_ST_SW_CERT_STATUS_A) { - unsigned char *p; - /*- - * Grow buffer if need be: the length calculation is as - * follows 1 (message type) + 3 (message length) + - * 1 (ocsp response type) + 3 (ocsp response length) - * + (ocsp response) - */ - if (!BUF_MEM_grow(s->init_buf, 8 + s->tlsext_ocsp_resplen)) { - s->state = SSL_ST_ERR; - return -1; - } - - p = (unsigned char *)s->init_buf->data; - - /* do the header */ - *(p++) = SSL3_MT_CERTIFICATE_STATUS; - /* message length */ - l2n3(s->tlsext_ocsp_resplen + 4, p); - /* status type */ - *(p++) = s->tlsext_status_type; - /* length of OCSP response */ - l2n3(s->tlsext_ocsp_resplen, p); - /* actual response */ - memcpy(p, s->tlsext_ocsp_resp, s->tlsext_ocsp_resplen); - /* number of bytes to write */ - s->init_num = 8 + s->tlsext_ocsp_resplen; - s->state = SSL3_ST_SW_CERT_STATUS_B; - s->init_off = 0; - } - - /* SSL3_ST_SW_CERT_STATUS_B */ - return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); -} - -#ifndef OPENSSL_NO_NEXTPROTONEG -/* - * ssl3_get_next_proto reads a Next Protocol Negotiation handshake message. - * It sets the next_proto member in s if found - */ -int ssl3_get_next_proto(SSL *s) -{ - int ok; - long n; - PACKET pkt, next_proto, padding; - size_t next_proto_len; - - /* - * Clients cannot send a NextProtocol message if we didn't see the - * extension in their ClientHello - */ - if (!s->s3->next_proto_neg_seen) { - SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, - SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION); - s->state = SSL_ST_ERR; - return -1; - } - - /* See the payload format below */ - n = s->method->ssl_get_message(s, - SSL3_ST_SR_NEXT_PROTO_A, - SSL3_ST_SR_NEXT_PROTO_B, - SSL3_MT_NEXT_PROTO, 514, &ok); - - if (!ok) - return ((int)n); - - /* - * s->state doesn't reflect whether ChangeCipherSpec has been received in - * this handshake, but s->s3->change_cipher_spec does (will be reset by - * ssl3_get_finished). - */ - if (!s->s3->change_cipher_spec) { - SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS); - s->state = SSL_ST_ERR; - return -1; - } - - if (n < 2) { - goto err; /* The body must be > 1 bytes long */ - } - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, ERR_R_INTERNAL_ERROR); - goto err; - } - - /*- - * The payload looks like: - * uint8 proto_len; - * uint8 proto[proto_len]; - * uint8 padding_len; - * uint8 padding[padding_len]; - */ - if (!PACKET_get_length_prefixed_1(&pkt, &next_proto) - || !PACKET_get_length_prefixed_1(&pkt, &padding) - || PACKET_remaining(&pkt) > 0) { - SSLerr(SSL_F_SSL3_GET_NEXT_PROTO, SSL_R_LENGTH_MISMATCH); - goto err; - } - - if (!PACKET_memdup(&next_proto, &s->next_proto_negotiated, - &next_proto_len)) { - s->next_proto_negotiated_len = 0; - goto err; - } - - s->next_proto_negotiated_len = (unsigned char)next_proto_len; - - return 1; -err: - s->state = SSL_ST_ERR; - return 0; -} -#endif - -#define SSLV2_CIPHER_LEN 3 - -STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, - PACKET *cipher_suites, - STACK_OF(SSL_CIPHER) **skp, - int sslv2format, int *al - ) -{ - const SSL_CIPHER *c; - STACK_OF(SSL_CIPHER) *sk; - int n; - /* 3 = SSLV2_CIPHER_LEN > TLS_CIPHER_LEN = 2. */ - unsigned char cipher[SSLV2_CIPHER_LEN]; - - s->s3->send_connection_binding = 0; - - n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN; - - if (PACKET_remaining(cipher_suites) == 0) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED); - *al = SSL_AD_ILLEGAL_PARAMETER; - return NULL; - } - - if (PACKET_remaining(cipher_suites) % n != 0) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, - SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); - *al = SSL_AD_DECODE_ERROR; - return NULL; - } - - if ((skp == NULL) || (*skp == NULL)) { - sk = sk_SSL_CIPHER_new_null(); /* change perhaps later */ - if(sk == NULL) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); - *al = SSL_AD_INTERNAL_ERROR; - return NULL; - } - } else { - sk = *skp; - sk_SSL_CIPHER_zero(sk); - } - - if (!PACKET_memdup(cipher_suites, &s->s3->tmp.ciphers_raw, - &s->s3->tmp.ciphers_rawlen)) { - *al = SSL_AD_INTERNAL_ERROR; - goto err; - } - - while (PACKET_copy_bytes(cipher_suites, cipher, n)) { - /* - * SSLv3 ciphers wrapped in an SSLv2-compatible ClientHello have the - * first byte set to zero, while true SSLv2 ciphers have a non-zero - * first byte. We don't support any true SSLv2 ciphers, so skip them. - */ - if (sslv2format && cipher[0] != '\0') - continue; - - /* Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV */ - if ((cipher[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && - (cipher[n - 1] == (SSL3_CK_SCSV & 0xff))) { - /* SCSV fatal if renegotiating */ - if (s->renegotiate) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, - SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING); - *al = SSL_AD_HANDSHAKE_FAILURE; - goto err; - } - s->s3->send_connection_binding = 1; -#ifdef OPENSSL_RI_DEBUG - fprintf(stderr, "SCSV received by server\n"); -#endif - continue; - } - - /* Check for TLS_FALLBACK_SCSV */ - if ((cipher[n - 2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) && - (cipher[n - 1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) { - /* - * The SCSV indicates that the client previously tried a higher - * version. Fail if the current version is an unexpected - * downgrade. - */ - if (!SSL_ctrl(s, SSL_CTRL_CHECK_PROTO_VERSION, 0, NULL)) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, - SSL_R_INAPPROPRIATE_FALLBACK); - *al = SSL_AD_INAPPROPRIATE_FALLBACK; - goto err; - } - continue; - } - - /* For SSLv2-compat, ignore leading 0-byte. */ - c = ssl_get_cipher_by_char(s, sslv2format ? &cipher[1] : cipher); - if (c != NULL) { - if (!sk_SSL_CIPHER_push(sk, c)) { - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); - *al = SSL_AD_INTERNAL_ERROR; - goto err; - } - } - } - if (PACKET_remaining(cipher_suites) > 0) { - *al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_INTERNAL_ERROR); - goto err; - } - - if (skp != NULL) - *skp = sk; - return (sk); - err: - if ((skp == NULL) || (*skp == NULL)) - sk_SSL_CIPHER_free(sk); - return NULL; -} diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 1caa3c8..3304a1d 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -625,7 +625,7 @@ STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx) STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s) { - if (s->type == SSL_ST_CONNECT) { /* we are in the client */ + if (!s->server) { /* we are in the client */ if (((s->version >> 8) == SSL3_VERSION_MAJOR) && (s->s3 != NULL)) return (s->s3->tmp.ca_names); else diff --git a/ssl/ssl_err.c b/ssl/ssl_err.c index 0b93db9..cbc4f59 100644 --- a/ssl/ssl_err.c +++ b/ssl/ssl_err.c @@ -112,6 +112,14 @@ static ERR_STRING_DATA SSL_str_functs[] = { {ERR_FUNC(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE), "dtls1_send_server_key_exchange"}, {ERR_FUNC(SSL_F_DTLS1_WRITE_APP_DATA_BYTES), "dtls1_write_app_data_bytes"}, + {ERR_FUNC(SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC), + "dtls_construct_change_cipher_spec"}, + {ERR_FUNC(SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST), + "dtls_construct_hello_verify_request"}, + {ERR_FUNC(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE), + "DTLS_GET_REASSEMBLED_MESSAGE"}, + {ERR_FUNC(SSL_F_DTLS_PROCESS_HELLO_VERIFY), "dtls_process_hello_verify"}, + {ERR_FUNC(SSL_F_READ_STATE_MACHINE), "READ_STATE_MACHINE"}, {ERR_FUNC(SSL_F_SSL3_ACCEPT), "ssl3_accept"}, {ERR_FUNC(SSL_F_SSL3_ADD_CERT_TO_BUF), "SSL3_ADD_CERT_TO_BUF"}, {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "ssl3_callback_ctrl"}, @@ -313,6 +321,7 @@ static ERR_STRING_DATA SSL_str_functs[] = { {ERR_FUNC(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE), "SSL_use_RSAPrivateKey_file"}, {ERR_FUNC(SSL_F_SSL_VERIFY_CERT_CHAIN), "ssl_verify_cert_chain"}, {ERR_FUNC(SSL_F_SSL_WRITE), "SSL_write"}, + {ERR_FUNC(SSL_F_STATE_MACHINE), "STATE_MACHINE"}, {ERR_FUNC(SSL_F_TLS12_CHECK_PEER_SIGALG), "tls12_check_peer_sigalg"}, {ERR_FUNC(SSL_F_TLS1_CERT_VERIFY_MAC), "tls1_cert_verify_mac"}, {ERR_FUNC(SSL_F_TLS1_CHANGE_CIPHER_STATE), "tls1_change_cipher_state"}, @@ -331,6 +340,54 @@ static ERR_STRING_DATA SSL_str_functs[] = { {ERR_FUNC(SSL_F_TLS1_PROCESS_HEARTBEAT), "tls1_process_heartbeat"}, {ERR_FUNC(SSL_F_TLS1_SETUP_KEY_BLOCK), "tls1_setup_key_block"}, {ERR_FUNC(SSL_F_TLS1_SET_SERVER_SIGALGS), "tls1_set_server_sigalgs"}, + {ERR_FUNC(SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK), + "tls_client_key_exchange_post_work"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST), + "tls_construct_certificate_request"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE), + "tls_construct_client_certificate"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO), "tls_construct_client_hello"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE), + "tls_construct_client_key_exchange"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY), + "tls_construct_client_verify"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_FINISHED), "tls_construct_finished"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_HELLO_REQUEST), + "tls_construct_hello_request"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE), + "tls_construct_server_certificate"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_SERVER_DONE), "tls_construct_server_done"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_SERVER_HELLO), "tls_construct_server_hello"}, + {ERR_FUNC(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE), + "tls_construct_server_key_exchange"}, + {ERR_FUNC(SSL_F_TLS_GET_MESSAGE_BODY), "tls_get_message_body"}, + {ERR_FUNC(SSL_F_TLS_GET_MESSAGE_HEADER), "tls_get_message_header"}, + {ERR_FUNC(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO), + "tls_post_process_client_hello"}, + {ERR_FUNC(SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE), + "tls_post_process_client_key_exchange"}, + {ERR_FUNC(SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE), + "tls_prepare_client_certificate"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST), + "tls_process_certificate_request"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CERT_STATUS), "tls_process_cert_status"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CERT_VERIFY), "tls_process_cert_verify"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC), + "tls_process_change_cipher_spec"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE), + "tls_process_client_certificate"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CLIENT_HELLO), "tls_process_client_hello"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE), + "tls_process_client_key_exchange"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_FINISHED), "tls_process_finished"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_KEY_EXCHANGE), "tls_process_key_exchange"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET), + "tls_process_new_session_ticket"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_NEXT_PROTO), "tls_process_next_proto"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE), + "tls_process_server_certificate"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_SERVER_DONE), "tls_process_server_done"}, + {ERR_FUNC(SSL_F_TLS_PROCESS_SERVER_HELLO), "tls_process_server_hello"}, {ERR_FUNC(SSL_F_USE_CERTIFICATE_CHAIN_FILE), "use_certificate_chain_file"}, {0, NULL} }; @@ -468,6 +525,7 @@ static ERR_STRING_DATA SSL_str_reasons[] = { "invalid ticket keys length"}, {ERR_REASON(SSL_R_INVALID_TRUST), "invalid trust"}, {ERR_REASON(SSL_R_LENGTH_MISMATCH), "length mismatch"}, + {ERR_REASON(SSL_R_LENGTH_TOO_LONG), "length too long"}, {ERR_REASON(SSL_R_LENGTH_TOO_SHORT), "length too short"}, {ERR_REASON(SSL_R_LIBRARY_BUG), "library bug"}, {ERR_REASON(SSL_R_LIBRARY_HAS_NO_CIPHERS), "library has no ciphers"}, diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index e80d5f1..7e30aba 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -215,9 +215,7 @@ int SSL_clear(SSL *s) return 0; } - s->type = 0; - - s->state = SSL_ST_BEFORE | ((s->server) ? SSL_ST_ACCEPT : SSL_ST_CONNECT); + ossl_statem_clear(s); s->version = s->method->version; s->client_version = s->version; @@ -232,7 +230,7 @@ int SSL_clear(SSL *s) * Check to see if we were changed into a different method, if so, revert * back if we are not doing session-id reuse. */ - if (!s->in_handshake && (s->session == NULL) + if (!ossl_statem_get_in_handshake(s) && (s->session == NULL) && (s->method != s->ctx->method)) { s->method->ssl_free(s); s->method = s->ctx->method; @@ -1082,7 +1080,7 @@ long SSL_ctrl(SSL *s, int cmd, long larg, void *parg) return TLS_CIPHER_LEN; } case SSL_CTRL_GET_EXTMS_SUPPORT: - if (!s->session || SSL_in_init(s) || s->in_handshake) + if (!s->session || SSL_in_init(s) || ossl_statem_get_in_handshake(s)) return -1; if (s->session->flags & SSL_SESS_FLAG_EXTMS) return 1; @@ -2397,7 +2395,7 @@ void SSL_set_accept_state(SSL *s) { s->server = 1; s->shutdown = 0; - s->state = SSL_ST_ACCEPT | SSL_ST_BEFORE; + ossl_statem_clear(s); s->handshake_func = s->method->ssl_accept; clear_ciphers(s); } @@ -2406,7 +2404,7 @@ void SSL_set_connect_state(SSL *s) { s->server = 0; s->shutdown = 0; - s->state = SSL_ST_CONNECT | SSL_ST_BEFORE; + ossl_statem_clear(s); s->handshake_func = s->method->ssl_connect; clear_ciphers(s); } @@ -2468,7 +2466,6 @@ SSL *SSL_dup(SSL *s) return (NULL); ret->version = s->version; - ret->type = s->type; ret->method = s->method; if (s->session != NULL) { @@ -2529,15 +2526,14 @@ SSL *SSL_dup(SSL *s) ret->wbio = ret->rbio; } ret->rwstate = s->rwstate; - ret->in_handshake = s->in_handshake; ret->handshake_func = s->handshake_func; ret->server = s->server; ret->renegotiate = s->renegotiate; ret->new_session = s->new_session; ret->quiet_shutdown = s->quiet_shutdown; ret->shutdown = s->shutdown; - ret->state = s->state; /* SSL_dup does not really work at any state, - * though */ + ret->statem = s->statem; /* SSL_dup does not really work at any state, + * though */ RECORD_LAYER_dup(&ret->rlayer, &s->rlayer); ret->init_num = 0; /* would have to copy ret->init_buf, * ret->init_msg, ret->init_num, @@ -2839,16 +2835,6 @@ void (*SSL_get_info_callback(const SSL *ssl)) (const SSL * /* ssl */ , return ssl->info_callback; } -int SSL_state(const SSL *ssl) -{ - return (ssl->state); -} - -void SSL_set_state(SSL *ssl, int state) -{ - ssl->state = state; -} - void SSL_set_verify_result(SSL *ssl, long arg) { ssl->verify_result = arg; diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index ad6ae0e..56ec70f 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -166,6 +166,7 @@ # include #include "record/record.h" +#include "statem/statem.h" #include "packet_locl.h" # ifdef OPENSSL_BUILD_SHLIBSSL @@ -568,8 +569,6 @@ struct ssl_method_st { int (*ssl_shutdown) (SSL *s); int (*ssl_renegotiate) (SSL *s); int (*ssl_renegotiate_check) (SSL *s); - long (*ssl_get_message) (SSL *s, int st1, int stn, int mt, long - max, int *ok); int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type, unsigned char *buf, int len, int peek); int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, int len); @@ -717,6 +716,7 @@ struct ssl_comp_st { DECLARE_STACK_OF(SSL_COMP) DECLARE_LHASH_OF(SSL_SESSION); + struct ssl_ctx_st { const SSL_METHOD *method; STACK_OF(SSL_CIPHER) *cipher_list; @@ -967,8 +967,7 @@ struct ssl_st { * DTLS1_VERSION) */ int version; - /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ - int type; + /* SSLv3 */ const SSL_METHOD *method; /* @@ -987,8 +986,7 @@ struct ssl_st { * request needs re-doing when in SSL_accept or SSL_connect */ int rwstate; - /* true when we are actually in SSL_accept() or SSL_connect() */ - int in_handshake; + int (*handshake_func) (SSL *); /* * Imagine that here's a boolean member "init" that is switched as soon @@ -997,7 +995,7 @@ struct ssl_st { * handshake_func is == 0 until then, we use this test instead of an * "init" member. */ - /* are we the server side? - mostly used by SSL_clear */ + /* are we the server side? */ int server; /* * Generate a new session or reuse an old one. @@ -1011,7 +1009,8 @@ struct ssl_st { /* we have shut things down, 0x01 sent, 0x02 for received */ int shutdown; /* where we are */ - int state; + OSSL_STATEM statem; + BUF_MEM *init_buf; /* buffer used during init */ void *init_msg; /* pointer to handshake message body, set by * ssl3_get_message() */ @@ -1257,9 +1256,6 @@ typedef struct ssl3_state_st { # ifndef OPENSSL_NO_EC EC_KEY *ecdh; /* holds short lived ECDH key */ # endif - /* used when SSL_ST_FLUSH_DATA is entered */ - int next_state; - int reuse_message; /* used for certificate requests */ int cert_req; int ctype_num; @@ -1419,9 +1415,9 @@ typedef struct hm_fragment_st { } hm_fragment; typedef struct dtls1_state_st { - unsigned int send_cookie; unsigned char cookie[DTLS1_COOKIE_LENGTH]; unsigned int cookie_len; + unsigned int cookie_verified; /* handshake message numbers */ unsigned short handshake_write_seq; @@ -1447,8 +1443,6 @@ typedef struct dtls1_state_st { unsigned int retransmitting; # ifndef OPENSSL_NO_SCTP - /* used when SSL_ST_XX_FLUSH is entered */ - int next_state; int shutdown_received; # endif } DTLS1_STATE; @@ -1746,7 +1740,6 @@ const SSL_METHOD *func_name(void) \ ssl3_shutdown, \ ssl3_renegotiate, \ ssl3_renegotiate_check, \ - ssl3_get_message, \ ssl3_read_bytes, \ ssl3_write_bytes, \ ssl3_dispatch_alert, \ @@ -1783,7 +1776,6 @@ const SSL_METHOD *func_name(void) \ ssl3_shutdown, \ ssl3_renegotiate, \ ssl3_renegotiate_check, \ - ssl3_get_message, \ ssl3_read_bytes, \ ssl3_write_bytes, \ ssl3_dispatch_alert, \ @@ -1821,7 +1813,6 @@ const SSL_METHOD *func_name(void) \ dtls1_shutdown, \ ssl3_renegotiate, \ ssl3_renegotiate_check, \ - dtls1_get_message, \ dtls1_read_bytes, \ dtls1_write_app_data_bytes, \ dtls1_dispatch_alert, \ @@ -1915,13 +1906,7 @@ __owur int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen, __owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); __owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); void ssl3_init_finished_mac(SSL *s); -__owur int ssl3_send_server_certificate(SSL *s); -__owur int ssl3_send_newsession_ticket(SSL *s); -__owur int ssl3_send_cert_status(SSL *s); -__owur int ssl3_get_change_cipher_spec(SSL *s, int a, int b); -__owur int ssl3_get_finished(SSL *s, int state_a, int state_b); __owur int ssl3_setup_key_block(SSL *s); -__owur int ssl3_send_change_cipher_spec(SSL *s, int state_a, int state_b); __owur int ssl3_change_cipher_state(SSL *s, int which); void ssl3_cleanup_key_block(SSL *s); __owur int ssl3_do_write(SSL *s, int type); @@ -1929,8 +1914,6 @@ int ssl3_send_alert(SSL *s, int level, int desc); __owur int ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, int len); __owur int ssl3_get_req_cert_type(SSL *s, unsigned char *p); -__owur long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); -__owur int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen); __owur int ssl3_num_ciphers(void); __owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u); int ssl3_renegotiate(SSL *ssl); @@ -1947,8 +1930,6 @@ __owur SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, __owur int ssl3_digest_cached_records(SSL *s, int keep); __owur int ssl3_new(SSL *s); void ssl3_free(SSL *s); -__owur int ssl3_accept(SSL *s); -__owur int ssl3_connect(SSL *s); __owur int ssl3_read(SSL *s, void *buf, int len); __owur int ssl3_peek(SSL *s, void *buf, int len); __owur int ssl3_write(SSL *s, const void *buf, int len); @@ -1977,7 +1958,6 @@ void dtls1_set_message_header(SSL *s, __owur int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); -__owur int dtls1_send_change_cipher_spec(SSL *s, int a, int b); __owur int dtls1_read_failed(SSL *s, int code); __owur int dtls1_buffer_message(SSL *s, int ccs); __owur int dtls1_retransmit_message(SSL *s, unsigned short seq, @@ -1996,47 +1976,13 @@ void dtls1_start_timer(SSL *s); void dtls1_stop_timer(SSL *s); __owur int dtls1_is_timer_expired(SSL *s); void dtls1_double_timeout(SSL *s); -__owur unsigned int dtls1_raw_hello_verify_request(unsigned char *buf, - unsigned char *cookie, - unsigned char cookie_len); +__owur unsigned int dtls_raw_hello_verify_request(unsigned char *buf, + unsigned char *cookie, + unsigned char cookie_len); __owur int dtls1_send_newsession_ticket(SSL *s); __owur unsigned int dtls1_min_mtu(SSL *s); -__owur unsigned int dtls1_link_min_mtu(void); void dtls1_hm_fragment_free(hm_fragment *frag); - -/* some client-only functions */ -__owur int ssl3_client_hello(SSL *s); -__owur int ssl3_get_server_hello(SSL *s); -__owur int ssl3_get_certificate_request(SSL *s); -__owur int ssl3_get_new_session_ticket(SSL *s); -__owur int ssl3_get_cert_status(SSL *s); -__owur int ssl3_get_server_done(SSL *s); -__owur int ssl3_send_client_verify(SSL *s); -__owur int ssl3_send_client_certificate(SSL *s); -__owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); -__owur int ssl3_send_client_key_exchange(SSL *s); -__owur int ssl3_get_key_exchange(SSL *s); -__owur int ssl3_get_server_certificate(SSL *s); -__owur int ssl3_check_cert_and_algorithm(SSL *s); -# ifndef OPENSSL_NO_NEXTPROTONEG -__owur int ssl3_send_next_proto(SSL *s); -# endif - -int dtls1_client_hello(SSL *s); - -/* some server-only functions */ -__owur int ssl3_get_client_hello(SSL *s); -__owur int ssl3_send_server_hello(SSL *s); -__owur int ssl3_send_hello_request(SSL *s); -__owur int ssl3_send_server_key_exchange(SSL *s); -__owur int ssl3_send_certificate_request(SSL *s); -__owur int ssl3_send_server_done(SSL *s); -__owur int ssl3_get_client_certificate(SSL *s); -__owur int ssl3_get_client_key_exchange(SSL *s); -__owur int ssl3_get_cert_verify(SSL *s); -# ifndef OPENSSL_NO_NEXTPROTONEG -__owur int ssl3_get_next_proto(SSL *s); -# endif +__owur int dtls1_query_mtu(SSL *s); __owur int tls1_new(SSL *s); void tls1_free(SSL *s); @@ -2045,14 +1991,11 @@ long tls1_ctrl(SSL *s, int cmd, long larg, void *parg); long tls1_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); __owur int dtls1_new(SSL *s); -__owur int dtls1_accept(SSL *s); -__owur int dtls1_connect(SSL *s); void dtls1_free(SSL *s); void dtls1_clear(SSL *s); long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); __owur int dtls1_shutdown(SSL *s); -__owur long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); __owur int dtls1_dispatch_alert(SSL *s); __owur int ssl_init_wbio_buffer(SSL *s, int push); diff --git a/ssl/ssl_stat.c b/ssl/ssl_stat.c index f59553b..3bd7843 100644 --- a/ssl/ssl_stat.c +++ b/ssl/ssl_stat.c @@ -89,231 +89,107 @@ const char *SSL_state_string_long(const SSL *s) { const char *str; - switch (s->state) { - case SSL_ST_BEFORE: + if (ossl_statem_in_error(s)) { + return "error"; + } + + switch (SSL_get_state(s)) { + case TLS_ST_BEFORE: str = "before SSL initialization"; break; - case SSL_ST_ACCEPT: - str = "before accept initialization"; - break; - case SSL_ST_CONNECT: - str = "before connect initialization"; - break; - case SSL_ST_OK: + case TLS_ST_OK: str = "SSL negotiation finished successfully"; break; - case SSL_ST_RENEGOTIATE: - str = "SSL renegotiate ciphers"; - break; - case SSL_ST_BEFORE | SSL_ST_CONNECT: - str = "before/connect initialization"; - break; - case SSL_ST_OK | SSL_ST_CONNECT: - str = "ok/connect SSL initialization"; - break; - case SSL_ST_BEFORE | SSL_ST_ACCEPT: - str = "before/accept initialization"; - break; - case SSL_ST_OK | SSL_ST_ACCEPT: - str = "ok/accept SSL initialization"; - break; - case SSL_ST_ERR: - str = "error"; - break; -#ifndef OPENSSL_NO_SSL3 /* SSLv3 additions */ - case SSL3_ST_CW_CLNT_HELLO_A: - str = "SSLv3 write client hello A"; - break; - case SSL3_ST_CW_CLNT_HELLO_B: - str = "SSLv3 write client hello B"; - break; - case SSL3_ST_CR_SRVR_HELLO_A: - str = "SSLv3 read server hello A"; - break; - case SSL3_ST_CR_SRVR_HELLO_B: - str = "SSLv3 read server hello B"; - break; - case SSL3_ST_CR_CERT_A: - str = "SSLv3 read server certificate A"; - break; - case SSL3_ST_CR_CERT_B: - str = "SSLv3 read server certificate B"; - break; - case SSL3_ST_CR_KEY_EXCH_A: - str = "SSLv3 read server key exchange A"; - break; - case SSL3_ST_CR_KEY_EXCH_B: - str = "SSLv3 read server key exchange B"; - break; - case SSL3_ST_CR_CERT_REQ_A: - str = "SSLv3 read server certificate request A"; - break; - case SSL3_ST_CR_CERT_REQ_B: - str = "SSLv3 read server certificate request B"; - break; - case SSL3_ST_CR_SESSION_TICKET_A: - str = "SSLv3 read server session ticket A"; + case TLS_ST_CW_CLNT_HELLO: + str = "SSLv3/TLS write client hello"; break; - case SSL3_ST_CR_SESSION_TICKET_B: - str = "SSLv3 read server session ticket B"; + case TLS_ST_CR_SRVR_HELLO: + str = "SSLv3/TLS read server hello"; break; - case SSL3_ST_CR_SRVR_DONE_A: - str = "SSLv3 read server done A"; + case TLS_ST_CR_CERT: + str = "SSLv3/TLS read server certificate"; break; - case SSL3_ST_CR_SRVR_DONE_B: - str = "SSLv3 read server done B"; + case TLS_ST_CR_KEY_EXCH: + str = "SSLv3/TLS read server key exchange"; break; - case SSL3_ST_CW_CERT_A: - str = "SSLv3 write client certificate A"; + case TLS_ST_CR_CERT_REQ: + str = "SSLv3/TLS read server certificate request"; break; - case SSL3_ST_CW_CERT_B: - str = "SSLv3 write client certificate B"; + case TLS_ST_CR_SESSION_TICKET: + str = "SSLv3/TLS read server session ticket"; break; - case SSL3_ST_CW_CERT_C: - str = "SSLv3 write client certificate C"; + case TLS_ST_CR_SRVR_DONE: + str = "SSLv3/TLS read server done"; break; - case SSL3_ST_CW_CERT_D: - str = "SSLv3 write client certificate D"; + case TLS_ST_CW_CERT: + str = "SSLv3/TLS write client certificate"; break; - case SSL3_ST_CW_KEY_EXCH_A: - str = "SSLv3 write client key exchange A"; + case TLS_ST_CW_KEY_EXCH: + str = "SSLv3/TLS write client key exchange"; break; - case SSL3_ST_CW_KEY_EXCH_B: - str = "SSLv3 write client key exchange B"; - break; - case SSL3_ST_CW_CERT_VRFY_A: - str = "SSLv3 write certificate verify A"; - break; - case SSL3_ST_CW_CERT_VRFY_B: - str = "SSLv3 write certificate verify B"; + case TLS_ST_CW_CERT_VRFY: + str = "SSLv3/TLS write certificate verify"; break; - case SSL3_ST_CW_CHANGE_A: - case SSL3_ST_SW_CHANGE_A: - str = "SSLv3 write change cipher spec A"; - break; - case SSL3_ST_CW_CHANGE_B: - case SSL3_ST_SW_CHANGE_B: - str = "SSLv3 write change cipher spec B"; - break; - case SSL3_ST_CW_FINISHED_A: - case SSL3_ST_SW_FINISHED_A: - str = "SSLv3 write finished A"; - break; - case SSL3_ST_CW_FINISHED_B: - case SSL3_ST_SW_FINISHED_B: - str = "SSLv3 write finished B"; + case TLS_ST_CW_CHANGE: + case TLS_ST_SW_CHANGE: + str = "SSLv3/TLS write change cipher spec"; break; - case SSL3_ST_CR_CHANGE_A: - case SSL3_ST_SR_CHANGE_A: - str = "SSLv3 read change cipher spec A"; + case TLS_ST_CW_FINISHED: + case TLS_ST_SW_FINISHED: + str = "SSLv3/TLS write finished"; break; - case SSL3_ST_CR_CHANGE_B: - case SSL3_ST_SR_CHANGE_B: - str = "SSLv3 read change cipher spec B"; + case TLS_ST_CR_CHANGE: + case TLS_ST_SR_CHANGE: + str = "SSLv3/TLS read change cipher spec"; break; - case SSL3_ST_CR_FINISHED_A: - case SSL3_ST_SR_FINISHED_A: - str = "SSLv3 read finished A"; - break; - case SSL3_ST_CR_FINISHED_B: - case SSL3_ST_SR_FINISHED_B: - str = "SSLv3 read finished B"; - break; - - case SSL3_ST_CW_FLUSH: - case SSL3_ST_SW_FLUSH: - str = "SSLv3 flush data"; + case TLS_ST_CR_FINISHED: + case TLS_ST_SR_FINISHED: + str = "SSLv3/TLS read finished"; break; - case SSL3_ST_SR_CLNT_HELLO_A: - str = "SSLv3 read client hello A"; - break; - case SSL3_ST_SR_CLNT_HELLO_B: - str = "SSLv3 read client hello B"; - break; - case SSL3_ST_SR_CLNT_HELLO_C: - str = "SSLv3 read client hello C"; - break; - case SSL3_ST_SW_HELLO_REQ_A: - str = "SSLv3 write hello request A"; - break; - case SSL3_ST_SW_HELLO_REQ_B: - str = "SSLv3 write hello request B"; - break; - case SSL3_ST_SW_HELLO_REQ_C: - str = "SSLv3 write hello request C"; - break; - case SSL3_ST_SW_SRVR_HELLO_A: - str = "SSLv3 write server hello A"; - break; - case SSL3_ST_SW_SRVR_HELLO_B: - str = "SSLv3 write server hello B"; - break; - case SSL3_ST_SW_CERT_A: - str = "SSLv3 write certificate A"; - break; - case SSL3_ST_SW_CERT_B: - str = "SSLv3 write certificate B"; - break; - case SSL3_ST_SW_KEY_EXCH_A: - str = "SSLv3 write key exchange A"; - break; - case SSL3_ST_SW_KEY_EXCH_B: - str = "SSLv3 write key exchange B"; - break; - case SSL3_ST_SW_CERT_REQ_A: - str = "SSLv3 write certificate request A"; + case TLS_ST_SR_CLNT_HELLO: + str = "SSLv3/TLS read client hello"; break; - case SSL3_ST_SW_CERT_REQ_B: - str = "SSLv3 write certificate request B"; + case TLS_ST_SW_HELLO_REQ: + str = "SSLv3/TLS write hello request"; break; - case SSL3_ST_SW_SESSION_TICKET_A: - str = "SSLv3 write session ticket A"; + case TLS_ST_SW_SRVR_HELLO: + str = "SSLv3/TLS write server hello"; break; - case SSL3_ST_SW_SESSION_TICKET_B: - str = "SSLv3 write session ticket B"; + case TLS_ST_SW_CERT: + str = "SSLv3/TLS write certificate"; break; - case SSL3_ST_SW_SRVR_DONE_A: - str = "SSLv3 write server done A"; + case TLS_ST_SW_KEY_EXCH: + str = "SSLv3/TLS write key exchange"; break; - case SSL3_ST_SW_SRVR_DONE_B: - str = "SSLv3 write server done B"; + case TLS_ST_SW_CERT_REQ: + str = "SSLv3/TLS write certificate request"; break; - case SSL3_ST_SR_CERT_A: - str = "SSLv3 read client certificate A"; + case TLS_ST_SW_SESSION_TICKET: + str = "SSLv3/TLS write session ticket"; break; - case SSL3_ST_SR_CERT_B: - str = "SSLv3 read client certificate B"; + case TLS_ST_SW_SRVR_DONE: + str = "SSLv3/TLS write server done"; break; - case SSL3_ST_SR_KEY_EXCH_A: - str = "SSLv3 read client key exchange A"; + case TLS_ST_SR_CERT: + str = "SSLv3/TLS read client certificate"; break; - case SSL3_ST_SR_KEY_EXCH_B: - str = "SSLv3 read client key exchange B"; + case TLS_ST_SR_KEY_EXCH: + str = "SSLv3/TLS read client key exchange"; break; - case SSL3_ST_SR_CERT_VRFY_A: - str = "SSLv3 read certificate verify A"; + case TLS_ST_SR_CERT_VRFY: + str = "SSLv3/TLS read certificate verify"; break; - case SSL3_ST_SR_CERT_VRFY_B: - str = "SSLv3 read certificate verify B"; - break; -#endif /* DTLS */ - case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: - str = "DTLS1 read hello verify request A"; - break; - case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: - str = "DTLS1 read hello verify request B"; - break; - case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: - str = "DTLS1 write hello verify request A"; + case DTLS_ST_CR_HELLO_VERIFY_REQUEST: + str = "DTLS1 read hello verify request"; break; - case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: - str = "DTLS1 write hello verify request B"; + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + str = "DTLS1 write hello verify request"; break; default: @@ -328,203 +204,100 @@ const char *SSL_state_string(const SSL *s) { const char *str; - switch (s->state) { - case SSL_ST_BEFORE: + if (ossl_statem_in_error(s)) { + return "SSLERR"; + } + + switch (SSL_get_state(s)) { + case TLS_ST_BEFORE: str = "PINIT "; break; - case SSL_ST_ACCEPT: - str = "AINIT "; - break; - case SSL_ST_CONNECT: - str = "CINIT "; - break; - case SSL_ST_OK: + case TLS_ST_OK: str = "SSLOK "; break; - case SSL_ST_ERR: - str = "SSLERR"; - break; -#ifndef OPENSSL_NO_SSL3 -/* SSLv3 additions */ - case SSL3_ST_SW_FLUSH: - case SSL3_ST_CW_FLUSH: - str = "3FLUSH"; - break; - case SSL3_ST_CW_CLNT_HELLO_A: - str = "3WCH_A"; - break; - case SSL3_ST_CW_CLNT_HELLO_B: - str = "3WCH_B"; - break; - case SSL3_ST_CR_SRVR_HELLO_A: - str = "3RSH_A"; - break; - case SSL3_ST_CR_SRVR_HELLO_B: - str = "3RSH_B"; - break; - case SSL3_ST_CR_CERT_A: - str = "3RSC_A"; - break; - case SSL3_ST_CR_CERT_B: - str = "3RSC_B"; - break; - case SSL3_ST_CR_KEY_EXCH_A: - str = "3RSKEA"; - break; - case SSL3_ST_CR_KEY_EXCH_B: - str = "3RSKEB"; - break; - case SSL3_ST_CR_CERT_REQ_A: - str = "3RCR_A"; - break; - case SSL3_ST_CR_CERT_REQ_B: - str = "3RCR_B"; - break; - case SSL3_ST_CR_SRVR_DONE_A: - str = "3RSD_A"; + case TLS_ST_CW_CLNT_HELLO: + str = "TWCH"; break; - case SSL3_ST_CR_SRVR_DONE_B: - str = "3RSD_B"; + case TLS_ST_CR_SRVR_HELLO: + str = "TRSH"; break; - case SSL3_ST_CW_CERT_A: - str = "3WCC_A"; + case TLS_ST_CR_CERT: + str = "TRSC"; break; - case SSL3_ST_CW_CERT_B: - str = "3WCC_B"; + case TLS_ST_CR_KEY_EXCH: + str = "TRSKE"; break; - case SSL3_ST_CW_CERT_C: - str = "3WCC_C"; + case TLS_ST_CR_CERT_REQ: + str = "TRCR"; break; - case SSL3_ST_CW_CERT_D: - str = "3WCC_D"; + case TLS_ST_CR_SRVR_DONE: + str = "TRSD"; break; - case SSL3_ST_CW_KEY_EXCH_A: - str = "3WCKEA"; + case TLS_ST_CW_CERT: + str = "TWCC"; break; - case SSL3_ST_CW_KEY_EXCH_B: - str = "3WCKEB"; + case TLS_ST_CW_KEY_EXCH: + str = "TWCKE"; break; - case SSL3_ST_CW_CERT_VRFY_A: - str = "3WCV_A"; - break; - case SSL3_ST_CW_CERT_VRFY_B: - str = "3WCV_B"; + case TLS_ST_CW_CERT_VRFY: + str = "TWCV"; break; - case SSL3_ST_SW_CHANGE_A: - case SSL3_ST_CW_CHANGE_A: - str = "3WCCSA"; - break; - case SSL3_ST_SW_CHANGE_B: - case SSL3_ST_CW_CHANGE_B: - str = "3WCCSB"; - break; - case SSL3_ST_SW_FINISHED_A: - case SSL3_ST_CW_FINISHED_A: - str = "3WFINA"; - break; - case SSL3_ST_SW_FINISHED_B: - case SSL3_ST_CW_FINISHED_B: - str = "3WFINB"; - break; - case SSL3_ST_SR_CHANGE_A: - case SSL3_ST_CR_CHANGE_A: - str = "3RCCSA"; + case TLS_ST_SW_CHANGE: + case TLS_ST_CW_CHANGE: + str = "TWCCS"; break; - case SSL3_ST_SR_CHANGE_B: - case SSL3_ST_CR_CHANGE_B: - str = "3RCCSB"; + case TLS_ST_SW_FINISHED: + case TLS_ST_CW_FINISHED: + str = "TWFIN"; break; - case SSL3_ST_SR_FINISHED_A: - case SSL3_ST_CR_FINISHED_A: - str = "3RFINA"; + case TLS_ST_SR_CHANGE: + case TLS_ST_CR_CHANGE: + str = "TRCCS"; break; - case SSL3_ST_SR_FINISHED_B: - case SSL3_ST_CR_FINISHED_B: - str = "3RFINB"; + case TLS_ST_SR_FINISHED: + case TLS_ST_CR_FINISHED: + str = "TRFIN"; break; - case SSL3_ST_SW_HELLO_REQ_A: - str = "3WHR_A"; - break; - case SSL3_ST_SW_HELLO_REQ_B: - str = "3WHR_B"; - break; - case SSL3_ST_SW_HELLO_REQ_C: - str = "3WHR_C"; - break; - case SSL3_ST_SR_CLNT_HELLO_A: - str = "3RCH_A"; - break; - case SSL3_ST_SR_CLNT_HELLO_B: - str = "3RCH_B"; - break; - case SSL3_ST_SR_CLNT_HELLO_C: - str = "3RCH_C"; + case TLS_ST_SW_HELLO_REQ: + str = "TWHR"; break; - case SSL3_ST_SW_SRVR_HELLO_A: - str = "3WSH_A"; + case TLS_ST_SR_CLNT_HELLO: + str = "TRCH"; break; - case SSL3_ST_SW_SRVR_HELLO_B: - str = "3WSH_B"; + case TLS_ST_SW_SRVR_HELLO: + str = "TWSH"; break; - case SSL3_ST_SW_CERT_A: - str = "3WSC_A"; + case TLS_ST_SW_CERT: + str = "TWSC"; break; - case SSL3_ST_SW_CERT_B: - str = "3WSC_B"; + case TLS_ST_SW_KEY_EXCH: + str = "TWSKE"; break; - case SSL3_ST_SW_KEY_EXCH_A: - str = "3WSKEA"; + case TLS_ST_SW_CERT_REQ: + str = "TWCR"; break; - case SSL3_ST_SW_KEY_EXCH_B: - str = "3WSKEB"; + case TLS_ST_SW_SRVR_DONE: + str = "TWSD"; break; - case SSL3_ST_SW_CERT_REQ_A: - str = "3WCR_A"; + case TLS_ST_SR_CERT: + str = "TRCC"; break; - case SSL3_ST_SW_CERT_REQ_B: - str = "3WCR_B"; + case TLS_ST_SR_KEY_EXCH: + str = "TRCKE"; break; - case SSL3_ST_SW_SRVR_DONE_A: - str = "3WSD_A"; + case TLS_ST_SR_CERT_VRFY: + str = "TRCV"; break; - case SSL3_ST_SW_SRVR_DONE_B: - str = "3WSD_B"; - break; - case SSL3_ST_SR_CERT_A: - str = "3RCC_A"; - break; - case SSL3_ST_SR_CERT_B: - str = "3RCC_B"; - break; - case SSL3_ST_SR_KEY_EXCH_A: - str = "3RCKEA"; - break; - case SSL3_ST_SR_KEY_EXCH_B: - str = "3RCKEB"; - break; - case SSL3_ST_SR_CERT_VRFY_A: - str = "3RCV_A"; - break; - case SSL3_ST_SR_CERT_VRFY_B: - str = "3RCV_B"; - break; -#endif /* DTLS */ - case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: - str = "DRCHVA"; - break; - case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: - str = "DRCHVB"; - break; - case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: - str = "DWCHVA"; + case DTLS_ST_CR_HELLO_VERIFY_REQUEST: + str = "DRCHV"; break; - case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: - str = "DWCHVB"; + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + str = "DWCHV"; break; default: diff --git a/ssl/statem/README b/ssl/statem/README new file mode 100644 index 0000000..145c69d --- /dev/null +++ b/ssl/statem/README @@ -0,0 +1,63 @@ +State Machine Design +==================== + +This file provides some guidance on the thinking behind the design of the +state machine code to aid future maintenance. + +The state machine code replaces an older state machine present in OpenSSL +versions 1.0.2 and below. The new state machine has the following objectives: + - Remove duplication of state code between client and server + - Remove duplication of state code between TLS and DTLS + - Simplify transitions and bring the logic together in a single location + so that it is easier to validate + - Remove duplication of code between each of the message handling functions + - Receive a message first and then work out whether that is a valid + transition - not the other way around (the other way causes lots of issues + where we are expecting one type of message next but actually get something + else) + - Separate message flow state from handshake state (in order to better + understand each) + - message flow state = when to flush buffers; handling restarts in the + event of NBIO events; handling the common flow of steps for reading a + message and the common flow of steps for writing a message etc + - handshake state = what handshake message are we working on now + - Control complexity: only the state machine can change state: keep all + the state changes local to the state machine component + +The message flow state machine is divided into a reading sub-state machine and a +writing sub-state machine. See the source comments in statem.c for a more +detailed description of the various states and transitions possible. + +Conceptually the state machine component is designed as follows: + + libssl + | +---------------------------|-----statem.h-------------------------------------- + | + _______V____________________ + | | + | statem.c | + | | + | Core state machine code | + |____________________________| + statem_locl.h ^ ^ + _________| |_______ + | | + _____________|____________ _____________|____________ + | | | | + | statem_clnt.c | | statem_srvr.c | + | | | | + | TLS/DTLS client specific | | TLS/DTLS server specific | + | state machine code | | state machine code | + |__________________________| |__________________________| + | |_______________|__ | + | ________________| | | + | | | | + ____________V_______V________ ________V______V_______________ + | | | | + | statem_both.c | | statem_dtls.c | + | | | | + | Non core functions common | | Non core functions common to | + | to both servers and clients | | both DTLS servers and clients | + |_____________________________| |_______________________________| + diff --git a/ssl/statem/statem.c b/ssl/statem/statem.c new file mode 100644 index 0000000..3a44846 --- /dev/null +++ b/ssl/statem/statem.c @@ -0,0 +1,891 @@ +/* ssl/statem/statem.c */ +/* + * Written by Matt Caswell for the OpenSSL project. + */ +/* ==================================================================== + * Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core at openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay at cryptsoft.com). This product includes software written by Tim + * Hudson (tjh at cryptsoft.com). + * + */ + +#include +#include "../ssl_locl.h" +#include "statem_locl.h" + +/* + * This file implements the SSL/TLS/DTLS state machines. + * + * There are two primary state machines: + * + * 1) Message flow state machine + * 2) Handshake state machine + * + * The Message flow state machine controls the reading and sending of messages + * including handling of non-blocking IO events, flushing of the underlying + * write BIO, handling unexpected messages, etc. It is itself broken into two + * separate sub-state machines which control reading and writing respectively. + * + * The Handshake state machine keeps track of the current SSL/TLS handshake + * state. Transitions of the handshake state are the result of events that + * occur within the Message flow state machine. + * + * Overall it looks like this: + * + * --------------------------------------------- ------------------- + * | | | | + * | Message flow state machine | | | + * | | | | + * | -------------------- -------------------- | Transition | Handshake state | + * | | MSG_FLOW_READING | | MSG_FLOW_WRITING | | Event | machine | + * | | sub-state | | sub-state | |----------->| | + * | | machine for | | machine for | | | | + * | | reading messages | | writing messages | | | | + * | -------------------- -------------------- | | | + * | | | | + * --------------------------------------------- ------------------- + * + */ + +/* Sub state machine return values */ +typedef enum { + /* Something bad happened or NBIO */ + SUB_STATE_ERROR, + /* Sub state finished go to the next sub state */ + SUB_STATE_FINISHED, + /* Sub state finished and handshake was completed */ + SUB_STATE_END_HANDSHAKE +} SUB_STATE_RETURN; + +static int state_machine(SSL *s, int server); +static void init_read_state_machine(SSL *s); +static SUB_STATE_RETURN read_state_machine(SSL *s); +static void init_write_state_machine(SSL *s); +static SUB_STATE_RETURN write_state_machine(SSL *s); + +OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl) +{ + return ssl->statem.hand_state; +} + +int SSL_in_init(SSL *s) +{ + return s->statem.in_init; +} + +int SSL_is_init_finished(SSL *s) +{ + return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK); +} + +int SSL_in_before(SSL *s) +{ + /* + * Historically being "in before" meant before anything had happened. In the + * current code though we remain in the "before" state for a while after we + * have started the handshake process (e.g. as a server waiting for the + * first message to arrive). There "in before" is taken to mean "in before" + * and not started any handshake process yet. + */ + return (s->statem.hand_state == TLS_ST_BEFORE) + && (s->statem.state == MSG_FLOW_UNINITED); +} + +/* + * Clear the state machine state and reset back to MSG_FLOW_UNINITED + */ +void ossl_statem_clear(SSL *s) +{ + s->statem.state = MSG_FLOW_UNINITED; + s->statem.hand_state = TLS_ST_BEFORE; + s->statem.in_init = 1; + s->statem.no_cert_verify = 0; +} + +/* + * Set the state machine up ready for a renegotiation handshake + */ +void ossl_statem_set_renegotiate(SSL *s) +{ + s->statem.state = MSG_FLOW_RENEGOTIATE; + s->statem.in_init = 1; +} + +/* + * Put the state machine into an error state. This is a permanent error for + * the current connection. + */ +void ossl_statem_set_error(SSL *s) +{ + s->statem.state = MSG_FLOW_ERROR; +} + +/* + * Discover whether the current connection is in the error state. + * + * Valid return values are: + * 1: Yes + * 0: No + */ +int ossl_statem_in_error(const SSL *s) +{ + if (s->statem.state == MSG_FLOW_ERROR) + return 1; + + return 0; +} + +void ossl_statem_set_in_init(SSL *s, int init) +{ + s->statem.in_init = init; +} + +int ossl_statem_get_in_handshake(SSL *s) +{ + return s->statem.in_handshake; +} + +void ossl_statem_set_in_handshake(SSL *s, int inhand) +{ + if (inhand) + s->statem.in_handshake++; + else + s->statem.in_handshake--; +} + +void ossl_statem_set_hello_verify_done(SSL *s) +{ + s->statem.state = MSG_FLOW_UNINITED; + s->statem.in_init = 1; + /* + * This will get reset (briefly) back to TLS_ST_BEFORE when we enter + * state_machine() because |state| is MSG_FLOW_UNINITED, but until then any + * calls to SSL_in_before() will return false. Also calls to + * SSL_state_string() and SSL_state_string_long() will return something + * sensible. + */ + s->statem.hand_state = TLS_ST_SR_CLNT_HELLO; +} + +int ossl_statem_connect(SSL *s) { + return state_machine(s, 0); +} + +int ossl_statem_accept(SSL *s) +{ + return state_machine(s, 1); +} + +static void (*get_callback(SSL *s))(const SSL *, int, int) +{ + if (s->info_callback != NULL) + return s->info_callback; + else if (s->ctx->info_callback != NULL) + return s->ctx->info_callback; + + return NULL; +} + +/* + * The main message flow state machine. We start in the MSG_FLOW_UNINITED or + * MSG_FLOW_RENEGOTIATE state and finish in MSG_FLOW_FINISHED. Valid states and + * transitions are as follows: + * + * MSG_FLOW_UNINITED MSG_FLOW_RENEGOTIATE + * | | + * +-----------------------+ + * v + * MSG_FLOW_WRITING <---> MSG_FLOW_READING + * | + * V + * MSG_FLOW_FINISHED + * | + * V + * [SUCCESS] + * + * We may exit at any point due to an error or NBIO event. If an NBIO event + * occurs then we restart at the point we left off when we are recalled. + * MSG_FLOW_WRITING and MSG_FLOW_READING have sub-state machines associated with them. + * + * In addition to the above there is also the MSG_FLOW_ERROR state. We can move + * into that state at any point in the event that an irrecoverable error occurs. + * + * Valid return values are: + * 1: Success + * <=0: NBIO or error + */ +static int state_machine(SSL *s, int server) { + BUF_MEM *buf = NULL; + unsigned long Time = (unsigned long)time(NULL); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + OSSL_STATEM *st = &s->statem; + int ret = -1; + int ssret; + + if (st->state == MSG_FLOW_ERROR) { + /* Shouldn't have been called if we're already in the error state */ + return -1; + } + + RAND_add(&Time, sizeof(Time), 0); + ERR_clear_error(); + clear_sys_error(); + + cb = get_callback(s); + + st->in_handshake++; + if (!SSL_in_init(s) || SSL_in_before(s)) { + if (!SSL_clear(s)) + return -1; + } + +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s)) { + /* + * Notify SCTP BIO socket to enter handshake mode and prevent stream + * identifier other than 0. Will be ignored if no SCTP is used. + */ + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, + st->in_handshake, NULL); + } +#endif + +#ifndef OPENSSL_NO_HEARTBEATS + /* + * If we're awaiting a HeartbeatResponse, pretend we already got and + * don't await it anymore, because Heartbeats don't make sense during + * handshakes anyway. + */ + if (s->tlsext_hb_pending) { + if (SSL_IS_DTLS(s)) + dtls1_stop_timer(s); + s->tlsext_hb_pending = 0; + s->tlsext_hb_seq++; + } +#endif + + /* Initialise state machine */ + + if (st->state == MSG_FLOW_RENEGOTIATE) { + s->renegotiate = 1; + if (!server) + s->ctx->stats.sess_connect_renegotiate++; + } + + if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE) { + if (st->state == MSG_FLOW_UNINITED) { + st->hand_state = TLS_ST_BEFORE; + } + + s->server = server; + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_START, 1); + + if (SSL_IS_DTLS(s)) { + if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00) && + (server + || (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00))) { + SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR); + goto end; + } + } else { + if ((s->version >> 8) != SSL3_VERSION_MAJOR + && s->version != TLS_ANY_VERSION) { + SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR); + goto end; + } + } + + if (!SSL_IS_DTLS(s)) { + if (s->version != TLS_ANY_VERSION && + !ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) { + SSLerr(SSL_F_STATE_MACHINE, SSL_R_VERSION_TOO_LOW); + goto end; + } + } + + if (s->init_buf == NULL) { + if ((buf = BUF_MEM_new()) == NULL) { + goto end; + } + if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { + goto end; + } + s->init_buf = buf; + buf = NULL; + } + + if (!ssl3_setup_buffers(s)) { + goto end; + } + s->init_num = 0; + + /* + * Should have been reset by tls_process_finished, too. + */ + s->s3->change_cipher_spec = 0; + + if (!server || st->state != MSG_FLOW_RENEGOTIATE) { + /* + * Ok, we now need to push on a buffering BIO ...but not with + * SCTP + */ +#ifndef OPENSSL_NO_SCTP + if (!SSL_IS_DTLS(s) || !BIO_dgram_is_sctp(SSL_get_wbio(s))) +#endif + if (!ssl_init_wbio_buffer(s, server ? 1 : 0)) { + goto end; + } + + ssl3_init_finished_mac(s); + } + + if (server) { + if (st->state != MSG_FLOW_RENEGOTIATE) { + s->ctx->stats.sess_accept++; + } else if (!s->s3->send_connection_binding && + !(s->options & + SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + /* + * Server attempting to renegotiate with client that doesn't + * support secure renegotiation. + */ + SSLerr(SSL_F_STATE_MACHINE, + SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + ossl_statem_set_error(s); + goto end; + } else { + /* + * st->state == MSG_FLOW_RENEGOTIATE, we will just send a + * HelloRequest + */ + s->ctx->stats.sess_accept_renegotiate++; + } + } else { + s->ctx->stats.sess_connect++; + + /* mark client_random uninitialized */ + memset(s->s3->client_random, 0, sizeof(s->s3->client_random)); + s->hit = 0; + + s->s3->tmp.cert_request = 0; + + if (SSL_IS_DTLS(s)) { + st->use_timer = 1; + } + } + + st->state = MSG_FLOW_WRITING; + init_write_state_machine(s); + st->read_state_first_init = 1; + } + + while(st->state != MSG_FLOW_FINISHED) { + if(st->state == MSG_FLOW_READING) { + ssret = read_state_machine(s); + if (ssret == SUB_STATE_FINISHED) { + st->state = MSG_FLOW_WRITING; + init_write_state_machine(s); + } else { + /* NBIO or error */ + goto end; + } + } else if (st->state == MSG_FLOW_WRITING) { + ssret = write_state_machine(s); + if (ssret == SUB_STATE_FINISHED) { + st->state = MSG_FLOW_READING; + init_read_state_machine(s); + } else if (ssret == SUB_STATE_END_HANDSHAKE) { + st->state = MSG_FLOW_FINISHED; + } else { + /* NBIO or error */ + goto end; + } + } else { + /* Error */ + ossl_statem_set_error(s); + goto end; + } + } + + st->state = MSG_FLOW_UNINITED; + ret = 1; + + end: + st->in_handshake--; + +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s)) { + /* + * Notify SCTP BIO socket to leave handshake mode and allow stream + * identifier other than 0. Will be ignored if no SCTP is used. + */ + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE, + st->in_handshake, NULL); + } +#endif + + BUF_MEM_free(buf); + if (cb != NULL) { + if (server) + cb(s, SSL_CB_ACCEPT_EXIT, ret); + else + cb(s, SSL_CB_CONNECT_EXIT, ret); + } + return ret; +} + +/* + * Initialise the MSG_FLOW_READING sub-state machine + */ +static void init_read_state_machine(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + st->read_state = READ_STATE_HEADER; +} + +/* + * This function implements the sub-state machine when the message flow is in + * MSG_FLOW_READING. The valid sub-states and transitions are: + * + * READ_STATE_HEADER <--+<-------------+ + * | | | + * v | | + * READ_STATE_BODY -----+-->READ_STATE_POST_PROCESS + * | | + * +----------------------------+ + * v + * [SUB_STATE_FINISHED] + * + * READ_STATE_HEADER has the responsibility for reading in the message header + * and transitioning the state of the handshake state machine. + * + * READ_STATE_BODY reads in the rest of the message and then subsequently + * processes it. + * + * READ_STATE_POST_PROCESS is an optional step that may occur if some post + * processing activity performed on the message may block. + * + * Any of the above states could result in an NBIO event occuring in which case + * control returns to the calling application. When this function is recalled we + * will resume in the same state where we left off. + */ +static SUB_STATE_RETURN read_state_machine(SSL *s) { + OSSL_STATEM *st = &s->statem; + int ret, mt; + unsigned long len = 0; + int (*transition)(SSL *s, int mt); + PACKET pkt; + MSG_PROCESS_RETURN (*process_message)(SSL *s, PACKET *pkt); + WORK_STATE (*post_process_message)(SSL *s, WORK_STATE wst); + unsigned long (*max_message_size)(SSL *s); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + + cb = get_callback(s); + + if(s->server) { + transition = ossl_statem_server_read_transition; + process_message = ossl_statem_server_process_message; + max_message_size = ossl_statem_server_max_message_size; + post_process_message = ossl_statem_server_post_process_message; + } else { + transition = ossl_statem_client_read_transition; + process_message = ossl_statem_client_process_message; + max_message_size = ossl_statem_client_max_message_size; + post_process_message = ossl_statem_client_post_process_message; + } + + if (st->read_state_first_init) { + s->first_packet = 1; + st->read_state_first_init = 0; + } + + while(1) { + switch(st->read_state) { + case READ_STATE_HEADER: + s->init_num = 0; + /* Get the state the peer wants to move to */ + if (SSL_IS_DTLS(s)) { + /* + * In DTLS we get the whole message in one go - header and body + */ + ret = dtls_get_message(s, &mt, &len); + } else { + ret = tls_get_message_header(s, &mt); + } + + if (ret == 0) { + /* Could be non-blocking IO */ + return SUB_STATE_ERROR; + } + + if (cb != NULL) { + /* Notify callback of an impending state change */ + if (s->server) + cb(s, SSL_CB_ACCEPT_LOOP, 1); + else + cb(s, SSL_CB_CONNECT_LOOP, 1); + } + /* + * Validate that we are allowed to move to the new state and move + * to that state if so + */ + if(!transition(s, mt)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL3_AD_UNEXPECTED_MESSAGE); + SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_UNEXPECTED_MESSAGE); + return SUB_STATE_ERROR; + } + + if (s->s3->tmp.message_size > max_message_size(s)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER); + SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_EXCESSIVE_MESSAGE_SIZE); + return SUB_STATE_ERROR; + } + + st->read_state = READ_STATE_BODY; + /* Fall through */ + + case READ_STATE_BODY: + if (!SSL_IS_DTLS(s)) { + /* We already got this above for DTLS */ + ret = tls_get_message_body(s, &len); + if (ret == 0) { + /* Could be non-blocking IO */ + return SUB_STATE_ERROR; + } + } + + s->first_packet = 0; + if (!PACKET_buf_init(&pkt, s->init_msg, len)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR); + return SUB_STATE_ERROR; + } + ret = process_message(s, &pkt); + if (ret == MSG_PROCESS_ERROR) { + return SUB_STATE_ERROR; + } + + if (ret == MSG_PROCESS_FINISHED_READING) { + if (SSL_IS_DTLS(s)) { + dtls1_stop_timer(s); + } + return SUB_STATE_FINISHED; + } + + if (ret == MSG_PROCESS_CONTINUE_PROCESSING) { + st->read_state = READ_STATE_POST_PROCESS; + st->read_state_work = WORK_MORE_A; + } else { + st->read_state = READ_STATE_HEADER; + } + break; + + case READ_STATE_POST_PROCESS: + st->read_state_work = post_process_message(s, st->read_state_work); + switch(st->read_state_work) { + default: + return SUB_STATE_ERROR; + + case WORK_FINISHED_CONTINUE: + st->read_state = READ_STATE_HEADER; + break; + + case WORK_FINISHED_STOP: + if (SSL_IS_DTLS(s)) { + dtls1_stop_timer(s); + } + return SUB_STATE_FINISHED; + } + break; + + default: + /* Shouldn't happen */ + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return SUB_STATE_ERROR; + } + } +} + +/* + * Send a previously constructed message to the peer. + */ +static int statem_do_write(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + if (st->hand_state == TLS_ST_CW_CHANGE + || st->hand_state == TLS_ST_SW_CHANGE) { + if (SSL_IS_DTLS(s)) + return dtls1_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC); + else + return ssl3_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC); + } else { + return ssl_do_write(s); + } +} + +/* + * Initialise the MSG_FLOW_WRITING sub-state machine + */ +static void init_write_state_machine(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + st->write_state = WRITE_STATE_TRANSITION; +} + +/* + * This function implements the sub-state machine when the message flow is in + * MSG_FLOW_WRITING. The valid sub-states and transitions are: + * + * +-> WRITE_STATE_TRANSITION ------> [SUB_STATE_FINISHED] + * | | + * | v + * | WRITE_STATE_PRE_WORK -----> [SUB_STATE_END_HANDSHAKE] + * | | + * | v + * | WRITE_STATE_SEND + * | | + * | v + * | WRITE_STATE_POST_WORK + * | | + * +-------------+ + * + * WRITE_STATE_TRANSITION transitions the state of the handshake state machine + + * WRITE_STATE_PRE_WORK performs any work necessary to prepare the later + * sending of the message. This could result in an NBIO event occuring in + * which case control returns to the calling application. When this function + * is recalled we will resume in the same state where we left off. + * + * WRITE_STATE_SEND sends the message and performs any work to be done after + * sending. + * + * WRITE_STATE_POST_WORK performs any work necessary after the sending of the + * message has been completed. As for WRITE_STATE_PRE_WORK this could also + * result in an NBIO event. + */ +static SUB_STATE_RETURN write_state_machine(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + int ret; + WRITE_TRAN (*transition)(SSL *s); + WORK_STATE (*pre_work)(SSL *s, WORK_STATE wst); + WORK_STATE (*post_work)(SSL *s, WORK_STATE wst); + int (*construct_message)(SSL *s); + void (*cb) (const SSL *ssl, int type, int val) = NULL; + + cb = get_callback(s); + + if(s->server) { + transition = ossl_statem_server_write_transition; + pre_work = ossl_statem_server_pre_work; + post_work = ossl_statem_server_post_work; + construct_message = ossl_statem_server_construct_message; + } else { + transition = ossl_statem_client_write_transition; + pre_work = ossl_statem_client_pre_work; + post_work = ossl_statem_client_post_work; + construct_message = ossl_statem_client_construct_message; + } + + while(1) { + switch(st->write_state) { + case WRITE_STATE_TRANSITION: + if (cb != NULL) { + /* Notify callback of an impending state change */ + if (s->server) + cb(s, SSL_CB_ACCEPT_LOOP, 1); + else + cb(s, SSL_CB_CONNECT_LOOP, 1); + } + switch(transition(s)) { + case WRITE_TRAN_CONTINUE: + st->write_state = WRITE_STATE_PRE_WORK; + st->write_state_work = WORK_MORE_A; + break; + + case WRITE_TRAN_FINISHED: + return SUB_STATE_FINISHED; + break; + + default: + return SUB_STATE_ERROR; + } + break; + + case WRITE_STATE_PRE_WORK: + switch(st->write_state_work = pre_work(s, st->write_state_work)) { + default: + return SUB_STATE_ERROR; + + case WORK_FINISHED_CONTINUE: + st->write_state = WRITE_STATE_SEND; + break; + + case WORK_FINISHED_STOP: + return SUB_STATE_END_HANDSHAKE; + } + if(construct_message(s) == 0) + return SUB_STATE_ERROR; + + /* Fall through */ + + case WRITE_STATE_SEND: + if (SSL_IS_DTLS(s) && st->use_timer) { + dtls1_start_timer(s); + } + ret = statem_do_write(s); + if (ret <= 0) { + return SUB_STATE_ERROR; + } + st->write_state = WRITE_STATE_POST_WORK; + st->write_state_work = WORK_MORE_A; + /* Fall through */ + + case WRITE_STATE_POST_WORK: + switch(st->write_state_work = post_work(s, st->write_state_work)) { + default: + return SUB_STATE_ERROR; + + case WORK_FINISHED_CONTINUE: + st->write_state = WRITE_STATE_TRANSITION; + break; + + case WORK_FINISHED_STOP: + return SUB_STATE_END_HANDSHAKE; + } + break; + + default: + return SUB_STATE_ERROR; + } + } +} + +/* + * Flush the write BIO + */ +int statem_flush(SSL *s) +{ + s->rwstate = SSL_WRITING; + if (BIO_flush(s->wbio) <= 0) { + return 0; + } + s->rwstate = SSL_NOTHING; + + return 1; +} + +/* + * Called by the record layer to determine whether application data is + * allowed to be sent in the current handshake state or not. + * + * Return values are: + * 1: Yes (application data allowed) + * 0: No (application data not allowed) + */ +int ossl_statem_app_data_allowed(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE) + return 0; + + if (!s->s3->in_read_app_data || (s->s3->total_renegotiations == 0)) + return 0; + + if (s->server) { + /* + * If we're a server and we haven't got as far as writing our + * ServerHello yet then we allow app data + */ + if (st->hand_state == TLS_ST_BEFORE + || st->hand_state == TLS_ST_SR_CLNT_HELLO) + return 1; + } else { + /* + * If we're a client and we haven't read the ServerHello yet then we + * allow app data + */ + if (st->hand_state == TLS_ST_CW_CLNT_HELLO) + return 1; + } + + return 0; +} + +#ifndef OPENSSL_NO_SCTP +/* + * Set flag used by SCTP to determine whether we are in the read sock state + */ +void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock) +{ + s->statem.in_sctp_read_sock = read_sock; +} + +/* + * Called by the record layer to determine whether we are in the read sock + * state or not. + * + * Return values are: + * 1: Yes (we are in the read sock state) + * 0: No (we are not in the read sock state) + */ +int statem_in_sctp_read_sock(SSL *s) +{ + return s->statem.in_sctp_read_sock; +} +#endif diff --git a/ssl/statem/statem.h b/ssl/statem/statem.h new file mode 100644 index 0000000..1350967 --- /dev/null +++ b/ssl/statem/statem.h @@ -0,0 +1,176 @@ +/* ssl/statem/statem.h */ +/* ==================================================================== + * Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core at openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay at cryptsoft.com). This product includes software written by Tim + * Hudson (tjh at cryptsoft.com). + * + */ + +/***************************************************************************** + * * + * These emums should be considered PRIVATE to the state machine. No * + * non-state machine code should need to use these * + * * + *****************************************************************************/ +/* + * Valid return codes used for functions performing work prior to or after + * sending or receiving a message + */ +typedef enum { + /* Something went wrong */ + WORK_ERROR, + /* We're done working and there shouldn't be anything else to do after */ + WORK_FINISHED_STOP, + /* We're done working move onto the next thing */ + WORK_FINISHED_CONTINUE, + /* We're working on phase A */ + WORK_MORE_A, + /* We're working on phase B */ + WORK_MORE_B +} WORK_STATE; + +/* Write transition return codes */ +typedef enum { + /* Something went wrong */ + WRITE_TRAN_ERROR, + /* A transition was successfully completed and we should continue */ + WRITE_TRAN_CONTINUE, + /* There is no more write work to be done */ + WRITE_TRAN_FINISHED +} WRITE_TRAN; + +/* Message flow states */ +typedef enum { + /* No handshake in progress */ + MSG_FLOW_UNINITED, + /* A permanent error with this connection */ + MSG_FLOW_ERROR, + /* We are about to renegotiate */ + MSG_FLOW_RENEGOTIATE, + /* We are reading messages */ + MSG_FLOW_READING, + /* We are writing messages */ + MSG_FLOW_WRITING, + /* Handshake has finished */ + MSG_FLOW_FINISHED +} MSG_FLOW_STATE; + +/* Read states */ +typedef enum { + READ_STATE_HEADER, + READ_STATE_BODY, + READ_STATE_POST_PROCESS +} READ_STATE; + +/* Write states */ +typedef enum { + WRITE_STATE_TRANSITION, + WRITE_STATE_PRE_WORK, + WRITE_STATE_SEND, + WRITE_STATE_POST_WORK +} WRITE_STATE; + + +/***************************************************************************** + * * + * This structure should be considered "opaque" to anything outside of the * + * state machine. No non-state machine code should be accessing the members * + * of this structure. * + * * + *****************************************************************************/ + +struct ossl_statem_st { + MSG_FLOW_STATE state; + WRITE_STATE write_state; + WORK_STATE write_state_work; + READ_STATE read_state; + WORK_STATE read_state_work; + OSSL_HANDSHAKE_STATE hand_state; + int in_init; + int read_state_first_init; + + /* true when we are actually in SSL_accept() or SSL_connect() */ + int in_handshake; + + /* Should we skip the CertificateVerify message? */ + unsigned int no_cert_verify; + + int use_timer; +#ifndef OPENSSL_NO_SCTP + int in_sctp_read_sock; +#endif +}; +typedef struct ossl_statem_st OSSL_STATEM; + + +/***************************************************************************** + * * + * The following macros/functions represent the libssl internal API to the * + * state machine. Any libssl code may call these functions/macros * + * * + *****************************************************************************/ + +__owur int ossl_statem_accept(SSL *s); +__owur int ossl_statem_connect(SSL *s); +void ossl_statem_clear(SSL *s); +void ossl_statem_set_renegotiate(SSL *s); +void ossl_statem_set_error(SSL *s); +int ossl_statem_in_error(const SSL *s); +void ossl_statem_set_in_init(SSL *s, int init); +int ossl_statem_get_in_handshake(SSL *s); +void ossl_statem_set_in_handshake(SSL *s, int inhand); +void ossl_statem_set_hello_verify_done(SSL *s); +__owur int ossl_statem_app_data_allowed(SSL *s); +#ifndef OPENSSL_NO_SCTP +void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock); +__owur int ossl_statem_in_sctp_read_sock(SSL *s); +#endif + + diff --git a/ssl/s3_clnt.c b/ssl/statem/statem_clnt.c similarity index 50% rename from ssl/s3_clnt.c rename to ssl/statem/statem_clnt.c index 8a89b42..c9d760f 100644 --- a/ssl/s3_clnt.c +++ b/ssl/statem/statem_clnt.c @@ -1,4 +1,4 @@ -/* ssl/s3_clnt.c */ +/* ssl/statem/statem_clnt.c */ /* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) * All rights reserved. * @@ -149,7 +149,8 @@ */ #include -#include "ssl_locl.h" +#include "../ssl_locl.h" +#include "statem_locl.h" #include #include #include @@ -163,259 +164,268 @@ # include #endif +static inline int cert_req_allowed(SSL *s); +static int key_exchange_expected(SSL *s); static int ssl_set_version(SSL *s); static int ca_dn_cmp(const X509_NAME *const *a, const X509_NAME *const *b); -static int ssl3_check_change(SSL *s); static int ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, unsigned char *p); -int ssl3_connect(SSL *s) +/* + * Is a CertificateRequest message allowed at the moment or not? + * + * Return values are: + * 1: Yes + * 0: No + */ +static inline int cert_req_allowed(SSL *s) { - BUF_MEM *buf = NULL; - unsigned long Time = (unsigned long)time(NULL); - void (*cb) (const SSL *ssl, int type, int val) = NULL; - int ret = -1; - int new_state, state, skip = 0; - - RAND_add(&Time, sizeof(Time), 0); - ERR_clear_error(); - clear_sys_error(); - - if (s->info_callback != NULL) - cb = s->info_callback; - else if (s->ctx->info_callback != NULL) - cb = s->ctx->info_callback; - - s->in_handshake++; - if (!SSL_in_init(s) || SSL_in_before(s)) { - if (!SSL_clear(s)) - return -1; + /* TLS does not like anon-DH with client cert */ + if ((s->version > SSL3_VERSION + && (s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL)) + || (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aSRP | SSL_aPSK))) + return 0; + + return 1; +} + +/* + * Should we expect the ServerKeyExchange message or not? + * + * Return values are: + * 1: Yes + * 0: No + * -1: Error + */ +static int key_exchange_expected(SSL *s) +{ + long alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * Can't skip server key exchange if this is an ephemeral + * ciphersuite or for SRP + */ + if (alg_k & (SSL_kDHE | SSL_kECDHE | SSL_kDHEPSK | SSL_kECDHEPSK + | SSL_kSRP)) { + return 1; } -#ifndef OPENSSL_NO_HEARTBEATS /* - * If we're awaiting a HeartbeatResponse, pretend we already got and - * don't await it anymore, because Heartbeats don't make sense during - * handshakes anyway. + * Export ciphersuites may have temporary RSA keys if the public key in the + * server certificate is longer than the maximum export strength */ - if (s->tlsext_hb_pending) { - s->tlsext_hb_pending = 0; - s->tlsext_hb_seq++; - } -#endif - - for (;;) { - state = s->state; - - switch (s->state) { - case SSL_ST_RENEGOTIATE: - s->renegotiate = 1; - s->state = SSL_ST_CONNECT; - s->ctx->stats.sess_connect_renegotiate++; - /* break */ - case SSL_ST_BEFORE: - case SSL_ST_CONNECT: - case SSL_ST_BEFORE | SSL_ST_CONNECT: - case SSL_ST_OK | SSL_ST_CONNECT: - - s->server = 0; - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_START, 1); - - if ((s->version >> 8) != SSL3_VERSION_MAJOR - && s->version != TLS_ANY_VERSION) { - SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - ret = -1; - goto end; - } + if ((alg_k & SSL_kRSA) && SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) { + EVP_PKEY *pkey; - if (s->version != TLS_ANY_VERSION && - !ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) { - SSLerr(SSL_F_SSL3_CONNECT, SSL_R_VERSION_TOO_LOW); - return -1; - } + pkey = X509_get_pubkey(s->session->peer); + if (pkey == NULL) + return -1; + + /* + * If the public key in the certificate is shorter than or equal to the + * maximum export strength then a temporary RSA key is not allowed + */ + if (EVP_PKEY_bits(pkey) + <= SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) + return 0; + + EVP_PKEY_free(pkey); + + return 1; + } + + return 0; +} + +/* + * ossl_statem_client_read_transition() encapsulates the logic for the allowed + * handshake state transitions when the client is reading messages from the + * server. The message type that the server has sent is provided in |mt|. The + * current state is in |s->statem.hand_state|. + * + * Return values are: + * 1: Success (transition allowed) + * 0: Error (transition not allowed) + */ +int ossl_statem_client_read_transition(SSL *s, int mt) +{ + OSSL_STATEM *st = &s->statem; + int ske_expected; - /* s->version=SSL3_VERSION; */ - s->type = SSL_ST_CONNECT; + switch(st->hand_state) { + case TLS_ST_CW_CLNT_HELLO: + if (mt == SSL3_MT_SERVER_HELLO) { + st->hand_state = TLS_ST_CR_SRVR_HELLO; + return 1; + } + + if (SSL_IS_DTLS(s)) { + if (mt == DTLS1_MT_HELLO_VERIFY_REQUEST) { + st->hand_state = DTLS_ST_CR_HELLO_VERIFY_REQUEST; + return 1; + } + } + break; - if (s->init_buf == NULL) { - if ((buf = BUF_MEM_new()) == NULL) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; + case TLS_ST_CR_SRVR_HELLO: + if (s->hit) { + if (s->tlsext_ticket_expected) { + if (mt == SSL3_MT_NEWSESSION_TICKET) { + st->hand_state = TLS_ST_CR_SESSION_TICKET; + return 1; } - if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; + } else if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + st->hand_state = TLS_ST_CR_CHANGE; + return 1; + } + } else { + if (SSL_IS_DTLS(s) && mt == DTLS1_MT_HELLO_VERIFY_REQUEST) { + st->hand_state = DTLS_ST_CR_HELLO_VERIFY_REQUEST; + return 1; + } else if (!(s->s3->tmp.new_cipher->algorithm_auth + & (SSL_aNULL | SSL_aSRP | SSL_aPSK))) { + if (mt == SSL3_MT_CERTIFICATE) { + st->hand_state = TLS_ST_CR_CERT; + return 1; + } + } else { + ske_expected = key_exchange_expected(s); + if (ske_expected < 0) + return 0; + /* SKE is optional for some PSK ciphersuites */ + if (ske_expected + || ((s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK) + && mt == SSL3_MT_SERVER_KEY_EXCHANGE)) { + if (mt == SSL3_MT_SERVER_KEY_EXCHANGE) { + st->hand_state = TLS_ST_CR_KEY_EXCH; + return 1; + } + } else if (mt == SSL3_MT_CERTIFICATE_REQUEST + && cert_req_allowed(s)) { + st->hand_state = TLS_ST_CR_CERT_REQ; + return 1; + } else if (mt == SSL3_MT_SERVER_DONE) { + st->hand_state = TLS_ST_CR_SRVR_DONE; + return 1; } - s->init_buf = buf; - buf = NULL; } + } + break; - if (!ssl3_setup_buffers(s)) { - ret = -1; - goto end; + case TLS_ST_CR_CERT: + if (s->tlsext_status_expected) { + if (mt == SSL3_MT_CERTIFICATE_STATUS) { + st->hand_state = TLS_ST_CR_CERT_STATUS; + return 1; } + return 0; + } + /* Fall through */ - /* setup buffing BIO */ - if (!ssl_init_wbio_buffer(s, 0)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; + case TLS_ST_CR_CERT_STATUS: + ske_expected = key_exchange_expected(s); + if (ske_expected < 0) + return 0; + /* SKE is optional for some PSK ciphersuites */ + if (ske_expected + || ((s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK) + && mt == SSL3_MT_SERVER_KEY_EXCHANGE)) { + if (mt == SSL3_MT_SERVER_KEY_EXCHANGE) { + st->hand_state = TLS_ST_CR_KEY_EXCH; + return 1; } + return 0; + } + /* Fall through */ - /* don't push the buffering BIO quite yet */ - - ssl3_init_finished_mac(s); - - s->state = SSL3_ST_CW_CLNT_HELLO_A; - s->ctx->stats.sess_connect++; - s->init_num = 0; - /* - * Should have been reset by ssl3_get_finished, too. - */ - s->s3->change_cipher_spec = 0; - break; - - case SSL3_ST_CW_CLNT_HELLO_A: - case SSL3_ST_CW_CLNT_HELLO_B: + case TLS_ST_CR_KEY_EXCH: + if (mt == SSL3_MT_CERTIFICATE_REQUEST) { + if (cert_req_allowed(s)) { + st->hand_state = TLS_ST_CR_CERT_REQ; + return 1; + } + return 0; + } + /* Fall through */ - s->shutdown = 0; - ret = ssl3_client_hello(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_SRVR_HELLO_A; - s->init_num = 0; + case TLS_ST_CR_CERT_REQ: + if (mt == SSL3_MT_SERVER_DONE) { + st->hand_state = TLS_ST_CR_SRVR_DONE; + return 1; + } + break; - /* turn on buffering for the next lot of output */ - if (s->bbio != s->wbio) - s->wbio = BIO_push(s->bbio, s->wbio); + case TLS_ST_CW_FINISHED: + if (mt == SSL3_MT_NEWSESSION_TICKET && s->tlsext_ticket_expected) { + st->hand_state = TLS_ST_CR_SESSION_TICKET; + return 1; + } else if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + st->hand_state = TLS_ST_CR_CHANGE; + return 1; + } + break; - break; + case TLS_ST_CR_SESSION_TICKET: + if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + st->hand_state = TLS_ST_CR_CHANGE; + return 1; + } + break; - case SSL3_ST_CR_SRVR_HELLO_A: - case SSL3_ST_CR_SRVR_HELLO_B: - ret = ssl3_get_server_hello(s); - if (ret <= 0) - goto end; + case TLS_ST_CR_CHANGE: + if (mt == SSL3_MT_FINISHED) { + st->hand_state = TLS_ST_CR_FINISHED; + return 1; + } + break; - if (s->hit) { - s->state = SSL3_ST_CR_CHANGE_A; - if (s->tlsext_ticket_expected) { - /* receive renewed session ticket */ - s->state = SSL3_ST_CR_SESSION_TICKET_A; - } - } else { - s->state = SSL3_ST_CR_CERT_A; - } - s->init_num = 0; - break; - case SSL3_ST_CR_CERT_A: - case SSL3_ST_CR_CERT_B: - /* Noop (ret = 0) for everything but EAP-FAST. */ - ret = ssl3_check_change(s); - if (ret < 0) - goto end; - if (ret == 1) { - s->hit = 1; - s->state = SSL3_ST_CR_CHANGE_A; - s->init_num = 0; - break; - } + default: + break; + } - /* Check if it is anon DH/ECDH, SRP auth */ - /* or PSK */ - if (!(s->s3->tmp.new_cipher->algorithm_auth & - (SSL_aNULL | SSL_aSRP | SSL_aPSK))) { - ret = ssl3_get_server_certificate(s); - if (ret <= 0) - goto end; - - if (s->tlsext_status_expected) - s->state = SSL3_ST_CR_CERT_STATUS_A; - else - s->state = SSL3_ST_CR_KEY_EXCH_A; - } else { - skip = 1; - s->state = SSL3_ST_CR_KEY_EXCH_A; - } + /* No valid transition found */ + return 0; +} - s->init_num = 0; - break; +/* + * client_write_transition() works out what handshake state to move to next + * when the client is writing messages to be sent to the server. + */ +WRITE_TRAN ossl_statem_client_write_transition(SSL *s) +{ + OSSL_STATEM *st = &s->statem; - case SSL3_ST_CR_KEY_EXCH_A: - case SSL3_ST_CR_KEY_EXCH_B: - ret = ssl3_get_key_exchange(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_CERT_REQ_A; - s->init_num = 0; + switch(st->hand_state) { + case TLS_ST_OK: + /* Renegotiation - fall through */ + case TLS_ST_BEFORE: + st->hand_state = TLS_ST_CW_CLNT_HELLO; + return WRITE_TRAN_CONTINUE; + case TLS_ST_CW_CLNT_HELLO: /* - * at this point we check that we have the required stuff from - * the server + * No transition at the end of writing because we don't know what + * we will be sent */ - if (!ssl3_check_cert_and_algorithm(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; - } - break; + return WRITE_TRAN_FINISHED; - case SSL3_ST_CR_CERT_REQ_A: - case SSL3_ST_CR_CERT_REQ_B: - ret = ssl3_get_certificate_request(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_SRVR_DONE_A; - s->init_num = 0; - break; + case DTLS_ST_CR_HELLO_VERIFY_REQUEST: + st->hand_state = TLS_ST_CW_CLNT_HELLO; + return WRITE_TRAN_CONTINUE; - case SSL3_ST_CR_SRVR_DONE_A: - case SSL3_ST_CR_SRVR_DONE_B: - ret = ssl3_get_server_done(s); - if (ret <= 0) - goto end; -#ifndef OPENSSL_NO_SRP - if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) { - if ((ret = SRP_Calc_A_param(s)) <= 0) { - SSLerr(SSL_F_SSL3_CONNECT, SSL_R_SRP_A_CALC); - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - goto end; - } - } -#endif + case TLS_ST_CR_SRVR_DONE: if (s->s3->tmp.cert_req) - s->state = SSL3_ST_CW_CERT_A; + st->hand_state = TLS_ST_CW_CERT; else - s->state = SSL3_ST_CW_KEY_EXCH_A; - s->init_num = 0; + st->hand_state = TLS_ST_CW_KEY_EXCH; + return WRITE_TRAN_CONTINUE; - break; - - case SSL3_ST_CW_CERT_A: - case SSL3_ST_CW_CERT_B: - case SSL3_ST_CW_CERT_C: - case SSL3_ST_CW_CERT_D: - ret = ssl3_send_client_certificate(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CW_KEY_EXCH_A; - s->init_num = 0; - break; + case TLS_ST_CW_CERT: + st->hand_state = TLS_ST_CW_KEY_EXCH; + return WRITE_TRAN_CONTINUE; - case SSL3_ST_CW_KEY_EXCH_A: - case SSL3_ST_CW_KEY_EXCH_B: - ret = ssl3_send_client_key_exchange(s); - if (ret <= 0) - goto end; - /* - * EAY EAY EAY need to check for DH fix cert sent back - */ + case TLS_ST_CW_KEY_EXCH: /* * For TLS, cert_req is set to 2, so a cert chain of nothing is * sent, but no verify packet is sent @@ -427,217 +437,381 @@ int ssl3_connect(SSL *s) * ECDH public key is sent inside the client certificate. */ if (s->s3->tmp.cert_req == 1) { - s->state = SSL3_ST_CW_CERT_VRFY_A; + st->hand_state = TLS_ST_CW_CERT_VRFY; } else { - s->state = SSL3_ST_CW_CHANGE_A; + st->hand_state = TLS_ST_CW_CHANGE; } if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) { - s->state = SSL3_ST_CW_CHANGE_A; + st->hand_state = TLS_ST_CW_CHANGE; } + return WRITE_TRAN_CONTINUE; - s->init_num = 0; - break; - - case SSL3_ST_CW_CERT_VRFY_A: - case SSL3_ST_CW_CERT_VRFY_B: - ret = ssl3_send_client_verify(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CW_CHANGE_A; - s->init_num = 0; - break; - - case SSL3_ST_CW_CHANGE_A: - case SSL3_ST_CW_CHANGE_B: - ret = ssl3_send_change_cipher_spec(s, - SSL3_ST_CW_CHANGE_A, - SSL3_ST_CW_CHANGE_B); - if (ret <= 0) - goto end; + case TLS_ST_CW_CERT_VRFY: + st->hand_state = TLS_ST_CW_CHANGE; + return WRITE_TRAN_CONTINUE; + case TLS_ST_CW_CHANGE: #if defined(OPENSSL_NO_NEXTPROTONEG) - s->state = SSL3_ST_CW_FINISHED_A; + st->hand_state = TLS_ST_CW_FINISHED; #else - if (s->s3->next_proto_neg_seen) - s->state = SSL3_ST_CW_NEXT_PROTO_A; + if (!SSL_IS_DTLS(s) && s->s3->next_proto_neg_seen) + st->hand_state = TLS_ST_CW_NEXT_PROTO; else - s->state = SSL3_ST_CW_FINISHED_A; + st->hand_state = TLS_ST_CW_FINISHED; #endif - s->init_num = 0; + return WRITE_TRAN_CONTINUE; - s->session->cipher = s->s3->tmp.new_cipher; -#ifdef OPENSSL_NO_COMP - s->session->compress_meth = 0; -#else - if (s->s3->tmp.new_compression == NULL) - s->session->compress_meth = 0; - else - s->session->compress_meth = s->s3->tmp.new_compression->id; +#if !defined(OPENSSL_NO_NEXTPROTONEG) + case TLS_ST_CW_NEXT_PROTO: + st->hand_state = TLS_ST_CW_FINISHED; + return WRITE_TRAN_CONTINUE; #endif - if (!s->method->ssl3_enc->setup_key_block(s)) { - ret = -1; - s->state = SSL_ST_ERR; - goto end; + + case TLS_ST_CW_FINISHED: + if (s->hit) { + st->hand_state = TLS_ST_OK; + ossl_statem_set_in_init(s, 0); + return WRITE_TRAN_CONTINUE; + } else { + return WRITE_TRAN_FINISHED; } - if (!s->method->ssl3_enc->change_cipher_state(s, - SSL3_CHANGE_CIPHER_CLIENT_WRITE)) - { - ret = -1; - s->state = SSL_ST_ERR; - goto end; + case TLS_ST_CR_FINISHED: + if (s->hit) { + st->hand_state = TLS_ST_CW_CHANGE; + return WRITE_TRAN_CONTINUE; + } else { + st->hand_state = TLS_ST_OK; + ossl_statem_set_in_init(s, 0); + return WRITE_TRAN_CONTINUE; } - break; + default: + /* Shouldn't happen */ + return WRITE_TRAN_ERROR; + } +} -#if !defined(OPENSSL_NO_NEXTPROTONEG) - case SSL3_ST_CW_NEXT_PROTO_A: - case SSL3_ST_CW_NEXT_PROTO_B: - ret = ssl3_send_next_proto(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CW_FINISHED_A; - break; -#endif +/* + * Perform any pre work that needs to be done prior to sending a message from + * the client to the server. + */ +WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_CW_CLNT_HELLO: + s->shutdown = 0; + if (SSL_IS_DTLS(s)) { + /* every DTLS ClientHello resets Finished MAC */ + ssl3_init_finished_mac(s); + } + break; - case SSL3_ST_CW_FINISHED_A: - case SSL3_ST_CW_FINISHED_B: - ret = ssl3_send_finished(s, - SSL3_ST_CW_FINISHED_A, - SSL3_ST_CW_FINISHED_B, - s->method-> - ssl3_enc->client_finished_label, - s->method-> - ssl3_enc->client_finished_label_len); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CW_FLUSH; + case TLS_ST_CW_CERT: + return tls_prepare_client_certificate(s, wst); + case TLS_ST_CW_CHANGE: + if (SSL_IS_DTLS(s)) { if (s->hit) { - s->s3->tmp.next_state = SSL_ST_OK; - } else { /* - * Allow NewSessionTicket if ticket expected + * We're into the last flight so we don't retransmit these + * messages unless we need to. */ - if (s->tlsext_ticket_expected) - s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A; - else - s->s3->tmp.next_state = SSL3_ST_CR_CHANGE_A; + st->use_timer = 0; } - s->init_num = 0; - break; +#ifndef OPENSSL_NO_SCTP + if (BIO_dgram_is_sctp(SSL_get_wbio(s))) + return dtls_wait_for_dry(s); +#endif + } + return WORK_FINISHED_CONTINUE; - case SSL3_ST_CR_SESSION_TICKET_A: - case SSL3_ST_CR_SESSION_TICKET_B: - ret = ssl3_get_new_session_ticket(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_CHANGE_A; - s->init_num = 0; - break; + case TLS_ST_OK: + return tls_finish_handshake(s, wst); - case SSL3_ST_CR_CERT_STATUS_A: - case SSL3_ST_CR_CERT_STATUS_B: - ret = ssl3_get_cert_status(s); - if (ret <= 0) - goto end; - s->state = SSL3_ST_CR_KEY_EXCH_A; - s->init_num = 0; - break; + default: + /* No pre work to be done */ + break; + } - case SSL3_ST_CR_CHANGE_A: - case SSL3_ST_CR_CHANGE_B: - ret = ssl3_get_change_cipher_spec(s, SSL3_ST_CR_CHANGE_A, - SSL3_ST_CR_CHANGE_B); - if (ret <= 0) - goto end; + return WORK_FINISHED_CONTINUE; +} - s->state = SSL3_ST_CR_FINISHED_A; - s->init_num = 0; - break; +/* + * Perform any work that needs to be done after sending a message from the + * client to the server. + */ +WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst) +{ + OSSL_STATEM *st = &s->statem; - case SSL3_ST_CR_FINISHED_A: - case SSL3_ST_CR_FINISHED_B: - ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A, - SSL3_ST_CR_FINISHED_B); - if (ret <= 0) - goto end; + s->init_num = 0; - if (s->hit) - s->state = SSL3_ST_CW_CHANGE_A; - else - s->state = SSL_ST_OK; - s->init_num = 0; - break; + switch(st->hand_state) { + case TLS_ST_CW_CLNT_HELLO: + if (SSL_IS_DTLS(s) && s->d1->cookie_len > 0 && statem_flush(s) != 1) + return WORK_MORE_A; +#ifndef OPENSSL_NO_SCTP + /* Disable buffering for SCTP */ + if (!SSL_IS_DTLS(s) || !BIO_dgram_is_sctp(SSL_get_wbio(s))) { +#endif + /* + * turn on buffering for the next lot of output + */ + if (s->bbio != s->wbio) + s->wbio = BIO_push(s->bbio, s->wbio); +#ifndef OPENSSL_NO_SCTP + } +#endif + if (SSL_IS_DTLS(s)) { + /* Treat the next message as the first packet */ + s->first_packet = 1; + } + break; + + case TLS_ST_CW_KEY_EXCH: + if (tls_client_key_exchange_post_work(s) == 0) + return WORK_ERROR; + break; + + case TLS_ST_CW_CHANGE: + s->session->cipher = s->s3->tmp.new_cipher; +#ifdef OPENSSL_NO_COMP + s->session->compress_meth = 0; +#else + if (s->s3->tmp.new_compression == NULL) + s->session->compress_meth = 0; + else + s->session->compress_meth = s->s3->tmp.new_compression->id; +#endif + if (!s->method->ssl3_enc->setup_key_block(s)) + return WORK_ERROR; - case SSL3_ST_CW_FLUSH: - s->rwstate = SSL_WRITING; - if (BIO_flush(s->wbio) <= 0) { - ret = -1; - goto end; + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_CLIENT_WRITE)) + return WORK_ERROR; + + if (SSL_IS_DTLS(s)) { +#ifndef OPENSSL_NO_SCTP + if (s->hit) { + /* + * Change to new shared key of SCTP-Auth, will be ignored if + * no SCTP used. + */ + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, + 0, NULL); } - s->rwstate = SSL_NOTHING; - s->state = s->s3->tmp.next_state; +#endif + + dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); + } + break; + + case TLS_ST_CW_FINISHED: +#ifndef OPENSSL_NO_SCTP + if (wst == WORK_MORE_A && SSL_IS_DTLS(s) && s->hit == 0) { + /* + * Change to new shared key of SCTP-Auth, will be ignored if + * no SCTP used. + */ + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, + 0, NULL); + } +#endif + if (statem_flush(s) != 1) + return WORK_MORE_B; + + if (s->hit && tls_finish_handshake(s, WORK_MORE_A) != 1) + return WORK_ERROR; + break; + + default: + /* No post work to be done */ + break; + } + + return WORK_FINISHED_CONTINUE; +} + +/* + * Construct a message to be sent from the client to the server. + * + * Valid return values are: + * 1: Success + * 0: Error + */ +int ossl_statem_client_construct_message(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_CW_CLNT_HELLO: + return tls_construct_client_hello(s); + + case TLS_ST_CW_CERT: + return tls_construct_client_certificate(s); + + case TLS_ST_CW_KEY_EXCH: + return tls_construct_client_key_exchange(s); + + case TLS_ST_CW_CERT_VRFY: + return tls_construct_client_verify(s); + + case TLS_ST_CW_CHANGE: + if (SSL_IS_DTLS(s)) + return dtls_construct_change_cipher_spec(s); + else + return tls_construct_change_cipher_spec(s); + +#if !defined(OPENSSL_NO_NEXTPROTONEG) + case TLS_ST_CW_NEXT_PROTO: + return tls_construct_next_proto(s); +#endif + case TLS_ST_CW_FINISHED: + return tls_construct_finished(s, + s->method-> + ssl3_enc->client_finished_label, + s->method-> + ssl3_enc->client_finished_label_len); + + default: + /* Shouldn't happen */ + break; + } + + return 0; +} + +/* + * Returns the maximum allowed length for the current message that we are + * reading. Excludes the message header. + */ +unsigned long ossl_statem_client_max_message_size(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_CR_SRVR_HELLO: + return SERVER_HELLO_MAX_LENGTH; + + case DTLS_ST_CR_HELLO_VERIFY_REQUEST: + return HELLO_VERIFY_REQUEST_MAX_LENGTH; + + case TLS_ST_CR_CERT: + return s->max_cert_list; + + case TLS_ST_CR_CERT_STATUS: + return SSL3_RT_MAX_PLAIN_LENGTH; + + case TLS_ST_CR_KEY_EXCH: + return SERVER_KEY_EXCH_MAX_LENGTH; + + case TLS_ST_CR_CERT_REQ: + return SSL3_RT_MAX_PLAIN_LENGTH; + + case TLS_ST_CR_SRVR_DONE: + return SERVER_HELLO_DONE_MAX_LENGTH; + + case TLS_ST_CR_CHANGE: + return CCS_MAX_LENGTH; + + case TLS_ST_CR_SESSION_TICKET: + return SSL3_RT_MAX_PLAIN_LENGTH; + + case TLS_ST_CR_FINISHED: + return FINISHED_MAX_LENGTH; + + default: + /* Shouldn't happen */ break; + } + + return 0; +} + +/* + * Process a message that the client has been received from the server. + */ +MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt) +{ + OSSL_STATEM *st = &s->statem; - case SSL_ST_OK: - /* clean a few things up */ - ssl3_cleanup_key_block(s); - BUF_MEM_free(s->init_buf); - s->init_buf = NULL; + switch(st->hand_state) { + case TLS_ST_CR_SRVR_HELLO: + return tls_process_server_hello(s, pkt); - /* remove the buffering */ - ssl_free_wbio_buffer(s); + case DTLS_ST_CR_HELLO_VERIFY_REQUEST: + return dtls_process_hello_verify(s, pkt); - s->init_num = 0; - s->renegotiate = 0; - s->new_session = 0; + case TLS_ST_CR_CERT: + return tls_process_server_certificate(s, pkt); - ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); - if (s->hit) - s->ctx->stats.sess_hit++; + case TLS_ST_CR_CERT_STATUS: + return tls_process_cert_status(s, pkt); - ret = 1; - /* s->server=0; */ - s->handshake_func = ssl3_connect; - s->ctx->stats.sess_connect_good++; + case TLS_ST_CR_KEY_EXCH: + return tls_process_key_exchange(s, pkt); - if (cb != NULL) - cb(s, SSL_CB_HANDSHAKE_DONE, 1); + case TLS_ST_CR_CERT_REQ: + return tls_process_certificate_request(s, pkt); - goto end; - /* break; */ + case TLS_ST_CR_SRVR_DONE: + return tls_process_server_done(s, pkt); + + case TLS_ST_CR_CHANGE: + return tls_process_change_cipher_spec(s, pkt); + + case TLS_ST_CR_SESSION_TICKET: + return tls_process_new_session_ticket(s, pkt); + + case TLS_ST_CR_FINISHED: + return tls_process_finished(s, pkt); - case SSL_ST_ERR: default: - SSLerr(SSL_F_SSL3_CONNECT, SSL_R_UNKNOWN_STATE); - ret = -1; - goto end; - /* break; */ - } + /* Shouldn't happen */ + break; + } - /* did we do anything */ - if (!s->s3->tmp.reuse_message && !skip) { - if (s->debug) { - if ((ret = BIO_flush(s->wbio)) <= 0) - goto end; - } + return MSG_PROCESS_ERROR; +} - if ((cb != NULL) && (s->state != state)) { - new_state = s->state; - s->state = state; - cb(s, SSL_CB_CONNECT_LOOP, 1); - s->state = new_state; - } - } - skip = 0; +/* + * Perform any further processing required following the receipt of a message + * from the server + */ +WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { +#ifndef OPENSSL_NO_SCTP + case TLS_ST_CR_SRVR_DONE: + /* We only get here if we are using SCTP and we are renegotiating */ + if (BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { + s->s3->in_read_app_data = 2; + s->rwstate = SSL_READING; + BIO_clear_retry_flags(SSL_get_rbio(s)); + BIO_set_retry_read(SSL_get_rbio(s)); + ossl_statem_set_sctp_read_sock(s, 1); + return WORK_MORE_A; + } + ossl_statem_set_sctp_read_sock(s, 0); + return WORK_FINISHED_STOP; +#endif + + case TLS_ST_CR_FINISHED: + if (!s->hit) + return tls_finish_handshake(s, wst); + else + return WORK_FINISHED_STOP; + default: + break; } - end: - s->in_handshake--; - BUF_MEM_free(buf); - if (cb != NULL) - cb(s, SSL_CB_CONNECT_EXIT, ret); - return (ret); + + /* Shouldn't happen */ + return WORK_ERROR; } /* @@ -739,7 +913,7 @@ static int ssl_set_version(SSL *s) return 1; } -int ssl3_client_hello(SSL *s) +int tls_construct_client_hello(SSL *s) { unsigned char *buf; unsigned char *p, *d; @@ -750,239 +924,229 @@ int ssl3_client_hello(SSL *s) int j; SSL_COMP *comp; #endif + SSL_SESSION *sess = s->session; buf = (unsigned char *)s->init_buf->data; - if (s->state == SSL3_ST_CW_CLNT_HELLO_A) { - SSL_SESSION *sess = s->session; - - /* Work out what SSL/TLS/DTLS version to use */ - if (ssl_set_version(s) == 0) - goto err; - - if ((sess == NULL) || (sess->ssl_version != s->version) || - /* - * In the case of EAP-FAST, we can have a pre-shared - * "ticket" without a session ID. - */ - (!sess->session_id_length && !sess->tlsext_tick) || - (sess->not_resumable)) { - if (!ssl_get_new_session(s, 0)) - goto err; - } - /* else use the pre-loaded session */ - p = s->s3->client_random; + /* Work out what SSL/TLS/DTLS version to use */ + if (ssl_set_version(s) == 0) + goto err; + if ((sess == NULL) || (sess->ssl_version != s->version) || /* - * for DTLS if client_random is initialized, reuse it, we are - * required to use same upon reply to HelloVerify + * In the case of EAP-FAST, we can have a pre-shared + * "ticket" without a session ID. */ - if (SSL_IS_DTLS(s)) { - size_t idx; - i = 1; - for (idx = 0; idx < sizeof(s->s3->client_random); idx++) { - if (p[idx]) { - i = 0; - break; - } - } - } else - i = 1; - - if (i && ssl_fill_hello_random(s, 0, p, - sizeof(s->s3->client_random)) <= 0) + (!sess->session_id_length && !sess->tlsext_tick) || + (sess->not_resumable)) { + if (!ssl_get_new_session(s, 0)) goto err; + } + /* else use the pre-loaded session */ - /* Do the message type and length last */ - d = p = ssl_handshake_start(s); - - /*- - * version indicates the negotiated version: for example from - * an SSLv2/v3 compatible client hello). The client_version - * field is the maximum version we permit and it is also - * used in RSA encrypted premaster secrets. Some servers can - * choke if we initially report a higher version then - * renegotiate to a lower one in the premaster secret. This - * didn't happen with TLS 1.0 as most servers supported it - * but it can with TLS 1.1 or later if the server only supports - * 1.0. - * - * Possible scenario with previous logic: - * 1. Client hello indicates TLS 1.2 - * 2. Server hello says TLS 1.0 - * 3. RSA encrypted premaster secret uses 1.2. - * 4. Handhaked proceeds using TLS 1.0. - * 5. Server sends hello request to renegotiate. - * 6. Client hello indicates TLS v1.0 as we now - * know that is maximum server supports. - * 7. Server chokes on RSA encrypted premaster secret - * containing version 1.0. - * - * For interoperability it should be OK to always use the - * maximum version we support in client hello and then rely - * on the checking of version to ensure the servers isn't - * being inconsistent: for example initially negotiating with - * TLS 1.0 and renegotiating with TLS 1.2. We do this by using - * client_version in client hello and not resetting it to - * the negotiated version. - */ - *(p++) = s->client_version >> 8; - *(p++) = s->client_version & 0xff; - - /* Random stuff */ - memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); - p += SSL3_RANDOM_SIZE; + p = s->s3->client_random; - /* Session ID */ - if (s->new_session) - i = 0; - else - i = s->session->session_id_length; - *(p++) = i; - if (i != 0) { - if (i > (int)sizeof(s->session->session_id)) { - SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto err; + /* + * for DTLS if client_random is initialized, reuse it, we are + * required to use same upon reply to HelloVerify + */ + if (SSL_IS_DTLS(s)) { + size_t idx; + i = 1; + for (idx = 0; idx < sizeof(s->s3->client_random); idx++) { + if (p[idx]) { + i = 0; + break; } - memcpy(p, s->session->session_id, i); - p += i; } + } else + i = 1; - /* cookie stuff for DTLS */ - if (SSL_IS_DTLS(s)) { - if (s->d1->cookie_len > sizeof(s->d1->cookie)) { - SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto err; - } - *(p++) = s->d1->cookie_len; - memcpy(p, s->d1->cookie, s->d1->cookie_len); - p += s->d1->cookie_len; + if (i && ssl_fill_hello_random(s, 0, p, + sizeof(s->s3->client_random)) <= 0) + goto err; + + /* Do the message type and length last */ + d = p = ssl_handshake_start(s); + + /*- + * version indicates the negotiated version: for example from + * an SSLv2/v3 compatible client hello). The client_version + * field is the maximum version we permit and it is also + * used in RSA encrypted premaster secrets. Some servers can + * choke if we initially report a higher version then + * renegotiate to a lower one in the premaster secret. This + * didn't happen with TLS 1.0 as most servers supported it + * but it can with TLS 1.1 or later if the server only supports + * 1.0. + * + * Possible scenario with previous logic: + * 1. Client hello indicates TLS 1.2 + * 2. Server hello says TLS 1.0 + * 3. RSA encrypted premaster secret uses 1.2. + * 4. Handhaked proceeds using TLS 1.0. + * 5. Server sends hello request to renegotiate. + * 6. Client hello indicates TLS v1.0 as we now + * know that is maximum server supports. + * 7. Server chokes on RSA encrypted premaster secret + * containing version 1.0. + * + * For interoperability it should be OK to always use the + * maximum version we support in client hello and then rely + * on the checking of version to ensure the servers isn't + * being inconsistent: for example initially negotiating with + * TLS 1.0 and renegotiating with TLS 1.2. We do this by using + * client_version in client hello and not resetting it to + * the negotiated version. + */ + *(p++) = s->client_version >> 8; + *(p++) = s->client_version & 0xff; + + /* Random stuff */ + memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); + p += SSL3_RANDOM_SIZE; + + /* Session ID */ + if (s->new_session) + i = 0; + else + i = s->session->session_id_length; + *(p++) = i; + if (i != 0) { + if (i > (int)sizeof(s->session->session_id)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; } + memcpy(p, s->session->session_id, i); + p += i; + } - /* Ciphers supported */ - i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2])); - if (i == 0) { - SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); + /* cookie stuff for DTLS */ + if (SSL_IS_DTLS(s)) { + if (s->d1->cookie_len > sizeof(s->d1->cookie)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; } + *(p++) = s->d1->cookie_len; + memcpy(p, s->d1->cookie, s->d1->cookie_len); + p += s->d1->cookie_len; + } + + /* Ciphers supported */ + i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &(p[2])); + if (i == 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, SSL_R_NO_CIPHERS_AVAILABLE); + goto err; + } #ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH - /* - * Some servers hang if client hello > 256 bytes as hack workaround - * chop number of supported ciphers to keep it well below this if we - * use TLS v1.2 - */ - if (TLS1_get_version(s) >= TLS1_2_VERSION - && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) - i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; + /* + * Some servers hang if client hello > 256 bytes as hack workaround + * chop number of supported ciphers to keep it well below this if we + * use TLS v1.2 + */ + if (TLS1_get_version(s) >= TLS1_2_VERSION + && i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH) + i = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1; #endif - s2n(i, p); - p += i; + s2n(i, p); + p += i; - /* COMPRESSION */ + /* COMPRESSION */ #ifdef OPENSSL_NO_COMP - *(p++) = 1; + *(p++) = 1; #else - if (!ssl_allow_compression(s) || !s->ctx->comp_methods) - j = 0; - else - j = sk_SSL_COMP_num(s->ctx->comp_methods); - *(p++) = 1 + j; - for (i = 0; i < j; i++) { - comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); - *(p++) = comp->id; - } + if (!ssl_allow_compression(s) || !s->ctx->comp_methods) + j = 0; + else + j = sk_SSL_COMP_num(s->ctx->comp_methods); + *(p++) = 1 + j; + for (i = 0; i < j; i++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, i); + *(p++) = comp->id; + } #endif - *(p++) = 0; /* Add the NULL method */ + *(p++) = 0; /* Add the NULL method */ - /* TLS extensions */ - if (ssl_prepare_clienthello_tlsext(s) <= 0) { - SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); - goto err; - } - if ((p = - ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH, - &al)) == NULL) { - ssl3_send_alert(s, SSL3_AL_FATAL, al); - SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto err; - } + /* TLS extensions */ + if (ssl_prepare_clienthello_tlsext(s) <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + if ((p = + ssl_add_clienthello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH, + &al)) == NULL) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } - l = p - d; - if (!ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l)) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); - SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); - goto err; - } - s->state = SSL3_ST_CW_CLNT_HELLO_B; + l = p - d; + if (!ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; } - /* SSL3_ST_CW_CLNT_HELLO_B */ - return ssl_do_write(s); + return 1; err: - s->state = SSL_ST_ERR; - return (-1); + ossl_statem_set_error(s); + return 0; } -int ssl3_get_server_hello(SSL *s) +MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt) { - STACK_OF(SSL_CIPHER) *sk; - const SSL_CIPHER *c; - PACKET pkt, session_id; - size_t session_id_len; - unsigned char *cipherchars; - int i, al = SSL_AD_INTERNAL_ERROR, ok; - unsigned int compression; - long n; -#ifndef OPENSSL_NO_COMP - SSL_COMP *comp; -#endif - /* - * Hello verify request and/or server hello version may not match so set - * first packet if we're negotiating version. - */ - s->first_packet = 1; - - n = s->method->ssl_get_message(s, - SSL3_ST_CR_SRVR_HELLO_A, - SSL3_ST_CR_SRVR_HELLO_B, -1, 20000, &ok); - - if (!ok) - return ((int)n); - - s->first_packet = 0; - if (SSL_IS_DTLS(s)) { - if (s->s3->tmp.message_type == DTLS1_MT_HELLO_VERIFY_REQUEST) { - if (s->d1->send_cookie == 0) { - s->s3->tmp.reuse_message = 1; - return 1; - } else { /* already sent a cookie */ + int al; + unsigned int cookie_len; + PACKET cookiepkt; - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_BAD_MESSAGE_TYPE); - goto f_err; - } - } + if (!PACKET_forward(pkt, 2) + || !PACKET_get_length_prefixed_1(pkt, &cookiepkt)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_DTLS_PROCESS_HELLO_VERIFY, SSL_R_LENGTH_MISMATCH); + goto f_err; } - if (s->s3->tmp.message_type != SSL3_MT_SERVER_HELLO) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_BAD_MESSAGE_TYPE); + cookie_len = PACKET_remaining(&cookiepkt); + if (cookie_len > sizeof(s->d1->cookie)) { + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_DTLS_PROCESS_HELLO_VERIFY, SSL_R_LENGTH_TOO_LONG); goto f_err; } - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + if (!PACKET_copy_bytes(&cookiepkt, s->d1->cookie, cookie_len)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_DTLS_PROCESS_HELLO_VERIFY, SSL_R_LENGTH_MISMATCH); goto f_err; } + s->d1->cookie_len = cookie_len; + + return MSG_PROCESS_FINISHED_READING; + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; +} + +MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) +{ + STACK_OF(SSL_CIPHER) *sk; + const SSL_CIPHER *c; + PACKET session_id; + size_t session_id_len; + unsigned char *cipherchars; + int i, al = SSL_AD_INTERNAL_ERROR; + unsigned int compression; +#ifndef OPENSSL_NO_COMP + SSL_COMP *comp; +#endif if (s->method->version == TLS_ANY_VERSION) { unsigned int sversion; - if (!PACKET_get_net_2(&pkt, &sversion)) { + if (!PACKET_get_net_2(pkt, &sversion)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } @@ -992,7 +1156,7 @@ int ssl3_get_server_hello(SSL *s) #ifndef OPENSSL_NO_SSL3 if ((sversion == SSL3_VERSION) && !(s->options & SSL_OP_NO_SSLv3)) { if (FIPS_mode()) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE); al = SSL_AD_PROTOCOL_VERSION; goto f_err; @@ -1009,14 +1173,14 @@ int ssl3_get_server_hello(SSL *s) !(s->options & SSL_OP_NO_TLSv1_2)) { s->method = TLSv1_2_client_method(); } else { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_UNSUPPORTED_PROTOCOL); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_UNSUPPORTED_PROTOCOL); al = SSL_AD_PROTOCOL_VERSION; goto f_err; } s->session->ssl_version = s->version = s->method->version; if (!ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_VERSION_TOO_LOW); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_VERSION_TOO_LOW); al = SSL_AD_PROTOCOL_VERSION; goto f_err; } @@ -1025,9 +1189,9 @@ int ssl3_get_server_hello(SSL *s) unsigned int hversion; int options; - if (!PACKET_get_net_2(&pkt, &hversion)) { + if (!PACKET_get_net_2(pkt, &hversion)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } @@ -1035,7 +1199,7 @@ int ssl3_get_server_hello(SSL *s) if (hversion == DTLS1_2_VERSION && !(options & SSL_OP_NO_DTLSv1_2)) s->method = DTLSv1_2_client_method(); else if (tls1_suiteb(s)) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); s->version = hversion; al = SSL_AD_PROTOCOL_VERSION; @@ -1043,7 +1207,7 @@ int ssl3_get_server_hello(SSL *s) } else if (hversion == DTLS1_VERSION && !(options & SSL_OP_NO_DTLSv1)) s->method = DTLSv1_client_method(); else { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_SSL_VERSION); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_WRONG_SSL_VERSION); s->version = hversion; al = SSL_AD_PROTOCOL_VERSION; goto f_err; @@ -1052,14 +1216,14 @@ int ssl3_get_server_hello(SSL *s) } else { unsigned char *vers; - if (!PACKET_get_bytes(&pkt, &vers, 2)) { + if (!PACKET_get_bytes(pkt, &vers, 2)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } if ((vers[0] != (s->version >> 8)) || (vers[1] != (s->version & 0xff))) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_SSL_VERSION); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_WRONG_SSL_VERSION); s->version = (s->version & 0xff00) | vers[1]; al = SSL_AD_PROTOCOL_VERSION; goto f_err; @@ -1068,30 +1232,30 @@ int ssl3_get_server_hello(SSL *s) /* load the server hello data */ /* load the server random */ - if (!PACKET_copy_bytes(&pkt, s->s3->server_random, SSL3_RANDOM_SIZE)) { + if (!PACKET_copy_bytes(pkt, s->s3->server_random, SSL3_RANDOM_SIZE)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } s->hit = 0; /* Get the session-id. */ - if (!PACKET_get_length_prefixed_1(&pkt, &session_id)) { + if (!PACKET_get_length_prefixed_1(pkt, &session_id)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); goto f_err; } session_id_len = PACKET_remaining(&session_id); if (session_id_len > sizeof s->session->session_id || session_id_len > SSL3_SESSION_ID_SIZE) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_SSL3_SESSION_ID_TOO_LONG); goto f_err; } - if (!PACKET_get_bytes(&pkt, &cipherchars, TLS_CIPHER_LEN)) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_bytes(pkt, &cipherchars, TLS_CIPHER_LEN)) { + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); al = SSL_AD_DECODE_ERROR; goto f_err; } @@ -1119,7 +1283,7 @@ int ssl3_get_server_hello(SSL *s) s->session->cipher = pref_cipher ? pref_cipher : ssl_get_cipher_by_char(s, cipherchars); } else { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, ERR_R_INTERNAL_ERROR); al = SSL_AD_INTERNAL_ERROR; goto f_err; } @@ -1132,7 +1296,7 @@ int ssl3_get_server_hello(SSL *s) || memcmp(s->session->sid_ctx, s->sid_ctx, s->sid_ctx_length)) { /* actually a client application bug */ al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); goto f_err; } @@ -1161,7 +1325,7 @@ int ssl3_get_server_hello(SSL *s) if (c == NULL) { /* unknown cipher */ al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_UNKNOWN_CIPHER_RETURNED); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_UNKNOWN_CIPHER_RETURNED); goto f_err; } /* Set version disabled mask now we know version */ @@ -1175,7 +1339,7 @@ int ssl3_get_server_hello(SSL *s) */ if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK)) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED); goto f_err; } @@ -1184,7 +1348,7 @@ int ssl3_get_server_hello(SSL *s) if (i < 0) { /* we did not say we would use this cipher */ al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_WRONG_CIPHER_RETURNED); goto f_err; } @@ -1197,7 +1361,7 @@ int ssl3_get_server_hello(SSL *s) s->session->cipher_id = s->session->cipher->id; if (s->hit && (s->session->cipher_id != c->id)) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED); goto f_err; } @@ -1210,15 +1374,15 @@ int ssl3_get_server_hello(SSL *s) goto f_err; /* lets get the compression algorithm */ /* COMPRESSION */ - if (!PACKET_get_1(&pkt, &compression)) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_1(pkt, &compression)) { + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_LENGTH_MISMATCH); al = SSL_AD_DECODE_ERROR; goto f_err; } #ifdef OPENSSL_NO_COMP if (compression != 0) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); goto f_err; } @@ -1227,13 +1391,13 @@ int ssl3_get_server_hello(SSL *s) * using compression. */ if (s->session->compress_meth != 0) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_INCONSISTENT_COMPRESSION); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_INCONSISTENT_COMPRESSION); goto f_err; } #else if (s->hit && compression != s->session->compress_meth) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED); goto f_err; } @@ -1241,7 +1405,7 @@ int ssl3_get_server_hello(SSL *s) comp = NULL; else if (!ssl_allow_compression(s)) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_COMPRESSION_DISABLED); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_COMPRESSION_DISABLED); goto f_err; } else { comp = ssl3_comp_find(s->ctx->comp_methods, compression); @@ -1249,7 +1413,7 @@ int ssl3_get_server_hello(SSL *s) if (compression != 0 && comp == NULL) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); goto f_err; } else { @@ -1258,77 +1422,76 @@ int ssl3_get_server_hello(SSL *s) #endif /* TLS extensions */ - if (!ssl_parse_serverhello_tlsext(s, &pkt)) { - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_PARSE_TLSEXT); + if (!ssl_parse_serverhello_tlsext(s, pkt)) { + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_PARSE_TLSEXT); goto err; } - if (PACKET_remaining(&pkt) != 0) { + if (PACKET_remaining(pkt) != 0) { /* wrong packet length */ al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_BAD_PACKET_LENGTH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_HELLO, SSL_R_BAD_PACKET_LENGTH); goto f_err; } - return (1); +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s) && s->hit) { + unsigned char sctpauthkey[64]; + char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; + + /* + * Add new shared key for SCTP-Auth, will be ignored if + * no SCTP used. + */ + memcpy(labelbuffer, DTLS1_SCTP_AUTH_LABEL, + sizeof(DTLS1_SCTP_AUTH_LABEL)); + + if (SSL_export_keying_material(s, sctpauthkey, + sizeof(sctpauthkey), + labelbuffer, + sizeof(labelbuffer), NULL, 0, + 0) <= 0) + goto err; + + BIO_ctrl(SSL_get_wbio(s), + BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, + sizeof(sctpauthkey), sctpauthkey); + } +#endif + + return MSG_PROCESS_CONTINUE_READING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: - s->state = SSL_ST_ERR; - return (-1); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } -int ssl3_get_server_certificate(SSL *s) +MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt) { - int al, i, ok, ret = -1, exp_idx; - unsigned long n, cert_list_len, cert_len; + int al, i, ret = MSG_PROCESS_ERROR, exp_idx; + unsigned long cert_list_len, cert_len; X509 *x = NULL; unsigned char *certstart, *certbytes; STACK_OF(X509) *sk = NULL; EVP_PKEY *pkey = NULL; - PACKET pkt; - - n = s->method->ssl_get_message(s, - SSL3_ST_CR_CERT_A, - SSL3_ST_CR_CERT_B, - -1, s->max_cert_list, &ok); - - if (!ok) - return ((int)n); - - if (s->s3->tmp.message_type == SSL3_MT_SERVER_KEY_EXCHANGE) { - s->s3->tmp.reuse_message = 1; - return (1); - } - - if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_BAD_MESSAGE_TYPE); - goto f_err; - } - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); - goto f_err; - } if ((sk = sk_X509_new_null()) == NULL) { - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } - if (!PACKET_get_net_3(&pkt, &cert_list_len) - || PACKET_remaining(&pkt) != cert_list_len) { + if (!PACKET_get_net_3(pkt, &cert_list_len) + || PACKET_remaining(pkt) != cert_list_len) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_LENGTH_MISMATCH); goto f_err; } - while (PACKET_remaining(&pkt)) { - if (!PACKET_get_net_3(&pkt, &cert_len) - || !PACKET_get_bytes(&pkt, &certbytes, cert_len)) { + while (PACKET_remaining(pkt)) { + if (!PACKET_get_net_3(pkt, &cert_len) + || !PACKET_get_bytes(pkt, &certbytes, cert_len)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_CERT_LENGTH_MISMATCH); goto f_err; } @@ -1337,17 +1500,17 @@ int ssl3_get_server_certificate(SSL *s) x = d2i_X509(NULL, (const unsigned char **)&certbytes, cert_len); if (x == NULL) { al = SSL_AD_BAD_CERTIFICATE; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_ASN1_LIB); + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, ERR_R_ASN1_LIB); goto f_err; } if (certbytes != (certstart + cert_len)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_CERT_LENGTH_MISMATCH); goto f_err; } if (!sk_X509_push(sk, x)) { - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE); goto err; } x = NULL; @@ -1356,13 +1519,13 @@ int ssl3_get_server_certificate(SSL *s) i = ssl_verify_cert_chain(s, sk); if (s->verify_mode != SSL_VERIFY_NONE && i <= 0) { al = ssl_verify_alarm_type(s->verify_result); - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_CERTIFICATE_VERIFY_FAILED); goto f_err; } ERR_clear_error(); /* but we keep s->verify_result */ if (i > 1) { - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, i); + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, i); al = SSL_AD_HANDSHAKE_FAILURE; goto f_err; } @@ -1383,7 +1546,7 @@ int ssl3_get_server_certificate(SSL *s) if (pkey == NULL || EVP_PKEY_missing_parameters(pkey)) { x = NULL; al = SSL3_AL_FATAL; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); goto f_err; } @@ -1392,7 +1555,7 @@ int ssl3_get_server_certificate(SSL *s) if (i < 0) { x = NULL; al = SSL3_AL_FATAL; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_UNKNOWN_CERTIFICATE_TYPE); goto f_err; } @@ -1401,7 +1564,7 @@ int ssl3_get_server_certificate(SSL *s) if (exp_idx >= 0 && i != exp_idx) { x = NULL; al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, + SSLerr(SSL_F_TLS_PROCESS_SERVER_CERTIFICATE, SSL_R_WRONG_CERTIFICATE_TYPE); goto f_err; } @@ -1413,28 +1576,28 @@ int ssl3_get_server_certificate(SSL *s) s->session->verify_result = s->verify_result; x = NULL; - ret = 1; + ret = MSG_PROCESS_CONTINUE_READING; goto done; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: - s->state = SSL_ST_ERR; + ossl_statem_set_error(s); done: EVP_PKEY_free(pkey); X509_free(x); sk_X509_pop_free(sk, X509_free); - return (ret); + return ret; } -int ssl3_get_key_exchange(SSL *s) +MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt) { #ifndef OPENSSL_NO_RSA unsigned char *q, md_buf[EVP_MAX_MD_SIZE * 2]; #endif EVP_MD_CTX md_ctx; - int al, j, verify_ret, ok; - long n, alg_k, alg_a; + int al, j, verify_ret; + long alg_k, alg_a; EVP_PKEY *pkey = NULL; const EVP_MD *md = NULL; #ifndef OPENSSL_NO_RSA @@ -1449,44 +1612,13 @@ int ssl3_get_key_exchange(SSL *s) EC_POINT *srvr_ecpoint = NULL; int curve_nid = 0; #endif - PACKET pkt, save_param_start, signature; + PACKET save_param_start, signature; EVP_MD_CTX_init(&md_ctx); - /* - * use same message size as in ssl3_get_certificate_request() as - * ServerKeyExchange message may be skipped - */ - n = s->method->ssl_get_message(s, - SSL3_ST_CR_KEY_EXCH_A, - SSL3_ST_CR_KEY_EXCH_B, - -1, s->max_cert_list, &ok); - if (!ok) - return ((int)n); - alg_k = s->s3->tmp.new_cipher->algorithm_mkey; - if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { - /* - * Can't skip server key exchange if this is an ephemeral - * ciphersuite. - */ - if (alg_k & (SSL_kDHE | SSL_kECDHE | SSL_kDHEPSK | SSL_kECDHEPSK)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); - al = SSL_AD_UNEXPECTED_MESSAGE; - goto f_err; - } - - s->s3->tmp.reuse_message = 1; - return (1); - } - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - al = SSL_AD_INTERNAL_ERROR; - goto f_err; - } - save_param_start = pkt; + save_param_start = *pkt; #ifndef OPENSSL_NO_RSA RSA_free(s->s3->peer_rsa_tmp); @@ -1509,8 +1641,8 @@ int ssl3_get_key_exchange(SSL *s) /* PSK ciphersuites are preceded by an identity hint */ if (alg_k & SSL_PSK) { PACKET psk_identity_hint; - if (!PACKET_get_length_prefixed_2(&pkt, &psk_identity_hint)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_length_prefixed_2(pkt, &psk_identity_hint)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } @@ -1522,7 +1654,7 @@ int ssl3_get_key_exchange(SSL *s) */ if (PACKET_remaining(&psk_identity_hint) > PSK_MAX_IDENTITY_LEN) { al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } @@ -1540,11 +1672,11 @@ int ssl3_get_key_exchange(SSL *s) #ifndef OPENSSL_NO_SRP if (alg_k & SSL_kSRP) { PACKET prime, generator, salt, server_pub; - if (!PACKET_get_length_prefixed_2(&pkt, &prime) - || !PACKET_get_length_prefixed_2(&pkt, &generator) - || !PACKET_get_length_prefixed_1(&pkt, &salt) - || !PACKET_get_length_prefixed_2(&pkt, &server_pub)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_length_prefixed_2(pkt, &prime) + || !PACKET_get_length_prefixed_2(pkt, &generator) + || !PACKET_get_length_prefixed_1(pkt, &salt) + || !PACKET_get_length_prefixed_2(pkt, &server_pub)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } @@ -1560,12 +1692,12 @@ int ssl3_get_key_exchange(SSL *s) || (s->srp_ctx.B = BN_bin2bn(PACKET_data(&server_pub), PACKET_remaining(&server_pub), NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } if (!srp_verify_server_param(s, &al)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_PARAMETERS); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_SRP_PARAMETERS); goto f_err; } @@ -1580,18 +1712,18 @@ int ssl3_get_key_exchange(SSL *s) /* Temporary RSA keys only allowed in export ciphersuites */ if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } - if (!PACKET_get_length_prefixed_2(&pkt, &mod) - || !PACKET_get_length_prefixed_2(&pkt, &exp)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_length_prefixed_2(pkt, &mod) + || !PACKET_get_length_prefixed_2(pkt, &exp)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } if ((rsa = RSA_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } @@ -1599,7 +1731,7 @@ int ssl3_get_key_exchange(SSL *s) rsa->n)) == NULL || (rsa->e = BN_bin2bn(PACKET_data(&exp), PACKET_remaining(&exp), rsa->e)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } @@ -1607,16 +1739,10 @@ int ssl3_get_key_exchange(SSL *s) if (alg_a & SSL_aRSA) pkey = X509_get_pubkey(s->session->peer); else { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } - if (EVP_PKEY_bits(pkey) <= SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); - goto f_err; - } - s->s3->peer_rsa_tmp = rsa; rsa = NULL; } @@ -1627,15 +1753,15 @@ int ssl3_get_key_exchange(SSL *s) else if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) { PACKET prime, generator, pub_key; - if (!PACKET_get_length_prefixed_2(&pkt, &prime) - || !PACKET_get_length_prefixed_2(&pkt, &generator) - || !PACKET_get_length_prefixed_2(&pkt, &pub_key)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_length_prefixed_2(pkt, &prime) + || !PACKET_get_length_prefixed_2(pkt, &generator) + || !PACKET_get_length_prefixed_2(pkt, &pub_key)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } if ((dh = DH_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_DH_LIB); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } @@ -1646,18 +1772,18 @@ int ssl3_get_key_exchange(SSL *s) || (dh->pub_key = BN_bin2bn(PACKET_data(&pub_key), PACKET_remaining(&pub_key), NULL)) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_BN_LIB); goto err; } if (BN_is_zero(dh->p) || BN_is_zero(dh->g) || BN_is_zero(dh->pub_key)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_VALUE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_DH_VALUE); goto f_err; } if (!ssl_security(s, SSL_SECOP_TMP_DH, DH_security_bits(dh), 0, dh)) { al = SSL_AD_HANDSHAKE_FAILURE; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_DH_KEY_TOO_SMALL); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_DH_KEY_TOO_SMALL); goto f_err; } if (alg_a & (SSL_aRSA|SSL_aDSS)) @@ -1677,7 +1803,7 @@ int ssl3_get_key_exchange(SSL *s) unsigned char *ecparams; if ((ecdh = EC_KEY_new()) == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } @@ -1686,8 +1812,8 @@ int ssl3_get_key_exchange(SSL *s) * public key. For now we only support named (not generic) curves and * ECParameters in this case is just three bytes. */ - if (!PACKET_get_bytes(&pkt, &ecparams, 3)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); + if (!PACKET_get_bytes(pkt, &ecparams, 3)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); goto f_err; } /* @@ -1695,24 +1821,24 @@ int ssl3_get_key_exchange(SSL *s) * invalid curve. ECParameters is 3 bytes. */ if (!tls1_check_curve(s, ecparams, 3)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_CURVE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_WRONG_CURVE); goto f_err; } if ((curve_nid = tls1_ec_curve_id2nid(*(ecparams + 2))) == 0) { al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS); goto f_err; } ngroup = EC_GROUP_new_by_curve_name(curve_nid); if (ngroup == NULL) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_EC_LIB); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } if (EC_KEY_set_group(ecdh, ngroup) == 0) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_EC_LIB); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } EC_GROUP_free(ngroup); @@ -1722,7 +1848,7 @@ int ssl3_get_key_exchange(SSL *s) if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && (EC_GROUP_get_degree(group) > 163)) { al = SSL_AD_EXPORT_RESTRICTION; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER); goto f_err; } @@ -1730,18 +1856,18 @@ int ssl3_get_key_exchange(SSL *s) /* Next, get the encoded ECPoint */ if (((srvr_ecpoint = EC_POINT_new(group)) == NULL) || ((bn_ctx = BN_CTX_new()) == NULL)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } - if (!PACKET_get_length_prefixed_1(&pkt, &encoded_pt)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_length_prefixed_1(pkt, &encoded_pt)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } if (EC_POINT_oct2point(group, srvr_ecpoint, PACKET_data(&encoded_pt), PACKET_remaining(&encoded_pt), bn_ctx) == 0) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_ECPOINT); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_ECPOINT); goto f_err; } @@ -1769,7 +1895,7 @@ int ssl3_get_key_exchange(SSL *s) srvr_ecpoint = NULL; } else if (alg_k) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } #endif /* !OPENSSL_NO_EC */ @@ -1783,17 +1909,17 @@ int ssl3_get_key_exchange(SSL *s) */ if (!PACKET_get_sub_packet(&save_param_start, ¶ms, PACKET_remaining(&save_param_start) - - PACKET_remaining(&pkt))) { + PACKET_remaining(pkt))) { al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; } if (SSL_USE_SIGALGS(s)) { unsigned char *sigalgs; int rv; - if (!PACKET_get_bytes(&pkt, &sigalgs, 2)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); + if (!PACKET_get_bytes(pkt, &sigalgs, 2)) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); goto f_err; } rv = tls12_check_peer_sigalg(&md, s, sigalgs, pkey); @@ -1809,14 +1935,14 @@ int ssl3_get_key_exchange(SSL *s) md = EVP_sha1(); } - if (!PACKET_get_length_prefixed_2(&pkt, &signature) - || PACKET_remaining(&pkt) != 0) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + if (!PACKET_get_length_prefixed_2(pkt, &signature) + || PACKET_remaining(pkt) != 0) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); goto f_err; } j = EVP_PKEY_size(pkey); if (j < 0) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; } @@ -1825,7 +1951,7 @@ int ssl3_get_key_exchange(SSL *s) */ if (PACKET_remaining(&signature) > (size_t)j) { /* wrong packet length */ - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_SIGNATURE_LENGTH); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_WRONG_SIGNATURE_LENGTH); goto f_err; } #ifndef OPENSSL_NO_RSA @@ -1854,13 +1980,13 @@ int ssl3_get_key_exchange(SSL *s) PACKET_remaining(&signature), pkey->pkey.rsa); if (verify_ret < 0) { al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_DECRYPT); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_RSA_DECRYPT); goto f_err; } if (verify_ret == 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); goto f_err; } } else @@ -1877,7 +2003,7 @@ int ssl3_get_key_exchange(SSL *s) PACKET_remaining(&signature), pkey) <= 0) { /* bad signature */ al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE); goto f_err; } } @@ -1887,18 +2013,18 @@ int ssl3_get_key_exchange(SSL *s) /* Might be wrong key type, check it */ if (ssl3_check_cert_and_algorithm(s)) /* Otherwise this shouldn't happen */ - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } /* still data left over */ - if (PACKET_remaining(&pkt) != 0) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_EXTRA_DATA_IN_MESSAGE); + if (PACKET_remaining(pkt) != 0) { + SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, SSL_R_EXTRA_DATA_IN_MESSAGE); goto f_err; } } EVP_PKEY_free(pkey); EVP_MD_CTX_cleanup(&md_ctx); - return (1); + return MSG_PROCESS_CONTINUE_READING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: @@ -1915,74 +2041,29 @@ int ssl3_get_key_exchange(SSL *s) EC_KEY_free(ecdh); #endif EVP_MD_CTX_cleanup(&md_ctx); - s->state = SSL_ST_ERR; - return (-1); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } -int ssl3_get_certificate_request(SSL *s) +MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt) { - int ok, ret = 0; - unsigned long n; + int ret = MSG_PROCESS_ERROR; unsigned int list_len, ctype_num, i, name_len; X509_NAME *xn = NULL; unsigned char *data; unsigned char *namestart, *namebytes; STACK_OF(X509_NAME) *ca_sk = NULL; - PACKET pkt; - - n = s->method->ssl_get_message(s, - SSL3_ST_CR_CERT_REQ_A, - SSL3_ST_CR_CERT_REQ_B, - -1, s->max_cert_list, &ok); - - if (!ok) - return ((int)n); - - s->s3->tmp.cert_req = 0; - - if (s->s3->tmp.message_type == SSL3_MT_SERVER_DONE) { - s->s3->tmp.reuse_message = 1; - /* - * If we get here we don't need any cached handshake records as we - * wont be doing client auth. - */ - if (!ssl3_digest_cached_records(s, 0)) - goto err; - return (1); - } - - if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_REQUEST) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_WRONG_MESSAGE_TYPE); - goto err; - } - - /* TLS does not like anon-DH with client cert */ - if (s->version > SSL3_VERSION) { - if (s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, - SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER); - goto err; - } - } - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_INTERNAL_ERROR); - goto err; - } if ((ca_sk = sk_X509_NAME_new(ca_dn_cmp)) == NULL) { - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); goto err; } /* get the certificate types */ - if (!PACKET_get_1(&pkt, &ctype_num) - || !PACKET_get_bytes(&pkt, &data, ctype_num)) { + if (!PACKET_get_1(pkt, &ctype_num) + || !PACKET_get_bytes(pkt, &data, ctype_num)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); goto err; } OPENSSL_free(s->cert->ctypes); @@ -1991,7 +2072,7 @@ int ssl3_get_certificate_request(SSL *s) /* If we exceed static buffer copy all to cert structure */ s->cert->ctypes = OPENSSL_malloc(ctype_num); if (s->cert->ctypes == NULL) { - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); goto err; } memcpy(s->cert->ctypes, data, ctype_num); @@ -2002,10 +2083,11 @@ int ssl3_get_certificate_request(SSL *s) s->s3->tmp.ctype[i] = data[i]; if (SSL_USE_SIGALGS(s)) { - if (!PACKET_get_net_2(&pkt, &list_len) - || !PACKET_get_bytes(&pkt, &data, list_len)) { + if (!PACKET_get_net_2(pkt, &list_len) + || !PACKET_get_bytes(pkt, &data, list_len)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, + SSL_R_LENGTH_MISMATCH); goto err; } @@ -2016,30 +2098,31 @@ int ssl3_get_certificate_request(SSL *s) } if ((list_len & 1) || !tls1_save_sigalgs(s, data, list_len)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, SSL_R_SIGNATURE_ALGORITHMS_ERROR); goto err; } if (!tls1_process_sigalgs(s)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); goto err; } } /* get the CA RDNs */ - if (!PACKET_get_net_2(&pkt, &list_len) - || PACKET_remaining(&pkt) != list_len) { + if (!PACKET_get_net_2(pkt, &list_len) + || PACKET_remaining(pkt) != list_len) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); goto err; } - while (PACKET_remaining(&pkt)) { - if (!PACKET_get_net_2(&pkt, &name_len) - || !PACKET_get_bytes(&pkt, &namebytes, name_len)) { + while (PACKET_remaining(pkt)) { + if (!PACKET_get_net_2(pkt, &name_len) + || !PACKET_get_bytes(pkt, &namebytes, name_len)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, + SSL_R_LENGTH_MISMATCH); goto err; } @@ -2048,18 +2131,18 @@ int ssl3_get_certificate_request(SSL *s) if ((xn = d2i_X509_NAME(NULL, (const unsigned char **)&namebytes, name_len)) == NULL) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_ASN1_LIB); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, ERR_R_ASN1_LIB); goto err; } if (namebytes != (namestart + name_len)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, SSL_R_CA_DN_LENGTH_MISMATCH); goto err; } if (!sk_X509_NAME_push(ca_sk, xn)) { - SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST, ERR_R_MALLOC_FAILURE); goto err; } } @@ -2071,13 +2154,13 @@ int ssl3_get_certificate_request(SSL *s) s->s3->tmp.ca_names = ca_sk; ca_sk = NULL; - ret = 1; + ret = MSG_PROCESS_CONTINUE_READING; goto done; err: - s->state = SSL_ST_ERR; + ossl_statem_set_error(s); done: sk_X509_NAME_pop_free(ca_sk, X509_NAME_free); - return (ret); + return ret; } static int ca_dn_cmp(const X509_NAME *const *a, const X509_NAME *const *b) @@ -2085,39 +2168,23 @@ static int ca_dn_cmp(const X509_NAME *const *a, const X509_NAME *const *b) return (X509_NAME_cmp(*a, *b)); } -int ssl3_get_new_session_ticket(SSL *s) +MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt) { - int ok, al, ret = 0; + int al; unsigned int ticklen; unsigned long ticket_lifetime_hint; - long n; - PACKET pkt; - - n = s->method->ssl_get_message(s, - SSL3_ST_CR_SESSION_TICKET_A, - SSL3_ST_CR_SESSION_TICKET_B, - SSL3_MT_NEWSESSION_TICKET, 16384, &ok); - - if (!ok) - return ((int)n); - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_INTERNAL_ERROR); - goto f_err; - } - if (!PACKET_get_net_4(&pkt, &ticket_lifetime_hint) - || !PACKET_get_net_2(&pkt, &ticklen) - || PACKET_remaining(&pkt) != ticklen) { + if (!PACKET_get_net_4(pkt, &ticket_lifetime_hint) + || !PACKET_get_net_2(pkt, &ticklen) + || PACKET_remaining(pkt) != ticklen) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); goto f_err; } /* Server is allowed to change its mind and send an empty ticket. */ if (ticklen == 0) - return 1; + return MSG_PROCESS_CONTINUE_READING; if (s->session->session_id_length > 0) { int i = s->session_ctx->session_cache_mode; @@ -2142,7 +2209,7 @@ int ssl3_get_new_session_ticket(SSL *s) if ((new_sess = ssl_session_dup(s->session, 0)) == 0) { al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); goto f_err; } @@ -2155,12 +2222,12 @@ int ssl3_get_new_session_ticket(SSL *s) s->session->tlsext_tick = OPENSSL_malloc(ticklen); if (!s->session->tlsext_tick) { - SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE); goto err; } - if (!PACKET_copy_bytes(&pkt, s->session->tlsext_tick, ticklen)) { + if (!PACKET_copy_bytes(pkt, s->session->tlsext_tick, ticklen)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH); goto f_err; } @@ -2180,57 +2247,42 @@ int ssl3_get_new_session_ticket(SSL *s) EVP_Digest(s->session->tlsext_tick, ticklen, s->session->session_id, &s->session->session_id_length, EVP_sha256(), NULL); - ret = 1; - return (ret); + return MSG_PROCESS_CONTINUE_READING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: - s->state = SSL_ST_ERR; - return (-1); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } -int ssl3_get_cert_status(SSL *s) +MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt) { - int ok, al; - unsigned long resplen, n; + int al; + unsigned long resplen; unsigned int type; - PACKET pkt; - n = s->method->ssl_get_message(s, - SSL3_ST_CR_CERT_STATUS_A, - SSL3_ST_CR_CERT_STATUS_B, - SSL3_MT_CERTIFICATE_STATUS, 16384, &ok); - - if (!ok) - return ((int)n); - - if (!PACKET_buf_init(&pkt, s->init_msg, n)) { - al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_INTERNAL_ERROR); - goto f_err; - } - if (!PACKET_get_1(&pkt, &type) + if (!PACKET_get_1(pkt, &type) || type != TLSEXT_STATUSTYPE_ocsp) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_UNSUPPORTED_STATUS_TYPE); + SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_UNSUPPORTED_STATUS_TYPE); goto f_err; } - if (!PACKET_get_net_3(&pkt, &resplen) - || PACKET_remaining(&pkt) != resplen) { + if (!PACKET_get_net_3(pkt, &resplen) + || PACKET_remaining(pkt) != resplen) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_LENGTH_MISMATCH); goto f_err; } OPENSSL_free(s->tlsext_ocsp_resp); s->tlsext_ocsp_resp = OPENSSL_malloc(resplen); if (!s->tlsext_ocsp_resp) { al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, ERR_R_MALLOC_FAILURE); goto f_err; } - if (!PACKET_copy_bytes(&pkt, s->tlsext_ocsp_resp, resplen)) { + if (!PACKET_copy_bytes(pkt, s->tlsext_ocsp_resp, resplen)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_LENGTH_MISMATCH); + SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_LENGTH_MISMATCH); goto f_err; } s->tlsext_ocsp_resplen = resplen; @@ -2239,47 +2291,64 @@ int ssl3_get_cert_status(SSL *s) ret = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); if (ret == 0) { al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, SSL_R_INVALID_STATUS_RESPONSE); + SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, SSL_R_INVALID_STATUS_RESPONSE); goto f_err; } if (ret < 0) { al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CERT_STATUS, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_PROCESS_CERT_STATUS, ERR_R_MALLOC_FAILURE); goto f_err; } } - return 1; + return MSG_PROCESS_CONTINUE_READING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); - s->state = SSL_ST_ERR; - return (-1); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } -int ssl3_get_server_done(SSL *s) +MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt) { - int ok, ret = 0; - long n; - - /* Second to last param should be very small, like 0 :-) */ - n = s->method->ssl_get_message(s, - SSL3_ST_CR_SRVR_DONE_A, - SSL3_ST_CR_SRVR_DONE_B, - SSL3_MT_SERVER_DONE, 30, &ok); - - if (!ok) - return ((int)n); - if (n > 0) { + if (PACKET_remaining(pkt) > 0) { /* should contain no data */ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); - SSLerr(SSL_F_SSL3_GET_SERVER_DONE, SSL_R_LENGTH_MISMATCH); - s->state = SSL_ST_ERR; - return -1; + SSLerr(SSL_F_TLS_PROCESS_SERVER_DONE, SSL_R_LENGTH_MISMATCH); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; + } + +#ifndef OPENSSL_NO_SRP + if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) { + if (SRP_Calc_A_param(s) <= 0) { + SSLerr(SSL_F_TLS_PROCESS_SERVER_DONE, SSL_R_SRP_A_CALC); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; + } + } +#endif + + /* + * at this point we check that we have the required stuff from + * the server + */ + if (!ssl3_check_cert_and_algorithm(s)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } - ret = 1; - return (ret); + +#ifndef OPENSSL_NO_SCTP + /* Only applies to renegotiation */ + if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s)) + && s->renegotiate != 0) + return MSG_PROCESS_CONTINUE_PROCESSING; + else +#endif + return MSG_PROCESS_FINISHED_READING; } -int ssl3_send_client_key_exchange(SSL *s) +int tls_construct_client_key_exchange(SSL *s) { unsigned char *p; int n; @@ -2303,580 +2372,540 @@ int ssl3_send_client_key_exchange(SSL *s) size_t pmslen = 0; alg_k = s->s3->tmp.new_cipher->algorithm_mkey; - if (s->state == SSL3_ST_CW_KEY_EXCH_A) { - p = ssl_handshake_start(s); + p = ssl_handshake_start(s); #ifndef OPENSSL_NO_PSK - if (alg_k & SSL_PSK) { - int psk_err = 1; - /* - * The callback needs PSK_MAX_IDENTITY_LEN + 1 bytes to return a - * \0-terminated identity. The last byte is for us for simulating - * strnlen. - */ - char identity[PSK_MAX_IDENTITY_LEN + 1]; - size_t identitylen; - unsigned char psk[PSK_MAX_PSK_LEN]; - size_t psklen; - - if (s->psk_client_callback == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - SSL_R_PSK_NO_CLIENT_CB); - goto err; - } - - memset(identity, 0, sizeof(identity)); + if (alg_k & SSL_PSK) { + int psk_err = 1; + /* + * The callback needs PSK_MAX_IDENTITY_LEN + 1 bytes to return a + * \0-terminated identity. The last byte is for us for simulating + * strnlen. + */ + char identity[PSK_MAX_IDENTITY_LEN + 1]; + size_t identitylen; + unsigned char psk[PSK_MAX_PSK_LEN]; + size_t psklen; + + if (s->psk_client_callback == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + SSL_R_PSK_NO_CLIENT_CB); + goto err; + } - psklen = s->psk_client_callback(s, s->session->psk_identity_hint, - identity, sizeof(identity) - 1, - psk, sizeof(psk)); + memset(identity, 0, sizeof(identity)); - if (psklen > PSK_MAX_PSK_LEN) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto psk_err; - } else if (psklen == 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - SSL_R_PSK_IDENTITY_NOT_FOUND); - goto psk_err; - } + psklen = s->psk_client_callback(s, s->session->psk_identity_hint, + identity, sizeof(identity) - 1, + psk, sizeof(psk)); - OPENSSL_free(s->s3->tmp.psk); - s->s3->tmp.psk = BUF_memdup(psk, psklen); - OPENSSL_cleanse(psk, psklen); + if (psklen > PSK_MAX_PSK_LEN) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto psk_err; + } else if (psklen == 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + SSL_R_PSK_IDENTITY_NOT_FOUND); + goto psk_err; + } - if (s->s3->tmp.psk == NULL) { - OPENSSL_cleanse(identity, sizeof(identity)); - goto memerr; - } + OPENSSL_free(s->s3->tmp.psk); + s->s3->tmp.psk = BUF_memdup(psk, psklen); + OPENSSL_cleanse(psk, psklen); - s->s3->tmp.psklen = psklen; + if (s->s3->tmp.psk == NULL) { + OPENSSL_cleanse(identity, sizeof(identity)); + goto memerr; + } - identitylen = strlen(identity); - if (identitylen > PSK_MAX_IDENTITY_LEN) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto psk_err; - } - OPENSSL_free(s->session->psk_identity); - s->session->psk_identity = BUF_strdup(identity); - if (s->session->psk_identity == NULL) { - OPENSSL_cleanse(identity, sizeof(identity)); - goto memerr; - } + s->s3->tmp.psklen = psklen; - s2n(identitylen, p); - memcpy(p, identity, identitylen); - pskhdrlen = 2 + identitylen; - p += identitylen; - psk_err = 0; - psk_err: + identitylen = strlen(identity); + if (identitylen > PSK_MAX_IDENTITY_LEN) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto psk_err; + } + OPENSSL_free(s->session->psk_identity); + s->session->psk_identity = BUF_strdup(identity); + if (s->session->psk_identity == NULL) { OPENSSL_cleanse(identity, sizeof(identity)); - if (psk_err != 0) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); - goto err; - } + goto memerr; } - if (alg_k & SSL_kPSK) { - n = 0; - } else -#endif - /* Fool emacs indentation */ - if (0) { + s2n(identitylen, p); + memcpy(p, identity, identitylen); + pskhdrlen = 2 + identitylen; + p += identitylen; + psk_err = 0; +psk_err: + OPENSSL_cleanse(identity, sizeof(identity)); + if (psk_err != 0) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + goto err; } + } + if (alg_k & SSL_kPSK) { + n = 0; + } else +#endif + + /* Fool emacs indentation */ + if (0) { + } #ifndef OPENSSL_NO_RSA - else if (alg_k & (SSL_kRSA | SSL_kRSAPSK)) { - RSA *rsa; - pmslen = SSL_MAX_MASTER_KEY_LENGTH; - pms = OPENSSL_malloc(pmslen); - if (!pms) - goto memerr; - - if (s->session->peer == NULL) { - /* - * We should always have a server certificate with SSL_kRSA. - */ - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } + else if (alg_k & (SSL_kRSA | SSL_kRSAPSK)) { + RSA *rsa; + pmslen = SSL_MAX_MASTER_KEY_LENGTH; + pms = OPENSSL_malloc(pmslen); + if (!pms) + goto memerr; + + if (s->session->peer == NULL) { + /* + * We should always have a server certificate with SSL_kRSA. + */ + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto err; + } - if (s->s3->peer_rsa_tmp != NULL) - rsa = s->s3->peer_rsa_tmp; - else { - pkey = X509_get_pubkey(s->session->peer); - if ((pkey == NULL) || (pkey->type != EVP_PKEY_RSA) - || (pkey->pkey.rsa == NULL)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - EVP_PKEY_free(pkey); - goto err; - } - rsa = pkey->pkey.rsa; + if (s->s3->peer_rsa_tmp != NULL) + rsa = s->s3->peer_rsa_tmp; + else { + pkey = X509_get_pubkey(s->session->peer); + if ((pkey == NULL) || (pkey->type != EVP_PKEY_RSA) + || (pkey->pkey.rsa == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); EVP_PKEY_free(pkey); + goto err; } + rsa = pkey->pkey.rsa; + EVP_PKEY_free(pkey); + } - pms[0] = s->client_version >> 8; - pms[1] = s->client_version & 0xff; - if (RAND_bytes(pms + 2, pmslen - 2) <= 0) - goto err; + pms[0] = s->client_version >> 8; + pms[1] = s->client_version & 0xff; + if (RAND_bytes(pms + 2, pmslen - 2) <= 0) + goto err; - q = p; - /* Fix buf for TLS and beyond */ - if (s->version > SSL3_VERSION) - p += 2; - n = RSA_public_encrypt(pmslen, pms, p, rsa, RSA_PKCS1_PADDING); + q = p; + /* Fix buf for TLS and beyond */ + if (s->version > SSL3_VERSION) + p += 2; + n = RSA_public_encrypt(pmslen, pms, p, rsa, RSA_PKCS1_PADDING); # ifdef PKCS1_CHECK - if (s->options & SSL_OP_PKCS1_CHECK_1) - p[1]++; - if (s->options & SSL_OP_PKCS1_CHECK_2) - tmp_buf[0] = 0x70; + if (s->options & SSL_OP_PKCS1_CHECK_1) + p[1]++; + if (s->options & SSL_OP_PKCS1_CHECK_2) + tmp_buf[0] = 0x70; # endif - if (n <= 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - SSL_R_BAD_RSA_ENCRYPT); - goto err; - } + if (n <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + SSL_R_BAD_RSA_ENCRYPT); + goto err; + } - /* Fix buf for TLS and beyond */ - if (s->version > SSL3_VERSION) { - s2n(n, q); - n += 2; - } + /* Fix buf for TLS and beyond */ + if (s->version > SSL3_VERSION) { + s2n(n, q); + n += 2; } + } #endif #ifndef OPENSSL_NO_DH - else if (alg_k & (SSL_kDHE | SSL_kDHr | SSL_kDHd | SSL_kDHEPSK)) { - DH *dh_srvr, *dh_clnt; - if (s->s3->peer_dh_tmp != NULL) - dh_srvr = s->s3->peer_dh_tmp; - else { - /* we get them from the cert */ - EVP_PKEY *spkey = NULL; - dh_srvr = NULL; - spkey = X509_get_pubkey(s->session->peer); - if (spkey) { - dh_srvr = EVP_PKEY_get1_DH(spkey); - EVP_PKEY_free(spkey); - } - if (dh_srvr == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } - } - if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) { - /* Use client certificate key */ - EVP_PKEY *clkey = s->cert->key->privatekey; - dh_clnt = NULL; - if (clkey) - dh_clnt = EVP_PKEY_get1_DH(clkey); - if (dh_clnt == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } - } else { - /* generate a new random key */ - if ((dh_clnt = DHparams_dup(dh_srvr)) == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); - goto err; - } - if (!DH_generate_key(dh_clnt)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); - DH_free(dh_clnt); - goto err; - } + else if (alg_k & (SSL_kDHE | SSL_kDHr | SSL_kDHd | SSL_kDHEPSK)) { + DH *dh_srvr, *dh_clnt; + if (s->s3->peer_dh_tmp != NULL) + dh_srvr = s->s3->peer_dh_tmp; + else { + /* we get them from the cert */ + EVP_PKEY *spkey = NULL; + dh_srvr = NULL; + spkey = X509_get_pubkey(s->session->peer); + if (spkey) { + dh_srvr = EVP_PKEY_get1_DH(spkey); + EVP_PKEY_free(spkey); } - - pmslen = DH_size(dh_clnt); - pms = OPENSSL_malloc(pmslen); - if (!pms) - goto memerr; - - /* - * use the 'p' output buffer for the DH key, but make sure to - * clear it out afterwards - */ - - n = DH_compute_key(pms, dh_srvr->pub_key, dh_clnt); - if (s->s3->peer_dh_tmp == NULL) - DH_free(dh_srvr); - - if (n <= 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); - DH_free(dh_clnt); + if (dh_srvr == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); goto err; } - pmslen = n; - - if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) - n = 0; - else { - /* send off the data */ - n = BN_num_bytes(dh_clnt->pub_key); - s2n(n, p); - BN_bn2bin(dh_clnt->pub_key, p); - n += 2; - } - - DH_free(dh_clnt); } -#endif - -#ifndef OPENSSL_NO_EC - else if (alg_k & (SSL_kECDHE | SSL_kECDHr | SSL_kECDHe | SSL_kECDHEPSK)) { - const EC_GROUP *srvr_group = NULL; - EC_KEY *tkey; - int ecdh_clnt_cert = 0; - int field_size = 0; - /* - * Did we send out the client's ECDH share for use in premaster - * computation as part of client certificate? If so, set - * ecdh_clnt_cert to 1. - */ - if ((alg_k & (SSL_kECDHr | SSL_kECDHe)) && (s->cert != NULL)) { - /*- - * XXX: For now, we do not support client - * authentication using ECDH certificates. - * To add such support, one needs to add - * code that checks for appropriate - * conditions and sets ecdh_clnt_cert to 1. - * For example, the cert have an ECC - * key on the same curve as the server's - * and the key should be authorized for - * key agreement. - * - * One also needs to add code in ssl3_connect - * to skip sending the certificate verify - * message. - * - * if ((s->cert->key->privatekey != NULL) && - * (s->cert->key->privatekey->type == - * EVP_PKEY_EC) && ...) - * ecdh_clnt_cert = 1; - */ - } - - if (s->s3->peer_ecdh_tmp != NULL) { - tkey = s->s3->peer_ecdh_tmp; - } else { - /* Get the Server Public Key from Cert */ - srvr_pub_pkey = X509_get_pubkey(s->session->peer); - if ((srvr_pub_pkey == NULL) - || (srvr_pub_pkey->type != EVP_PKEY_EC) - || (srvr_pub_pkey->pkey.ec == NULL)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } - - tkey = srvr_pub_pkey->pkey.ec; - } - - srvr_group = EC_KEY_get0_group(tkey); - srvr_ecpoint = EC_KEY_get0_public_key(tkey); - - if ((srvr_group == NULL) || (srvr_ecpoint == NULL)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, + if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) { + /* Use client certificate key */ + EVP_PKEY *clkey = s->cert->key->privatekey; + dh_clnt = NULL; + if (clkey) + dh_clnt = EVP_PKEY_get1_DH(clkey); + if (dh_clnt == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; } - - if ((clnt_ecdh = EC_KEY_new()) == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_MALLOC_FAILURE); - goto err; - } - - if (!EC_KEY_set_group(clnt_ecdh, srvr_group)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); - goto err; - } - if (ecdh_clnt_cert) { - /* - * Reuse key info from our certificate We only need our - * private key to perform the ECDH computation. - */ - const BIGNUM *priv_key; - tkey = s->cert->key->privatekey->pkey.ec; - priv_key = EC_KEY_get0_private_key(tkey); - if (priv_key == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_MALLOC_FAILURE); - goto err; - } - if (!EC_KEY_set_private_key(clnt_ecdh, priv_key)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); - goto err; - } - } else { - /* Generate a new ECDH key pair */ - if (!(EC_KEY_generate_key(clnt_ecdh))) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_ECDH_LIB); - goto err; - } - } - - /* - * use the 'p' output buffer for the ECDH key, but make sure to - * clear it out afterwards - */ - - field_size = EC_GROUP_get_degree(srvr_group); - if (field_size <= 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); + } else { + /* generate a new random key */ + if ((dh_clnt = DHparams_dup(dh_srvr)) == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); goto err; } - pmslen = (field_size + 7) / 8; - pms = OPENSSL_malloc(pmslen); - if (!pms) - goto memerr; - n = ECDH_compute_key(pms, pmslen, srvr_ecpoint, clnt_ecdh, NULL); - if (n <= 0 || pmslen != (size_t)n) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); + if (!DH_generate_key(dh_clnt)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); + DH_free(dh_clnt); goto err; } + } - if (ecdh_clnt_cert) { - /* Send empty client key exch message */ - n = 0; - } else { - /* - * First check the size of encoding and allocate memory - * accordingly. - */ - encoded_pt_len = - EC_POINT_point2oct(srvr_group, - EC_KEY_get0_public_key(clnt_ecdh), - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, NULL); - - encodedPoint = (unsigned char *) - OPENSSL_malloc(encoded_pt_len * sizeof(unsigned char)); - bn_ctx = BN_CTX_new(); - if ((encodedPoint == NULL) || (bn_ctx == NULL)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_MALLOC_FAILURE); - goto err; - } + pmslen = DH_size(dh_clnt); + pms = OPENSSL_malloc(pmslen); + if (!pms) + goto memerr; - /* Encode the public key */ - n = EC_POINT_point2oct(srvr_group, - EC_KEY_get0_public_key(clnt_ecdh), - POINT_CONVERSION_UNCOMPRESSED, - encodedPoint, encoded_pt_len, bn_ctx); - - *p = n; /* length of encoded point */ - /* Encoded point will be copied here */ - p += 1; - /* copy the point */ - memcpy(p, encodedPoint, n); - /* increment n to account for length field */ - n += 1; - } + /* + * use the 'p' output buffer for the DH key, but make sure to + * clear it out afterwards + */ - /* Free allocated memory */ - BN_CTX_free(bn_ctx); - OPENSSL_free(encodedPoint); - EC_KEY_free(clnt_ecdh); - EVP_PKEY_free(srvr_pub_pkey); + n = DH_compute_key(pms, dh_srvr->pub_key, dh_clnt); + if (s->s3->peer_dh_tmp == NULL) + DH_free(dh_srvr); + + if (n <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); + DH_free(dh_clnt); + goto err; } -#endif /* !OPENSSL_NO_EC */ - else if (alg_k & SSL_kGOST) { - /* GOST key exchange message creation */ - EVP_PKEY_CTX *pkey_ctx; - X509 *peer_cert; - size_t msglen; - unsigned int md_len; - unsigned char shared_ukm[32], tmp[256]; - EVP_MD_CTX *ukm_hash; - EVP_PKEY *pub_key; - - pmslen = 32; - pms = OPENSSL_malloc(pmslen); - if (!pms) - goto memerr; + pmslen = n; - /* - * Get server sertificate PKEY and create ctx from it - */ - peer_cert = s->session->peer; - if (!peer_cert) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER); - goto err; - } + if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) + n = 0; + else { + /* send off the data */ + n = BN_num_bytes(dh_clnt->pub_key); + s2n(n, p); + BN_bn2bin(dh_clnt->pub_key, p); + n += 2; + } - pkey_ctx = EVP_PKEY_CTX_new(pub_key = - X509_get_pubkey(peer_cert), NULL); - /* - * If we have send a certificate, and certificate key + DH_free(dh_clnt); + } +#endif + +#ifndef OPENSSL_NO_EC + else if (alg_k & (SSL_kECDHE | SSL_kECDHr | SSL_kECDHe | SSL_kECDHEPSK)) { + const EC_GROUP *srvr_group = NULL; + EC_KEY *tkey; + int ecdh_clnt_cert = 0; + int field_size = 0; + /* + * Did we send out the client's ECDH share for use in premaster + * computation as part of client certificate? If so, set + * ecdh_clnt_cert to 1. + */ + if ((alg_k & (SSL_kECDHr | SSL_kECDHe)) && (s->cert != NULL)) { + /*- + * XXX: For now, we do not support client + * authentication using ECDH certificates. + * To add such support, one needs to add + * code that checks for appropriate + * conditions and sets ecdh_clnt_cert to 1. + * For example, the cert have an ECC + * key on the same curve as the server's + * and the key should be authorized for + * key agreement. * - * * parameters match those of server certificate, use - * certificate key for key exchange + * One also needs to add code in ssl3_connect + * to skip sending the certificate verify + * message. + * + * if ((s->cert->key->privatekey != NULL) && + * (s->cert->key->privatekey->type == + * EVP_PKEY_EC) && ...) + * ecdh_clnt_cert = 1; */ + } - /* Otherwise, generate ephemeral key pair */ - - EVP_PKEY_encrypt_init(pkey_ctx); - /* Generate session key */ - if (RAND_bytes(pms, pmslen) <= 0) { - EVP_PKEY_CTX_free(pkey_ctx); - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, + if (s->s3->peer_ecdh_tmp != NULL) { + tkey = s->s3->peer_ecdh_tmp; + } else { + /* Get the Server Public Key from Cert */ + srvr_pub_pkey = X509_get_pubkey(s->session->peer); + if ((srvr_pub_pkey == NULL) + || (srvr_pub_pkey->type != EVP_PKEY_EC) + || (srvr_pub_pkey->pkey.ec == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; - }; - /* - * If we have client certificate, use its secret as peer key - */ - if (s->s3->tmp.cert_req && s->cert->key->privatekey) { - if (EVP_PKEY_derive_set_peer - (pkey_ctx, s->cert->key->privatekey) <= 0) { - /* - * If there was an error - just ignore it. Ephemeral key - * * would be used - */ - ERR_clear_error(); - } } + + tkey = srvr_pub_pkey->pkey.ec; + } + + srvr_group = EC_KEY_get0_group(tkey); + srvr_ecpoint = EC_KEY_get0_public_key(tkey); + + if ((srvr_group == NULL) || (srvr_ecpoint == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto err; + } + + if ((clnt_ecdh = EC_KEY_new()) == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!EC_KEY_set_group(clnt_ecdh, srvr_group)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); + goto err; + } + if (ecdh_clnt_cert) { /* - * Compute shared IV and store it in algorithm-specific context - * data + * Reuse key info from our certificate We only need our + * private key to perform the ECDH computation. */ - ukm_hash = EVP_MD_CTX_create(); - EVP_DigestInit(ukm_hash, - EVP_get_digestbynid(NID_id_GostR3411_94)); - EVP_DigestUpdate(ukm_hash, s->s3->client_random, - SSL3_RANDOM_SIZE); - EVP_DigestUpdate(ukm_hash, s->s3->server_random, - SSL3_RANDOM_SIZE); - EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len); - EVP_MD_CTX_destroy(ukm_hash); - if (EVP_PKEY_CTX_ctrl - (pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8, - shared_ukm) < 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - SSL_R_LIBRARY_BUG); + const BIGNUM *priv_key; + tkey = s->cert->key->privatekey->pkey.ec; + priv_key = EC_KEY_get0_private_key(tkey); + if (priv_key == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_MALLOC_FAILURE); goto err; } - /* Make GOST keytransport blob message */ - /* - * Encapsulate it into sequence - */ - *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; - msglen = 255; - if (EVP_PKEY_encrypt(pkey_ctx, tmp, &msglen, pms, pmslen) < 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - SSL_R_LIBRARY_BUG); + if (!EC_KEY_set_private_key(clnt_ecdh, priv_key)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); goto err; } - if (msglen >= 0x80) { - *(p++) = 0x81; - *(p++) = msglen & 0xff; - n = msglen + 3; - } else { - *(p++) = msglen & 0xff; - n = msglen + 2; - } - memcpy(p, tmp, msglen); - /* Check if pubkey from client certificate was used */ - if (EVP_PKEY_CTX_ctrl - (pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) { - /* Set flag "skip certificate verify" */ - s->s3->flags |= TLS1_FLAGS_SKIP_CERT_VERIFY; + } else { + /* Generate a new ECDH key pair */ + if (!(EC_KEY_generate_key(clnt_ecdh))) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_ECDH_LIB); + goto err; } - EVP_PKEY_CTX_free(pkey_ctx); - EVP_PKEY_free(pub_key); + } + + /* + * use the 'p' output buffer for the ECDH key, but make sure to + * clear it out afterwards + */ + field_size = EC_GROUP_get_degree(srvr_group); + if (field_size <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; } -#ifndef OPENSSL_NO_SRP - else if (alg_k & SSL_kSRP) { - if (s->srp_ctx.A != NULL) { - /* send off the data */ - n = BN_num_bytes(s->srp_ctx.A); - s2n(n, p); - BN_bn2bin(s->srp_ctx.A, p); - n += 2; - } else { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; - } - OPENSSL_free(s->session->srp_username); - s->session->srp_username = BUF_strdup(s->srp_ctx.login); - if (s->session->srp_username == NULL) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, + pmslen = (field_size + 7) / 8; + pms = OPENSSL_malloc(pmslen); + if (!pms) + goto memerr; + n = ECDH_compute_key(pms, pmslen, srvr_ecpoint, clnt_ecdh, NULL); + if (n <= 0 || pmslen != (size_t)n) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; + } + + if (ecdh_clnt_cert) { + /* Send empty client key exch message */ + n = 0; + } else { + /* + * First check the size of encoding and allocate memory + * accordingly. + */ + encoded_pt_len = + EC_POINT_point2oct(srvr_group, + EC_KEY_get0_public_key(clnt_ecdh), + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, NULL); + + encodedPoint = (unsigned char *) + OPENSSL_malloc(encoded_pt_len * sizeof(unsigned char)); + bn_ctx = BN_CTX_new(); + if ((encodedPoint == NULL) || (bn_ctx == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); goto err; } - } -#endif - else { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); - goto err; + + /* Encode the public key */ + n = EC_POINT_point2oct(srvr_group, + EC_KEY_get0_public_key(clnt_ecdh), + POINT_CONVERSION_UNCOMPRESSED, + encodedPoint, encoded_pt_len, bn_ctx); + + *p = n; /* length of encoded point */ + /* Encoded point will be copied here */ + p += 1; + /* copy the point */ + memcpy(p, encodedPoint, n); + /* increment n to account for length field */ + n += 1; } -#ifndef OPENSSL_NO_PSK - n += pskhdrlen; -#endif + /* Free allocated memory */ + BN_CTX_free(bn_ctx); + OPENSSL_free(encodedPoint); + EC_KEY_free(clnt_ecdh); + EVP_PKEY_free(srvr_pub_pkey); + } +#endif /* !OPENSSL_NO_EC */ + else if (alg_k & SSL_kGOST) { + /* GOST key exchange message creation */ + EVP_PKEY_CTX *pkey_ctx; + X509 *peer_cert; + size_t msglen; + unsigned int md_len; + unsigned char shared_ukm[32], tmp[256]; + EVP_MD_CTX *ukm_hash; + EVP_PKEY *pub_key; + + pmslen = 32; + pms = OPENSSL_malloc(pmslen); + if (!pms) + goto memerr; - if (!ssl_set_handshake_header(s, SSL3_MT_CLIENT_KEY_EXCHANGE, n)) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + /* + * Get server sertificate PKEY and create ctx from it + */ + peer_cert = s->session->peer; + if (!peer_cert) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER); goto err; } - s->state = SSL3_ST_CW_KEY_EXCH_B; - } + pkey_ctx = EVP_PKEY_CTX_new(pub_key = + X509_get_pubkey(peer_cert), NULL); + /* + * If we have send a certificate, and certificate key + * + * * parameters match those of server certificate, use + * certificate key for key exchange + */ - /* SSL3_ST_CW_KEY_EXCH_B */ - n = ssl_do_write(s); -#ifndef OPENSSL_NO_SRP - /* Check for SRP */ - if (alg_k & SSL_kSRP) { + /* Otherwise, generate ephemeral key pair */ + + EVP_PKEY_encrypt_init(pkey_ctx); + /* Generate session key */ + if (RAND_bytes(pms, pmslen) <= 0) { + EVP_PKEY_CTX_free(pkey_ctx); + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto err; + }; /* - * If everything written generate master key: no need to save PMS as - * srp_generate_client_master_secret generates it internally. + * If we have client certificate, use its secret as peer key */ - if (n > 0) { - if (!srp_generate_client_master_secret(s)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, - ERR_R_INTERNAL_ERROR); - goto err; + if (s->s3->tmp.cert_req && s->cert->key->privatekey) { + if (EVP_PKEY_derive_set_peer + (pkey_ctx, s->cert->key->privatekey) <= 0) { + /* + * If there was an error - just ignore it. Ephemeral key + * * would be used + */ + ERR_clear_error(); } } - } else -#endif - /* If we haven't written everything save PMS */ - if (n <= 0) { - s->s3->tmp.pms = pms; - s->s3->tmp.pmslen = pmslen; - } else { - /* If we don't have a PMS restore */ - if (pms == NULL) { - pms = s->s3->tmp.pms; - pmslen = s->s3->tmp.pmslen; + /* + * Compute shared IV and store it in algorithm-specific context + * data + */ + ukm_hash = EVP_MD_CTX_create(); + EVP_DigestInit(ukm_hash, + EVP_get_digestbynid(NID_id_GostR3411_94)); + EVP_DigestUpdate(ukm_hash, s->s3->client_random, + SSL3_RANDOM_SIZE); + EVP_DigestUpdate(ukm_hash, s->s3->server_random, + SSL3_RANDOM_SIZE); + EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len); + EVP_MD_CTX_destroy(ukm_hash); + if (EVP_PKEY_CTX_ctrl + (pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8, + shared_ukm) < 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + SSL_R_LIBRARY_BUG); + goto err; } - if (pms == NULL && !(alg_k & SSL_kPSK)) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + /* Make GOST keytransport blob message */ + /* + * Encapsulate it into sequence + */ + *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; + msglen = 255; + if (EVP_PKEY_encrypt(pkey_ctx, tmp, &msglen, pms, pmslen) < 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + SSL_R_LIBRARY_BUG); goto err; } - if (!ssl_generate_master_secret(s, pms, pmslen, 1)) { - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + if (msglen >= 0x80) { + *(p++) = 0x81; + *(p++) = msglen & 0xff; + n = msglen + 3; + } else { + *(p++) = msglen & 0xff; + n = msglen + 2; + } + memcpy(p, tmp, msglen); + /* Check if pubkey from client certificate was used */ + if (EVP_PKEY_CTX_ctrl + (pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) { + /* Set flag "skip certificate verify" */ + s->s3->flags |= TLS1_FLAGS_SKIP_CERT_VERIFY; + } + EVP_PKEY_CTX_free(pkey_ctx); + EVP_PKEY_free(pub_key); + + } +#ifndef OPENSSL_NO_SRP + else if (alg_k & SSL_kSRP) { + if (s->srp_ctx.A != NULL) { + /* send off the data */ + n = BN_num_bytes(s->srp_ctx.A); + s2n(n, p); + BN_bn2bin(s->srp_ctx.A, p); + n += 2; + } else { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto err; + } + OPENSSL_free(s->session->srp_username); + s->session->srp_username = BUF_strdup(s->srp_ctx.login); + if (s->session->srp_username == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, + ERR_R_MALLOC_FAILURE); goto err; } } - return n; +#endif + else { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto err; + } + +#ifndef OPENSSL_NO_PSK + n += pskhdrlen; +#endif + + if (!ssl_set_handshake_header(s, SSL3_MT_CLIENT_KEY_EXCHANGE, n)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto err; + } + + s->s3->tmp.pms = pms; + s->s3->tmp.pmslen = pmslen; + + return 1; memerr: ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); err: OPENSSL_clear_free(pms, pmslen); s->s3->tmp.pms = NULL; @@ -2890,11 +2919,70 @@ int ssl3_send_client_key_exchange(SSL *s) OPENSSL_clear_free(s->s3->tmp.psk, s->s3->tmp.psklen); s->s3->tmp.psk = NULL; #endif - s->state = SSL_ST_ERR; - return (-1); + ossl_statem_set_error(s); + return 0; +} + +int tls_client_key_exchange_post_work(SSL *s) +{ + unsigned char *pms = NULL; + size_t pmslen = 0; + +#ifndef OPENSSL_NO_SRP + /* Check for SRP */ + if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) { + if (!srp_generate_client_master_secret(s)) { + SSLerr(SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK, + ERR_R_INTERNAL_ERROR); + goto err; + } + return 1; + } +#endif + pms = s->s3->tmp.pms; + pmslen = s->s3->tmp.pmslen; + + if (pms == NULL && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK, ERR_R_MALLOC_FAILURE); + goto err; + } + if (!ssl_generate_master_secret(s, pms, pmslen, 1)) { + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK, ERR_R_INTERNAL_ERROR); + goto err; + } + +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s)) { + unsigned char sctpauthkey[64]; + char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; + + /* + * Add new shared key for SCTP-Auth, will be ignored if no SCTP + * used. + */ + memcpy(labelbuffer, DTLS1_SCTP_AUTH_LABEL, + sizeof(DTLS1_SCTP_AUTH_LABEL)); + + if (SSL_export_keying_material(s, sctpauthkey, + sizeof(sctpauthkey), labelbuffer, + sizeof(labelbuffer), NULL, 0, 0) <= 0) + goto err; + + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, + sizeof(sctpauthkey), sctpauthkey); + } +#endif + + return 1; + err: + OPENSSL_clear_free(pms, pmslen); + s->s3->tmp.pms = NULL; + return 0; } -int ssl3_send_client_verify(SSL *s) +int tls_construct_client_verify(SSL *s) { unsigned char *p; unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; @@ -2907,123 +2995,120 @@ int ssl3_send_client_verify(SSL *s) EVP_MD_CTX_init(&mctx); - if (s->state == SSL3_ST_CW_CERT_VRFY_A) { - p = ssl_handshake_start(s); - pkey = s->cert->key->privatekey; + p = ssl_handshake_start(s); + pkey = s->cert->key->privatekey; /* Create context from key and test if sha1 is allowed as digest */ - pctx = EVP_PKEY_CTX_new(pkey, NULL); - EVP_PKEY_sign_init(pctx); - if (EVP_PKEY_CTX_set_signature_md(pctx, EVP_sha1()) > 0) { - if (!SSL_USE_SIGALGS(s)) - s->method->ssl3_enc->cert_verify_mac(s, - NID_sha1, - &(data - [MD5_DIGEST_LENGTH])); - } else { - ERR_clear_error(); + pctx = EVP_PKEY_CTX_new(pkey, NULL); + EVP_PKEY_sign_init(pctx); + if (EVP_PKEY_CTX_set_signature_md(pctx, EVP_sha1()) > 0) { + if (!SSL_USE_SIGALGS(s)) + s->method->ssl3_enc->cert_verify_mac(s, + NID_sha1, + &(data + [MD5_DIGEST_LENGTH])); + } else { + ERR_clear_error(); + } + /* + * For TLS v1.2 send signature algorithm and signature using agreed + * digest and cached handshake records. + */ + if (SSL_USE_SIGALGS(s)) { + long hdatalen = 0; + void *hdata; + const EVP_MD *md = s->s3->tmp.md[s->cert->key - s->cert->pkeys]; + hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); + if (hdatalen <= 0 || !tls12_get_sigandhash(p, pkey, md)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); + goto err; } - /* - * For TLS v1.2 send signature algorithm and signature using agreed - * digest and cached handshake records. - */ - if (SSL_USE_SIGALGS(s)) { - long hdatalen = 0; - void *hdata; - const EVP_MD *md = s->s3->tmp.md[s->cert->key - s->cert->pkeys]; - hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); - if (hdatalen <= 0 || !tls12_get_sigandhash(p, pkey, md)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); - goto err; - } - p += 2; + p += 2; #ifdef SSL_DEBUG - fprintf(stderr, "Using TLS 1.2 with client alg %s\n", - EVP_MD_name(md)); + fprintf(stderr, "Using TLS 1.2 with client alg %s\n", + EVP_MD_name(md)); #endif - if (!EVP_SignInit_ex(&mctx, md, NULL) - || !EVP_SignUpdate(&mctx, hdata, hdatalen) - || !EVP_SignFinal(&mctx, p + 2, &u, pkey)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_EVP_LIB); - goto err; - } - s2n(u, p); - n = u + 4; - /* Digest cached records and discard handshake buffer */ - if (!ssl3_digest_cached_records(s, 0)) - goto err; - } else + if (!EVP_SignInit_ex(&mctx, md, NULL) + || !EVP_SignUpdate(&mctx, hdata, hdatalen) + || !EVP_SignFinal(&mctx, p + 2, &u, pkey)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_EVP_LIB); + goto err; + } + s2n(u, p); + n = u + 4; + /* Digest cached records and discard handshake buffer */ + if (!ssl3_digest_cached_records(s, 0)) + goto err; + } else #ifndef OPENSSL_NO_RSA - if (pkey->type == EVP_PKEY_RSA) { - s->method->ssl3_enc->cert_verify_mac(s, NID_md5, &(data[0])); - if (RSA_sign(NID_md5_sha1, data, - MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, - &(p[2]), &u, pkey->pkey.rsa) <= 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_RSA_LIB); - goto err; - } - s2n(u, p); - n = u + 2; - } else + if (pkey->type == EVP_PKEY_RSA) { + s->method->ssl3_enc->cert_verify_mac(s, NID_md5, &(data[0])); + if (RSA_sign(NID_md5_sha1, data, + MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, + &(p[2]), &u, pkey->pkey.rsa) <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_RSA_LIB); + goto err; + } + s2n(u, p); + n = u + 2; + } else #endif #ifndef OPENSSL_NO_DSA - if (pkey->type == EVP_PKEY_DSA) { - if (!DSA_sign(pkey->save_type, - &(data[MD5_DIGEST_LENGTH]), - SHA_DIGEST_LENGTH, &(p[2]), - (unsigned int *)&j, pkey->pkey.dsa)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_DSA_LIB); - goto err; - } - s2n(j, p); - n = j + 2; - } else + if (pkey->type == EVP_PKEY_DSA) { + if (!DSA_sign(pkey->save_type, + &(data[MD5_DIGEST_LENGTH]), + SHA_DIGEST_LENGTH, &(p[2]), + (unsigned int *)&j, pkey->pkey.dsa)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_DSA_LIB); + goto err; + } + s2n(j, p); + n = j + 2; + } else #endif #ifndef OPENSSL_NO_EC - if (pkey->type == EVP_PKEY_EC) { - if (!ECDSA_sign(pkey->save_type, - &(data[MD5_DIGEST_LENGTH]), - SHA_DIGEST_LENGTH, &(p[2]), - (unsigned int *)&j, pkey->pkey.ec)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_ECDSA_LIB); - goto err; - } - s2n(j, p); - n = j + 2; - } else -#endif - if (pkey->type == NID_id_GostR3410_2001) { - unsigned char signbuf[64]; - int i; - size_t sigsize = 64; - s->method->ssl3_enc->cert_verify_mac(s, - NID_id_GostR3411_94, data); - if (EVP_PKEY_sign(pctx, signbuf, &sigsize, data, 32) <= 0) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); - goto err; - } - for (i = 63, j = 0; i >= 0; j++, i--) { - p[2 + j] = signbuf[i]; - } - s2n(j, p); - n = j + 2; - } else { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); + if (pkey->type == EVP_PKEY_EC) { + if (!ECDSA_sign(pkey->save_type, + &(data[MD5_DIGEST_LENGTH]), + SHA_DIGEST_LENGTH, &(p[2]), + (unsigned int *)&j, pkey->pkey.ec)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_ECDSA_LIB); goto err; } - if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_VERIFY, n)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); + s2n(j, p); + n = j + 2; + } else +#endif + if (pkey->type == NID_id_GostR3410_2001) { + unsigned char signbuf[64]; + int i; + size_t sigsize = 64; + s->method->ssl3_enc->cert_verify_mac(s, + NID_id_GostR3411_94, data); + if (EVP_PKEY_sign(pctx, signbuf, &sigsize, data, 32) <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } - s->state = SSL3_ST_CW_CERT_VRFY_B; + for (i = 63, j = 0; i >= 0; j++, i--) { + p[2 + j] = signbuf[i]; + } + s2n(j, p); + n = j + 2; + } else { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); + goto err; + } + if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_VERIFY, n)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); + goto err; } + EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_CTX_free(pctx); - return ssl_do_write(s); + return 1; err: EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_CTX_free(pctx); - s->state = SSL_ST_ERR; - return (-1); + return 0; } /* @@ -3069,35 +3154,36 @@ static int ssl3_check_client_certificate(SSL *s) return 1; } -int ssl3_send_client_certificate(SSL *s) +WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst) { X509 *x509 = NULL; EVP_PKEY *pkey = NULL; int i; - if (s->state == SSL3_ST_CW_CERT_A) { + if (wst == WORK_MORE_A) { /* Let cert callback update client certificates if required */ if (s->cert->cert_cb) { i = s->cert->cert_cb(s, s->cert->cert_cb_arg); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; - return -1; + return WORK_MORE_A; } if (i == 0) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - s->state = SSL_ST_ERR; + ossl_statem_set_error(s); return 0; } s->rwstate = SSL_NOTHING; } if (ssl3_check_client_certificate(s)) - s->state = SSL3_ST_CW_CERT_C; - else - s->state = SSL3_ST_CW_CERT_B; + return WORK_FINISHED_CONTINUE; + + /* Fall through to WORK_MORE_B */ + wst = WORK_MORE_B; } /* We need to get a client cert */ - if (s->state == SSL3_ST_CW_CERT_B) { + if (wst == WORK_MORE_B) { /* * If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP; * return(-1); We then get retied later @@ -3105,16 +3191,15 @@ int ssl3_send_client_certificate(SSL *s) i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { s->rwstate = SSL_X509_LOOKUP; - return (-1); + return WORK_MORE_B; } s->rwstate = SSL_NOTHING; if ((i == 1) && (pkey != NULL) && (x509 != NULL)) { - s->state = SSL3_ST_CW_CERT_B; if (!SSL_use_certificate(s, x509) || !SSL_use_PrivateKey(s, pkey)) i = 0; } else if (i == 1) { i = 0; - SSLerr(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE, + SSLerr(SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE, SSL_R_BAD_DATA_RETURNED_BY_CALLBACK); } @@ -3126,34 +3211,36 @@ int ssl3_send_client_certificate(SSL *s) if (s->version == SSL3_VERSION) { s->s3->tmp.cert_req = 0; ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_CERTIFICATE); - return (1); + return WORK_FINISHED_CONTINUE; } else { s->s3->tmp.cert_req = 2; if (!ssl3_digest_cached_records(s, 0)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - s->state = SSL_ST_ERR; + ossl_statem_set_error(s); return 0; } } } - /* Ok, we have a cert */ - s->state = SSL3_ST_CW_CERT_C; + return WORK_FINISHED_CONTINUE; } - if (s->state == SSL3_ST_CW_CERT_C) { - s->state = SSL3_ST_CW_CERT_D; - if (!ssl3_output_cert_chain(s, - (s->s3->tmp.cert_req == - 2) ? NULL : s->cert->key)) { - SSLerr(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE, ERR_R_INTERNAL_ERROR); - ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - s->state = SSL_ST_ERR; - return 0; - } + /* Shouldn't ever get here */ + return WORK_ERROR; +} + +int tls_construct_client_certificate(SSL *s) +{ + if (!ssl3_output_cert_chain(s, + (s->s3->tmp.cert_req == + 2) ? NULL : s->cert->key)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE, ERR_R_INTERNAL_ERROR); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; } - /* SSL3_ST_CW_CERT_D */ - return ssl_do_write(s); + + return 1; } #define has_bits(i,m) (((i)&(m)) == (m)) @@ -3317,67 +3404,25 @@ int ssl3_check_cert_and_algorithm(SSL *s) return (0); } -/* - * Normally, we can tell if the server is resuming the session from - * the session ID. EAP-FAST (RFC 4851), however, relies on the next server - * message after the ServerHello to determine if the server is resuming. - * Therefore, we allow EAP-FAST to peek ahead. - * ssl3_check_change returns 1 if we are resuming from an external - * pre-shared secret, we have a "ticket" and the next server message - * is CCS; and 0 otherwise. It returns -1 upon an error. - */ -static int ssl3_check_change(SSL *s) -{ - int ok = 0; - - if (s->version < TLS1_VERSION || !s->tls_session_secret_cb || - !s->session->tlsext_tick) - return 0; - - /* - * This function is called when we might get a Certificate message instead, - * so permit appropriate message length. - * We ignore the return value as we're only interested in the message type - * and not its length. - */ - s->method->ssl_get_message(s, - SSL3_ST_CR_CERT_A, - SSL3_ST_CR_CERT_B, - -1, s->max_cert_list, &ok); - - if (!ok) - return -1; - - s->s3->tmp.reuse_message = 1; - - if (s->s3->tmp.message_type == SSL3_MT_CHANGE_CIPHER_SPEC) - return 1; - - return 0; -} - #ifndef OPENSSL_NO_NEXTPROTONEG -int ssl3_send_next_proto(SSL *s) +int tls_construct_next_proto(SSL *s) { unsigned int len, padding_len; unsigned char *d; - if (s->state == SSL3_ST_CW_NEXT_PROTO_A) { - len = s->next_proto_negotiated_len; - padding_len = 32 - ((len + 2) % 32); - d = (unsigned char *)s->init_buf->data; - d[4] = len; - memcpy(d + 5, s->next_proto_negotiated, len); - d[5 + len] = padding_len; - memset(d + 6 + len, 0, padding_len); - *(d++) = SSL3_MT_NEXT_PROTO; - l2n3(2 + len + padding_len, d); - s->state = SSL3_ST_CW_NEXT_PROTO_B; - s->init_num = 4 + 2 + len + padding_len; - s->init_off = 0; - } - - return ssl3_do_write(s, SSL3_RT_HANDSHAKE); + len = s->next_proto_negotiated_len; + padding_len = 32 - ((len + 2) % 32); + d = (unsigned char *)s->init_buf->data; + d[4] = len; + memcpy(d + 5, s->next_proto_negotiated, len); + d[5 + len] = padding_len; + memset(d + 6 + len, 0, padding_len); + *(d++) = SSL3_MT_NEXT_PROTO; + l2n3(2 + len + padding_len, d); + s->init_num = 4 + 2 + len + padding_len; + s->init_off = 0; + + return 1; } #endif diff --git a/ssl/d1_both.c b/ssl/statem/statem_dtls.c similarity index 76% rename from ssl/d1_both.c rename to ssl/statem/statem_dtls.c index 02a464e..58a0959 100644 --- a/ssl/d1_both.c +++ b/ssl/statem/statem_dtls.c @@ -1,4 +1,4 @@ -/* ssl/d1_both.c */ +/* ssl/statem/statem_dtls.c */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra at cs.stanford.edu) for the OpenSSL project 2005. @@ -116,7 +116,8 @@ #include #include #include -#include "ssl_locl.h" +#include "../ssl_locl.h" +#include "statem_locl.h" #include #include #include @@ -149,9 +150,6 @@ static unsigned char bitmask_start_values[] = static unsigned char bitmask_end_values[] = { 0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f }; -/* XDTLS: figure out the right values */ -static const unsigned int g_probable_mtu[] = { 1500, 512, 256 }; - static void dtls1_fix_message_header(SSL *s, unsigned long frag_off, unsigned long frag_len); static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p); @@ -160,8 +158,7 @@ static void dtls1_set_message_header_int(SSL *s, unsigned char mt, unsigned short seq_num, unsigned long frag_off, unsigned long frag_len); -static long dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, - long max, int *ok); +static int dtls_get_reassembled_message(SSL *s, long *len); static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len, int reassembly) @@ -215,36 +212,6 @@ void dtls1_hm_fragment_free(hm_fragment *frag) OPENSSL_free(frag); } -static int dtls1_query_mtu(SSL *s) -{ - if (s->d1->link_mtu) { - s->d1->mtu = - s->d1->link_mtu - BIO_dgram_get_mtu_overhead(SSL_get_wbio(s)); - s->d1->link_mtu = 0; - } - - /* AHA! Figure out the MTU, and stick to the right size */ - if (s->d1->mtu < dtls1_min_mtu(s)) { - if (!(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU)) { - s->d1->mtu = - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL); - - /* - * I've seen the kernel return bogus numbers when it doesn't know - * (initial write), so just make sure we have a reasonable number - */ - if (s->d1->mtu < dtls1_min_mtu(s)) { - /* Set to min mtu */ - s->d1->mtu = dtls1_min_mtu(s); - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SET_MTU, - s->d1->mtu, NULL); - } - } else - return 0; - } - return 1; -} - /* * send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or * SSL3_RT_CHANGE_CIPHER_SPEC) @@ -437,77 +404,41 @@ int dtls1_do_write(SSL *s, int type) return (0); } -/* - * Obtain handshake message of message type 'mt' (any if mt == -1), maximum - * acceptable body length 'max'. Read an entire handshake message. Handshake - * messages arrive in fragments. - */ -long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) +int dtls_get_message(SSL *s, int *mt, unsigned long *len) { - int i, al; struct hm_header_st *msg_hdr; unsigned char *p; unsigned long msg_len; - - /* - * s3->tmp is used to store messages that are unexpected, caused by the - * absence of an optional handshake message - */ - if (s->s3->tmp.reuse_message) { - if ((mt >= 0) && (s->s3->tmp.message_type != mt)) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_DTLS1_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); - goto f_err; - } - *ok = 1; - - - /* - * Messages reused from dtls1_listen also have the record header in - * the buffer which we need to skip over. - */ - if (s->s3->tmp.reuse_message == DTLS1_SKIP_RECORD_HEADER) { - s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH - + DTLS1_RT_HEADER_LENGTH; - } else { - s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; - } - s->init_num = (int)s->s3->tmp.message_size; - s->s3->tmp.reuse_message = 0; - return s->init_num; - } + int ok; + long tmplen; msg_hdr = &s->d1->r_msg_hdr; memset(msg_hdr, 0, sizeof(*msg_hdr)); again: - i = dtls1_get_message_fragment(s, st1, stn, mt, max, ok); - if (i == DTLS1_HM_BAD_FRAGMENT || i == DTLS1_HM_FRAGMENT_RETRY) { + ok = dtls_get_reassembled_message(s, &tmplen); + if (tmplen == DTLS1_HM_BAD_FRAGMENT + || tmplen == DTLS1_HM_FRAGMENT_RETRY) { /* bad fragment received */ goto again; - } else if (i <= 0 && !*ok) { - return i; + } else if (tmplen <= 0 && !ok) { + return 0; } - if (mt >= 0 && s->s3->tmp.message_type != mt) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_DTLS1_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); - goto f_err; - } + *mt = s->s3->tmp.message_type; p = (unsigned char *)s->init_buf->data; - if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + if (*mt == SSL3_MT_CHANGE_CIPHER_SPEC) { if (s->msg_callback) { s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, p, 1, s, s->msg_callback_arg); } /* * This isn't a real handshake message so skip the processing below. - * dtls1_get_message_fragment() will never return a CCS if mt == -1, - * so we are ok to continue in that case. */ - return i; + *len = (unsigned long)tmplen; + return 1; } msg_len = msg_hdr->msg_len; @@ -534,16 +465,12 @@ long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; - return s->init_num; + *len = s->init_num; - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - *ok = 0; - return -1; + return 1; } -static int dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr, - int max) +static int dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr) { size_t frag_off, frag_len, msg_len; @@ -557,11 +484,6 @@ static int dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr, return SSL_AD_ILLEGAL_PARAMETER; } - if ((frag_off + frag_len) > (unsigned long)max) { - SSLerr(SSL_F_DTLS1_PREPROCESS_FRAGMENT, SSL_R_EXCESSIVE_MESSAGE_SIZE); - return SSL_AD_ILLEGAL_PARAMETER; - } - if (s->d1->r_msg_hdr.frag_off == 0) { /* first fragment */ /* * msg_len is limited to 2^24, but is effectively checked against max @@ -590,7 +512,7 @@ static int dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr, return 0; /* no error */ } -static int dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok) +static int dtls1_retrieve_buffered_fragment(SSL *s, int *ok) { /*- * (0) check whether the desired fragment is available @@ -617,7 +539,7 @@ static int dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok) unsigned long frag_len = frag->msg_header.frag_len; pqueue_pop(s->d1->buffered_messages); - al = dtls1_preprocess_fragment(s, &frag->msg_header, max); + al = dtls1_preprocess_fragment(s, &frag->msg_header); if (al == 0) { /* no alert */ unsigned char *p = @@ -858,20 +780,21 @@ dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr, return i; } -static long -dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) +static int dtls_get_reassembled_message(SSL *s, long *len) { unsigned char wire[DTLS1_HM_HEADER_LENGTH]; - unsigned long len, frag_off, frag_len; + unsigned long mlen, frag_off, frag_len; int i, al, recvd_type; struct hm_header_st msg_hdr; + int ok; redo: /* see if we have the required fragment already */ - if ((frag_len = dtls1_retrieve_buffered_fragment(s, max, ok)) || *ok) { - if (*ok) + if ((frag_len = dtls1_retrieve_buffered_fragment(s, &ok)) || ok) { + if (ok) s->init_num = frag_len; - return frag_len; + *len = frag_len; + return ok; } /* read handshake message header */ @@ -879,53 +802,37 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) DTLS1_HM_HEADER_LENGTH, 0); if (i <= 0) { /* nbio, or an error */ s->rwstate = SSL_READING; - *ok = 0; - return i; + *len = i; + return 0; } if(recvd_type == SSL3_RT_CHANGE_CIPHER_SPEC) { - /* This isn't a real handshake message - its a CCS. - * There is no message sequence number in a CCS to give us confidence - * that this was really intended to be at this point in the handshake - * sequence. Therefore we only allow this if we were explicitly looking - * for it (i.e. if |mt| is -1 we still don't allow it). - */ - if(mt == SSL3_MT_CHANGE_CIPHER_SPEC) { - if (wire[0] != SSL3_MT_CCS) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL_R_BAD_CHANGE_CIPHER_SPEC); - goto f_err; - } - - memcpy(s->init_buf->data, wire, i); - s->init_num = i - 1; - s->init_msg = s->init_buf->data + 1; - s->s3->tmp.message_type = SSL3_MT_CHANGE_CIPHER_SPEC; - s->s3->tmp.message_size = i - 1; - s->state = stn; - *ok = 1; - return i-1; - } else { - /* - * We weren't expecting a CCS yet. Probably something got - * re-ordered or this is a retransmit. We should drop this and try - * again. - */ - s->init_num = 0; - goto redo; + if (wire[0] != SSL3_MT_CCS) { + al = SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, + SSL_R_BAD_CHANGE_CIPHER_SPEC); + goto f_err; } + + memcpy(s->init_buf->data, wire, i); + s->init_num = i - 1; + s->init_msg = s->init_buf->data + 1; + s->s3->tmp.message_type = SSL3_MT_CHANGE_CIPHER_SPEC; + s->s3->tmp.message_size = i - 1; + *len = i - 1; + return 1; } /* Handshake fails if message header is incomplete */ if (i != DTLS1_HM_HEADER_LENGTH) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL_R_UNEXPECTED_MESSAGE); + SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } /* parse the message fragment header */ dtls1_get_message_header(wire, &msg_hdr); - len = msg_hdr.msg_len; + mlen = msg_hdr.msg_len; frag_off = msg_hdr.frag_off; frag_len = msg_hdr.frag_len; @@ -935,7 +842,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) */ if (frag_len > RECORD_LAYER_get_rrec_length(&s->rlayer)) { al = SSL3_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL_R_BAD_LENGTH); + SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, SSL_R_BAD_LENGTH); goto f_err; } @@ -945,11 +852,15 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) * While listening, we accept seq 1 (ClientHello with cookie) * although we're still expecting seq 0 (ClientHello) */ - if (msg_hdr.seq != s->d1->handshake_read_seq) - return dtls1_process_out_of_seq_message(s, &msg_hdr, ok); + if (msg_hdr.seq != s->d1->handshake_read_seq) { + *len = dtls1_process_out_of_seq_message(s, &msg_hdr, &ok); + return ok; + } - if (frag_len && frag_len < len) - return dtls1_reassemble_fragment(s, &msg_hdr, ok); + if (frag_len && frag_len < mlen) { + *len = dtls1_reassemble_fragment(s, &msg_hdr, &ok); + return ok; + } if (!s->server && s->d1->r_msg_hdr.frag_off == 0 && wire[0] == SSL3_MT_HELLO_REQUEST) { @@ -969,13 +880,13 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) } else { /* Incorrectly formated Hello request */ al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, + SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; } } - if ((al = dtls1_preprocess_fragment(s, &msg_hdr, max))) + if ((al = dtls1_preprocess_fragment(s, &msg_hdr))) goto f_err; if (frag_len > 0) { @@ -991,8 +902,8 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) */ if (i <= 0) { s->rwstate = SSL_READING; - *ok = 0; - return i; + *len = i; + return 0; } } else i = 0; @@ -1003,28 +914,24 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) */ if (i != (int)frag_len) { al = SSL3_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT, SSL3_AD_ILLEGAL_PARAMETER); + SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, SSL3_AD_ILLEGAL_PARAMETER); goto f_err; } - *ok = 1; - s->state = stn; - /* * Note that s->init_num is *not* used as current offset in * s->init_buf->data, but as a counter summing up fragments' lengths: as * soon as they sum up to handshake packet length, we assume we have got * all the fragments. */ - s->init_num = frag_len; - return frag_len; + *len = s->init_num = frag_len; + return 1; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); s->init_num = 0; - - *ok = 0; - return (-1); + *len = -1; + return 0; } /*- @@ -1036,40 +943,56 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, int mt, long max, int *ok) * ssl->session->read_compression assign * ssl->session->read_hash assign */ -int dtls1_send_change_cipher_spec(SSL *s, int a, int b) +int dtls_construct_change_cipher_spec(SSL *s) { unsigned char *p; - if (s->state == a) { - p = (unsigned char *)s->init_buf->data; - *p++ = SSL3_MT_CCS; - s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; - s->init_num = DTLS1_CCS_HEADER_LENGTH; + p = (unsigned char *)s->init_buf->data; + *p++ = SSL3_MT_CCS; + s->d1->handshake_write_seq = s->d1->next_handshake_write_seq; + s->init_num = DTLS1_CCS_HEADER_LENGTH; - if (s->version == DTLS1_BAD_VER) { - s->d1->next_handshake_write_seq++; - s2n(s->d1->handshake_write_seq, p); - s->init_num += 2; - } + if (s->version == DTLS1_BAD_VER) { + s->d1->next_handshake_write_seq++; + s2n(s->d1->handshake_write_seq, p); + s->init_num += 2; + } - s->init_off = 0; + s->init_off = 0; - dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, - s->d1->handshake_write_seq, 0, 0); + dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, + s->d1->handshake_write_seq, 0, 0); - /* buffer the message to handle re-xmits */ - if (!dtls1_buffer_message(s, 1)) { - SSLerr(SSL_F_DTLS1_SEND_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); - return -1; - } - - s->state = b; + /* buffer the message to handle re-xmits */ + if (!dtls1_buffer_message(s, 1)) { + SSLerr(SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); + return 0; } - /* SSL3_ST_CW_CHANGE_B */ - return (dtls1_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC)); + return 1; } +#ifndef OPENSSL_NO_SCTP +WORK_STATE dtls_wait_for_dry(SSL *s) +{ + int ret; + + /* read app data until dry event */ + ret = BIO_dgram_sctp_wait_for_dry(SSL_get_wbio(s)); + if (ret < 0) + return WORK_ERROR; + + if (ret == 0) { + s->s3->in_read_app_data = 2; + s->rwstate = SSL_READING; + BIO_clear_retry_flags(SSL_get_rbio(s)); + BIO_set_retry_read(SSL_get_rbio(s)); + return WORK_MORE_A; + } + return WORK_FINISHED_CONTINUE; +} +#endif + int dtls1_read_failed(SSL *s, int code) { if (code > 0) { @@ -1346,17 +1269,6 @@ static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p) return p; } -unsigned int dtls1_link_min_mtu(void) -{ - return (g_probable_mtu[(sizeof(g_probable_mtu) / - sizeof(g_probable_mtu[0])) - 1]); -} - -unsigned int dtls1_min_mtu(SSL *s) -{ - return dtls1_link_min_mtu() - BIO_dgram_get_mtu_overhead(SSL_get_wbio(s)); -} - void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) { @@ -1369,194 +1281,4 @@ dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) n2l3(data, msg_hdr->frag_len); } -int dtls1_shutdown(SSL *s) -{ - int ret; -#ifndef OPENSSL_NO_SCTP - BIO *wbio; - - wbio = SSL_get_wbio(s); - if (wbio != NULL && BIO_dgram_is_sctp(wbio) && - !(s->shutdown & SSL_SENT_SHUTDOWN)) { - ret = BIO_dgram_sctp_wait_for_dry(wbio); - if (ret < 0) - return -1; - - if (ret == 0) - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN, 1, - NULL); - } -#endif - ret = ssl3_shutdown(s); -#ifndef OPENSSL_NO_SCTP - BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN, 0, NULL); -#endif - return ret; -} - -#ifndef OPENSSL_NO_HEARTBEATS -int dtls1_process_heartbeat(SSL *s, unsigned char *p, unsigned int length) -{ - unsigned char *pl; - unsigned short hbtype; - unsigned int payload; - unsigned int padding = 16; /* Use minimum padding */ - - if (s->msg_callback) - s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT, - p, length, s, s->msg_callback_arg); - - /* Read type and payload length first */ - if (1 + 2 + 16 > length) - return 0; /* silently discard */ - if (length > SSL3_RT_MAX_PLAIN_LENGTH) - return 0; /* silently discard per RFC 6520 sec. 4 */ - - hbtype = *p++; - n2s(p, payload); - if (1 + 2 + payload + 16 > length) - return 0; /* silently discard per RFC 6520 sec. 4 */ - pl = p; - - if (hbtype == TLS1_HB_REQUEST) { - unsigned char *buffer, *bp; - unsigned int write_length = 1 /* heartbeat type */ + - 2 /* heartbeat length */ + - payload + padding; - int r; - - if (write_length > SSL3_RT_MAX_PLAIN_LENGTH) - return 0; - - /* - * Allocate memory for the response, size is 1 byte message type, - * plus 2 bytes payload length, plus payload, plus padding - */ - buffer = OPENSSL_malloc(write_length); - if (buffer == NULL) - return -1; - bp = buffer; - - /* Enter response type, length and copy payload */ - *bp++ = TLS1_HB_RESPONSE; - s2n(payload, bp); - memcpy(bp, pl, payload); - bp += payload; - /* Random padding */ - if (RAND_bytes(bp, padding) <= 0) { - OPENSSL_free(buffer); - return -1; - } - - r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, write_length); - - if (r >= 0 && s->msg_callback) - s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT, - buffer, write_length, s, s->msg_callback_arg); - - OPENSSL_free(buffer); - - if (r < 0) - return r; - } else if (hbtype == TLS1_HB_RESPONSE) { - unsigned int seq; - - /* - * We only send sequence numbers (2 bytes unsigned int), and 16 - * random bytes, so we just try to read the sequence number - */ - n2s(pl, seq); - - if (payload == 18 && seq == s->tlsext_hb_seq) { - dtls1_stop_timer(s); - s->tlsext_hb_seq++; - s->tlsext_hb_pending = 0; - } - } - - return 0; -} - -int dtls1_heartbeat(SSL *s) -{ - unsigned char *buf, *p; - int ret = -1; - unsigned int payload = 18; /* Sequence number + random bytes */ - unsigned int padding = 16; /* Use minimum padding */ - - /* Only send if peer supports and accepts HB requests... */ - if (!(s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) || - s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_SEND_REQUESTS) { - SSLerr(SSL_F_DTLS1_HEARTBEAT, SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT); - return -1; - } - - /* ...and there is none in flight yet... */ - if (s->tlsext_hb_pending) { - SSLerr(SSL_F_DTLS1_HEARTBEAT, SSL_R_TLS_HEARTBEAT_PENDING); - return -1; - } - /* ...and no handshake in progress. */ - if (SSL_in_init(s) || s->in_handshake) { - SSLerr(SSL_F_DTLS1_HEARTBEAT, SSL_R_UNEXPECTED_MESSAGE); - return -1; - } - - /* - * Check if padding is too long, payload and padding must not exceed 2^14 - * - 3 = 16381 bytes in total. - */ - OPENSSL_assert(payload + padding <= 16381); - - /*- - * Create HeartBeat message, we just use a sequence number - * as payload to distuingish different messages and add - * some random stuff. - * - Message Type, 1 byte - * - Payload Length, 2 bytes (unsigned int) - * - Payload, the sequence number (2 bytes uint) - * - Payload, random bytes (16 bytes uint) - * - Padding - */ - buf = OPENSSL_malloc(1 + 2 + payload + padding); - if (buf == NULL) { - SSLerr(SSL_F_DTLS1_HEARTBEAT, ERR_R_MALLOC_FAILURE); - return -1; - } - p = buf; - /* Message Type */ - *p++ = TLS1_HB_REQUEST; - /* Payload length (18 bytes here) */ - s2n(payload, p); - /* Sequence number */ - s2n(s->tlsext_hb_seq, p); - /* 16 random bytes */ - if (RAND_bytes(p, 16) <= 0) { - SSLerr(SSL_F_DTLS1_HEARTBEAT, ERR_R_INTERNAL_ERROR); - goto err; - } - p += 16; - /* Random padding */ - if (RAND_bytes(p, padding) <= 0) { - SSLerr(SSL_F_DTLS1_HEARTBEAT, ERR_R_INTERNAL_ERROR); - goto err; - } - - ret = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buf, 3 + payload + padding); - if (ret >= 0) { - if (s->msg_callback) - s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT, - buf, 3 + payload + padding, - s, s->msg_callback_arg); - - dtls1_start_timer(s); - s->tlsext_hb_pending = 1; - } - - err: - OPENSSL_free(buf); - - return ret; -} -#endif diff --git a/ssl/s3_both.c b/ssl/statem/statem_lib.c similarity index 64% rename from ssl/s3_both.c rename to ssl/statem/statem_lib.c index 4d69c2a..2c100dc 100644 --- a/ssl/s3_both.c +++ b/ssl/statem/statem_lib.c @@ -1,4 +1,4 @@ -/* ssl/s3_both.c */ +/* ssl/statem/statem_lib.c */ /* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) * All rights reserved. * @@ -117,7 +117,8 @@ #include #include #include -#include "ssl_locl.h" +#include "../ssl_locl.h" +#include "statem_locl.h" #include #include #include @@ -156,46 +157,42 @@ int ssl3_do_write(SSL *s, int type) return (0); } -int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) +int tls_construct_finished(SSL *s, const char *sender, int slen) { unsigned char *p; int i; unsigned long l; - if (s->state == a) { - p = ssl_handshake_start(s); + p = ssl_handshake_start(s); - i = s->method->ssl3_enc->final_finish_mac(s, - sender, slen, - s->s3->tmp.finish_md); - if (i <= 0) - return 0; - s->s3->tmp.finish_md_len = i; - memcpy(p, s->s3->tmp.finish_md, i); - l = i; + i = s->method->ssl3_enc->final_finish_mac(s, + sender, slen, + s->s3->tmp.finish_md); + if (i <= 0) + return 0; + s->s3->tmp.finish_md_len = i; + memcpy(p, s->s3->tmp.finish_md, i); + l = i; - /* - * Copy the finished so we can use it for renegotiation checks - */ - if (s->type == SSL_ST_CONNECT) { - OPENSSL_assert(i <= EVP_MAX_MD_SIZE); - memcpy(s->s3->previous_client_finished, s->s3->tmp.finish_md, i); - s->s3->previous_client_finished_len = i; - } else { - OPENSSL_assert(i <= EVP_MAX_MD_SIZE); - memcpy(s->s3->previous_server_finished, s->s3->tmp.finish_md, i); - s->s3->previous_server_finished_len = i; - } + /* + * Copy the finished so we can use it for renegotiation checks + */ + if (!s->server) { + OPENSSL_assert(i <= EVP_MAX_MD_SIZE); + memcpy(s->s3->previous_client_finished, s->s3->tmp.finish_md, i); + s->s3->previous_client_finished_len = i; + } else { + OPENSSL_assert(i <= EVP_MAX_MD_SIZE); + memcpy(s->s3->previous_server_finished, s->s3->tmp.finish_md, i); + s->s3->previous_server_finished_len = i; + } - if (!ssl_set_handshake_header(s, SSL3_MT_FINISHED, l)) { - SSLerr(SSL_F_SSL3_SEND_FINISHED, ERR_R_INTERNAL_ERROR); - return -1; - } - s->state = b; + if (!ssl_set_handshake_header(s, SSL3_MT_FINISHED, l)) { + SSLerr(SSL_F_TLS_CONSTRUCT_FINISHED, ERR_R_INTERNAL_ERROR); + return 0; } - /* SSL3_ST_SEND_xxxxxx_HELLO_B */ - return ssl_do_write(s); + return 1; } #ifndef OPENSSL_NO_NEXTPROTONEG @@ -213,7 +210,7 @@ static void ssl3_take_mac(SSL *s) */ if (s->s3->tmp.new_cipher == NULL) return; - if (s->state & SSL_ST_CONNECT) { + if (!s->server) { sender = s->method->ssl3_enc->server_finished_label; slen = s->method->ssl3_enc->server_finished_label_len; } else { @@ -228,33 +225,32 @@ static void ssl3_take_mac(SSL *s) } #endif -int ssl3_get_change_cipher_spec(SSL *s, int a, int b) +MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt) { - int ok, al; - long n; - - n = s->method->ssl_get_message(s, a, b, SSL3_MT_CHANGE_CIPHER_SPEC, 1, &ok); - - if (!ok) - return ((int)n); - + int al; + long remain; + + remain = PACKET_remaining(pkt); /* * 'Change Cipher Spec' is just a single byte, which should already have * been consumed by ssl_get_message() so there should be no bytes left, * unless we're using DTLS1_BAD_VER, which has an extra 2 bytes */ if (SSL_IS_DTLS(s)) { - if ((s->version == DTLS1_BAD_VER && n != DTLS1_CCS_HEADER_LENGTH + 1) + if ((s->version == DTLS1_BAD_VER + && remain != DTLS1_CCS_HEADER_LENGTH + 1) || (s->version != DTLS1_BAD_VER - && n != DTLS1_CCS_HEADER_LENGTH - 1)) { + && remain != DTLS1_CCS_HEADER_LENGTH - 1)) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CHANGE_CIPHER_SPEC, SSL_R_BAD_CHANGE_CIPHER_SPEC); + SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, + SSL_R_BAD_CHANGE_CIPHER_SPEC); goto f_err; } } else { - if (n != 0) { + if (remain != 0) { al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_CHANGE_CIPHER_SPEC, SSL_R_BAD_CHANGE_CIPHER_SPEC); + SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, + SSL_R_BAD_CHANGE_CIPHER_SPEC); goto f_err; } } @@ -262,14 +258,14 @@ int ssl3_get_change_cipher_spec(SSL *s, int a, int b) /* Check we have a cipher to change to */ if (s->s3->tmp.new_cipher == NULL) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY); + SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY); goto f_err; } s->s3->change_cipher_spec = 1; if (!ssl3_do_change_cipher_spec(s)) { al = SSL_AD_INTERNAL_ERROR; - SSLerr(SSL_F_SSL3_GET_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); + SSLerr(SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); goto f_err; } @@ -289,59 +285,43 @@ int ssl3_get_change_cipher_spec(SSL *s, int a, int b) #endif } - return 1; + return MSG_PROCESS_CONTINUE_READING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); - return 0; + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } - -int ssl3_get_finished(SSL *s, int a, int b) +MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt) { - int al, i, ok; - long n; - unsigned char *p; - -#ifdef OPENSSL_NO_NEXTPROTONEG - /* - * the mac has already been generated when we received the change cipher - * spec message and is in s->s3->tmp.peer_finish_md - */ -#endif - - /* 64 argument should actually be 36+4 :-) */ - n = s->method->ssl_get_message(s, a, b, SSL3_MT_FINISHED, 64, &ok); - - if (!ok) - return ((int)n); + int al, i; /* If this occurs, we have missed a message */ if (!s->s3->change_cipher_spec) { al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_FINISHED, SSL_R_GOT_A_FIN_BEFORE_A_CCS); + SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_GOT_A_FIN_BEFORE_A_CCS); goto f_err; } s->s3->change_cipher_spec = 0; - p = (unsigned char *)s->init_msg; i = s->s3->tmp.peer_finish_md_len; - if (i != n) { + if ((unsigned long)i != PACKET_remaining(pkt)) { al = SSL_AD_DECODE_ERROR; - SSLerr(SSL_F_SSL3_GET_FINISHED, SSL_R_BAD_DIGEST_LENGTH); + SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_BAD_DIGEST_LENGTH); goto f_err; } - if (CRYPTO_memcmp(p, s->s3->tmp.peer_finish_md, i) != 0) { + if (CRYPTO_memcmp(PACKET_data(pkt), s->s3->tmp.peer_finish_md, i) != 0) { al = SSL_AD_DECRYPT_ERROR; - SSLerr(SSL_F_SSL3_GET_FINISHED, SSL_R_DIGEST_CHECK_FAILED); + SSLerr(SSL_F_TLS_PROCESS_FINISHED, SSL_R_DIGEST_CHECK_FAILED); goto f_err; } /* * Copy the finished so we can use it for renegotiation checks */ - if (s->type == SSL_ST_ACCEPT) { + if (s->server) { OPENSSL_assert(i <= EVP_MAX_MD_SIZE); memcpy(s->s3->previous_client_finished, s->s3->tmp.peer_finish_md, i); s->s3->previous_client_finished_len = i; @@ -351,36 +331,23 @@ int ssl3_get_finished(SSL *s, int a, int b) s->s3->previous_server_finished_len = i; } - return (1); + return MSG_PROCESS_CONTINUE_PROCESSING; f_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); - return (0); + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; } -/*- - * for these 2 messages, we need to - * ssl->enc_read_ctx re-init - * ssl->rlayer.read_sequence zero - * ssl->s3->read_mac_secret re-init - * ssl->session->read_sym_enc assign - * ssl->session->read_compression assign - * ssl->session->read_hash assign - */ -int ssl3_send_change_cipher_spec(SSL *s, int a, int b) +int tls_construct_change_cipher_spec(SSL *s) { unsigned char *p; - if (s->state == a) { - p = (unsigned char *)s->init_buf->data; - *p = SSL3_MT_CCS; - s->init_num = 1; - s->init_off = 0; - - s->state = b; - } + p = (unsigned char *)s->init_buf->data; + *p = SSL3_MT_CCS; + s->init_num = 1; + s->init_off = 0; - /* SSL3_ST_CW_CHANGE_B */ - return (ssl3_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC)); + return 1; } unsigned long ssl3_output_cert_chain(SSL *s, CERT_PKEY *cpk) @@ -403,151 +370,187 @@ unsigned long ssl3_output_cert_chain(SSL *s, CERT_PKEY *cpk) return l + SSL_HM_HEADER_LENGTH(s); } -/* - * Obtain handshake message of message type 'mt' (any if mt == -1), maximum - * acceptable body length 'max'. The first four bytes (msg_type and length) - * are read in state 'st1', the body is read in state 'stn'. - */ -long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) +WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst) { - unsigned char *p; - unsigned long l; - long n; - int i, al, recvd_type; + void (*cb) (const SSL *ssl, int type, int val) = NULL; - if (s->s3->tmp.reuse_message) { - s->s3->tmp.reuse_message = 0; - if ((mt >= 0) && (s->s3->tmp.message_type != mt)) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); - goto f_err; +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))) { + WORK_STATE ret; + ret = dtls_wait_for_dry(s); + if (ret != WORK_FINISHED_CONTINUE) + return ret; + } +#endif + + /* clean a few things up */ + ssl3_cleanup_key_block(s); + + if (!SSL_IS_DTLS(s)) { + /* + * We don't do this in DTLS because we may still need the init_buf + * in case there are any unexpected retransmits + */ + BUF_MEM_free(s->init_buf); + s->init_buf = NULL; + } + + ssl_free_wbio_buffer(s); + + s->init_num = 0; + + if (!s->server || s->renegotiate == 2) { + /* skipped if we just sent a HelloRequest */ + s->renegotiate = 0; + s->new_session = 0; + + if (s->server) { + s->renegotiate = 0; + s->new_session = 0; + + ssl_update_cache(s, SSL_SESS_CACHE_SERVER); + + s->ctx->stats.sess_accept_good++; + s->handshake_func = ossl_statem_accept; + } else { + ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); + if (s->hit) + s->ctx->stats.sess_hit++; + + s->handshake_func = ossl_statem_connect; + s->ctx->stats.sess_connect_good++; + } + + if (s->info_callback != NULL) + cb = s->info_callback; + else if (s->ctx->info_callback != NULL) + cb = s->ctx->info_callback; + + if (cb != NULL) + cb(s, SSL_CB_HANDSHAKE_DONE, 1); + + if (SSL_IS_DTLS(s)) { + /* done with handshaking */ + s->d1->handshake_read_seq = 0; + s->d1->handshake_write_seq = 0; + s->d1->next_handshake_write_seq = 0; } - *ok = 1; - s->state = stn; - s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH; - s->init_num = (int)s->s3->tmp.message_size; - return s->init_num; } + return WORK_FINISHED_STOP; +} + +int tls_get_message_header(SSL *s, int *mt) +{ + /* s->init_num < SSL3_HM_HEADER_LENGTH */ + int skip_message, i, recvd_type, al; + unsigned char *p; + unsigned long l; + p = (unsigned char *)s->init_buf->data; - if (s->state == st1) { - /* s->init_num < SSL3_HM_HEADER_LENGTH */ - int skip_message; - - do { - while (s->init_num < SSL3_HM_HEADER_LENGTH) { - i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type, - &p[s->init_num], SSL3_HM_HEADER_LENGTH - s->init_num, 0); - if (i <= 0) { - s->rwstate = SSL_READING; - *ok = 0; - return i; - } - if (s->init_num == 0 - && recvd_type == SSL3_RT_CHANGE_CIPHER_SPEC - && (mt < 0 || mt == SSL3_MT_CHANGE_CIPHER_SPEC)) { - if (*p != SSL3_MT_CCS) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_MESSAGE, - SSL_R_UNEXPECTED_MESSAGE); - goto f_err; - } - s->init_num = i - 1; - s->init_msg = p + 1; - s->s3->tmp.message_type = SSL3_MT_CHANGE_CIPHER_SPEC; - s->s3->tmp.message_size = i - 1; - s->state = stn; - *ok = 1; + do { + while (s->init_num < SSL3_HM_HEADER_LENGTH) { + i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type, + &p[s->init_num], SSL3_HM_HEADER_LENGTH - s->init_num, 0); + if (i <= 0) { + s->rwstate = SSL_READING; + return 0; + } + if (recvd_type == SSL3_RT_CHANGE_CIPHER_SPEC) { + s->s3->tmp.message_type = *mt = SSL3_MT_CHANGE_CIPHER_SPEC; + s->init_num = i - 1; + s->s3->tmp.message_size = i; + return 1; + } else if (recvd_type != SSL3_RT_HANDSHAKE) { + al = SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_CCS_RECEIVED_EARLY); + goto f_err; + } + s->init_num += i; + } + + skip_message = 0; + if (!s->server) + if (p[0] == SSL3_MT_HELLO_REQUEST) + /* + * The server may always send 'Hello Request' messages -- + * we are doing a handshake anyway now, so ignore them if + * their format is correct. Does not count for 'Finished' + * MAC. + */ + if (p[1] == 0 && p[2] == 0 && p[3] == 0) { + s->init_num = 0; + skip_message = 1; + if (s->msg_callback) - s->msg_callback(0, s->version, - SSL3_RT_CHANGE_CIPHER_SPEC, p, 1, s, + s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, + p, SSL3_HM_HEADER_LENGTH, s, s->msg_callback_arg); - return i - 1; - } else if (recvd_type != SSL3_RT_HANDSHAKE) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_CCS_RECEIVED_EARLY); - goto f_err; } - s->init_num += i; - } + } while (skip_message); + /* s->init_num == SSL3_HM_HEADER_LENGTH */ - skip_message = 0; - if (!s->server) - if (p[0] == SSL3_MT_HELLO_REQUEST) - /* - * The server may always send 'Hello Request' messages -- - * we are doing a handshake anyway now, so ignore them if - * their format is correct. Does not count for 'Finished' - * MAC. - */ - if (p[1] == 0 && p[2] == 0 && p[3] == 0) { - s->init_num = 0; - skip_message = 1; - - if (s->msg_callback) - s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, - p, SSL3_HM_HEADER_LENGTH, s, - s->msg_callback_arg); - } - } while (skip_message); - /* s->init_num == SSL3_HM_HEADER_LENGTH */ - - if ((mt >= 0) && (*p != mt)) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); + *mt = *p; + s->s3->tmp.message_type = *(p++); + + if(RECORD_LAYER_is_sslv2_record(&s->rlayer)) { + /* + * Only happens with SSLv3+ in an SSLv2 backward compatible + * ClientHello + */ + /* + * Total message size is the remaining record bytes to read + * plus the SSL3_HM_HEADER_LENGTH bytes that we already read + */ + l = RECORD_LAYER_get_rrec_length(&s->rlayer) + + SSL3_HM_HEADER_LENGTH; + if (l && !BUF_MEM_grow_clean(s->init_buf, (int)l)) { + SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, ERR_R_BUF_LIB); + goto err; + } + s->s3->tmp.message_size = l; + + s->init_msg = s->init_buf->data; + s->init_num = SSL3_HM_HEADER_LENGTH; + } else { + n2l3(p, l); + /* BUF_MEM_grow takes an 'int' parameter */ + if (l > (INT_MAX - SSL3_HM_HEADER_LENGTH)) { + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_EXCESSIVE_MESSAGE_SIZE); goto f_err; } + if (l && !BUF_MEM_grow_clean(s->init_buf, + (int)l + SSL3_HM_HEADER_LENGTH)) { + SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, ERR_R_BUF_LIB); + goto err; + } + s->s3->tmp.message_size = l; - s->s3->tmp.message_type = *(p++); - - if(RECORD_LAYER_is_sslv2_record(&s->rlayer)) { - /* - * Only happens with SSLv3+ in an SSLv2 backward compatible - * ClientHello - */ - /* - * Total message size is the remaining record bytes to read - * plus the SSL3_HM_HEADER_LENGTH bytes that we already read - */ - l = RECORD_LAYER_get_rrec_length(&s->rlayer) - + SSL3_HM_HEADER_LENGTH; - if (l && !BUF_MEM_grow_clean(s->init_buf, (int)l)) { - SSLerr(SSL_F_SSL3_GET_MESSAGE, ERR_R_BUF_LIB); - goto err; - } - s->s3->tmp.message_size = l; - s->state = stn; + s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH; + s->init_num = 0; + } - s->init_msg = s->init_buf->data; - s->init_num = SSL3_HM_HEADER_LENGTH; - } else { - n2l3(p, l); - if (l > (unsigned long)max) { - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_EXCESSIVE_MESSAGE_SIZE); - goto f_err; - } - /* BUF_MEM_grow takes an 'int' parameter */ - if (l > (INT_MAX - SSL3_HM_HEADER_LENGTH)) { - al = SSL_AD_ILLEGAL_PARAMETER; - SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_EXCESSIVE_MESSAGE_SIZE); - goto f_err; - } - if (l && !BUF_MEM_grow_clean(s->init_buf, - (int)l + SSL3_HM_HEADER_LENGTH)) { - SSLerr(SSL_F_SSL3_GET_MESSAGE, ERR_R_BUF_LIB); - goto err; - } - s->s3->tmp.message_size = l; - s->state = stn; + return 1; + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + err: + return 0; +} - s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH; - s->init_num = 0; - } +int tls_get_message_body(SSL *s, unsigned long *len) +{ + long n; + unsigned char *p; + int i; + + if (s->s3->tmp.message_type == SSL3_MT_CHANGE_CIPHER_SPEC) { + /* We've already read everything in */ + *len = (unsigned long)s->init_num; + return 1; } - /* next state (stn) */ p = s->init_msg; n = s->s3->tmp.message_size - s->init_num; while (n > 0) { @@ -555,8 +558,8 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) &p[s->init_num], n, 0); if (i <= 0) { s->rwstate = SSL_READING; - *ok = 0; - return i; + *len = 0; + return 0; } s->init_num += i; n -= i; @@ -586,13 +589,18 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) s->msg_callback_arg); } - *ok = 1; - return s->init_num; - f_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - err: - *ok = 0; - return (-1); + /* + * init_num should never be negative...should probably be declared + * unsigned + */ + if (s->init_num < 0) { + SSLerr(SSL_F_TLS_GET_MESSAGE_BODY, ERR_R_INTERNAL_ERROR); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); + *len = 0; + return 0; + } + *len = (unsigned long)s->init_num; + return 1; } int ssl_cert_type(X509 *x, EVP_PKEY *pkey) diff --git a/ssl/statem/statem_locl.h b/ssl/statem/statem_locl.h new file mode 100644 index 0000000..4c3d797 --- /dev/null +++ b/ssl/statem/statem_locl.h @@ -0,0 +1,171 @@ +/* ssl/statem/statem_locl.h */ +/* ==================================================================== + * Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core at openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay at cryptsoft.com). This product includes software written by Tim + * Hudson (tjh at cryptsoft.com). + * + */ + +/***************************************************************************** + * * + * The following definitions are PRIVATE to the state machine. They should * + * NOT be used outside of the state machine. * + * * + *****************************************************************************/ + +/* Max message length definitions */ + +/* The spec allows for a longer length than this, but we limit it */ +#define HELLO_VERIFY_REQUEST_MAX_LENGTH 258 +#define SERVER_HELLO_MAX_LENGTH 20000 +#define SERVER_KEY_EXCH_MAX_LENGTH 102400 +#define SERVER_HELLO_DONE_MAX_LENGTH 0 +#define CCS_MAX_LENGTH 1 +/* Max should actually be 36 but we are generous */ +#define FINISHED_MAX_LENGTH 64 + +/* Message processing return codes */ +typedef enum { + /* Something bad happened */ + MSG_PROCESS_ERROR, + /* We've finished reading - swap to writing */ + MSG_PROCESS_FINISHED_READING, + /* + * We've completed the main processing of this message but there is some + * post processing to be done. + */ + MSG_PROCESS_CONTINUE_PROCESSING, + /* We've finished this message - read the next message */ + MSG_PROCESS_CONTINUE_READING +} MSG_PROCESS_RETURN; + +/* Flush the write BIO */ +int statem_flush(SSL *s); + +/* + * TLS/DTLS client state machine functions + */ +int ossl_statem_client_read_transition(SSL *s, int mt); +WRITE_TRAN ossl_statem_client_write_transition(SSL *s); +WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst); +WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst); +int ossl_statem_client_construct_message(SSL *s); +unsigned long ossl_statem_client_max_message_size(SSL *s); +MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt); +WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst); + +/* + * TLS/DTLS server state machine functions + */ +int ossl_statem_server_read_transition(SSL *s, int mt); +WRITE_TRAN ossl_statem_server_write_transition(SSL *s); +WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst); +WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst); +int ossl_statem_server_construct_message(SSL *s); +unsigned long ossl_statem_server_max_message_size(SSL *s); +MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt); +WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst); + +/* Functions for getting new message data */ +__owur int tls_get_message_header(SSL *s, int *mt); +__owur int tls_get_message_body(SSL *s, unsigned long *len); +__owur int dtls_get_message(SSL *s, int *mt, unsigned long *len); + +/* Message construction and processing functions */ +__owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt); +__owur int tls_construct_change_cipher_spec(SSL *s); +__owur int dtls_construct_change_cipher_spec(SSL *s); + +__owur int tls_construct_finished(SSL *s, const char *sender, int slen); +__owur WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst); +__owur WORK_STATE dtls_wait_for_dry(SSL *s); + +/* some client-only functions */ +__owur int tls_construct_client_hello(SSL *s); +__owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt); +__owur int tls_construct_client_verify(SSL *s); +__owur WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst); +__owur int tls_construct_client_certificate(SSL *s); +__owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); +__owur int tls_construct_client_key_exchange(SSL *s); +__owur int tls_client_key_exchange_post_work(SSL *s); +__owur int tls_construct_cert_status(SSL *s); +__owur MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, + PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt); +__owur int ssl3_check_cert_and_algorithm(SSL *s); +# ifndef OPENSSL_NO_NEXTPROTONEG +__owur int tls_construct_next_proto(SSL *s); +# endif +__owur MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt); + +/* some server-only functions */ +__owur MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt); +__owur WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst); +__owur int tls_construct_server_hello(SSL *s); +__owur int tls_construct_hello_request(SSL *s); +__owur int dtls_construct_hello_verify_request(SSL *s); +__owur int tls_construct_server_certificate(SSL *s); +__owur int tls_construct_server_key_exchange(SSL *s); +__owur int tls_construct_certificate_request(SSL *s); +__owur int tls_construct_server_done(SSL *s); +__owur MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt); +__owur WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst); +__owur MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt); +# ifndef OPENSSL_NO_NEXTPROTONEG +__owur MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt); +# endif +__owur int tls_construct_new_session_ticket(SSL *s); diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c new file mode 100644 index 0000000..6f51d5d --- /dev/null +++ b/ssl/statem/statem_srvr.c @@ -0,0 +1,3652 @@ +/* ssl/statem/statem_srvr.c -*- mode:C; c-file-style: "eay" -*- */ +/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay at cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh at cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay at cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core at openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay at cryptsoft.com). This product includes software written by Tim + * Hudson (tjh at cryptsoft.com). + * + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * + * Portions of the attached software ("Contribution") are developed by + * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. + * + * The Contribution is licensed pursuant to the OpenSSL open source + * license provided above. + * + * ECC cipher suite support in OpenSSL originally written by + * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. + * + */ +/* ==================================================================== + * Copyright 2005 Nokia. All rights reserved. + * + * The portions of the attached software ("Contribution") is developed by + * Nokia Corporation and is licensed pursuant to the OpenSSL open source + * license. + * + * The Contribution, originally written by Mika Kousa and Pasi Eronen of + * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites + * support (see RFC 4279) to OpenSSL. + * + * No patent licenses or other rights except those expressly stated in + * the OpenSSL open source license shall be deemed granted or received + * expressly, by implication, estoppel, or otherwise. + * + * No assurances are provided by Nokia that the Contribution does not + * infringe the patent or other intellectual property rights of any third + * party or that the license provides you with all the necessary rights + * to make use of the Contribution. + * + * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN + * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA + * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY + * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR + * OTHERWISE. + */ + + +#include +#include "../ssl_locl.h" +#include "statem_locl.h" +#include "internal/constant_time_locl.h" +#include +#include +#include +#include +#include +#include +#ifndef OPENSSL_NO_DH +# include +#endif +#include +#include + +static STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, + PACKET *cipher_suites, + STACK_OF(SSL_CIPHER) **skp, + int sslv2format, int *al); + +/* + * server_read_transition() encapsulates the logic for the allowed handshake + * state transitions when the server is reading messages from the client. The + * message type that the client has sent is provided in |mt|. The current state + * is in |s->statem.hand_state|. + * + * Valid return values are: + * 1: Success (transition allowed) + * 0: Error (transition not allowed) + */ +int ossl_statem_server_read_transition(SSL *s, int mt) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_BEFORE: + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + if (mt == SSL3_MT_CLIENT_HELLO) { + st->hand_state = TLS_ST_SR_CLNT_HELLO; + return 1; + } + break; + + case TLS_ST_SW_SRVR_DONE: + /* + * If we get a CKE message after a ServerDone then either + * 1) We didn't request a Certificate + * OR + * 2) If we did request one then + * a) We allow no Certificate to be returned + * AND + * b) We are running SSL3 (in TLS1.0+ the client must return a 0 + * list if we requested a certificate) + */ + if (mt == SSL3_MT_CLIENT_KEY_EXCHANGE + && (!s->s3->tmp.cert_request + || (!((s->verify_mode & SSL_VERIFY_PEER) && + (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) + && (s->version == SSL3_VERSION)))) { + st->hand_state = TLS_ST_SR_KEY_EXCH; + return 1; + } else if (s->s3->tmp.cert_request) { + if (mt == SSL3_MT_CERTIFICATE) { + st->hand_state = TLS_ST_SR_CERT; + return 1; + } + } + break; + + case TLS_ST_SR_CERT: + if (mt == SSL3_MT_CLIENT_KEY_EXCHANGE) { + st->hand_state = TLS_ST_SR_KEY_EXCH; + return 1; + } + break; + + case TLS_ST_SR_KEY_EXCH: + /* + * We should only process a CertificateVerify message if we have + * received a Certificate from the client. If so then |s->session->peer| + * will be non NULL. In some instances a CertificateVerify message is + * not required even if the peer has sent a Certificate (e.g. such as in + * the case of static DH). In that case |st->no_cert_verify| should be + * set. + */ + if (s->session->peer == NULL || st->no_cert_verify) { + if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + /* + * For the ECDH ciphersuites when the client sends its ECDH + * pub key in a certificate, the CertificateVerify message is + * not sent. Also for GOST ciphersuites when the client uses + * its key from the certificate for key exchange. + */ + st->hand_state = TLS_ST_SR_CHANGE; + return 1; + } + } else { + if (mt == SSL3_MT_CERTIFICATE_VERIFY) { + st->hand_state = TLS_ST_SR_CERT_VRFY; + return 1; + } + } + break; + + case TLS_ST_SR_CERT_VRFY: + if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + st->hand_state = TLS_ST_SR_CHANGE; + return 1; + } + break; + + case TLS_ST_SR_CHANGE: +#ifndef OPENSSL_NO_NEXTPROTONEG + if (s->s3->next_proto_neg_seen) { + if (mt == SSL3_MT_NEXT_PROTO) { + st->hand_state = TLS_ST_SR_NEXT_PROTO; + return 1; + } + } else { +#endif + if (mt == SSL3_MT_FINISHED) { + st->hand_state = TLS_ST_SR_FINISHED; + return 1; + } +#ifndef OPENSSL_NO_NEXTPROTONEG + } +#endif + break; + +#ifndef OPENSSL_NO_NEXTPROTONEG + case TLS_ST_SR_NEXT_PROTO: + if (mt == SSL3_MT_FINISHED) { + st->hand_state = TLS_ST_SR_FINISHED; + return 1; + } + break; +#endif + + case TLS_ST_SW_FINISHED: + if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) { + st->hand_state = TLS_ST_SR_CHANGE; + return 1; + } + break; + + default: + break; + } + + /* No valid transition found */ + return 0; +} + +/* + * Should we send a ServerKeyExchange message? + * + * Valid return values are: + * 1: Yes + * 0: No + */ +static int send_server_key_exchange(SSL *s) +{ + unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + + /* + * only send a ServerKeyExchange if DH, fortezza or RSA but we have a + * sign only certificate PSK: may send PSK identity hints For + * ECC ciphersuites, we send a serverKeyExchange message only if + * the cipher suite is either ECDH-anon or ECDHE. In other cases, + * the server certificate contains the server's public key for + * key exchange. + */ + if ( (alg_k & SSL_kDHE) + || (alg_k & SSL_kECDHE) + || ((alg_k & SSL_kRSA) + && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL + || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) + && EVP_PKEY_size(s->cert->pkeys + [SSL_PKEY_RSA_ENC].privatekey) * + 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) + ) + ) + ) + /* + * PSK: send ServerKeyExchange if PSK identity hint if + * provided + */ +#ifndef OPENSSL_NO_PSK + /* Only send SKE if we have identity hint for plain PSK */ + || ((alg_k & (SSL_kPSK | SSL_kRSAPSK)) + && s->cert->psk_identity_hint) + /* For other PSK always send SKE */ + || (alg_k & (SSL_PSK & (SSL_kDHEPSK | SSL_kECDHEPSK))) +#endif +#ifndef OPENSSL_NO_SRP + /* SRP: send ServerKeyExchange */ + || (alg_k & SSL_kSRP) +#endif + ) { + return 1; + } + + return 0; +} + +/* + * Should we send a CertificateRequest message? + * + * Valid return values are: + * 1: Yes + * 0: No + */ +static int send_certificate_request(SSL *s) +{ + if ( + /* don't request cert unless asked for it: */ + s->verify_mode & SSL_VERIFY_PEER + /* + * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert + * during re-negotiation: + */ + && ((s->session->peer == NULL) || + !(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) + /* + * never request cert in anonymous ciphersuites (see + * section "Certificate request" in SSL 3 drafts and in + * RFC 2246): + */ + && (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) + /* + * ... except when the application insists on + * verification (against the specs, but s3_clnt.c accepts + * this for SSL 3) + */ + || (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) + /* don't request certificate for SRP auth */ + && !(s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) + /* + * With normal PSK Certificates and Certificate Requests + * are omitted + */ + && !(s->s3->tmp.new_cipher->algorithm_auth & SSL_aPSK)) { + return 1; + } + + return 0; +} + +/* + * server_write_transition() works out what handshake state to move to next + * when the server is writing messages to be sent to the client. + */ +WRITE_TRAN ossl_statem_server_write_transition(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_BEFORE: + /* Just go straight to trying to read from the client */; + return WRITE_TRAN_FINISHED; + + case TLS_ST_OK: + /* We must be trying to renegotiate */ + st->hand_state = TLS_ST_SW_HELLO_REQ; + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SW_HELLO_REQ: + st->hand_state = TLS_ST_OK; + ossl_statem_set_in_init(s, 0); + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SR_CLNT_HELLO: + if (SSL_IS_DTLS(s) && !s->d1->cookie_verified + && (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE)) + st->hand_state = DTLS_ST_SW_HELLO_VERIFY_REQUEST; + else + st->hand_state = TLS_ST_SW_SRVR_HELLO; + return WRITE_TRAN_CONTINUE; + + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + return WRITE_TRAN_FINISHED; + + case TLS_ST_SW_SRVR_HELLO: + if (s->hit) { + if (s->tlsext_ticket_expected) + st->hand_state = TLS_ST_SW_SESSION_TICKET; + else + st->hand_state = TLS_ST_SW_CHANGE; + } else { + /* Check if it is anon DH or anon ECDH, */ + /* normal PSK or SRP */ + if (!(s->s3->tmp.new_cipher->algorithm_auth & + (SSL_aNULL | SSL_aSRP | SSL_aPSK))) { + st->hand_state = TLS_ST_SW_CERT; + } else if (send_server_key_exchange(s)) { + st->hand_state = TLS_ST_SW_KEY_EXCH; + } else if (send_certificate_request(s)) { + st->hand_state = TLS_ST_SW_CERT_REQ; + } else { + st->hand_state = TLS_ST_SW_SRVR_DONE; + } + } + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SW_CERT: + if (s->tlsext_status_expected) { + st->hand_state = TLS_ST_SW_CERT_STATUS; + return WRITE_TRAN_CONTINUE; + } + /* Fall through */ + + case TLS_ST_SW_CERT_STATUS: + if (send_server_key_exchange(s)) { + st->hand_state = TLS_ST_SW_KEY_EXCH; + return WRITE_TRAN_CONTINUE; + } + /* Fall through */ + + case TLS_ST_SW_KEY_EXCH: + if (send_certificate_request(s)) { + st->hand_state = TLS_ST_SW_CERT_REQ; + return WRITE_TRAN_CONTINUE; + } + /* Fall through */ + + case TLS_ST_SW_CERT_REQ: + st->hand_state = TLS_ST_SW_SRVR_DONE; + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SW_SRVR_DONE: + return WRITE_TRAN_FINISHED; + + case TLS_ST_SR_FINISHED: + if (s->hit) { + st->hand_state = TLS_ST_OK; + ossl_statem_set_in_init(s, 0); + return WRITE_TRAN_CONTINUE; + } else if (s->tlsext_ticket_expected) { + st->hand_state = TLS_ST_SW_SESSION_TICKET; + } else { + st->hand_state = TLS_ST_SW_CHANGE; + } + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SW_SESSION_TICKET: + st->hand_state = TLS_ST_SW_CHANGE; + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SW_CHANGE: + st->hand_state = TLS_ST_SW_FINISHED; + return WRITE_TRAN_CONTINUE; + + case TLS_ST_SW_FINISHED: + if (s->hit) { + return WRITE_TRAN_FINISHED; + } + st->hand_state = TLS_ST_OK; + ossl_statem_set_in_init(s, 0); + return WRITE_TRAN_CONTINUE; + + default: + /* Shouldn't happen */ + return WRITE_TRAN_ERROR; + } +} + +/* + * Perform any pre work that needs to be done prior to sending a message from + * the server to the client. + */ +WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_SW_HELLO_REQ: + s->shutdown = 0; + if (SSL_IS_DTLS(s)) + dtls1_clear_record_buffer(s); + break; + + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + s->shutdown = 0; + if (SSL_IS_DTLS(s)) { + dtls1_clear_record_buffer(s); + /* We don't buffer this message so don't use the timer */ + st->use_timer = 0; + } + break; + + case TLS_ST_SW_SRVR_HELLO: + if (SSL_IS_DTLS(s)) { + /* + * Messages we write from now on should be bufferred and + * retransmitted if necessary, so we need to use the timer now + */ + st->use_timer = 1; + } + break; + + case TLS_ST_SW_SRVR_DONE: +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))) + return dtls_wait_for_dry(s); +#endif + return WORK_FINISHED_CONTINUE; + + case TLS_ST_SW_SESSION_TICKET: + if (SSL_IS_DTLS(s)) { + /* + * We're into the last flight. We don't retransmit the last flight + * unless we need to, so we don't use the timer + */ + st->use_timer = 0; + } + break; + + case TLS_ST_SW_CHANGE: + s->session->cipher = s->s3->tmp.new_cipher; + if (!s->method->ssl3_enc->setup_key_block(s)) { + ossl_statem_set_error(s); + return WORK_ERROR; + } + if (SSL_IS_DTLS(s)) { + /* + * We're into the last flight. We don't retransmit the last flight + * unless we need to, so we don't use the timer. This might have + * already been set to 0 if we sent a NewSessionTicket message, + * but we'll set it again here in case we didn't. + */ + st->use_timer = 0; + } + return WORK_FINISHED_CONTINUE; + + case TLS_ST_OK: + return tls_finish_handshake(s, wst); + + default: + /* No pre work to be done */ + break; + } + + return WORK_FINISHED_CONTINUE; +} + +/* + * Perform any work that needs to be done after sending a message from the + * server to the client. + */ +WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst) +{ + OSSL_STATEM *st = &s->statem; + + s->init_num = 0; + + switch(st->hand_state) { + case TLS_ST_SW_HELLO_REQ: + if (statem_flush(s) != 1) + return WORK_MORE_A; + ssl3_init_finished_mac(s); + break; + + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + if (statem_flush(s) != 1) + return WORK_MORE_A; + /* HelloVerifyRequest resets Finished MAC */ + if (s->version != DTLS1_BAD_VER) + ssl3_init_finished_mac(s); + /* + * The next message should be another ClientHello which we need to + * treat like it was the first packet + */ + s->first_packet = 1; + break; + + case TLS_ST_SW_SRVR_HELLO: +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s) && s->hit) { + unsigned char sctpauthkey[64]; + char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; + + /* + * Add new shared key for SCTP-Auth, will be ignored if no + * SCTP used. + */ + memcpy(labelbuffer, DTLS1_SCTP_AUTH_LABEL, + sizeof(DTLS1_SCTP_AUTH_LABEL)); + + if (SSL_export_keying_material(s, sctpauthkey, + sizeof(sctpauthkey), labelbuffer, + sizeof(labelbuffer), NULL, 0, 0) <= 0) { + ossl_statem_set_error(s); + return WORK_ERROR; + } + + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, + sizeof(sctpauthkey), sctpauthkey); + } +#endif + break; + + case TLS_ST_SW_CHANGE: +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s) && !s->hit) { + /* + * Change to new shared key of SCTP-Auth, will be ignored if + * no SCTP used. + */ + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, + 0, NULL); + } +#endif + if (!s->method->ssl3_enc->change_cipher_state(s, + SSL3_CHANGE_CIPHER_SERVER_WRITE)) { + ossl_statem_set_error(s); + return WORK_ERROR; + } + + if (SSL_IS_DTLS(s)) + dtls1_reset_seq_numbers(s, SSL3_CC_WRITE); + break; + + case TLS_ST_SW_SRVR_DONE: + if (statem_flush(s) != 1) + return WORK_MORE_A; + break; + + case TLS_ST_SW_FINISHED: + if (statem_flush(s) != 1) + return WORK_MORE_A; +#ifndef OPENSSL_NO_SCTP + if (SSL_IS_DTLS(s) && s->hit) { + /* + * Change to new shared key of SCTP-Auth, will be ignored if + * no SCTP used. + */ + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY, + 0, NULL); + } +#endif + break; + + default: + /* No post work to be done */ + break; + } + + return WORK_FINISHED_CONTINUE; +} + +/* + * Construct a message to be sent from the server to the client. + * + * Valid return values are: + * 1: Success + * 0: Error + */ +int ossl_statem_server_construct_message(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case DTLS_ST_SW_HELLO_VERIFY_REQUEST: + return dtls_construct_hello_verify_request(s); + + case TLS_ST_SW_HELLO_REQ: + return tls_construct_hello_request(s); + + case TLS_ST_SW_SRVR_HELLO: + return tls_construct_server_hello(s); + + case TLS_ST_SW_CERT: + return tls_construct_server_certificate(s); + + case TLS_ST_SW_KEY_EXCH: + return tls_construct_server_key_exchange(s); + + case TLS_ST_SW_CERT_REQ: + return tls_construct_certificate_request(s); + + case TLS_ST_SW_SRVR_DONE: + return tls_construct_server_done(s); + + case TLS_ST_SW_SESSION_TICKET: + return tls_construct_new_session_ticket(s); + + case TLS_ST_SW_CERT_STATUS: + return tls_construct_cert_status(s); + + case TLS_ST_SW_CHANGE: + if (SSL_IS_DTLS(s)) + return dtls_construct_change_cipher_spec(s); + else + return tls_construct_change_cipher_spec(s); + + case TLS_ST_SW_FINISHED: + return tls_construct_finished(s, + s->method-> + ssl3_enc->server_finished_label, + s->method-> + ssl3_enc->server_finished_label_len); + + default: + /* Shouldn't happen */ + break; + } + + return 0; +} + +#define CLIENT_KEY_EXCH_MAX_LENGTH 2048 +#define NEXT_PROTO_MAX_LENGTH 514 + +/* + * Returns the maximum allowed length for the current message that we are + * reading. Excludes the message header. + */ +unsigned long ossl_statem_server_max_message_size(SSL *s) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_SR_CLNT_HELLO: + return SSL3_RT_MAX_PLAIN_LENGTH; + + case TLS_ST_SR_CERT: + return s->max_cert_list; + + case TLS_ST_SR_KEY_EXCH: + return CLIENT_KEY_EXCH_MAX_LENGTH; + + case TLS_ST_SR_CERT_VRFY: + return SSL3_RT_MAX_PLAIN_LENGTH; + +#ifndef OPENSSL_NO_NEXTPROTONEG + case TLS_ST_SR_NEXT_PROTO: + return NEXT_PROTO_MAX_LENGTH; +#endif + + case TLS_ST_SR_CHANGE: + return CCS_MAX_LENGTH; + + case TLS_ST_SR_FINISHED: + return FINISHED_MAX_LENGTH; + + default: + /* Shouldn't happen */ + break; + } + + return 0; +} + +/* + * Process a message that the server has received from the client. + */ +MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_SR_CLNT_HELLO: + return tls_process_client_hello(s, pkt); + + case TLS_ST_SR_CERT: + return tls_process_client_certificate(s, pkt); + + case TLS_ST_SR_KEY_EXCH: + return tls_process_client_key_exchange(s, pkt); + + case TLS_ST_SR_CERT_VRFY: + return tls_process_cert_verify(s, pkt); + +#ifndef OPENSSL_NO_NEXTPROTONEG + case TLS_ST_SR_NEXT_PROTO: + return tls_process_next_proto(s, pkt); +#endif + + case TLS_ST_SR_CHANGE: + return tls_process_change_cipher_spec(s, pkt); + + case TLS_ST_SR_FINISHED: + return tls_process_finished(s, pkt); + + default: + /* Shouldn't happen */ + break; + } + + return MSG_PROCESS_ERROR; +} + +/* + * Perform any further processing required following the receipt of a message + * from the client + */ +WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst) +{ + OSSL_STATEM *st = &s->statem; + + switch(st->hand_state) { + case TLS_ST_SR_CLNT_HELLO: + return tls_post_process_client_hello(s, wst); + + case TLS_ST_SR_KEY_EXCH: + return tls_post_process_client_key_exchange(s, wst); + + case TLS_ST_SR_CERT_VRFY: +#ifndef OPENSSL_NO_SCTP + if ( /* Is this SCTP? */ + BIO_dgram_is_sctp(SSL_get_wbio(s)) + /* Are we renegotiating? */ + && s->renegotiate + && BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { + s->s3->in_read_app_data = 2; + s->rwstate = SSL_READING; + BIO_clear_retry_flags(SSL_get_rbio(s)); + BIO_set_retry_read(SSL_get_rbio(s)); + statem_set_sctp_read_sock(s, 1); + return WORK_MORE_A; + } else { + ossl_ossl_statem_set_sctp_read_sock(s, 0); + } +#endif + return WORK_FINISHED_CONTINUE; + + + case TLS_ST_SR_FINISHED: + if (s->hit) + return tls_finish_handshake(s, wst); + else + return WORK_FINISHED_STOP; + default: + break; + } + + /* Shouldn't happen */ + return WORK_ERROR; +} + +#ifndef OPENSSL_NO_SRP +static int ssl_check_srp_ext_ClientHello(SSL *s, int *al) +{ + int ret = SSL_ERROR_NONE; + + *al = SSL_AD_UNRECOGNIZED_NAME; + + if ((s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) && + (s->srp_ctx.TLS_ext_srp_username_callback != NULL)) { + if (s->srp_ctx.login == NULL) { + /* + * RFC 5054 says SHOULD reject, we do so if There is no srp + * login name + */ + ret = SSL3_AL_FATAL; + *al = SSL_AD_UNKNOWN_PSK_IDENTITY; + } else { + ret = SSL_srp_server_param_with_username(s, al); + } + } + return ret; +} +#endif + +int tls_construct_hello_request(SSL *s) +{ + if (!ssl_set_handshake_header(s, SSL3_MT_HELLO_REQUEST, 0)) { + SSLerr(SSL_F_TLS_CONSTRUCT_HELLO_REQUEST, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + + return 1; +} + +unsigned int dtls_raw_hello_verify_request(unsigned char *buf, + unsigned char *cookie, + unsigned char cookie_len) +{ + unsigned int msg_len; + unsigned char *p; + + p = buf; + /* Always use DTLS 1.0 version: see RFC 6347 */ + *(p++) = DTLS1_VERSION >> 8; + *(p++) = DTLS1_VERSION & 0xFF; + + *(p++) = (unsigned char)cookie_len; + memcpy(p, cookie, cookie_len); + p += cookie_len; + msg_len = p - buf; + + return msg_len; +} + +int dtls_construct_hello_verify_request(SSL *s) +{ + unsigned int len; + unsigned char *buf; + + buf = (unsigned char *)s->init_buf->data; + + if (s->ctx->app_gen_cookie_cb == NULL || + s->ctx->app_gen_cookie_cb(s, s->d1->cookie, + &(s->d1->cookie_len)) == 0 || + s->d1->cookie_len > 255) { + SSLerr(SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST, + SSL_R_COOKIE_GEN_CALLBACK_FAILURE); + ossl_statem_set_error(s); + return 0; + } + + len = dtls_raw_hello_verify_request(&buf[DTLS1_HM_HEADER_LENGTH], + s->d1->cookie, s->d1->cookie_len); + + dtls1_set_message_header(s, buf, DTLS1_MT_HELLO_VERIFY_REQUEST, len, 0, + len); + len += DTLS1_HM_HEADER_LENGTH; + + /* number of bytes to write */ + s->init_num = len; + s->init_off = 0; + + return 1; +} + +MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt) +{ + int i, al = SSL_AD_INTERNAL_ERROR; + unsigned int j, complen = 0; + unsigned long id; + SSL_CIPHER *c; +#ifndef OPENSSL_NO_COMP + SSL_COMP *comp = NULL; +#endif + STACK_OF(SSL_CIPHER) *ciphers = NULL; + int protverr = 1; + /* |cookie| will only be initialized for DTLS. */ + PACKET session_id, cipher_suites, compression, extensions, cookie; + int is_v2_record; + + is_v2_record = RECORD_LAYER_is_sslv2_record(&s->rlayer); + + PACKET_null_init(&cookie); + /* First lets get s->client_version set correctly */ + if (is_v2_record) { + unsigned int version; + unsigned int mt; + /*- + * An SSLv3/TLSv1 backwards-compatible CLIENT-HELLO in an SSLv2 + * header is sent directly on the wire, not wrapped as a TLS + * record. Our record layer just processes the message length and passes + * the rest right through. Its format is: + * Byte Content + * 0-1 msg_length - decoded by the record layer + * 2 msg_type - s->init_msg points here + * 3-4 version + * 5-6 cipher_spec_length + * 7-8 session_id_length + * 9-10 challenge_length + * ... ... + */ + + if (!PACKET_get_1(pkt, &mt) + || mt != SSL2_MT_CLIENT_HELLO) { + /* + * Should never happen. We should have tested this in the record + * layer in order to have determined that this is a SSLv2 record + * in the first place + */ + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (!PACKET_get_net_2(pkt, &version)) { + /* No protocol version supplied! */ + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); + goto err; + } + if (version == 0x0002) { + /* This is real SSLv2. We don't support it. */ + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); + goto err; + } else if ((version & 0xff00) == (SSL3_VERSION_MAJOR << 8)) { + /* SSLv3/TLS */ + s->client_version = version; + } else { + /* No idea what protocol this is */ + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); + goto err; + } + } else { + /* + * use version from inside client hello, not from record header (may + * differ: see RFC 2246, Appendix E, second paragraph) + */ + if(!PACKET_get_net_2(pkt, (unsigned int *)&s->client_version)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + } + + /* Do SSL/TLS version negotiation if applicable */ + if (!SSL_IS_DTLS(s)) { + if (s->version != TLS_ANY_VERSION) { + if (s->client_version >= s->version) { + protverr = 0; + } + } else if (s->client_version >= SSL3_VERSION) { + switch(s->client_version) { + default: + case TLS1_2_VERSION: + if(!(s->options & SSL_OP_NO_TLSv1_2)) { + s->version = TLS1_2_VERSION; + s->method = TLSv1_2_server_method(); + protverr = 0; + break; + } + /* Deliberately fall through */ + case TLS1_1_VERSION: + if(!(s->options & SSL_OP_NO_TLSv1_1)) { + s->version = TLS1_1_VERSION; + s->method = TLSv1_1_server_method(); + protverr = 0; + break; + } + /* Deliberately fall through */ + case TLS1_VERSION: + if(!(s->options & SSL_OP_NO_TLSv1)) { + s->version = TLS1_VERSION; + s->method = TLSv1_server_method(); + protverr = 0; + break; + } + /* Deliberately fall through */ + case SSL3_VERSION: +#ifndef OPENSSL_NO_SSL3 + if(!(s->options & SSL_OP_NO_SSLv3)) { + s->version = SSL3_VERSION; + s->method = SSLv3_server_method(); + protverr = 0; + break; + } +#else + break; +#endif + } + } + } else if (s->client_version <= s->version + || s->method->version == DTLS_ANY_VERSION) { + /* + * For DTLS we just check versions are potentially compatible. Version + * negotiation comes later. + */ + protverr = 0; + } + + if (protverr) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_UNKNOWN_PROTOCOL); + if ((!s->enc_write_ctx && !s->write_hash)) { + /* + * similar to ssl3_get_record, send alert using remote version + * number + */ + s->version = s->client_version; + } + al = SSL_AD_PROTOCOL_VERSION; + goto f_err; + } + + /* Parse the message and load client random. */ + if (is_v2_record) { + /* + * Handle an SSLv2 backwards compatible ClientHello + * Note, this is only for SSLv3+ using the backward compatible format. + * Real SSLv2 is not supported, and is rejected above. + */ + unsigned int cipher_len, session_id_len, challenge_len; + PACKET challenge; + + if (!PACKET_get_net_2(pkt, &cipher_len) + || !PACKET_get_net_2(pkt, &session_id_len) + || !PACKET_get_net_2(pkt, &challenge_len)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_RECORD_LENGTH_MISMATCH); + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + + if (!PACKET_get_sub_packet(pkt, &cipher_suites, cipher_len) + || !PACKET_get_sub_packet(pkt, &session_id, session_id_len) + || !PACKET_get_sub_packet(pkt, &challenge, challenge_len) + /* No extensions. */ + || PACKET_remaining(pkt) != 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_RECORD_LENGTH_MISMATCH); + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + + /* Load the client random */ + challenge_len = challenge_len > SSL3_RANDOM_SIZE ? SSL3_RANDOM_SIZE : + challenge_len; + memset(s->s3->client_random, 0, SSL3_RANDOM_SIZE); + if (!PACKET_copy_bytes(&challenge, + s->s3->client_random + SSL3_RANDOM_SIZE - + challenge_len, challenge_len)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + al = SSL_AD_INTERNAL_ERROR; + goto f_err; + } + + PACKET_null_init(&compression); + PACKET_null_init(&extensions); + } else { + /* Regular ClientHello. */ + if (!PACKET_copy_bytes(pkt, s->s3->client_random, SSL3_RANDOM_SIZE) + || !PACKET_get_length_prefixed_1(pkt, &session_id)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + + if (SSL_IS_DTLS(s)) { + if (!PACKET_get_length_prefixed_1(pkt, &cookie)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + /* + * If we require cookies and this ClientHello doesn't contain one, + * just return since we do not want to allocate any memory yet. + * So check cookie length... + */ + if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { + if (PACKET_remaining(&cookie) == 0) + return 1; + } + } + + if (!PACKET_get_length_prefixed_2(pkt, &cipher_suites) + || !PACKET_get_length_prefixed_1(pkt, &compression)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + /* Could be empty. */ + extensions = *pkt; + } + + s->hit = 0; + + /* + * We don't allow resumption in a backwards compatible ClientHello. + * TODO(openssl-team): in TLS1.1+, session_id MUST be empty. + * + * Versions before 0.9.7 always allow clients to resume sessions in + * renegotiation. 0.9.7 and later allow this by default, but optionally + * ignore resumption requests with flag + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather + * than a change to default behavior so that applications relying on + * this for security won't even compile against older library versions). + * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to + * request renegotiation but not a new session (s->new_session remains + * unset): for servers, this essentially just means that the + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be + * ignored. + */ + if (is_v2_record || + (s->new_session && + (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) { + if (!ssl_get_new_session(s, 1)) + goto err; + } else { + i = ssl_get_prev_session(s, &extensions, &session_id); + /* + * Only resume if the session's version matches the negotiated + * version. + * RFC 5246 does not provide much useful advice on resumption + * with a different protocol version. It doesn't forbid it but + * the sanity of such behaviour would be questionable. + * In practice, clients do not accept a version mismatch and + * will abort the handshake with an error. + */ + if (i == 1 && s->version == s->session->ssl_version) { + /* previous session */ + s->hit = 1; + } else if (i == -1) { + goto err; + } else { + /* i == 0 */ + if (!ssl_get_new_session(s, 1)) + goto err; + } + } + + if (SSL_IS_DTLS(s)) { + /* Empty cookie was already handled above by returning early. */ + if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) { + if (s->ctx->app_verify_cookie_cb != NULL) { + if (s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookie), + PACKET_remaining(&cookie)) == 0) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_COOKIE_MISMATCH); + goto f_err; + /* else cookie verification succeeded */ + } + /* default verification */ + } else if (!PACKET_equal(&cookie, s->d1->cookie, + s->d1->cookie_len)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH); + goto f_err; + } + s->d1->cookie_verified = 1; + } + if (s->method->version == DTLS_ANY_VERSION) { + /* Select version to use */ + if (s->client_version <= DTLS1_2_VERSION && + !(s->options & SSL_OP_NO_DTLSv1_2)) { + s->version = DTLS1_2_VERSION; + s->method = DTLSv1_2_server_method(); + } else if (tls1_suiteb(s)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE); + s->version = s->client_version; + al = SSL_AD_PROTOCOL_VERSION; + goto f_err; + } else if (s->client_version <= DTLS1_VERSION && + !(s->options & SSL_OP_NO_DTLSv1)) { + s->version = DTLS1_VERSION; + s->method = DTLSv1_server_method(); + } else { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_WRONG_VERSION_NUMBER); + s->version = s->client_version; + al = SSL_AD_PROTOCOL_VERSION; + goto f_err; + } + s->session->ssl_version = s->version; + } + } + + if (ssl_bytes_to_cipher_list(s, &cipher_suites, &(ciphers), + is_v2_record, &al) == NULL) { + goto f_err; + } + + /* If it is a hit, check that the cipher is in the list */ + if (s->hit) { + j = 0; + id = s->session->cipher->id; + +#ifdef CIPHER_DEBUG + fprintf(stderr, "client sent %d ciphers\n", + sk_SSL_CIPHER_num(ciphers)); +#endif + for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { + c = sk_SSL_CIPHER_value(ciphers, i); +#ifdef CIPHER_DEBUG + fprintf(stderr, "client [%2d of %2d]:%s\n", + i, sk_SSL_CIPHER_num(ciphers), SSL_CIPHER_get_name(c)); +#endif + if (c->id == id) { + j = 1; + break; + } + } + if (j == 0) { + /* + * we need to have the cipher in the cipher list if we are asked + * to reuse it + */ + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_REQUIRED_CIPHER_MISSING); + goto f_err; + } + } + + complen = PACKET_remaining(&compression); + for (j = 0; j < complen; j++) { + if (PACKET_data(&compression)[j] == 0) + break; + } + + if (j >= complen) { + /* no compress */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED); + goto f_err; + } + + /* TLS extensions */ + if (s->version >= SSL3_VERSION) { + if (!ssl_parse_clienthello_tlsext(s, &extensions)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_PARSE_TLSEXT); + goto err; + } + } + + /* + * Check if we want to use external pre-shared secret for this handshake + * for not reused session only. We need to generate server_random before + * calling tls_session_secret_cb in order to allow SessionTicket + * processing to use it in key derivation. + */ + { + unsigned char *pos; + pos = s->s3->server_random; + if (ssl_fill_hello_random(s, 1, pos, SSL3_RANDOM_SIZE) <= 0) { + goto f_err; + } + } + + if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) { + SSL_CIPHER *pref_cipher = NULL; + + s->session->master_key_length = sizeof(s->session->master_key); + if (s->tls_session_secret_cb(s, s->session->master_key, + &s->session->master_key_length, ciphers, + &pref_cipher, + s->tls_session_secret_cb_arg)) { + s->hit = 1; + s->session->ciphers = ciphers; + s->session->verify_result = X509_V_OK; + + ciphers = NULL; + + /* check if some cipher was preferred by call back */ + pref_cipher = + pref_cipher ? pref_cipher : ssl3_choose_cipher(s, + s-> + session->ciphers, + SSL_get_ciphers + (s)); + if (pref_cipher == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER); + goto f_err; + } + + s->session->cipher = pref_cipher; + sk_SSL_CIPHER_free(s->cipher_list); + s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers); + sk_SSL_CIPHER_free(s->cipher_list_by_id); + s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers); + } + } + + /* + * Worst case, we will use the NULL compression, but if we have other + * options, we will now look for them. We have complen-1 compression + * algorithms from the client, starting at q. + */ + s->s3->tmp.new_compression = NULL; +#ifndef OPENSSL_NO_COMP + /* This only happens if we have a cache hit */ + if (s->session->compress_meth != 0) { + int m, comp_id = s->session->compress_meth; + unsigned int k; + /* Perform sanity checks on resumed compression algorithm */ + /* Can't disable compression */ + if (!ssl_allow_compression(s)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_INCONSISTENT_COMPRESSION); + goto f_err; + } + /* Look for resumed compression method */ + for (m = 0; m < sk_SSL_COMP_num(s->ctx->comp_methods); m++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, m); + if (comp_id == comp->id) { + s->s3->tmp.new_compression = comp; + break; + } + } + if (s->s3->tmp.new_compression == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_INVALID_COMPRESSION_ALGORITHM); + goto f_err; + } + /* Look for resumed method in compression list */ + for (k = 0; k < complen; k++) { + if (PACKET_data(&compression)[k] == comp_id) + break; + } + if (k >= complen) { + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, + SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING); + goto f_err; + } + } else if (s->hit) + comp = NULL; + else if (ssl_allow_compression(s) && s->ctx->comp_methods) { + /* See if we have a match */ + int m, nn, v, done = 0; + unsigned int o; + + nn = sk_SSL_COMP_num(s->ctx->comp_methods); + for (m = 0; m < nn; m++) { + comp = sk_SSL_COMP_value(s->ctx->comp_methods, m); + v = comp->id; + for (o = 0; o < complen; o++) { + if (v == PACKET_data(&compression)[o]) { + done = 1; + break; + } + } + if (done) + break; + } + if (done) + s->s3->tmp.new_compression = comp; + else + comp = NULL; + } +#else + /* + * If compression is disabled we'd better not try to resume a session + * using compression. + */ + if (s->session->compress_meth != 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_INCONSISTENT_COMPRESSION); + goto f_err; + } +#endif + + /* + * Given s->session->ciphers and SSL_get_ciphers, we must pick a cipher + */ + + if (!s->hit) { +#ifdef OPENSSL_NO_COMP + s->session->compress_meth = 0; +#else + s->session->compress_meth = (comp == NULL) ? 0 : comp->id; +#endif + sk_SSL_CIPHER_free(s->session->ciphers); + s->session->ciphers = ciphers; + if (ciphers == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); + goto f_err; + } + ciphers = NULL; + if (!tls1_set_server_sigalgs(s)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); + goto err; + } + } + + sk_SSL_CIPHER_free(ciphers); + return MSG_PROCESS_CONTINUE_PROCESSING; + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + err: + ossl_statem_set_error(s); + + sk_SSL_CIPHER_free(ciphers); + return MSG_PROCESS_ERROR; + +} + +WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst) +{ + int al = SSL_AD_HANDSHAKE_FAILURE; + SSL_CIPHER *cipher; + + if (wst == WORK_MORE_A) { + if (!s->hit) { + /* Let cert callback update server certificates if required */ + if (s->cert->cert_cb) { + int rv = s->cert->cert_cb(s, s->cert->cert_cb_arg); + if (rv == 0) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, SSL_R_CERT_CB_ERROR); + goto f_err; + } + if (rv < 0) { + s->rwstate = SSL_X509_LOOKUP; + return WORK_MORE_A; + } + s->rwstate = SSL_NOTHING; + } + cipher = ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s)); + + if (cipher == NULL) { + SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER); + goto f_err; + } + s->s3->tmp.new_cipher = cipher; + /* check whether we should disable session resumption */ + if (s->not_resumable_session_cb != NULL) + s->session->not_resumable = s->not_resumable_session_cb(s, + ((cipher->algorithm_mkey & (SSL_kDHE | SSL_kECDHE)) != 0)); + if (s->session->not_resumable) + /* do not send a session ticket */ + s->tlsext_ticket_expected = 0; + } else { + /* Session-id reuse */ + s->s3->tmp.new_cipher = s->session->cipher; + } + + if (!SSL_USE_SIGALGS(s) || !(s->verify_mode & SSL_VERIFY_PEER)) { + if (!ssl3_digest_cached_records(s, 0)) { + al = SSL_AD_INTERNAL_ERROR; + goto f_err; + } + } + + /*- + * we now have the following setup. + * client_random + * cipher_list - our prefered list of ciphers + * ciphers - the clients prefered list of ciphers + * compression - basically ignored right now + * ssl version is set - sslv3 + * s->session - The ssl session has been setup. + * s->hit - session reuse flag + * s->s3->tmp.new_cipher- the new cipher to use. + */ + + /* Handles TLS extensions that we couldn't check earlier */ + if (s->version >= SSL3_VERSION) { + if (ssl_check_clienthello_tlsext_late(s) <= 0) { + SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, + SSL_R_CLIENTHELLO_TLSEXT); + goto f_err; + } + } + + wst = WORK_MORE_B; + } +#ifndef OPENSSL_NO_SRP + if (wst == WORK_MORE_B) { + int ret; + if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { + /* + * callback indicates further work to be done + */ + s->rwstate = SSL_X509_LOOKUP; + return WORK_MORE_B; + } + if (ret != SSL_ERROR_NONE) { + /* + * This is not really an error but the only means to for + * a client to detect whether srp is supported. + */ + if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) + SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, + SSL_R_CLIENTHELLO_TLSEXT); + goto f_err; + } + } +#endif + s->renegotiate = 2; + + return WORK_FINISHED_STOP; + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + ossl_statem_set_error(s); + return WORK_ERROR; +} + +int tls_construct_server_hello(SSL *s) +{ + unsigned char *buf; + unsigned char *p, *d; + int i, sl; + int al = 0; + unsigned long l; + + buf = (unsigned char *)s->init_buf->data; + + /* Do the message type and length last */ + d = p = ssl_handshake_start(s); + + *(p++) = s->version >> 8; + *(p++) = s->version & 0xff; + + /* + * Random stuff. Filling of the server_random takes place in + * tls_process_client_hello() + */ + memcpy(p, s->s3->server_random, SSL3_RANDOM_SIZE); + p += SSL3_RANDOM_SIZE; + + /*- + * There are several cases for the session ID to send + * back in the server hello: + * - For session reuse from the session cache, + * we send back the old session ID. + * - If stateless session reuse (using a session ticket) + * is successful, we send back the client's "session ID" + * (which doesn't actually identify the session). + * - If it is a new session, we send back the new + * session ID. + * - However, if we want the new session to be single-use, + * we send back a 0-length session ID. + * s->hit is non-zero in either case of session reuse, + * so the following won't overwrite an ID that we're supposed + * to send back. + */ + if (s->session->not_resumable || + (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER) + && !s->hit)) + s->session->session_id_length = 0; + + sl = s->session->session_id_length; + if (sl > (int)sizeof(s->session->session_id)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + *(p++) = sl; + memcpy(p, s->session->session_id, sl); + p += sl; + + /* put the cipher */ + i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p); + p += i; + + /* put the compression method */ +#ifdef OPENSSL_NO_COMP + *(p++) = 0; +#else + if (s->s3->tmp.new_compression == NULL) + *(p++) = 0; + else + *(p++) = s->s3->tmp.new_compression->id; +#endif + + if (ssl_prepare_serverhello_tlsext(s) <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_HELLO, SSL_R_SERVERHELLO_TLSEXT); + ossl_statem_set_error(s); + return 0; + } + if ((p = + ssl_add_serverhello_tlsext(s, p, buf + SSL3_RT_MAX_PLAIN_LENGTH, + &al)) == NULL) { + ssl3_send_alert(s, SSL3_AL_FATAL, al); + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + + /* do the header */ + l = (p - d); + if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_HELLO, l)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_HELLO, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + + return 1; +} + +int tls_construct_server_done(SSL *s) +{ + if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_DONE, 0)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_DONE, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + + if (!s->s3->tmp.cert_request) { + if (!ssl3_digest_cached_records(s, 0)) { + ossl_statem_set_error(s); + } + } + + return 1; +} + +int tls_construct_server_key_exchange(SSL *s) +{ +#ifndef OPENSSL_NO_RSA + unsigned char *q; + int j, num; + RSA *rsa; + unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH]; + unsigned int u; +#endif +#ifndef OPENSSL_NO_DH + DH *dh = NULL, *dhp; +#endif +#ifndef OPENSSL_NO_EC + EC_KEY *ecdh = NULL, *ecdhp; + unsigned char *encodedPoint = NULL; + int encodedlen = 0; + int curve_id = 0; + BN_CTX *bn_ctx = NULL; +#endif + EVP_PKEY *pkey; + const EVP_MD *md = NULL; + unsigned char *p, *d; + int al, i; + unsigned long type; + int n; + CERT *cert; + BIGNUM *r[4]; + int nr[4], kn; + BUF_MEM *buf; + EVP_MD_CTX md_ctx; + + EVP_MD_CTX_init(&md_ctx); + + type = s->s3->tmp.new_cipher->algorithm_mkey; + cert = s->cert; + + buf = s->init_buf; + + r[0] = r[1] = r[2] = r[3] = NULL; + n = 0; +#ifndef OPENSSL_NO_PSK + if (type & SSL_PSK) { + /* + * reserve size for record length and PSK identity hint + */ + n += 2; + if (s->cert->psk_identity_hint) + n += strlen(s->cert->psk_identity_hint); + } + /* Plain PSK or RSAPSK nothing to do */ + if (type & (SSL_kPSK | SSL_kRSAPSK)) { + } else +#endif /* !OPENSSL_NO_PSK */ +#ifndef OPENSSL_NO_RSA + if (type & SSL_kRSA) { + rsa = cert->rsa_tmp; + if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) { + rsa = s->cert->rsa_tmp_cb(s, + SSL_C_IS_EXPORT(s->s3-> + tmp.new_cipher), + SSL_C_EXPORT_PKEYLENGTH(s->s3-> + tmp.new_cipher)); + if (rsa == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_ERROR_GENERATING_TMP_RSA_KEY); + goto f_err; + } + RSA_up_ref(rsa); + cert->rsa_tmp = rsa; + } + if (rsa == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_MISSING_TMP_RSA_KEY); + goto f_err; + } + r[0] = rsa->n; + r[1] = rsa->e; + s->s3->tmp.use_rsa_tmp = 1; + } else +#endif +#ifndef OPENSSL_NO_DH + if (type & (SSL_kDHE | SSL_kDHEPSK)) { + if (s->cert->dh_tmp_auto) { + dhp = ssl_get_auto_dh(s); + if (dhp == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto f_err; + } + } else + dhp = cert->dh_tmp; + if ((dhp == NULL) && (s->cert->dh_tmp_cb != NULL)) + dhp = s->cert->dh_tmp_cb(s, + SSL_C_IS_EXPORT(s->s3-> + tmp.new_cipher), + SSL_C_EXPORT_PKEYLENGTH(s->s3-> + tmp.new_cipher)); + if (dhp == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_MISSING_TMP_DH_KEY); + goto f_err; + } + if (!ssl_security(s, SSL_SECOP_TMP_DH, + DH_security_bits(dhp), 0, dhp)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_DH_KEY_TOO_SMALL); + goto f_err; + } + if (s->s3->tmp.dh != NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto err; + } + + if (s->cert->dh_tmp_auto) + dh = dhp; + else if ((dh = DHparams_dup(dhp)) == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); + goto err; + } + + s->s3->tmp.dh = dh; + if ((dhp->pub_key == NULL || + dhp->priv_key == NULL || + (s->options & SSL_OP_SINGLE_DH_USE))) { + if (!DH_generate_key(dh)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); + goto err; + } + } else { + dh->pub_key = BN_dup(dhp->pub_key); + dh->priv_key = BN_dup(dhp->priv_key); + if ((dh->pub_key == NULL) || (dh->priv_key == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_DH_LIB); + goto err; + } + } + r[0] = dh->p; + r[1] = dh->g; + r[2] = dh->pub_key; + } else +#endif +#ifndef OPENSSL_NO_EC + if (type & (SSL_kECDHE | SSL_kECDHEPSK)) { + const EC_GROUP *group; + + ecdhp = cert->ecdh_tmp; + if (s->cert->ecdh_tmp_auto) { + /* Get NID of appropriate shared curve */ + int nid = tls1_shared_curve(s, -2); + if (nid != NID_undef) + ecdhp = EC_KEY_new_by_curve_name(nid); + } else if ((ecdhp == NULL) && s->cert->ecdh_tmp_cb) { + ecdhp = s->cert->ecdh_tmp_cb(s, + SSL_C_IS_EXPORT(s->s3-> + tmp.new_cipher), + SSL_C_EXPORT_PKEYLENGTH(s-> + s3->tmp.new_cipher)); + } + if (ecdhp == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_MISSING_TMP_ECDH_KEY); + goto f_err; + } + + if (s->s3->tmp.ecdh != NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto err; + } + + /* Duplicate the ECDH structure. */ + if (ecdhp == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; + } + if (s->cert->ecdh_tmp_auto) + ecdh = ecdhp; + else if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; + } + + s->s3->tmp.ecdh = ecdh; + if ((EC_KEY_get0_public_key(ecdh) == NULL) || + (EC_KEY_get0_private_key(ecdh) == NULL) || + (s->options & SSL_OP_SINGLE_ECDH_USE)) { + if (!EC_KEY_generate_key(ecdh)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + ERR_R_ECDH_LIB); + goto err; + } + } + + if (((group = EC_KEY_get0_group(ecdh)) == NULL) || + (EC_KEY_get0_public_key(ecdh) == NULL) || + (EC_KEY_get0_private_key(ecdh) == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; + } + + if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && + (EC_GROUP_get_degree(group) > 163)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER); + goto err; + } + + /* + * XXX: For now, we only support ephemeral ECDH keys over named + * (not generic) curves. For supported named curves, curve_id is + * non-zero. + */ + if ((curve_id = + tls1_ec_nid2curve_id(EC_GROUP_get_curve_name(group))) + == 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_UNSUPPORTED_ELLIPTIC_CURVE); + goto err; + } + + /* + * Encode the public key. First check the size of encoding and + * allocate memory accordingly. + */ + encodedlen = EC_POINT_point2oct(group, + EC_KEY_get0_public_key(ecdh), + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, NULL); + + encodedPoint = (unsigned char *) + OPENSSL_malloc(encodedlen * sizeof(unsigned char)); + bn_ctx = BN_CTX_new(); + if ((encodedPoint == NULL) || (bn_ctx == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + ERR_R_MALLOC_FAILURE); + goto err; + } + + encodedlen = EC_POINT_point2oct(group, + EC_KEY_get0_public_key(ecdh), + POINT_CONVERSION_UNCOMPRESSED, + encodedPoint, encodedlen, bn_ctx); + + if (encodedlen == 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; + } + + BN_CTX_free(bn_ctx); + bn_ctx = NULL; + + /* + * XXX: For now, we only support named (not generic) curves in + * ECDH ephemeral key exchanges. In this situation, we need four + * additional bytes to encode the entire ServerECDHParams + * structure. + */ + n += 4 + encodedlen; + + /* + * We'll generate the serverKeyExchange message explicitly so we + * can set these to NULLs + */ + r[0] = NULL; + r[1] = NULL; + r[2] = NULL; + r[3] = NULL; + } else +#endif /* !OPENSSL_NO_EC */ +#ifndef OPENSSL_NO_SRP + if (type & SSL_kSRP) { + if ((s->srp_ctx.N == NULL) || + (s->srp_ctx.g == NULL) || + (s->srp_ctx.s == NULL) || (s->srp_ctx.B == NULL)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_MISSING_SRP_PARAM); + goto err; + } + r[0] = s->srp_ctx.N; + r[1] = s->srp_ctx.g; + r[2] = s->srp_ctx.s; + r[3] = s->srp_ctx.B; + } else +#endif + { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); + goto f_err; + } + for (i = 0; i < 4 && r[i] != NULL; i++) { + nr[i] = BN_num_bytes(r[i]); +#ifndef OPENSSL_NO_SRP + if ((i == 2) && (type & SSL_kSRP)) + n += 1 + nr[i]; + else +#endif + n += 2 + nr[i]; + } + + if (!(s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL|SSL_aSRP)) + && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK)) { + if ((pkey = ssl_get_sign_pkey(s, s->s3->tmp.new_cipher, &md)) + == NULL) { + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + kn = EVP_PKEY_size(pkey); + } else { + pkey = NULL; + kn = 0; + } + + if (!BUF_MEM_grow_clean(buf, n + SSL_HM_HEADER_LENGTH(s) + kn)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_LIB_BUF); + goto err; + } + d = p = ssl_handshake_start(s); + +#ifndef OPENSSL_NO_PSK + if (type & SSL_PSK) { + /* copy PSK identity hint */ + if (s->cert->psk_identity_hint) { + s2n(strlen(s->cert->psk_identity_hint), p); + strncpy((char *)p, s->cert->psk_identity_hint, + strlen(s->cert->psk_identity_hint)); + p += strlen(s->cert->psk_identity_hint); + } else { + s2n(0, p); + } + } +#endif + + for (i = 0; i < 4 && r[i] != NULL; i++) { +#ifndef OPENSSL_NO_SRP + if ((i == 2) && (type & SSL_kSRP)) { + *p = nr[i]; + p++; + } else +#endif + s2n(nr[i], p); + BN_bn2bin(r[i], p); + p += nr[i]; + } + +#ifndef OPENSSL_NO_EC + if (type & (SSL_kECDHE | SSL_kECDHEPSK)) { + /* + * XXX: For now, we only support named (not generic) curves. In + * this situation, the serverKeyExchange message has: [1 byte + * CurveType], [2 byte CurveName] [1 byte length of encoded + * point], followed by the actual encoded point itself + */ + *p = NAMED_CURVE_TYPE; + p += 1; + *p = 0; + p += 1; + *p = curve_id; + p += 1; + *p = encodedlen; + p += 1; + memcpy(p, encodedPoint, encodedlen); + OPENSSL_free(encodedPoint); + encodedPoint = NULL; + p += encodedlen; + } +#endif + + /* not anonymous */ + if (pkey != NULL) { + /* + * n is the length of the params, they start at &(d[4]) and p + * points to the space at the end. + */ +#ifndef OPENSSL_NO_RSA + if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) { + q = md_buf; + j = 0; + for (num = 2; num > 0; num--) { + EVP_MD_CTX_set_flags(&md_ctx, + EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); + EVP_DigestInit_ex(&md_ctx, (num == 2) + ? s->ctx->md5 : s->ctx->sha1, NULL); + EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]), + SSL3_RANDOM_SIZE); + EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]), + SSL3_RANDOM_SIZE); + EVP_DigestUpdate(&md_ctx, d, n); + EVP_DigestFinal_ex(&md_ctx, q, (unsigned int *)&i); + q += i; + j += i; + } + if (RSA_sign(NID_md5_sha1, md_buf, j, + &(p[2]), &u, pkey->pkey.rsa) <= 0) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_LIB_RSA); + goto err; + } + s2n(u, p); + n += u + 2; + } else +#endif + if (md) { + /* send signature algorithm */ + if (SSL_USE_SIGALGS(s)) { + if (!tls12_get_sigandhash(p, pkey, md)) { + /* Should never happen */ + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto f_err; + } + p += 2; + } +#ifdef SSL_DEBUG + fprintf(stderr, "Using hash %s\n", EVP_MD_name(md)); +#endif + EVP_SignInit_ex(&md_ctx, md, NULL); + EVP_SignUpdate(&md_ctx, &(s->s3->client_random[0]), + SSL3_RANDOM_SIZE); + EVP_SignUpdate(&md_ctx, &(s->s3->server_random[0]), + SSL3_RANDOM_SIZE); + EVP_SignUpdate(&md_ctx, d, n); + if (!EVP_SignFinal(&md_ctx, &(p[2]), + (unsigned int *)&i, pkey)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_LIB_EVP); + goto err; + } + s2n(i, p); + n += i + 2; + if (SSL_USE_SIGALGS(s)) + n += 2; + } else { + /* Is this error check actually needed? */ + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, + SSL_R_UNKNOWN_PKEY_TYPE); + goto f_err; + } + } + + if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_KEY_EXCHANGE, n)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + + EVP_MD_CTX_cleanup(&md_ctx); + return 1; + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + err: +#ifndef OPENSSL_NO_EC + OPENSSL_free(encodedPoint); + BN_CTX_free(bn_ctx); +#endif + EVP_MD_CTX_cleanup(&md_ctx); + ossl_statem_set_error(s); + return 0; +} + +int tls_construct_certificate_request(SSL *s) +{ + unsigned char *p, *d; + int i, j, nl, off, n; + STACK_OF(X509_NAME) *sk = NULL; + X509_NAME *name; + BUF_MEM *buf; + + buf = s->init_buf; + + d = p = ssl_handshake_start(s); + + /* get the list of acceptable cert types */ + p++; + n = ssl3_get_req_cert_type(s, p); + d[0] = n; + p += n; + n++; + + if (SSL_USE_SIGALGS(s)) { + const unsigned char *psigs; + unsigned char *etmp = p; + nl = tls12_get_psigalgs(s, &psigs); + /* Skip over length for now */ + p += 2; + nl = tls12_copy_sigalgs(s, p, psigs, nl); + /* Now fill in length */ + s2n(nl, etmp); + p += nl; + n += nl + 2; + } + + off = n; + p += 2; + n += 2; + + sk = SSL_get_client_CA_list(s); + nl = 0; + if (sk != NULL) { + for (i = 0; i < sk_X509_NAME_num(sk); i++) { + name = sk_X509_NAME_value(sk, i); + j = i2d_X509_NAME(name, NULL); + if (!BUF_MEM_grow_clean + (buf, SSL_HM_HEADER_LENGTH(s) + n + j + 2)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST, + ERR_R_BUF_LIB); + goto err; + } + p = ssl_handshake_start(s) + n; + s2n(j, p); + i2d_X509_NAME(name, &p); + n += 2 + j; + nl += 2 + j; + } + } + /* else no CA names */ + p = ssl_handshake_start(s) + off; + s2n(nl, p); + + if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_REQUEST, n)) { + SSLerr(SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST, ERR_R_INTERNAL_ERROR); + goto err; + } + + s->s3->tmp.cert_request = 1; + + return 1; + err: + ossl_statem_set_error(s); + return 0; +} + +MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt) +{ + int al; + unsigned int i; + unsigned long alg_k; +#ifndef OPENSSL_NO_RSA + RSA *rsa = NULL; + EVP_PKEY *pkey = NULL; +#endif +#ifndef OPENSSL_NO_DH + BIGNUM *pub = NULL; + DH *dh_srvr, *dh_clnt = NULL; +#endif +#ifndef OPENSSL_NO_EC + EC_KEY *srvr_ecdh = NULL; + EVP_PKEY *clnt_pub_pkey = NULL; + EC_POINT *clnt_ecpoint = NULL; + BN_CTX *bn_ctx = NULL; +#endif + PACKET enc_premaster; + unsigned char *data, *rsa_decrypt = NULL; + + alg_k = s->s3->tmp.new_cipher->algorithm_mkey; + +#ifndef OPENSSL_NO_PSK + /* For PSK parse and retrieve identity, obtain PSK key */ + if (alg_k & SSL_PSK) { + unsigned char psk[PSK_MAX_PSK_LEN]; + size_t psklen; + PACKET psk_identity; + + if (!PACKET_get_length_prefixed_2(pkt, &psk_identity)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + if (PACKET_remaining(&psk_identity) > PSK_MAX_IDENTITY_LEN) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_DATA_LENGTH_TOO_LONG); + goto f_err; + } + if (s->psk_server_callback == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_PSK_NO_SERVER_CB); + goto f_err; + } + + if (!PACKET_strndup(&psk_identity, &s->session->psk_identity)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + al = SSL_AD_INTERNAL_ERROR; + goto f_err; + } + + psklen = s->psk_server_callback(s, s->session->psk_identity, + psk, sizeof(psk)); + + if (psklen > PSK_MAX_PSK_LEN) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } else if (psklen == 0) { + /* + * PSK related to the given identity not found + */ + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_PSK_IDENTITY_NOT_FOUND); + al = SSL_AD_UNKNOWN_PSK_IDENTITY; + goto f_err; + } + + OPENSSL_free(s->s3->tmp.psk); + s->s3->tmp.psk = BUF_memdup(psk, psklen); + OPENSSL_cleanse(psk, psklen); + + if (s->s3->tmp.psk == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto f_err; + } + + s->s3->tmp.psklen = psklen; + } + if (alg_k & SSL_kPSK) { + /* Identity extracted earlier: should be nothing left */ + if (PACKET_remaining(pkt) != 0) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + /* PSK handled by ssl_generate_master_secret */ + if (!ssl_generate_master_secret(s, NULL, 0, 0)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_RSA + if (alg_k & (SSL_kRSA | SSL_kRSAPSK)) { + unsigned char rand_premaster_secret[SSL_MAX_MASTER_KEY_LENGTH]; + int decrypt_len; + unsigned char decrypt_good, version_good; + size_t j; + + /* FIX THIS UP EAY EAY EAY EAY */ + if (s->s3->tmp.use_rsa_tmp) { + if ((s->cert != NULL) && (s->cert->rsa_tmp != NULL)) + rsa = s->cert->rsa_tmp; + /* + * Don't do a callback because rsa_tmp should be sent already + */ + if (rsa == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_MISSING_TMP_RSA_PKEY); + goto f_err; + + } + } else { + pkey = s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey; + if ((pkey == NULL) || + (pkey->type != EVP_PKEY_RSA) || (pkey->pkey.rsa == NULL)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_MISSING_RSA_CERTIFICATE); + goto f_err; + } + rsa = pkey->pkey.rsa; + } + + /* SSLv3 and pre-standard DTLS omit the length bytes. */ + if (s->version == SSL3_VERSION || s->version == DTLS1_BAD_VER) { + enc_premaster = *pkt; + } else { + PACKET orig = *pkt; + if (!PACKET_get_length_prefixed_2(pkt, &enc_premaster) + || PACKET_remaining(pkt) != 0) { + /* Try SSLv3 behaviour for TLS. */ + if (s->options & SSL_OP_TLS_D5_BUG) { + enc_premaster = orig; + } else { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_LENGTH_MISMATCH); + goto f_err; + } + } + } + + /* + * We want to be sure that the plaintext buffer size makes it safe to + * iterate over the entire size of a premaster secret + * (SSL_MAX_MASTER_KEY_LENGTH). Reject overly short RSA keys because + * their ciphertext cannot accommodate a premaster secret anyway. + */ + if (RSA_size(rsa) < SSL_MAX_MASTER_KEY_LENGTH) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + RSA_R_KEY_SIZE_TOO_SMALL); + goto f_err; + } + + rsa_decrypt = OPENSSL_malloc(RSA_size(rsa)); + if (rsa_decrypt == NULL) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto f_err; + } + + /* + * We must not leak whether a decryption failure occurs because of + * Bleichenbacher's attack on PKCS #1 v1.5 RSA padding (see RFC 2246, + * section 7.4.7.1). The code follows that advice of the TLS RFC and + * generates a random premaster secret for the case that the decrypt + * fails. See https://tools.ietf.org/html/rfc5246#section-7.4.7.1 + */ + + if (RAND_bytes(rand_premaster_secret, + sizeof(rand_premaster_secret)) <= 0) { + goto err; + } + + decrypt_len = RSA_private_decrypt(PACKET_remaining(&enc_premaster), + PACKET_data(&enc_premaster), + rsa_decrypt, rsa, RSA_PKCS1_PADDING); + ERR_clear_error(); + + /* + * decrypt_len should be SSL_MAX_MASTER_KEY_LENGTH. decrypt_good will + * be 0xff if so and zero otherwise. + */ + decrypt_good = + constant_time_eq_int_8(decrypt_len, SSL_MAX_MASTER_KEY_LENGTH); + + /* + * If the version in the decrypted pre-master secret is correct then + * version_good will be 0xff, otherwise it'll be zero. The + * Klima-Pokorny-Rosa extension of Bleichenbacher's attack + * (http://eprint.iacr.org/2003/052/) exploits the version number + * check as a "bad version oracle". Thus version checks are done in + * constant time and are treated like any other decryption error. + */ + version_good = + constant_time_eq_8(rsa_decrypt[0], + (unsigned)(s->client_version >> 8)); + version_good &= + constant_time_eq_8(rsa_decrypt[1], + (unsigned)(s->client_version & 0xff)); + + /* + * The premaster secret must contain the same version number as the + * ClientHello to detect version rollback attacks (strangely, the + * protocol does not offer such protection for DH ciphersuites). + * However, buggy clients exist that send the negotiated protocol + * version instead if the server does not support the requested + * protocol version. If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such + * clients. + */ + if (s->options & SSL_OP_TLS_ROLLBACK_BUG) { + unsigned char workaround_good; + workaround_good = + constant_time_eq_8(rsa_decrypt[0], (unsigned)(s->version >> 8)); + workaround_good &= + constant_time_eq_8(rsa_decrypt[1], + (unsigned)(s->version & 0xff)); + version_good |= workaround_good; + } + + /* + * Both decryption and version must be good for decrypt_good to + * remain non-zero (0xff). + */ + decrypt_good &= version_good; + + /* + * Now copy rand_premaster_secret over from p using + * decrypt_good_mask. If decryption failed, then p does not + * contain valid plaintext, however, a check above guarantees + * it is still sufficiently large to read from. + */ + for (j = 0; j < sizeof(rand_premaster_secret); j++) { + rsa_decrypt[j] = + constant_time_select_8(decrypt_good, rsa_decrypt[j], + rand_premaster_secret[j]); + } + + if (!ssl_generate_master_secret(s, rsa_decrypt, + sizeof(rand_premaster_secret), 0)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + OPENSSL_free(rsa_decrypt); + rsa_decrypt = NULL; + } else +#endif +#ifndef OPENSSL_NO_DH + if (alg_k & (SSL_kDHE | SSL_kDHr | SSL_kDHd | SSL_kDHEPSK)) { + int idx = -1; + EVP_PKEY *skey = NULL; + PACKET bookmark = *pkt; + unsigned char shared[(OPENSSL_DH_MAX_MODULUS_BITS + 7) / 8]; + + if (!PACKET_get_net_2(pkt, &i)) { + if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG); + goto f_err; + } + i = 0; + } + if (PACKET_remaining(pkt) != i) { + if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG); + goto err; + } else { + *pkt = bookmark; + i = PACKET_remaining(pkt); + } + } + if (alg_k & SSL_kDHr) + idx = SSL_PKEY_DH_RSA; + else if (alg_k & SSL_kDHd) + idx = SSL_PKEY_DH_DSA; + if (idx >= 0) { + skey = s->cert->pkeys[idx].privatekey; + if ((skey == NULL) || + (skey->type != EVP_PKEY_DH) || (skey->pkey.dh == NULL)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_MISSING_RSA_CERTIFICATE); + goto f_err; + } + dh_srvr = skey->pkey.dh; + } else if (s->s3->tmp.dh == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_MISSING_TMP_DH_KEY); + goto f_err; + } else + dh_srvr = s->s3->tmp.dh; + + if (PACKET_remaining(pkt) == 0L) { + /* Get pubkey from cert */ + EVP_PKEY *clkey = X509_get_pubkey(s->session->peer); + if (clkey) { + if (EVP_PKEY_cmp_parameters(clkey, skey) == 1) + dh_clnt = EVP_PKEY_get1_DH(clkey); + } + if (dh_clnt == NULL) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_MISSING_TMP_DH_KEY); + goto f_err; + } + EVP_PKEY_free(clkey); + pub = dh_clnt->pub_key; + } else { + if (!PACKET_get_bytes(pkt, &data, i)) { + /* We already checked we have enough data */ + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + goto f_err; + } + pub = BN_bin2bn(data, i, NULL); + } + if (pub == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, SSL_R_BN_LIB); + goto err; + } + + i = DH_compute_key(shared, pub, dh_srvr); + + if (i <= 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_DH_LIB); + BN_clear_free(pub); + goto err; + } + + DH_free(s->s3->tmp.dh); + s->s3->tmp.dh = NULL; + if (dh_clnt) + DH_free(dh_clnt); + else + BN_clear_free(pub); + pub = NULL; + if (!ssl_generate_master_secret(s, shared, i, 0)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + if (dh_clnt) { + s->statem.no_cert_verify = 1; + return MSG_PROCESS_CONTINUE_PROCESSING; + } + } else +#endif + +#ifndef OPENSSL_NO_EC + if (alg_k & (SSL_kECDHE | SSL_kECDHr | SSL_kECDHe | SSL_kECDHEPSK)) { + int field_size = 0; + const EC_KEY *tkey; + const EC_GROUP *group; + const BIGNUM *priv_key; + unsigned char *shared; + + /* initialize structures for server's ECDH key pair */ + if ((srvr_ecdh = EC_KEY_new()) == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* Let's get server private key and group information */ + if (alg_k & (SSL_kECDHr | SSL_kECDHe)) { + /* use the certificate */ + tkey = s->cert->pkeys[SSL_PKEY_ECC].privatekey->pkey.ec; + } else { + /* + * use the ephermeral values we saved when generating the + * ServerKeyExchange msg. + */ + tkey = s->s3->tmp.ecdh; + } + + group = EC_KEY_get0_group(tkey); + priv_key = EC_KEY_get0_private_key(tkey); + + if (!EC_KEY_set_group(srvr_ecdh, group) || + !EC_KEY_set_private_key(srvr_ecdh, priv_key)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); + goto err; + } + + /* Let's get client's public key */ + if ((clnt_ecpoint = EC_POINT_new(group)) == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto err; + } + + if (PACKET_remaining(pkt) == 0L) { + /* Client Publickey was in Client Certificate */ + + if (alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_MISSING_TMP_ECDH_KEY); + goto f_err; + } + if (((clnt_pub_pkey = X509_get_pubkey(s->session->peer)) + == NULL) || (clnt_pub_pkey->type != EVP_PKEY_EC)) { + /* + * XXX: For now, we do not support client authentication + * using ECDH certificates so this branch (n == 0L) of the + * code is never executed. When that support is added, we + * ought to ensure the key received in the certificate is + * authorized for key agreement. ECDH_compute_key implicitly + * checks that the two ECDH shares are for the same group. + */ + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_UNABLE_TO_DECODE_ECDH_CERTS); + goto f_err; + } + + if (EC_POINT_copy(clnt_ecpoint, + EC_KEY_get0_public_key(clnt_pub_pkey-> + pkey.ec)) == 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); + goto err; + } + s->statem.no_cert_verify = 1; + } else { + /* + * Get client's public key from encoded point in the + * ClientKeyExchange message. + */ + if ((bn_ctx = BN_CTX_new()) == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + ERR_R_MALLOC_FAILURE); + goto err; + } + + /* Get encoded point length */ + if (!PACKET_get_1(pkt, &i)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_LENGTH_MISMATCH); + goto f_err; + } + if (!PACKET_get_bytes(pkt, &data, i) + || PACKET_remaining(pkt) != 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); + goto err; + } + if (EC_POINT_oct2point(group, clnt_ecpoint, data, i, bn_ctx) == 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_EC_LIB); + goto err; + } + } + + /* Compute the shared pre-master secret */ + field_size = EC_GROUP_get_degree(group); + if (field_size <= 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); + goto err; + } + shared = OPENSSL_malloc((field_size + 7) / 8); + if (shared == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto err; + } + i = ECDH_compute_key(shared, (field_size + 7) / 8, clnt_ecpoint, + srvr_ecdh, NULL); + if (i <= 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_ECDH_LIB); + OPENSSL_free(shared); + goto err; + } + + EVP_PKEY_free(clnt_pub_pkey); + EC_POINT_free(clnt_ecpoint); + EC_KEY_free(srvr_ecdh); + BN_CTX_free(bn_ctx); + EC_KEY_free(s->s3->tmp.ecdh); + s->s3->tmp.ecdh = NULL; + + if (!ssl_generate_master_secret(s, shared, i, 1)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + return MSG_PROCESS_CONTINUE_PROCESSING; + } else +#endif +#ifndef OPENSSL_NO_SRP + if (alg_k & SSL_kSRP) { + if (!PACKET_get_net_2(pkt, &i) + || !PACKET_get_bytes(pkt, &data, i)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, SSL_R_BAD_SRP_A_LENGTH); + goto f_err; + } + if ((s->srp_ctx.A = BN_bin2bn(data, i, NULL)) == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_BN_LIB); + goto err; + } + if (BN_ucmp(s->srp_ctx.A, s->srp_ctx.N) >= 0 + || BN_is_zero(s->srp_ctx.A)) { + al = SSL_AD_ILLEGAL_PARAMETER; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_BAD_SRP_PARAMETERS); + goto f_err; + } + OPENSSL_free(s->session->srp_username); + s->session->srp_username = BUF_strdup(s->srp_ctx.login); + if (s->session->srp_username == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE); + goto err; + } + + if (!srp_generate_server_master_secret(s)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto err; + } + } else +#endif /* OPENSSL_NO_SRP */ + if (alg_k & SSL_kGOST) { + EVP_PKEY_CTX *pkey_ctx; + EVP_PKEY *client_pub_pkey = NULL, *pk = NULL; + unsigned char premaster_secret[32], *start; + size_t outlen = 32, inlen; + unsigned long alg_a; + int Ttag, Tclass; + long Tlen; + long sess_key_len; + + /* Get our certificate private key */ + alg_a = s->s3->tmp.new_cipher->algorithm_auth; + if (alg_a & SSL_aGOST01) + pk = s->cert->pkeys[SSL_PKEY_GOST01].privatekey; + + pkey_ctx = EVP_PKEY_CTX_new(pk, NULL); + EVP_PKEY_decrypt_init(pkey_ctx); + /* + * If client certificate is present and is of the same type, maybe + * use it for key exchange. Don't mind errors from + * EVP_PKEY_derive_set_peer, because it is completely valid to use a + * client certificate for authorization only. + */ + client_pub_pkey = X509_get_pubkey(s->session->peer); + if (client_pub_pkey) { + if (EVP_PKEY_derive_set_peer(pkey_ctx, client_pub_pkey) <= 0) + ERR_clear_error(); + } + /* Decrypt session key */ + sess_key_len = PACKET_remaining(pkt); + if (!PACKET_get_bytes(pkt, &data, sess_key_len)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + if (ASN1_get_object ((const unsigned char **)&data, &Tlen, &Ttag, + &Tclass, sess_key_len) != V_ASN1_CONSTRUCTED + || Ttag != V_ASN1_SEQUENCE + || Tclass != V_ASN1_UNIVERSAL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_DECRYPTION_FAILED); + goto gerr; + } + start = data; + inlen = Tlen; + if (EVP_PKEY_decrypt + (pkey_ctx, premaster_secret, &outlen, start, inlen) <= 0) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, + SSL_R_DECRYPTION_FAILED); + goto gerr; + } + /* Generate master secret */ + if (!ssl_generate_master_secret(s, premaster_secret, + sizeof(premaster_secret), 0)) { + al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); + goto f_err; + } + /* Check if pubkey from client certificate was used */ + if (EVP_PKEY_CTX_ctrl + (pkey_ctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 2, NULL) > 0) + s->statem.no_cert_verify = 1; + + EVP_PKEY_free(client_pub_pkey); + EVP_PKEY_CTX_free(pkey_ctx); + return MSG_PROCESS_CONTINUE_PROCESSING; + gerr: + EVP_PKEY_free(client_pub_pkey); + EVP_PKEY_CTX_free(pkey_ctx); + goto err; + } else { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, SSL_R_UNKNOWN_CIPHER_TYPE); + goto f_err; + } + + return MSG_PROCESS_CONTINUE_PROCESSING; + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_SRP) + err: +#endif +#ifndef OPENSSL_NO_EC + EVP_PKEY_free(clnt_pub_pkey); + EC_POINT_free(clnt_ecpoint); + EC_KEY_free(srvr_ecdh); + BN_CTX_free(bn_ctx); + OPENSSL_free(rsa_decrypt); +#endif +#ifndef OPENSSL_NO_PSK + OPENSSL_clear_free(s->s3->tmp.psk, s->s3->tmp.psklen); + s->s3->tmp.psk = NULL; +#endif + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; +} + +WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst) +{ +#ifndef OPENSSL_NO_SCTP + if (wst == WORK_MORE_A) { + if (SSL_IS_DTLS(s)) { + unsigned char sctpauthkey[64]; + char labelbuffer[sizeof(DTLS1_SCTP_AUTH_LABEL)]; + /* + * Add new shared key for SCTP-Auth, will be ignored if no SCTP + * used. + */ + memcpy(labelbuffer, DTLS1_SCTP_AUTH_LABEL, + sizeof(DTLS1_SCTP_AUTH_LABEL)); + + if (SSL_export_keying_material(s, sctpauthkey, + sizeof(sctpauthkey), labelbuffer, + sizeof(labelbuffer), NULL, 0, 0) <= 0) { + ossl_statem_set_error(s); + return WORK_ERROR;; + } + + BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY, + sizeof(sctpauthkey), sctpauthkey); + } + wst = WORK_MORE_B; + } + + if ((wst == WORK_MORE_B) + /* Is this SCTP? */ + && BIO_dgram_is_sctp(SSL_get_wbio(s)) + /* Are we renegotiating? */ + && s->renegotiate + /* Are we going to skip the CertificateVerify? */ + && (s->session->peer == NULL || s->statem.no_cert_verify) + && BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) { + s->s3->in_read_app_data = 2; + s->rwstate = SSL_READING; + BIO_clear_retry_flags(SSL_get_rbio(s)); + BIO_set_retry_read(SSL_get_rbio(s)); + statem_set_sctp_read_sock(s, 1); + return WORK_MORE_B; + } else { + ossl_statem_set_sctp_read_sock(s, 0); + } +#endif + + if (s->statem.no_cert_verify) { + /* No certificate verify so we no longer need the handshake_buffer */ + BIO_free(s->s3->handshake_buffer); + return WORK_FINISHED_CONTINUE; + } else if (SSL_USE_SIGALGS(s)) { + if (!s->session->peer) { + /* No peer certificate so we no longer need the handshake_buffer */ + BIO_free(s->s3->handshake_buffer); + return WORK_FINISHED_CONTINUE; + } + if (!s->s3->handshake_buffer) { + SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE, + ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return WORK_ERROR; + } + /* + * For sigalgs freeze the handshake buffer. If we support + * extms we've done this already so this is a no-op + */ + if (!ssl3_digest_cached_records(s, 1)) { + ossl_statem_set_error(s); + return WORK_ERROR; + } + } else { + int offset = 0; + int dgst_num; + + /* + * We need to get hashes here so if there is a client cert, + * it can be verified FIXME - digest processing for + * CertificateVerify should be generalized. But it is next + * step + */ + if (!ssl3_digest_cached_records(s, 0)) { + ossl_statem_set_error(s); + return WORK_ERROR; + } + for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) { + if (s->s3->handshake_dgst[dgst_num]) { + int dgst_size; + + s->method->ssl3_enc->cert_verify_mac(s, + EVP_MD_CTX_type + (s-> + s3->handshake_dgst + [dgst_num]), + &(s->s3-> + tmp.cert_verify_md + [offset])); + dgst_size = + EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); + if (dgst_size < 0) { + ossl_statem_set_error(s); + return WORK_ERROR; + } + offset += dgst_size; + } + } + } + + return WORK_FINISHED_CONTINUE; +} + +MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt) +{ + EVP_PKEY *pkey = NULL; + unsigned char *sig, *data; + int al, ret = MSG_PROCESS_ERROR; + int type = 0, i, j; + unsigned int len; + X509 *peer; + const EVP_MD *md = NULL; + EVP_MD_CTX mctx; + EVP_MD_CTX_init(&mctx); + + peer = s->session->peer; + pkey = X509_get_pubkey(peer); + type = X509_certificate_type(peer, pkey); + + if (!(type & EVP_PKT_SIGN)) { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, + SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE); + al = SSL_AD_ILLEGAL_PARAMETER; + goto f_err; + } + + /* Check for broken implementations of GOST ciphersuites */ + /* + * If key is GOST and n is exactly 64, it is bare signature without + * length field + */ + if (PACKET_remaining(pkt) == 64 && pkey->type == NID_id_GostR3410_2001) { + len = 64; + } else { + if (SSL_USE_SIGALGS(s)) { + int rv; + + if (!PACKET_get_bytes(pkt, &sig, 2)) { + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + rv = tls12_check_peer_sigalg(&md, s, sig, pkey); + if (rv == -1) { + al = SSL_AD_INTERNAL_ERROR; + goto f_err; + } else if (rv == 0) { + al = SSL_AD_DECODE_ERROR; + goto f_err; + } +#ifdef SSL_DEBUG + fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); +#endif + } + if (!PACKET_get_net_2(pkt, &len)) { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_LENGTH_MISMATCH); + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + } + j = EVP_PKEY_size(pkey); + if (((int)len > j) || ((int)PACKET_remaining(pkt) > j) + || (PACKET_remaining(pkt) == 0)) { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_SIZE); + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + if (!PACKET_get_bytes(pkt, &data, len)) { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_LENGTH_MISMATCH); + al = SSL_AD_DECODE_ERROR; + goto f_err; + } + + if (SSL_USE_SIGALGS(s)) { + long hdatalen = 0; + void *hdata; + hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); + if (hdatalen <= 0) { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_INTERNAL_ERROR); + al = SSL_AD_INTERNAL_ERROR; + goto f_err; + } +#ifdef SSL_DEBUG + fprintf(stderr, "Using TLS 1.2 with client verify alg %s\n", + EVP_MD_name(md)); +#endif + if (!EVP_VerifyInit_ex(&mctx, md, NULL) + || !EVP_VerifyUpdate(&mctx, hdata, hdatalen)) { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB); + al = SSL_AD_INTERNAL_ERROR; + goto f_err; + } + + if (EVP_VerifyFinal(&mctx, data, len, pkey) <= 0) { + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_SIGNATURE); + goto f_err; + } + } else +#ifndef OPENSSL_NO_RSA + if (pkey->type == EVP_PKEY_RSA) { + i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, + MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, data, len, + pkey->pkey.rsa); + if (i < 0) { + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_RSA_DECRYPT); + goto f_err; + } + if (i == 0) { + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_RSA_SIGNATURE); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_DSA + if (pkey->type == EVP_PKEY_DSA) { + j = DSA_verify(pkey->save_type, + &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), + SHA_DIGEST_LENGTH, data, len, pkey->pkey.dsa); + if (j <= 0) { + /* bad signature */ + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_DSA_SIGNATURE); + goto f_err; + } + } else +#endif +#ifndef OPENSSL_NO_EC + if (pkey->type == EVP_PKEY_EC) { + j = ECDSA_verify(pkey->save_type, + &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), + SHA_DIGEST_LENGTH, data, len, pkey->pkey.ec); + if (j <= 0) { + /* bad signature */ + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); + goto f_err; + } + } else +#endif + if (pkey->type == NID_id_GostR3410_2001) { + unsigned char signature[64]; + int idx; + EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(pkey, NULL); + EVP_PKEY_verify_init(pctx); + if (len != 64) { + fprintf(stderr, "GOST signature length is %d", len); + } + for (idx = 0; idx < 64; idx++) { + signature[63 - idx] = data[idx]; + } + j = EVP_PKEY_verify(pctx, signature, 64, s->s3->tmp.cert_verify_md, + 32); + EVP_PKEY_CTX_free(pctx); + if (j <= 0) { + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); + goto f_err; + } + } else { + SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_INTERNAL_ERROR); + al = SSL_AD_UNSUPPORTED_CERTIFICATE; + goto f_err; + } + + ret = MSG_PROCESS_CONTINUE_PROCESSING; + if (0) { + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + ossl_statem_set_error(s); + } + BIO_free(s->s3->handshake_buffer); + s->s3->handshake_buffer = NULL; + EVP_MD_CTX_cleanup(&mctx); + EVP_PKEY_free(pkey); + return ret; +} + +MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt) +{ + int i, al = SSL_AD_INTERNAL_ERROR, ret = MSG_PROCESS_ERROR; + X509 *x = NULL; + unsigned long l, llen; + const unsigned char *certstart; + unsigned char *certbytes; + STACK_OF(X509) *sk = NULL; + PACKET spkt; + + if ((sk = sk_X509_new_null()) == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); + goto f_err; + } + + if (!PACKET_get_net_3(pkt, &llen) + || !PACKET_get_sub_packet(pkt, &spkt, llen) + || PACKET_remaining(pkt) != 0) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, SSL_R_LENGTH_MISMATCH); + goto f_err; + } + + while (PACKET_remaining(&spkt) > 0) { + if (!PACKET_get_net_3(&spkt, &l) + || !PACKET_get_bytes(&spkt, &certbytes, l)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, + SSL_R_CERT_LENGTH_MISMATCH); + goto f_err; + } + + certstart = certbytes; + x = d2i_X509(NULL, (const unsigned char **)&certbytes, l); + if (x == NULL) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, ERR_R_ASN1_LIB); + goto f_err; + } + if (certbytes != (certstart + l)) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, + SSL_R_CERT_LENGTH_MISMATCH); + goto f_err; + } + if (!sk_X509_push(sk, x)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); + goto f_err; + } + x = NULL; + } + + if (sk_X509_num(sk) <= 0) { + /* TLS does not mind 0 certs returned */ + if (s->version == SSL3_VERSION) { + al = SSL_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, + SSL_R_NO_CERTIFICATES_RETURNED); + goto f_err; + } + /* Fail for TLS only if we required a certificate */ + else if ((s->verify_mode & SSL_VERIFY_PEER) && + (s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, + SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE); + al = SSL_AD_HANDSHAKE_FAILURE; + goto f_err; + } + /* No client certificate so digest cached records */ + if (s->s3->handshake_buffer && !ssl3_digest_cached_records(s, 0)) { + goto f_err; + } + } else { + EVP_PKEY *pkey; + i = ssl_verify_cert_chain(s, sk); + if (i <= 0) { + al = ssl_verify_alarm_type(s->verify_result); + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, + SSL_R_CERTIFICATE_VERIFY_FAILED); + goto f_err; + } + if (i > 1) { + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, i); + al = SSL_AD_HANDSHAKE_FAILURE; + goto f_err; + } + pkey = X509_get_pubkey(sk_X509_value(sk, 0)); + if (pkey == NULL) { + al = SSL3_AD_HANDSHAKE_FAILURE; + SSLerr(SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE, + SSL_R_UNKNOWN_CERTIFICATE_TYPE); + goto f_err; + } + EVP_PKEY_free(pkey); + } + + X509_free(s->session->peer); + s->session->peer = sk_X509_shift(sk); + s->session->verify_result = s->verify_result; + + sk_X509_pop_free(s->session->peer_chain, X509_free); + s->session->peer_chain = sk; + /* + * Inconsistency alert: cert_chain does *not* include the peer's own + * certificate, while we do include it in s3_clnt.c + */ + sk = NULL; + ret = MSG_PROCESS_CONTINUE_READING; + goto done; + + f_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + ossl_statem_set_error(s); + done: + X509_free(x); + sk_X509_pop_free(sk, X509_free); + return ret; +} + +int tls_construct_server_certificate(SSL *s) +{ + CERT_PKEY *cpk; + + cpk = ssl_get_server_send_pkey(s); + if (cpk == NULL) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + + if (!ssl3_output_cert_chain(s, cpk)) { + SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE, ERR_R_INTERNAL_ERROR); + ossl_statem_set_error(s); + return 0; + } + + return 1; +} + +int tls_construct_new_session_ticket(SSL *s) +{ + unsigned char *senc = NULL; + EVP_CIPHER_CTX ctx; + HMAC_CTX hctx; + unsigned char *p, *macstart; + const unsigned char *const_p; + int len, slen_full, slen; + SSL_SESSION *sess; + unsigned int hlen; + SSL_CTX *tctx = s->initial_ctx; + unsigned char iv[EVP_MAX_IV_LENGTH]; + unsigned char key_name[16]; + + /* get session encoding length */ + slen_full = i2d_SSL_SESSION(s->session, NULL); + /* + * Some length values are 16 bits, so forget it if session is too + * long + */ + if (slen_full == 0 || slen_full > 0xFF00) { + ossl_statem_set_error(s); + return 0; + } + senc = OPENSSL_malloc(slen_full); + if (!senc) { + ossl_statem_set_error(s); + return 0; + } + + EVP_CIPHER_CTX_init(&ctx); + HMAC_CTX_init(&hctx); + + p = senc; + if (!i2d_SSL_SESSION(s->session, &p)) + goto err; + + /* + * create a fresh copy (not shared with other threads) to clean up + */ + const_p = senc; + sess = d2i_SSL_SESSION(NULL, &const_p, slen_full); + if (sess == NULL) + goto err; + sess->session_id_length = 0; /* ID is irrelevant for the ticket */ + + slen = i2d_SSL_SESSION(sess, NULL); + if (slen == 0 || slen > slen_full) { /* shouldn't ever happen */ + SSL_SESSION_free(sess); + goto err; + } + p = senc; + if (!i2d_SSL_SESSION(sess, &p)) { + SSL_SESSION_free(sess); + goto err; + } + SSL_SESSION_free(sess); + + /*- + * Grow buffer if need be: the length calculation is as + * follows handshake_header_length + + * 4 (ticket lifetime hint) + 2 (ticket length) + + * 16 (key name) + max_iv_len (iv length) + + * session_length + max_enc_block_size (max encrypted session + * length) + max_md_size (HMAC). + */ + if (!BUF_MEM_grow(s->init_buf, + SSL_HM_HEADER_LENGTH(s) + 22 + EVP_MAX_IV_LENGTH + + EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + slen)) + goto err; + + p = ssl_handshake_start(s); + /* + * Initialize HMAC and cipher contexts. If callback present it does + * all the work otherwise use generated values from parent ctx. + */ + if (tctx->tlsext_ticket_key_cb) { + if (tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx, + &hctx, 1) < 0) + goto err; + } else { + if (RAND_bytes(iv, 16) <= 0) + goto err; + if (!EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, + tctx->tlsext_tick_aes_key, iv)) + goto err; + if (!HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, + EVP_sha256(), NULL)) + goto err; + memcpy(key_name, tctx->tlsext_tick_key_name, 16); + } + + /* + * Ticket lifetime hint (advisory only): We leave this unspecified + * for resumed session (for simplicity), and guess that tickets for + * new sessions will live as long as their sessions. + */ + l2n(s->hit ? 0 : s->session->timeout, p); + + /* Skip ticket length for now */ + p += 2; + /* Output key name */ + macstart = p; + memcpy(p, key_name, 16); + p += 16; + /* output IV */ + memcpy(p, iv, EVP_CIPHER_CTX_iv_length(&ctx)); + p += EVP_CIPHER_CTX_iv_length(&ctx); + /* Encrypt session data */ + if (!EVP_EncryptUpdate(&ctx, p, &len, senc, slen)) + goto err; + p += len; + if (!EVP_EncryptFinal(&ctx, p, &len)) + goto err; + p += len; + + if (!HMAC_Update(&hctx, macstart, p - macstart)) + goto err; + if (!HMAC_Final(&hctx, p, &hlen)) + goto err; + + EVP_CIPHER_CTX_cleanup(&ctx); + HMAC_CTX_cleanup(&hctx); + + p += hlen; + /* Now write out lengths: p points to end of data written */ + /* Total length */ + len = p - ssl_handshake_start(s); + /* Skip ticket lifetime hint */ + p = ssl_handshake_start(s) + 4; + s2n(len - 6, p); + if (!ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len)) + goto err; + OPENSSL_free(senc); + + return 1; + err: + OPENSSL_free(senc); + EVP_CIPHER_CTX_cleanup(&ctx); + HMAC_CTX_cleanup(&hctx); + ossl_statem_set_error(s); + return 0; +} + +int tls_construct_cert_status(SSL *s) +{ + unsigned char *p; + /*- + * Grow buffer if need be: the length calculation is as + * follows 1 (message type) + 3 (message length) + + * 1 (ocsp response type) + 3 (ocsp response length) + * + (ocsp response) + */ + if (!BUF_MEM_grow(s->init_buf, 8 + s->tlsext_ocsp_resplen)) { + ossl_statem_set_error(s); + return 0; + } + + p = (unsigned char *)s->init_buf->data; + + /* do the header */ + *(p++) = SSL3_MT_CERTIFICATE_STATUS; + /* message length */ + l2n3(s->tlsext_ocsp_resplen + 4, p); + /* status type */ + *(p++) = s->tlsext_status_type; + /* length of OCSP response */ + l2n3(s->tlsext_ocsp_resplen, p); + /* actual response */ + memcpy(p, s->tlsext_ocsp_resp, s->tlsext_ocsp_resplen); + /* number of bytes to write */ + s->init_num = 8 + s->tlsext_ocsp_resplen; + s->init_off = 0; + + return 1; +} + +#ifndef OPENSSL_NO_NEXTPROTONEG +/* + * tls_process_next_proto reads a Next Protocol Negotiation handshake message. + * It sets the next_proto member in s if found + */ +MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt) +{ + PACKET next_proto, padding; + size_t next_proto_len; + + /*- + * The payload looks like: + * uint8 proto_len; + * uint8 proto[proto_len]; + * uint8 padding_len; + * uint8 padding[padding_len]; + */ + if (!PACKET_get_length_prefixed_1(pkt, &next_proto) + || !PACKET_get_length_prefixed_1(pkt, &padding) + || PACKET_remaining(pkt) > 0) { + SSLerr(SSL_F_TLS_PROCESS_NEXT_PROTO, SSL_R_LENGTH_MISMATCH); + goto err; + } + + if (!PACKET_memdup(&next_proto, &s->next_proto_negotiated, + &next_proto_len)) { + s->next_proto_negotiated_len = 0; + goto err; + } + + s->next_proto_negotiated_len = (unsigned char)next_proto_len; + + return MSG_PROCESS_CONTINUE_READING; +err: + ossl_statem_set_error(s); + return MSG_PROCESS_ERROR; +} +#endif + +#define SSLV2_CIPHER_LEN 3 + +STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, + PACKET *cipher_suites, + STACK_OF(SSL_CIPHER) **skp, + int sslv2format, int *al + ) +{ + const SSL_CIPHER *c; + STACK_OF(SSL_CIPHER) *sk; + int n; + /* 3 = SSLV2_CIPHER_LEN > TLS_CIPHER_LEN = 2. */ + unsigned char cipher[SSLV2_CIPHER_LEN]; + + s->s3->send_connection_binding = 0; + + n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN; + + if (PACKET_remaining(cipher_suites) == 0) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED); + *al = SSL_AD_ILLEGAL_PARAMETER; + return NULL; + } + + if (PACKET_remaining(cipher_suites) % n != 0) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, + SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); + *al = SSL_AD_DECODE_ERROR; + return NULL; + } + + if ((skp == NULL) || (*skp == NULL)) { + sk = sk_SSL_CIPHER_new_null(); /* change perhaps later */ + if(sk == NULL) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); + *al = SSL_AD_INTERNAL_ERROR; + return NULL; + } + } else { + sk = *skp; + sk_SSL_CIPHER_zero(sk); + } + + if (!PACKET_memdup(cipher_suites, &s->s3->tmp.ciphers_raw, + &s->s3->tmp.ciphers_rawlen)) { + *al = SSL_AD_INTERNAL_ERROR; + goto err; + } + + while (PACKET_copy_bytes(cipher_suites, cipher, n)) { + /* + * SSLv3 ciphers wrapped in an SSLv2-compatible ClientHello have the + * first byte set to zero, while true SSLv2 ciphers have a non-zero + * first byte. We don't support any true SSLv2 ciphers, so skip them. + */ + if (sslv2format && cipher[0] != '\0') + continue; + + /* Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV */ + if ((cipher[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && + (cipher[n - 1] == (SSL3_CK_SCSV & 0xff))) { + /* SCSV fatal if renegotiating */ + if (s->renegotiate) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, + SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING); + *al = SSL_AD_HANDSHAKE_FAILURE; + goto err; + } + s->s3->send_connection_binding = 1; +#ifdef OPENSSL_RI_DEBUG + fprintf(stderr, "SCSV received by server\n"); +#endif + continue; + } + + /* Check for TLS_FALLBACK_SCSV */ + if ((cipher[n - 2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) && + (cipher[n - 1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) { + /* + * The SCSV indicates that the client previously tried a higher + * version. Fail if the current version is an unexpected + * downgrade. + */ + if (!SSL_ctrl(s, SSL_CTRL_CHECK_PROTO_VERSION, 0, NULL)) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, + SSL_R_INAPPROPRIATE_FALLBACK); + *al = SSL_AD_INAPPROPRIATE_FALLBACK; + goto err; + } + continue; + } + + /* For SSLv2-compat, ignore leading 0-byte. */ + c = ssl_get_cipher_by_char(s, sslv2format ? &cipher[1] : cipher); + if (c != NULL) { + if (!sk_SSL_CIPHER_push(sk, c)) { + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); + *al = SSL_AD_INTERNAL_ERROR; + goto err; + } + } + } + if (PACKET_remaining(cipher_suites) > 0) { + *al = SSL_AD_INTERNAL_ERROR; + SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_INTERNAL_ERROR); + goto err; + } + + if (skp != NULL) + *skp = sk; + return (sk); + err: + if ((skp == NULL) || (*skp == NULL)) + sk_SSL_CIPHER_free(sk); + return NULL; +} diff --git a/ssl/t1_clnt.c b/ssl/t1_clnt.c deleted file mode 100644 index 9e117e9..0000000 --- a/ssl/t1_clnt.c +++ /dev/null @@ -1,107 +0,0 @@ -/* ssl/t1_clnt.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include "ssl_locl.h" -#include -#include -#include -#include - -static const SSL_METHOD *tls1_get_client_method(int ver); -static const SSL_METHOD *tls1_get_client_method(int ver) -{ - if (ver == TLS_ANY_VERSION) - return TLS_client_method(); - if (ver == TLS1_2_VERSION) - return TLSv1_2_client_method(); - if (ver == TLS1_1_VERSION) - return TLSv1_1_client_method(); - if (ver == TLS1_VERSION) - return TLSv1_client_method(); -#ifndef OPENSSL_NO_SSL3 - if (ver == SSL3_VERSION) - return (SSLv3_client_method()); -#endif - return NULL; -} - -IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, TLS_client_method, - ssl_undefined_function, - ssl3_connect, - tls1_get_client_method, TLSv1_2_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_2_VERSION, TLSv1_2_client_method, - ssl_undefined_function, - ssl3_connect, - tls1_get_client_method, TLSv1_2_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_1_VERSION, TLSv1_1_client_method, - ssl_undefined_function, - ssl3_connect, - tls1_get_client_method, TLSv1_1_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_VERSION, TLSv1_client_method, - ssl_undefined_function, - ssl3_connect, tls1_get_client_method, TLSv1_enc_data) - -#ifndef OPENSSL_NO_SSL3_METHOD -IMPLEMENT_ssl3_meth_func(SSLv3_client_method, - ssl_undefined_function, - ssl3_connect, tls1_get_client_method) -#endif diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 6446623..f42fb64 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -3680,7 +3680,7 @@ int tls1_heartbeat(SSL *s) } /* ...and no handshake in progress. */ - if (SSL_in_init(s) || s->in_handshake) { + if (SSL_in_init(s) || ossl_statem_get_in_handshake(s)) { SSLerr(SSL_F_TLS1_HEARTBEAT, SSL_R_UNEXPECTED_MESSAGE); return -1; } diff --git a/ssl/t1_meth.c b/ssl/t1_meth.c deleted file mode 100644 index aa16d3f..0000000 --- a/ssl/t1_meth.c +++ /dev/null @@ -1,100 +0,0 @@ -/* ssl/t1_meth.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include -#include "ssl_locl.h" - -static const SSL_METHOD *tls1_get_method(int ver) -{ - if (ver == TLS_ANY_VERSION) - return TLS_method(); - if (ver == TLS1_2_VERSION) - return TLSv1_2_method(); - if (ver == TLS1_1_VERSION) - return TLSv1_1_method(); - if (ver == TLS1_VERSION) - return TLSv1_method(); -#ifndef OPENSSL_NO_SSL3 - if (ver == SSL3_VERSION) - return (SSLv3_method()); - else -#endif - return NULL; -} - -IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, TLS_method, - ssl3_accept, - ssl3_connect, tls1_get_method, TLSv1_2_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_2_VERSION, TLSv1_2_method, - ssl3_accept, - ssl3_connect, tls1_get_method, TLSv1_2_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_1_VERSION, TLSv1_1_method, - ssl3_accept, - ssl3_connect, tls1_get_method, TLSv1_1_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_VERSION, TLSv1_method, - ssl3_accept, - ssl3_connect, tls1_get_method, TLSv1_enc_data) - -#ifndef OPENSSL_NO_SSL3_METHOD -IMPLEMENT_ssl3_meth_func(SSLv3_method, - ssl3_accept, ssl3_connect, tls1_get_method) -#endif diff --git a/ssl/t1_srvr.c b/ssl/t1_srvr.c deleted file mode 100644 index 6e54b51..0000000 --- a/ssl/t1_srvr.c +++ /dev/null @@ -1,109 +0,0 @@ -/* ssl/t1_srvr.c */ -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay at cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh at cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay at cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh at cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include "ssl_locl.h" -#include -#include -#include -#include -#include - -static const SSL_METHOD *tls1_get_server_method(int ver); -static const SSL_METHOD *tls1_get_server_method(int ver) -{ - if (ver == TLS_ANY_VERSION) - return TLS_server_method(); - if (ver == TLS1_2_VERSION) - return TLSv1_2_server_method(); - if (ver == TLS1_1_VERSION) - return TLSv1_1_server_method(); - if (ver == TLS1_VERSION) - return TLSv1_server_method(); -#ifndef OPENSSL_NO_SSL3 - if (ver == SSL3_VERSION) - return (SSLv3_server_method()); -#endif - return NULL; -} - -IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, TLS_server_method, - ssl3_accept, - ssl_undefined_function, - tls1_get_server_method, TLSv1_2_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_2_VERSION, TLSv1_2_server_method, - ssl3_accept, - ssl_undefined_function, - tls1_get_server_method, TLSv1_2_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_1_VERSION, TLSv1_1_server_method, - ssl3_accept, - ssl_undefined_function, - tls1_get_server_method, TLSv1_1_enc_data) - -IMPLEMENT_tls_meth_func(TLS1_VERSION, TLSv1_server_method, - ssl3_accept, - ssl_undefined_function, - tls1_get_server_method, TLSv1_enc_data) - -#ifndef OPENSSL_NO_SSL3_METHOD -IMPLEMENT_ssl3_meth_func(SSLv3_server_method, - ssl3_accept, - ssl_undefined_function, tls1_get_server_method) -#endif diff --git a/test/Makefile b/test/Makefile index 6f32758..ffeba40 100644 --- a/test/Makefile +++ b/test/Makefile @@ -559,7 +559,7 @@ heartbeat_test.o: ../include/openssl/ssl3.h ../include/openssl/stack.h heartbeat_test.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h heartbeat_test.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h heartbeat_test.o: ../ssl/packet_locl.h ../ssl/record/record.h ../ssl/ssl_locl.h -heartbeat_test.o: heartbeat_test.c testutil.h +heartbeat_test.o: ../ssl/statem/statem.h heartbeat_test.c testutil.h hmactest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h hmactest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h hmactest.o: ../include/openssl/evp.h ../include/openssl/hmac.h @@ -681,7 +681,8 @@ ssltest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h ssltest.o: ../include/openssl/x509v3.h ../ssl/packet_locl.h -ssltest.o: ../ssl/record/record.h ../ssl/ssl_locl.h ssltest.c +ssltest.o: ../ssl/record/record.h ../ssl/ssl_locl.h ../ssl/statem/statem.h +ssltest.o: ssltest.c testutil.o: ../e_os.h ../include/openssl/e_os2.h testutil.o: ../include/openssl/opensslconf.h testutil.c testutil.h v3nametest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h diff --git a/util/ssleay.num b/util/ssleay.num index 4c8a783..b3f6324 100755 --- a/util/ssleay.num +++ b/util/ssleay.num @@ -145,7 +145,7 @@ SSL_set_shutdown 162 EXIST::FUNCTION: SSL_set_verify_result 163 EXIST::FUNCTION: SSL_version 164 EXIST::FUNCTION: SSL_get_info_callback 165 EXIST::FUNCTION: -SSL_state 166 EXIST::FUNCTION: +SSL_state 166 NOEXIST::FUNCTION: SSL_CTX_get_ex_new_index 167 EXIST::FUNCTION: SSL_SESSION_get_ex_new_index 168 EXIST::FUNCTION: SSL_get_ex_new_index 169 EXIST::FUNCTION: @@ -304,7 +304,7 @@ SSL_cache_hit 344 EXIST::FUNCTION: SSL_get0_kssl_ctx 345 NOEXIST::FUNCTION: SSL_set0_kssl_ctx 346 NOEXIST::FUNCTION: SSL_SESSION_get0_id 347 NOEXIST::FUNCTION: -SSL_set_state 348 EXIST::FUNCTION: +SSL_set_state 348 NOEXIST::FUNCTION: SSL_CIPHER_get_id 349 EXIST::FUNCTION: TLSv1_2_method 350 EXIST::FUNCTION: SSL_SESSION_get_id_len 351 NOEXIST::FUNCTION: @@ -405,3 +405,7 @@ SSL_get_client_random 439 EXIST::FUNCTION: SSL_SESSION_get_master_key 440 EXIST::FUNCTION: SSL_CTX_set_default_verify_dir 441 EXIST::FUNCTION: SSL_CTX_set_default_verify_file 442 EXIST::FUNCTION: +SSL_in_init 443 EXIST::FUNCTION: +SSL_in_before 444 EXIST::FUNCTION: +SSL_is_init_finished 445 EXIST::FUNCTION: +SSL_get_state 446 EXIST::FUNCTION: From matt at openssl.org Fri Oct 30 09:23:44 2015 From: matt at openssl.org (Matt Caswell) Date: Fri, 30 Oct 2015 09:23:44 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1446197024.370324.6231.nullmailer@dev.openssl.org> The branch master has been updated via 87d9cafa332bd006086b56dc645c03fe7cfed654 (commit) from b7fa1f989d0059ad7b992c11797f37f095d61204 (commit) - Log ----------------------------------------------------------------- commit 87d9cafa332bd006086b56dc645c03fe7cfed654 Author: Matt Caswell Date: Thu Oct 29 14:50:40 2015 +0000 Remove some SSLv2 references There were a few remaining references to SSLv2 support which are no longer relevant now that it has been removed. Reviewed-by: Rich Salz Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: doc/ssl/SSL_CONF_cmd.pod | 12 ++++++------ doc/ssl/SSL_CTX_set_options.pod | 13 ++----------- doc/ssl/SSL_read.pod | 5 ----- doc/ssl/SSL_write.pod | 4 ---- doc/ssl/ssl.pod | 6 ++---- ssl/ssl_lib.c | 3 +-- ssl/ssl_locl.h | 2 +- 7 files changed, 12 insertions(+), 33 deletions(-) diff --git a/doc/ssl/SSL_CONF_cmd.pod b/doc/ssl/SSL_CONF_cmd.pod index e8eeb15..bebd204 100644 --- a/doc/ssl/SSL_CONF_cmd.pod +++ b/doc/ssl/SSL_CONF_cmd.pod @@ -371,16 +371,16 @@ argument. The order of operations is significant. This can be used to set either defaults or values which cannot be overridden. For example if an application calls: - SSL_CONF_cmd(ctx, "Protocol", "-SSLv2"); + SSL_CONF_cmd(ctx, "Protocol", "-SSLv3"); SSL_CONF_cmd(ctx, userparam, uservalue); -it will disable SSLv2 support by default but the user can override it. If +it will disable SSLv3 support by default but the user can override it. If however the call sequence is: SSL_CONF_cmd(ctx, userparam, uservalue); - SSL_CONF_cmd(ctx, "Protocol", "-SSLv2"); + SSL_CONF_cmd(ctx, "Protocol", "-SSLv3"); -SSLv2 is B disabled and attempt to override this by the user are +SSLv3 is B disabled and attempt to override this by the user are ignored. By checking the return code of SSL_CTX_cmd() it is possible to query if a @@ -416,9 +416,9 @@ Set supported signature algorithms: SSL_CONF_cmd(ctx, "SignatureAlgorithms", "ECDSA+SHA256:RSA+SHA256:DSA+SHA256"); -Enable all protocols except SSLv3 and SSLv2: +Enable all protocols except SSLv3: - SSL_CONF_cmd(ctx, "Protocol", "ALL,-SSLv3,-SSLv2"); + SSL_CONF_cmd(ctx, "Protocol", "ALL,-SSLv3"); Only enable TLSv1.2: diff --git a/doc/ssl/SSL_CTX_set_options.pod b/doc/ssl/SSL_CTX_set_options.pod index 3a75cda..7754e75 100644 --- a/doc/ssl/SSL_CTX_set_options.pod +++ b/doc/ssl/SSL_CTX_set_options.pod @@ -141,9 +141,8 @@ This option is no longer implemented and is treated as no op. When choosing a cipher, use the server's preferences instead of the client preferences. When not set, the SSL server will always follow the clients -preferences. When set, the SSLv3/TLSv1 server will choose following its -own preferences. Because of the different protocol, for SSLv2 the server -will send its list of preferences to the client and the client chooses. +preferences. When set, the SSL/TLS server will choose following its +own preferences. =item SSL_OP_PKCS1_CHECK_1 @@ -154,11 +153,6 @@ will send its list of preferences to the client and the client chooses. ... - -=item SSL_OP_NO_SSLv2 - -Do not use the SSLv2 protocol. - =item SSL_OP_NO_SSLv3 Do not use the SSLv3 protocol. @@ -200,9 +194,6 @@ OpenSSL always attempts to use secure renegotiation as described in RFC5746. This counters the prefix attack described in CVE-2009-3555 and elsewhere. -The deprecated and highly broken SSLv2 protocol does not support -renegotiation at all: its use is B discouraged. - This attack has far reaching consequences which application writers should be aware of. In the description below an implementation supporting secure renegotiation is referred to as I. A server not supporting secure diff --git a/doc/ssl/SSL_read.pod b/doc/ssl/SSL_read.pod index 947c868..e0a9bd4 100644 --- a/doc/ssl/SSL_read.pod +++ b/doc/ssl/SSL_read.pod @@ -98,11 +98,6 @@ incomplete. Call SSL_get_error() with the return value B to find out, whether an error occurred or the connection was shut down cleanly (SSL_ERROR_ZERO_RETURN). -SSLv2 (deprecated) does not support a shutdown alert protocol, so it can -only be detected, whether the underlying connection was closed. It cannot -be checked, whether the closure was initiated by the peer or by something -else. - =item E0 The read operation was not successful, because either an error occurred diff --git a/doc/ssl/SSL_write.pod b/doc/ssl/SSL_write.pod index a9841ed..1fff854 100644 --- a/doc/ssl/SSL_write.pod +++ b/doc/ssl/SSL_write.pod @@ -86,10 +86,6 @@ was closed. Call SSL_get_error() with the return value B to find out, whether an error occurred or the connection was shut down cleanly (SSL_ERROR_ZERO_RETURN). -SSLv2 (deprecated) does not support a shutdown alert protocol, so it can -only be detected, whether the underlying connection was closed. It cannot -be checked, why the closure happened. - =item E0 The write operation was not successful, because either an error occurred diff --git a/doc/ssl/ssl.pod b/doc/ssl/ssl.pod index 9413907..421d500 100644 --- a/doc/ssl/ssl.pod +++ b/doc/ssl/ssl.pod @@ -93,9 +93,7 @@ inside this header file. =item B -That's the sub header file dealing with the SSLv2 protocol only. -I. +Unused. Present for backwards compatibility only. =item B @@ -175,7 +173,7 @@ definitions in the header files. =item char *B(SSL_CIPHER *cipher); -Returns a string like "C" or "C" which indicates the +Returns a string like "C" or "C" which indicates the SSL/TLS protocol version to which I belongs (i.e. where it was defined in the specification the first time). diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 7e30aba..a8e2093 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -856,7 +856,7 @@ int SSL_copy_session_id(SSL *t, const SSL *f) } /* - * what if we are setup as SSLv2 but want to talk SSLv3 or vice-versa + * what if we are setup for one protocol version but want to talk another */ if (t->method != f->method) { t->method->ssl_free(t); /* cleanup current */ @@ -1361,7 +1361,6 @@ int SSL_set_cipher_list(SSL *s, const char *str) return 1; } -/* works well for SSLv2, not so good for SSLv3 */ char *SSL_get_shared_ciphers(const SSL *s, char *buf, int len) { char *p; diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 56ec70f..5a94066 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -555,7 +555,7 @@ struct ssl_cipher_st { int alg_bits; /* Number of bits for algorithm */ }; -/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ +/* Used to hold SSL/TLS functions */ struct ssl_method_st { int version; int (*ssl_new) (SSL *s); From builds at travis-ci.org Fri Oct 30 09:38:59 2015 From: builds at travis-ci.org (Travis CI) Date: Fri, 30 Oct 2015 09:38:59 +0000 Subject: [openssl-commits] Broken: openssl/openssl#539 (master - b7fa1f9) In-Reply-To: Message-ID: <56333ab3bb80_33f099e152620@5aaee9ac-1dd3-4688-b796-f326223e8dda.mail> Build Update for openssl/openssl ------------------------------------- Build: #539 Status: Broken Duration: 32 minutes and 5 seconds Commit: b7fa1f9 (master) Author: Matt Caswell Message: Add SRP and PSK to disallowed CertificateRequest ciphersuites There was a discrepancy between what ciphersuites we allowed to send a CertificateRequest, and what ciphersuites we allowed to receive one. So add PSK and SRP to the disallowed ones. Reviewed-by: Tim Hudson Reviewed-by: Richard Levitte View the changeset: https://github.com/openssl/openssl/compare/94b3664a5282...b7fa1f989d00 View the full build log and details: https://travis-ci.org/openssl/openssl/builds/88297063 -- You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications -------------- next part -------------- An HTML attachment was scrubbed... URL: From rsalz at openssl.org Fri Oct 30 21:21:54 2015 From: rsalz at openssl.org (Rich Salz) Date: Fri, 30 Oct 2015 21:21:54 +0000 Subject: [openssl-commits] [openssl] master update Message-ID: <1446240114.938893.15882.nullmailer@dev.openssl.org> The branch master has been updated via b0700d2c8de79252ba605748a075cf2e5d670da1 (commit) from 87d9cafa332bd006086b56dc645c03fe7cfed654 (commit) - Log ----------------------------------------------------------------- commit b0700d2c8de79252ba605748a075cf2e5d670da1 Author: Rich Salz Date: Tue Oct 27 15:11:48 2015 -0400 Replace "SSLeay" in API with OpenSSL All instances of SSLeay (any combination of case) were replaced with the case-equivalent OpenSSL. Reviewed-by: Richard Levitte ----------------------------------------------------------------------- Summary of changes: CHANGES | 4 + apps/CA.com | 23 +- apps/CA.pl.in | 6 +- apps/openssl.c | 3 +- apps/s_server.c | 2 +- apps/speed.c | 8 +- apps/version.c | 14 +- crypto/bn/bn_lcl.h | 14 +- crypto/bn/bn_prime.h | 516 +++++++++++++++++----------------- crypto/bn/bn_prime.pl | 39 +-- crypto/cversion.c | 22 +- crypto/des/Makefile | 5 +- crypto/des/des_ver.h | 73 ----- crypto/des/ecb_enc.c | 1 - crypto/des/rpc_enc.c | 1 - crypto/engine/eng_cryptodev.c | 10 +- crypto/engine/eng_openssl.c | 2 +- crypto/lhash/lh_stats.c | 2 +- crypto/lock.c | 4 +- crypto/rand/md_rand.c | 66 ++--- crypto/rand/rand_err.c | 4 +- crypto/rand/rand_lib.c | 8 +- crypto/rsa/rsa_eay.c | 2 +- crypto/rsa/rsa_lib.c | 2 +- demos/easy_tls/easy-tls.c | 2 +- demos/engines/ibmca/hw_ibmca.c | 4 +- demos/engines/zencod/hw_zencod.c | 12 +- demos/pkcs12/pkwrite.c | 2 +- demos/sign/sign.c | 2 +- demos/ssl/cli.cpp | 4 +- demos/ssl/inetdsrv.cpp | 2 +- demos/ssl/serv.cpp | 6 +- doc/apps/dhparam.pod | 2 +- doc/apps/enc.pod | 5 +- doc/apps/req.pod | 3 +- doc/apps/verify.pod | 2 +- doc/crypto/OPENSSL_VERSION_NUMBER.pod | 8 +- doc/crypto/RAND_set_rand_method.pod | 8 +- doc/crypto/SSLeay_version.pod | 70 ----- doc/ssl/SSL_library_init.pod | 6 +- e_os.h | 26 +- engines/e_capi.c | 2 +- engines/e_chil.c | 4 +- engines/e_gmp.c | 2 +- engines/e_ubsec.c | 12 +- include/openssl/crypto.h | 24 +- include/openssl/dsa.h | 5 +- include/openssl/evp.h | 3 - include/openssl/rand.h | 4 +- include/openssl/rsa.h | 4 +- include/openssl/ssl.h | 15 +- include/openssl/x509.h | 3 +- test/recipes/80-test_ca.t | 6 +- test/recipes/80-test_tsa.t | 2 +- util/libeay.num | 8 +- 55 files changed, 438 insertions(+), 651 deletions(-) delete mode 100644 crypto/des/des_ver.h delete mode 100644 doc/crypto/SSLeay_version.pod diff --git a/CHANGES b/CHANGES index a8629d8..86c572d 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,10 @@ also been removed. [Matt Caswell] + *) All instances of the string "ssleay" in the public API were replaced + with OpenSSL (case-matching; e.g., OPENSSL_VERSION for #define's) + [Rich Salz] + *) The demo files in crypto/threads were moved to demo/threads. [Rich Salz] diff --git a/apps/CA.com b/apps/CA.com index 2c0d465..95925d3 100644 --- a/apps/CA.com +++ b/apps/CA.com @@ -10,29 +10,14 @@ $! At the end of that grab newreq.pem and newcert.pem (one has the key $! and the other the certificate) and cat them together and that is what $! you want/need ... I'll make even this a little cleaner later. $! -$! -$! 12-Jan-96 tjh Added more things ... including CA -signcert which -$! converts a certificate to a request and then signs it. -$! 10-Jan-96 eay Fixed a few more bugs and added the SSLEAY_CONFIG -$! environment variable so this can be driven from -$! a script. -$! 25-Jul-96 eay Cleaned up filenames some more. -$! 11-Jun-96 eay Fixed a few filename missmatches. -$! 03-May-96 eay Modified to use 'openssl cmd' instead of 'cmd'. -$! 18-Apr-96 tjh Original hacking -$! -$! Tim Hudson -$! tjh at cryptsoft.com -$! -$! -$! default ssleay.cnf file has setup as per the following +$! default openssl.cnf file has setup as per the following $! demoCA ... where everything is stored $ -$ IF F$TYPE(SSLEAY_CONFIG) .EQS. "" THEN SSLEAY_CONFIG := SSLLIB:SSLEAY.CNF +$ IF F$TYPE(OPENSSL_CONFIG) .EQS. "" THEN OPENSSL_CONFIG := SSLLIB:OPENSSL.CNF $ $ DAYS = "-days 365" -$ REQ = openssl + " req " + SSLEAY_CONFIG -$ CA = openssl + " ca " + SSLEAY_CONFIG +$ REQ = openssl + " req " + OPENSSL_CONFIG +$ CA = openssl + " ca " + OPENSSL_CONFIG $ VERIFY = openssl + " verify" $ X509 = openssl + " x509" $ PKCS12 = openssl + " pkcs12" diff --git a/apps/CA.pl.in b/apps/CA.pl.in index 5c8cdd0..a814ebf 100644 --- a/apps/CA.pl.in +++ b/apps/CA.pl.in @@ -16,11 +16,11 @@ if(defined $ENV{'OPENSSL'}) { my $verbose = 1; -my $SSLEAY_CONFIG = $ENV{"SSLEAY_CONFIG"}; +my $OPENSSL_CONFIG = $ENV{"OPENSSL_CONFIG"}; my $DAYS = "-days 365"; my $CADAYS = "-days 1095"; # 3 years -my $REQ = "$openssl req $SSLEAY_CONFIG"; -my $CA = "$openssl ca $SSLEAY_CONFIG"; +my $REQ = "$openssl req $OPENSSL_CONFIG"; +my $CA = "$openssl ca $OPENSSL_CONFIG"; my $VERIFY = "$openssl verify"; my $X509 = "$openssl x509"; my $PKCS12 = "$openssl pkcs12"; diff --git a/apps/openssl.c b/apps/openssl.c index 2b0425b..1fd3e73 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -217,8 +217,7 @@ static char *make_config_name() size_t len; char *p; - if ((t = getenv("OPENSSL_CONF")) != NULL - || (t = getenv("SSLEAY_CONF")) != NULL) + if ((t = getenv("OPENSSL_CONF")) != NULL) return BUF_strdup(t); t = X509_get_default_cert_area(); diff --git a/apps/s_server.c b/apps/s_server.c index aa01d43..4848fbe 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -2719,7 +2719,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context) "HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n"); BIO_puts(io, "\n"); BIO_puts(io, "
    \n");
    -/*                      BIO_puts(io,SSLeay_version(SSLEAY_VERSION));*/
    +/*                      BIO_puts(io,OpenSSL_version(OPENSSL_VERSION));*/
                 BIO_puts(io, "\n");
                 for (i = 0; i < local_argc; i++) {
                     const char *myp;
    diff --git a/apps/speed.c b/apps/speed.c
    index faa3e15..68530b1 100644
    --- a/apps/speed.c
    +++ b/apps/speed.c
    @@ -869,7 +869,7 @@ int speed_main(int argc, char **argv)
     #ifndef OPENSSL_NO_RSA
     # ifndef RSA_NULL
             if (strcmp(*argv, "openssl") == 0) {
    -            RSA_set_default_method(RSA_PKCS1_SSLeay());
    +            RSA_set_default_method(RSA_PKCS1_OpenSSL());
                 continue;
             }
     # endif
    @@ -2041,8 +2041,8 @@ int speed_main(int argc, char **argv)
      show_res:
     #endif
         if (!mr) {
    -        printf("%s\n", SSLeay_version(SSLEAY_VERSION));
    -        printf("%s\n", SSLeay_version(SSLEAY_BUILT_ON));
    +        printf("%s\n", OpenSSL_version(OPENSSL_VERSION));
    +        printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON));
             printf("options:");
             printf("%s ", BN_options());
     #ifndef OPENSSL_NO_MD2
    @@ -2063,7 +2063,7 @@ int speed_main(int argc, char **argv)
     #ifndef OPENSSL_NO_BF
             printf("%s ", BF_options());
     #endif
    -        printf("\n%s\n", SSLeay_version(SSLEAY_CFLAGS));
    +        printf("\n%s\n", OpenSSL_version(OPENSSL_CFLAGS));
         }
     
         if (pr_header) {
    diff --git a/apps/version.c b/apps/version.c
    index 1fa7cfe..073aa93 100644
    --- a/apps/version.c
    +++ b/apps/version.c
    @@ -193,17 +193,17 @@ int version_main(int argc, char **argv)
             version = 1;
     
         if (version) {
    -        if (SSLeay() == SSLEAY_VERSION_NUMBER) {
    -            printf("%s\n", SSLeay_version(SSLEAY_VERSION));
    +        if (OpenSSL_version_num() == OPENSSL_VERSION_NUMBER) {
    +            printf("%s\n", OpenSSL_version(OPENSSL_VERSION));
             } else {
                 printf("%s (Library: %s)\n",
    -                   OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
    +                   OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
             }
         }
         if (date)
    -        printf("%s\n", SSLeay_version(SSLEAY_BUILT_ON));
    +        printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON));
         if (platform)
    -        printf("%s\n", SSLeay_version(SSLEAY_PLATFORM));
    +        printf("%s\n", OpenSSL_version(OPENSSL_PLATFORM));
         if (options) {
             printf("options:  ");
             printf("%s ", BN_options());
    @@ -225,9 +225,9 @@ int version_main(int argc, char **argv)
             printf("\n");
         }
         if (cflags)
    -        printf("%s\n", SSLeay_version(SSLEAY_CFLAGS));
    +        printf("%s\n", OpenSSL_version(OPENSSL_CFLAGS));
         if (dir)
    -        printf("%s\n", SSLeay_version(SSLEAY_DIR));
    +        printf("%s\n", OpenSSL_version(OPENSSL_DIR));
         ret = 0;
      end:
         return (ret);
    diff --git a/crypto/bn/bn_lcl.h b/crypto/bn/bn_lcl.h
    index b9d124a..1a75c10 100644
    --- a/crypto/bn/bn_lcl.h
    +++ b/crypto/bn/bn_lcl.h
    @@ -292,23 +292,11 @@ struct bn_gencb_st {
      * (with draws in between).  Very small exponents are often selected
      * with low Hamming weight, so we use  w = 1  for b <= 23.
      */
    -# if 1
    -#  define BN_window_bits_for_exponent_size(b) \
    +# define BN_window_bits_for_exponent_size(b) \
                     ((b) > 671 ? 6 : \
                      (b) > 239 ? 5 : \
                      (b) >  79 ? 4 : \
                      (b) >  23 ? 3 : 1)
    -# else
    -/*
    - * Old SSLeay/OpenSSL table. Maximum window size was 5, so this table differs
    - * for b==1024; but it coincides for other interesting values (b==160,
    - * b==512).
    - */
    -#  define BN_window_bits_for_exponent_size(b) \
    -                ((b) > 255 ? 5 : \
    -                 (b) > 127 ? 4 : \
    -                 (b) >  17 ? 3 : 1)
    -# endif
     
     /*
      * BN_mod_exp_mont_conttime is based on the assumption that the L1 data cache
    diff --git a/crypto/bn/bn_prime.h b/crypto/bn/bn_prime.h
    index 5cf0de1..c2824a8 100644
    --- a/crypto/bn/bn_prime.h
    +++ b/crypto/bn/bn_prime.h
    @@ -63,264 +63,264 @@ typedef unsigned short prime_t;
     # define NUMPRIMES 54
     typedef unsigned char prime_t;
     #endif
    -static const prime_t primes[NUMPRIMES] = {
    -    2, 3, 5, 7, 11, 13, 17, 19,
    -    23, 29, 31, 37, 41, 43, 47, 53,
    -    59, 61, 67, 71, 73, 79, 83, 89,
    -    97, 101, 103, 107, 109, 113, 127, 131,
    -    137, 139, 149, 151, 157, 163, 167, 173,
    -    179, 181, 191, 193, 197, 199, 211, 223,
    -    227, 229, 233, 239, 241, 251,
    +static const prime_t primes[NUMPRIMES]= {
    +       2,    3,    5,    7,   11,   13,   17,   19, 
    +      23,   29,   31,   37,   41,   43,   47,   53, 
    +      59,   61,   67,   71,   73,   79,   83,   89, 
    +      97,  101,  103,  107,  109,  113,  127,  131, 
    +     137,  139,  149,  151,  157,  163,  167,  173, 
    +     179,  181,  191,  193,  197,  199,  211,  223, 
    +     227,  229,  233,  239,  241,  251, 
     #ifndef EIGHT_BIT
    -    257, 263,
    -    269, 271, 277, 281, 283, 293, 307, 311,
    -    313, 317, 331, 337, 347, 349, 353, 359,
    -    367, 373, 379, 383, 389, 397, 401, 409,
    -    419, 421, 431, 433, 439, 443, 449, 457,
    -    461, 463, 467, 479, 487, 491, 499, 503,
    -    509, 521, 523, 541, 547, 557, 563, 569,
    -    571, 577, 587, 593, 599, 601, 607, 613,
    -    617, 619, 631, 641, 643, 647, 653, 659,
    -    661, 673, 677, 683, 691, 701, 709, 719,
    -    727, 733, 739, 743, 751, 757, 761, 769,
    -    773, 787, 797, 809, 811, 821, 823, 827,
    -    829, 839, 853, 857, 859, 863, 877, 881,
    -    883, 887, 907, 911, 919, 929, 937, 941,
    -    947, 953, 967, 971, 977, 983, 991, 997,
    -    1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049,
    -    1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097,
    -    1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163,
    -    1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223,
    -    1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283,
    -    1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321,
    -    1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
    -    1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459,
    -    1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511,
    -    1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571,
    -    1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619,
    -    1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693,
    -    1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747,
    -    1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
    -    1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877,
    -    1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949,
    -    1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003,
    -    2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069,
    -    2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129,
    -    2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203,
    -    2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267,
    -    2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311,
    -    2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377,
    -    2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423,
    -    2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503,
    -    2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579,
    -    2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657,
    -    2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693,
    -    2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741,
    -    2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801,
    -    2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861,
    -    2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939,
    -    2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011,
    -    3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079,
    -    3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167,
    -    3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221,
    -    3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301,
    -    3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347,
    -    3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413,
    -    3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491,
    -    3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541,
    -    3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607,
    -    3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671,
    -    3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727,
    -    3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797,
    -    3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863,
    -    3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923,
    -    3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003,
    -    4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057,
    -    4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129,
    -    4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211,
    -    4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259,
    -    4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337,
    -    4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409,
    -    4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481,
    -    4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547,
    -    4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621,
    -    4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673,
    -    4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751,
    -    4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813,
    -    4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909,
    -    4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967,
    -    4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011,
    -    5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087,
    -    5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167,
    -    5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233,
    -    5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309,
    -    5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399,
    -    5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443,
    -    5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507,
    -    5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573,
    -    5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653,
    -    5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711,
    -    5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791,
    -    5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849,
    -    5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897,
    -    5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007,
    -    6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073,
    -    6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133,
    -    6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211,
    -    6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271,
    -    6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329,
    -    6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379,
    -    6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473,
    -    6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563,
    -    6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637,
    -    6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701,
    -    6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779,
    -    6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833,
    -    6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907,
    -    6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971,
    -    6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027,
    -    7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121,
    -    7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207,
    -    7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253,
    -    7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349,
    -    7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457,
    -    7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517,
    -    7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561,
    -    7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621,
    -    7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691,
    -    7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757,
    -    7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853,
    -    7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919,
    -    7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009,
    -    8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087,
    -    8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161,
    -    8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231,
    -    8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291,
    -    8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369,
    -    8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443,
    -    8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537,
    -    8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609,
    -    8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677,
    -    8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731,
    -    8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803,
    -    8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861,
    -    8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941,
    -    8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011,
    -    9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091,
    -    9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161,
    -    9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227,
    -    9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311,
    -    9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377,
    -    9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433,
    -    9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491,
    -    9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587,
    -    9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649,
    -    9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733,
    -    9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791,
    -    9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857,
    -    9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929,
    -    9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037,
    -    10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099,
    -    10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163,
    -    10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247,
    -    10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303,
    -    10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369,
    -    10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459,
    -    10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531,
    -    10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627,
    -    10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691,
    -    10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771,
    -    10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859,
    -    10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937,
    -    10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003,
    -    11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087,
    -    11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161,
    -    11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251,
    -    11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317,
    -    11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399,
    -    11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483,
    -    11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551,
    -    11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657,
    -    11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731,
    -    11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813,
    -    11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887,
    -    11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941,
    -    11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011,
    -    12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101,
    -    12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161,
    -    12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251,
    -    12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323,
    -    12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401,
    -    12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473,
    -    12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527,
    -    12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589,
    -    12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653,
    -    12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739,
    -    12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821,
    -    12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907,
    -    12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967,
    -    12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033,
    -    13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109,
    -    13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177,
    -    13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259,
    -    13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337,
    -    13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421,
    -    13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499,
    -    13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597,
    -    13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681,
    -    13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723,
    -    13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799,
    -    13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879,
    -    13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933,
    -    13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033,
    -    14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143,
    -    14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221,
    -    14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323,
    -    14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407,
    -    14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461,
    -    14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549,
    -    14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627,
    -    14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699,
    -    14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753,
    -    14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821,
    -    14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887,
    -    14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957,
    -    14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073,
    -    15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137,
    -    15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217,
    -    15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277,
    -    15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331,
    -    15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401,
    -    15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473,
    -    15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569,
    -    15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643,
    -    15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727,
    -    15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773,
    -    15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859,
    -    15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919,
    -    15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007,
    -    16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087,
    -    16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183,
    -    16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249,
    -    16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349,
    -    16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427,
    -    16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493,
    -    16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603,
    -    16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661,
    -    16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747,
    -    16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843,
    -    16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927,
    -    16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993,
    -    17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053,
    -    17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159,
    -    17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231,
    -    17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327,
    -    17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389,
    -    17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467,
    -    17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519,
    -    17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599,
    -    17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683,
    -    17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783,
    -    17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863,
    +     257,  263, 
    +     269,  271,  277,  281,  283,  293,  307,  311, 
    +     313,  317,  331,  337,  347,  349,  353,  359, 
    +     367,  373,  379,  383,  389,  397,  401,  409, 
    +     419,  421,  431,  433,  439,  443,  449,  457, 
    +     461,  463,  467,  479,  487,  491,  499,  503, 
    +     509,  521,  523,  541,  547,  557,  563,  569, 
    +     571,  577,  587,  593,  599,  601,  607,  613, 
    +     617,  619,  631,  641,  643,  647,  653,  659, 
    +     661,  673,  677,  683,  691,  701,  709,  719, 
    +     727,  733,  739,  743,  751,  757,  761,  769, 
    +     773,  787,  797,  809,  811,  821,  823,  827, 
    +     829,  839,  853,  857,  859,  863,  877,  881, 
    +     883,  887,  907,  911,  919,  929,  937,  941, 
    +     947,  953,  967,  971,  977,  983,  991,  997, 
    +    1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 
    +    1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 
    +    1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 
    +    1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 
    +    1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 
    +    1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 
    +    1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 
    +    1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 
    +    1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 
    +    1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 
    +    1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 
    +    1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 
    +    1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 
    +    1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 
    +    1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 
    +    1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 
    +    1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 
    +    2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 
    +    2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 
    +    2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 
    +    2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 
    +    2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 
    +    2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 
    +    2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 
    +    2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 
    +    2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 
    +    2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 
    +    2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 
    +    2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 
    +    2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 
    +    2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 
    +    2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 
    +    2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 
    +    3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 
    +    3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 
    +    3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 
    +    3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 
    +    3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 
    +    3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 
    +    3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 
    +    3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 
    +    3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 
    +    3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 
    +    3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 
    +    3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 
    +    3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 
    +    3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 
    +    3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 
    +    4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 
    +    4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 
    +    4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 
    +    4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 
    +    4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 
    +    4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 
    +    4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 
    +    4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 
    +    4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 
    +    4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 
    +    4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 
    +    4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 
    +    4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 
    +    4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 
    +    4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 
    +    5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 
    +    5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 
    +    5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 
    +    5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 
    +    5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 
    +    5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 
    +    5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 
    +    5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 
    +    5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 
    +    5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 
    +    5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 
    +    5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 
    +    5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 
    +    5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 
    +    6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 
    +    6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 
    +    6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 
    +    6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 
    +    6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 
    +    6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 
    +    6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 
    +    6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 
    +    6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 
    +    6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 
    +    6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 
    +    6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 
    +    6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 
    +    6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 
    +    6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 
    +    7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 
    +    7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 
    +    7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 
    +    7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 
    +    7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 
    +    7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 
    +    7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 
    +    7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 
    +    7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 
    +    7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 
    +    7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 
    +    7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 
    +    7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 
    +    8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 
    +    8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 
    +    8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 
    +    8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 
    +    8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 
    +    8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 
    +    8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 
    +    8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 
    +    8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 
    +    8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 
    +    8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 
    +    8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 
    +    8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 
    +    8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 
    +    9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 
    +    9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 
    +    9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 
    +    9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 
    +    9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 
    +    9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 
    +    9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 
    +    9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 
    +    9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 
    +    9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 
    +    9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 
    +    9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 
    +    9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 
    +    9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, 
    +    10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, 
    +    10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, 
    +    10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, 
    +    10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, 
    +    10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, 
    +    10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, 
    +    10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, 
    +    10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, 
    +    10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, 
    +    10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, 
    +    10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, 
    +    10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, 
    +    10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, 
    +    11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, 
    +    11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, 
    +    11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, 
    +    11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, 
    +    11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, 
    +    11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, 
    +    11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, 
    +    11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, 
    +    11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, 
    +    11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, 
    +    11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, 
    +    11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, 
    +    11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, 
    +    12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, 
    +    12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, 
    +    12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, 
    +    12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, 
    +    12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, 
    +    12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, 
    +    12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, 
    +    12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, 
    +    12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, 
    +    12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, 
    +    12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, 
    +    12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, 
    +    12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, 
    +    12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, 
    +    13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, 
    +    13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, 
    +    13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, 
    +    13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, 
    +    13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, 
    +    13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, 
    +    13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, 
    +    13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, 
    +    13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, 
    +    13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, 
    +    13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, 
    +    13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, 
    +    13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, 
    +    14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, 
    +    14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, 
    +    14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, 
    +    14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, 
    +    14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, 
    +    14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, 
    +    14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, 
    +    14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, 
    +    14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, 
    +    14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, 
    +    14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, 
    +    14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, 
    +    14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, 
    +    15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, 
    +    15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, 
    +    15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, 
    +    15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, 
    +    15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, 
    +    15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, 
    +    15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, 
    +    15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, 
    +    15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, 
    +    15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, 
    +    15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, 
    +    15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, 
    +    15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, 
    +    16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, 
    +    16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, 
    +    16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, 
    +    16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, 
    +    16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, 
    +    16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, 
    +    16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, 
    +    16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, 
    +    16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, 
    +    16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, 
    +    16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, 
    +    16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, 
    +    17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 
    +    17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, 
    +    17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, 
    +    17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, 
    +    17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, 
    +    17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, 
    +    17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, 
    +    17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, 
    +    17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, 
    +    17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, 
    +    17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, 
     #endif
     };
    diff --git a/crypto/bn/bn_prime.pl b/crypto/bn/bn_prime.pl
    index 3fafb6f..4e4426a 100644
    --- a/crypto/bn/bn_prime.pl
    +++ b/crypto/bn/bn_prime.pl
    @@ -18,17 +18,6 @@ loop: while ($#primes < $num-1)
     	push(@primes,$p);
     	}
     
    -# print <<"EOF";
    -# /* Auto generated by bn_prime.pl */
    -# /* Copyright (C) 1995-1997 Eric Young (eay\@mincom.oz.au).
    -#  * All rights reserved.
    -#  * Copyright remains Eric Young's, and as such any Copyright notices in
    -#  * the code are not to be removed.
    -#  * See the COPYRIGHT file in the SSLeay distribution for more details.
    -#  */
    -# 
    -# EOF
    -
     print <<\EOF;
     /* Auto generated by bn_prime.pl */
     /* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com)
    @@ -37,21 +26,21 @@ print <<\EOF;
      * This package is an SSL implementation written
      * by Eric Young (eay at cryptsoft.com).
      * The implementation was written so as to conform with Netscapes SSL.
    - * 
    + *
      * This library is free for commercial and non-commercial use as long as
      * the following conditions are aheared to.  The following conditions
      * apply to all code found in this distribution, be it the RC4, RSA,
      * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
      * included with this distribution is covered by the same copyright terms
      * except that the holder is Tim Hudson (tjh at cryptsoft.com).
    - * 
    + *
      * Copyright remains Eric Young's, and as such any Copyright notices in
      * the code are not to be removed.
      * If this package is used in a product, Eric Young should be given attribution
      * as the author of the parts of the library used.
      * This can be in the form of a textual message at program startup or
      * in documentation (online or textual) provided with the package.
    - * 
    + *
      * Redistribution and use in source and binary forms, with or without
      * modification, are permitted provided that the following conditions
      * are met:
    @@ -66,10 +55,10 @@ print <<\EOF;
      *     Eric Young (eay at cryptsoft.com)"
      *    The word 'cryptographic' can be left out if the rouines from the library
      *    being used are not cryptographic related :-).
    - * 4. If you include any Windows specific code (or a derivative thereof) from 
    + * 4. If you include any Windows specific code (or a derivative thereof) from
      *    the apps directory (application code) you must include an acknowledgement:
      *    "This product includes software written by Tim Hudson (tjh at cryptsoft.com)"
    - * 
    + *
      * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
      * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    @@ -81,7 +70,7 @@ print <<\EOF;
      * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      * SUCH DAMAGE.
    - * 
    + *
      * The licence and distribution terms for any publically available version or
      * derivative of this code cannot be changed.  i.e. this code cannot simply be
      * copied and put under another distribution licence
    @@ -100,20 +89,18 @@ for ($i=0; $i <= $#primes; $i++)
     	}
     
     printf "#ifndef EIGHT_BIT\n";
    -printf "#define NUMPRIMES %d\n",$num;
    +printf "# define NUMPRIMES %d\n",$num;
     printf "typedef unsigned short prime_t;\n";
     printf "#else\n";
    -printf "#define NUMPRIMES %d\n",$eight;
    +printf "# define NUMPRIMES %d\n",$eight;
     printf "typedef unsigned char prime_t;\n";
     printf "#endif\n";
    -print "static const prime_t primes[NUMPRIMES]=\n\t{\n\t";
    +print "static const prime_t primes[NUMPRIMES]= {\n    ";
     $init=0;
     for ($i=0; $i <= $#primes; $i++)
     	{
    -	printf "\n#ifndef EIGHT_BIT\n\t" if ($primes[$i] > 256) && !($init++);
    -	printf("\n\t") if (($i%8) == 0) && ($i != 0);
    -	printf("%4d,",$primes[$i]);
    +	printf "\n#ifndef EIGHT_BIT\n    " if ($primes[$i] > 256) && !($init++);
    +	printf "\n    " if (($i%8) == 0) && ($i != 0);
    +	printf "%4d, ", $primes[$i];
     	}
    -print "\n#endif\n\t};\n";
    -
    -
    +print "\n#endif\n};\n";
    diff --git a/crypto/cversion.c b/crypto/cversion.c
    index 6111b65..aa479a9 100644
    --- a/crypto/cversion.c
    +++ b/crypto/cversion.c
    @@ -62,11 +62,16 @@
     # include "buildinf.h"
     #endif
     
    -const char *SSLeay_version(int t)
    +unsigned long OpenSSL_version_num()
     {
    -    if (t == SSLEAY_VERSION)
    +    return OPENSSL_VERSION_NUMBER;
    +}
    +
    +const char *OpenSSL_version(int t)
    +{
    +    if (t == OPENSSL_VERSION)
             return OPENSSL_VERSION_TEXT;
    -    if (t == SSLEAY_BUILT_ON) {
    +    if (t == OPENSSL_BUILT_ON) {
     #ifdef DATE
     # ifdef OPENSSL_USE_BUILD_DATE
             return (DATE);
    @@ -77,21 +82,21 @@ const char *SSLeay_version(int t)
             return ("built on: date not available");
     #endif
         }
    -    if (t == SSLEAY_CFLAGS) {
    +    if (t == OPENSSL_CFLAGS) {
     #ifdef CFLAGS
             return (CFLAGS);
     #else
             return ("compiler: information not available");
     #endif
         }
    -    if (t == SSLEAY_PLATFORM) {
    +    if (t == OPENSSL_PLATFORM) {
     #ifdef PLATFORM
             return (PLATFORM);
     #else
             return ("platform: information not available");
     #endif
         }
    -    if (t == SSLEAY_DIR) {
    +    if (t == OPENSSL_DIR) {
     #ifdef OPENSSLDIR
             return "OPENSSLDIR: \"" OPENSSLDIR "\"";
     #else
    @@ -100,8 +105,3 @@ const char *SSLeay_version(int t)
         }
         return ("not available");
     }
    -
    -unsigned long SSLeay(void)
    -{
    -    return (SSLEAY_VERSION_NUMBER);
    -}
    diff --git a/crypto/des/Makefile b/crypto/des/Makefile
    index 56c41f1..1233fad 100644
    --- a/crypto/des/Makefile
    +++ b/crypto/des/Makefile
    @@ -114,7 +114,7 @@ ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
     ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
     ecb_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
     ecb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
    -ecb_enc.o: des_locl.h des_ver.h ecb_enc.c
    +ecb_enc.o: des_locl.h ecb_enc.c
     enc_read.o: ../../e_os.h ../../include/openssl/bio.h
     enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
     enc_read.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
    @@ -161,8 +161,7 @@ read2pwd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
     read2pwd.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
     read2pwd.o: read2pwd.c
     rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h
    -rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h
    -rpc_enc.o: rpc_enc.c
    +rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h rpc_des.h rpc_enc.c
     set_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
     set_key.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
     set_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
    diff --git a/crypto/des/des_ver.h b/crypto/des/des_ver.h
    deleted file mode 100644
    index 276de2b..0000000
    --- a/crypto/des/des_ver.h
    +++ /dev/null
    @@ -1,73 +0,0 @@
    -/* crypto/des/des_ver.h */
    -/* Copyright (C) 1995-1998 Eric Young (eay at cryptsoft.com)
    - * All rights reserved.
    - *
    - * This package is an SSL implementation written
    - * by Eric Young (eay at cryptsoft.com).
    - * The implementation was written so as to conform with Netscapes SSL.
    - *
    - * This library is free for commercial and non-commercial use as long as
    - * the following conditions are aheared to.  The following conditions
    - * apply to all code found in this distribution, be it the RC4, RSA,
    - * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
    - * included with this distribution is covered by the same copyright terms
    - * except that the holder is Tim Hudson (tjh at cryptsoft.com).
    - *
    - * Copyright remains Eric Young's, and as such any Copyright notices in
    - * the code are not to be removed.
    - * If this package is used in a product, Eric Young should be given attribution
    - * as the author of the parts of the library used.
    - * This can be in the form of a textual message at program startup or
    - * in documentation (online or textual) provided with the package.
    - *
    - * Redistribution and use in source and binary forms, with or without
    - * modification, are permitted provided that the following conditions
    - * are met:
    - * 1. Redistributions of source code must retain the copyright
    - *    notice, this list of conditions and the following disclaimer.
    - * 2. Redistributions in binary form must reproduce the above copyright
    - *    notice, this list of conditions and the following disclaimer in the
    - *    documentation and/or other materials provided with the distribution.
    - * 3. All advertising materials mentioning features or use of this software
    - *    must display the following acknowledgement:
    - *    "This product includes cryptographic software written by
    - *     Eric Young (eay at cryptsoft.com)"
    - *    The word 'cryptographic' can be left out if the rouines from the library
    - *    being used are not cryptographic related :-).
    - * 4. If you include any Windows specific code (or a derivative thereof) from
    - *    the apps directory (application code) you must include an acknowledgement:
    - *    "This product includes software written by Tim Hudson (tjh at cryptsoft.com)"
    - *
    - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
    - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    - * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    - * SUCH DAMAGE.
    - *
    - * The licence and distribution terms for any publically available version or
    - * derivative of this code cannot be changed.  i.e. this code cannot simply be
    - * copied and put under another distribution licence
    - * [including the GNU Public Licence.]
    - */
    -
    -#include 
    -
    -#ifdef OPENSSL_BUILD_SHLIBCRYPTO
    -# undef OPENSSL_EXTERN
    -# define OPENSSL_EXTERN OPENSSL_EXPORT
    -#endif
    -
    -/* The following macros make sure the names are different from libdes names */
    -#define DES_version OSSL_DES_version
    -#define libdes_version OSSL_libdes_version
    -
    -/* SSLeay version string */
    -OPENSSL_EXTERN const char OSSL_DES_version[];
    -/* old libdes version string */
    -OPENSSL_EXTERN const char OSSL_libdes_version[];
    diff --git a/crypto/des/ecb_enc.c b/crypto/des/ecb_enc.c
    index d638a49..4f104ea 100644
    --- a/crypto/des/ecb_enc.c
    +++ b/crypto/des/ecb_enc.c
    @@ -57,7 +57,6 @@
      */
     
     #include "des_locl.h"
    -#include "des_ver.h"
     #include 
     #include 
     
    diff --git a/crypto/des/rpc_enc.c b/crypto/des/rpc_enc.c
    index a5cd7dd..2245bca 100644
    --- a/crypto/des/rpc_enc.c
    +++ b/crypto/des/rpc_enc.c
    @@ -58,7 +58,6 @@
     
     #include "rpc_des.h"
     #include "des_locl.h"
    -#include "des_ver.h"
     
     int _des_crypt(char *buf, int len, struct desparams *desp);
     int _des_crypt(char *buf, int len, struct desparams *desp)
    diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
    index c660bb3..d058dba 100644
    --- a/crypto/engine/eng_cryptodev.c
    +++ b/crypto/engine/eng_cryptodev.c
    @@ -1129,12 +1129,12 @@ cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
         kop.crk_iparams = 3;
     
         if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL)) {
    -        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *meth = RSA_PKCS1_OpenSSL();
             printf("OCF asym process failed, Running in software\n");
             ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
     
         } else if (ECANCELED == kop.crk_status) {
    -        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *meth = RSA_PKCS1_OpenSSL();
             printf("OCF hardware operation cancelled. Running in Software\n");
             ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
         }
    @@ -1185,12 +1185,12 @@ cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
         kop.crk_iparams = 6;
     
         if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL)) {
    -        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *meth = RSA_PKCS1_OpenSSL();
             printf("OCF asym process failed, running in Software\n");
             ret = (*meth->rsa_mod_exp) (r0, I, rsa, ctx);
     
         } else if (ECANCELED == kop.crk_status) {
    -        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *meth = RSA_PKCS1_OpenSSL();
             printf("OCF hardware operation cancelled. Running in Software\n");
             ret = (*meth->rsa_mod_exp) (r0, I, rsa, ctx);
         }
    @@ -1477,7 +1477,7 @@ void ENGINE_load_cryptodev(void)
         }
     
         if (ENGINE_set_RSA(engine, &cryptodev_rsa)) {
    -        const RSA_METHOD *rsa_meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *rsa_meth = RSA_PKCS1_OpenSSL();
     
             cryptodev_rsa.bn_mod_exp = rsa_meth->bn_mod_exp;
             cryptodev_rsa.rsa_mod_exp = rsa_meth->rsa_mod_exp;
    diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
    index 095b5a0..244a609 100644
    --- a/crypto/engine/eng_openssl.c
    +++ b/crypto/engine/eng_openssl.c
    @@ -158,7 +158,7 @@ static int bind_helper(ENGINE *e)
     # ifndef OPENSSL_NO_DH
             || !ENGINE_set_DH(e, DH_get_default_method())
     # endif
    -        || !ENGINE_set_RAND(e, RAND_SSLeay())
    +        || !ENGINE_set_RAND(e, RAND_OpenSSL())
     # ifdef TEST_ENG_OPENSSL_RC4
             || !ENGINE_set_ciphers(e, openssl_ciphers)
     # endif
    diff --git a/crypto/lhash/lh_stats.c b/crypto/lhash/lh_stats.c
    index 09e1bff..b7d9524 100644
    --- a/crypto/lhash/lh_stats.c
    +++ b/crypto/lhash/lh_stats.c
    @@ -60,7 +60,7 @@
     #include 
     #include 
     /*
    - * If you wish to build this outside of SSLeay, remove the following lines
    + * If you wish to build this outside of OpenSSL, remove the following lines
      * and things should work as expected
      */
     #include "internal/cryptlib.h"
    diff --git a/crypto/lock.c b/crypto/lock.c
    index 12e4323..d24527a 100644
    --- a/crypto/lock.c
    +++ b/crypto/lock.c
    @@ -118,7 +118,7 @@
     #include 
     
     #if defined(OPENSSL_SYS_WIN32)
    -static double SSLeay_MSVC5_hack = 0.0; /* and for VC1.5 */
    +static double OpenSSL_MSVC5_hack = 0.0; /* and for VC1.5 */
     #endif
     
     DECLARE_STACK_OF(CRYPTO_dynlock)
    @@ -207,7 +207,7 @@ int CRYPTO_get_new_lockid(char *name)
          * using /MT. Without this, the application cannot use any floating point
          * printf's. It also seems to be needed for Visual C 1.5 (win16)
          */
    -    SSLeay_MSVC5_hack = (double)name[0] * (double)name[1];
    +    OpenSSL_MSVC5_hack = (double)name[0] * (double)name[1];
     #endif
     
         if ((app_locks == NULL)
    diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
    index c7d54ed..0eaaf62 100644
    --- a/crypto/rand/md_rand.c
    +++ b/crypto/rand/md_rand.c
    @@ -166,35 +166,35 @@ int rand_predictable = 0;
     
     static void rand_hw_seed(EVP_MD_CTX *ctx);
     
    -static void ssleay_rand_cleanup(void);
    -static int ssleay_rand_seed(const void *buf, int num);
    -static int ssleay_rand_add(const void *buf, int num, double add_entropy);
    -static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo);
    -static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num);
    +static void rand_cleanup(void);
    +static int rand_seed(const void *buf, int num);
    +static int rand_add(const void *buf, int num, double add_entropy);
    +static int rand_bytes(unsigned char *buf, int num, int pseudo);
    +static int rand_nopseudo_bytes(unsigned char *buf, int num);
     #ifndef OPENSSL_NO_DEPRECATED
    -static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
    +static int rand_pseudo_bytes(unsigned char *buf, int num);
     #endif
    -static int ssleay_rand_status(void);
    +static int rand_status(void);
     
    -static RAND_METHOD rand_ssleay_meth = {
    -    ssleay_rand_seed,
    -    ssleay_rand_nopseudo_bytes,
    -    ssleay_rand_cleanup,
    -    ssleay_rand_add,
    +static RAND_METHOD rand_meth = {
    +    rand_seed,
    +    rand_nopseudo_bytes,
    +    rand_cleanup,
    +    rand_add,
     #ifndef OPENSSL_NO_DEPRECATED
    -    ssleay_rand_pseudo_bytes,
    +    rand_pseudo_bytes,
     #else
         NULL,
     #endif
    -    ssleay_rand_status
    +    rand_status
     };
     
    -RAND_METHOD *RAND_SSLeay(void)
    +RAND_METHOD *RAND_OpenSSL(void)
     {
    -    return (&rand_ssleay_meth);
    +    return (&rand_meth);
     }
     
    -static void ssleay_rand_cleanup(void)
    +static void rand_cleanup(void)
     {
         OPENSSL_cleanse(state, sizeof(state));
         state_num = 0;
    @@ -206,7 +206,7 @@ static void ssleay_rand_cleanup(void)
         initialized = 0;
     }
     
    -static int ssleay_rand_add(const void *buf, int num, double add)
    +static int rand_add(const void *buf, int num, double add)
     {
         int i, j, k, st_idx;
         long md_c[2];
    @@ -355,12 +355,12 @@ static int ssleay_rand_add(const void *buf, int num, double add)
         return rv;
     }
     
    -static int ssleay_rand_seed(const void *buf, int num)
    +static int rand_seed(const void *buf, int num)
     {
    -    return ssleay_rand_add(buf, num, (double)num);
    +    return rand_add(buf, num, (double)num);
     }
     
    -static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
    +static int rand_bytes(unsigned char *buf, int num, int pseudo)
     {
         static volatile int stirred_pool = 0;
         int i, j, k, st_num, st_idx;
    @@ -433,7 +433,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
     
         CRYPTO_w_lock(CRYPTO_LOCK_RAND);
     
    -    /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
    +    /* prevent rand_bytes() from trying to obtain the lock again */
         CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
         CRYPTO_THREADID_current(&locking_threadid);
         CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
    @@ -470,7 +470,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
              * In the output function only half of 'md' remains secret, so we
              * better make sure that the required entropy gets 'evenly
              * distributed' through 'state', our randomness pool. The input
    -         * function (ssleay_rand_add) chains all of 'md', which makes it more
    +         * function (rand_add) chains all of 'md', which makes it more
              * suitable for this purpose.
              */
     
    @@ -482,9 +482,9 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
     #define DUMMY_SEED "...................." /* at least MD_DIGEST_LENGTH */
                 /*
                  * Note that the seed does not matter, it's just that
    -             * ssleay_rand_add expects to have something to hash.
    +             * rand_add expects to have something to hash.
                  */
    -            ssleay_rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);
    +            rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);
                 n -= MD_DIGEST_LENGTH;
             }
             if (ok)
    @@ -588,34 +588,34 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
         else if (pseudo)
             return 0;
         else {
    -        RANDerr(RAND_F_SSLEAY_RAND_BYTES, RAND_R_PRNG_NOT_SEEDED);
    +        RANDerr(RAND_F_RAND_BYTES, RAND_R_PRNG_NOT_SEEDED);
             ERR_add_error_data(1, "You need to read the OpenSSL FAQ, "
                                "http://www.openssl.org/support/faq.html");
             return (0);
         }
      err:
         EVP_MD_CTX_cleanup(&m);
    -    RANDerr(RAND_F_SSLEAY_RAND_BYTES, ERR_R_EVP_LIB);
    +    RANDerr(RAND_F_RAND_BYTES, ERR_R_EVP_LIB);
         return 0;
     
     }
     
    -static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num)
    +static int rand_nopseudo_bytes(unsigned char *buf, int num)
     {
    -    return ssleay_rand_bytes(buf, num, 0);
    +    return rand_bytes(buf, num, 0);
     }
     
     #ifndef OPENSSL_NO_DEPRECATED
     /*
      * pseudo-random bytes that are guaranteed to be unique but not unpredictable
      */
    -static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
    +static int rand_pseudo_bytes(unsigned char *buf, int num)
     {
    -    return ssleay_rand_bytes(buf, num, 1);
    +    return rand_bytes(buf, num, 1);
     }
     #endif
     
    -static int ssleay_rand_status(void)
    +static int rand_status(void)
     {
         CRYPTO_THREADID cur;
         int ret;
    @@ -637,7 +637,7 @@ static int ssleay_rand_status(void)
             CRYPTO_w_lock(CRYPTO_LOCK_RAND);
     
             /*
    -         * prevent ssleay_rand_bytes() from trying to obtain the lock again
    +         * prevent rand_bytes() from trying to obtain the lock again
              */
             CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
             CRYPTO_THREADID_cpy(&locking_threadid, &cur);
    diff --git a/crypto/rand/rand_err.c b/crypto/rand/rand_err.c
    index 6ab904d..c22677e 100644
    --- a/crypto/rand/rand_err.c
    +++ b/crypto/rand/rand_err.c
    @@ -1,6 +1,6 @@
     /* crypto/rand/rand_err.c */
     /* ====================================================================
    - * Copyright (c) 1999-2010 The OpenSSL Project.  All rights reserved.
    + * Copyright (c) 1999-2015 The OpenSSL Project.  All rights reserved.
      *
      * Redistribution and use in source and binary forms, with or without
      * modification, are permitted provided that the following conditions
    @@ -75,8 +75,8 @@ static ERR_STRING_DATA RAND_str_functs[] = {
         {ERR_FUNC(RAND_F_FIPS_SET_PRNG_SEED), "FIPS_SET_PRNG_SEED"},
         {ERR_FUNC(RAND_F_FIPS_SET_TEST_MODE), "FIPS_SET_TEST_MODE"},
         {ERR_FUNC(RAND_F_FIPS_X931_SET_DT), "FIPS_x931_set_dt"},
    +    {ERR_FUNC(RAND_F_RAND_BYTES), "RAND_bytes"},
         {ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"},
    -    {ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"},
         {0, NULL}
     };
     
    diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
    index 102ed05..55c90cc 100644
    --- a/crypto/rand/rand_lib.c
    +++ b/crypto/rand/rand_lib.c
    @@ -104,7 +104,7 @@ const RAND_METHOD *RAND_get_rand_method(void)
                 funct_ref = e;
             else
     #endif
    -            default_RAND_meth = RAND_SSLeay();
    +            default_RAND_meth = RAND_OpenSSL();
         }
         return default_RAND_meth;
     }
    @@ -197,7 +197,7 @@ static size_t drbg_get_entropy(DRBG_CTX *ctx, unsigned char **pout,
         *pout = OPENSSL_malloc(min_len);
         if (!*pout)
             return 0;
    -    if (RAND_SSLeay()->bytes(*pout, min_len) <= 0) {
    +    if (RAND_OpenSSL()->bytes(*pout, min_len) <= 0) {
             OPENSSL_free(*pout);
             *pout = NULL;
             return 0;
    @@ -234,12 +234,12 @@ static size_t drbg_get_adin(DRBG_CTX *ctx, unsigned char **pout)
     static int drbg_rand_add(DRBG_CTX *ctx, const void *in, int inlen,
                              double entropy)
     {
    -    return RAND_SSLeay()->add(in, inlen, entropy);
    +    return RAND_OpenSSL()->add(in, inlen, entropy);
     }
     
     static int drbg_rand_seed(DRBG_CTX *ctx, const void *in, int inlen)
     {
    -    return RAND_SSLeay()->seed(in, inlen);
    +    return RAND_OpenSSL()->seed(in, inlen);
     }
     
     int RAND_init_fips(void)
    diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c
    index 837e915..a41964d 100644
    --- a/crypto/rsa/rsa_eay.c
    +++ b/crypto/rsa/rsa_eay.c
    @@ -146,7 +146,7 @@ static RSA_METHOD rsa_pkcs1_eay_meth = {
         NULL                        /* rsa_keygen */
     };
     
    -const RSA_METHOD *RSA_PKCS1_SSLeay(void)
    +const RSA_METHOD *RSA_PKCS1_OpenSSL(void)
     {
         return (&rsa_pkcs1_eay_meth);
     }
    diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c
    index c64dad4..594722b 100644
    --- a/crypto/rsa/rsa_lib.c
    +++ b/crypto/rsa/rsa_lib.c
    @@ -87,7 +87,7 @@ const RSA_METHOD *RSA_get_default_method(void)
     #ifdef RSA_NULL
             default_RSA_meth = RSA_null_method();
     #else
    -        default_RSA_meth = RSA_PKCS1_SSLeay();
    +        default_RSA_meth = RSA_PKCS1_OpenSSL();
     #endif
         }
     
    diff --git a/demos/easy_tls/easy-tls.c b/demos/easy_tls/easy-tls.c
    index 5b65780..e42d28a 100644
    --- a/demos/easy_tls/easy-tls.c
    +++ b/demos/easy_tls/easy-tls.c
    @@ -418,7 +418,7 @@ static int tls_init(void *apparg)
             return 0;
     
         SSL_load_error_strings();
    -    if (!SSL_library_init() /* aka SSLeay_add_ssl_algorithms() */ ) {
    +    if (!SSL_library_init()) {
             tls_errprintf(1, apparg, "SSL_library_init failed.\n");
             return -1;
         }
    diff --git a/demos/engines/ibmca/hw_ibmca.c b/demos/engines/ibmca/hw_ibmca.c
    index 29f8547..c0f2982 100644
    --- a/demos/engines/ibmca/hw_ibmca.c
    +++ b/demos/engines/ibmca/hw_ibmca.c
    @@ -241,14 +241,14 @@ static int bind_helper(ENGINE *e)
     
     #  ifndef OPENSSL_NO_RSA
         /*
    -     * We know that the "PKCS1_SSLeay()" functions hook properly to the
    +     * We know that the "PKCS1_OpenSSL()" functions hook properly to the
          * ibmca-specific mod_exp and mod_exp_crt so we use those functions. NB:
          * We don't use ENGINE_openssl() or anything "more generic" because
          * something like the RSAref code may not hook properly, and if you own
          * one of these cards then you have the right to do RSA operations on it
          * anyway!
          */
    -    meth1 = RSA_PKCS1_SSLeay();
    +    meth1 = RSA_PKCS1_OpenSSL();
         ibmca_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
         ibmca_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
         ibmca_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
    diff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c
    index 5f50980..132ece0 100644
    --- a/demos/engines/zencod/hw_zencod.c
    +++ b/demos/engines/zencod/hw_zencod.c
    @@ -309,14 +309,14 @@ static int bind_helper(ENGINE *e)
         }
     #  ifndef OPENSSL_NO_RSA
         /*
    -     * We know that the "PKCS1_SSLeay()" functions hook properly to the
    +     * We know that the "PKCS1_OpenSSL()" functions hook properly to the
          * Zencod-specific mod_exp and mod_exp_crt so we use those functions. NB:
          * We don't use ENGINE_openssl() or anything "more generic" because
          * something like the RSAref code may not hook properly, and if you own
          * one of these cards then you have the right to do RSA operations on it
          * anyway!
          */
    -    meth_rsa = RSA_PKCS1_SSLeay();
    +    meth_rsa = RSA_PKCS1_OpenSSL();
     
         zencod_rsa.rsa_pub_enc = meth_rsa->rsa_pub_enc;
         zencod_rsa.rsa_pub_dec = meth_rsa->rsa_pub_dec;
    @@ -358,9 +358,9 @@ static int bind_helper(ENGINE *e)
     #  endif
     
         /*
    -     * We use OpenSSL (SSLeay) meth to supply what we don't provide ;-*)
    +     * We use OpenSSL meth to supply what we don't provide ;-*)
          */
    -    meth_rand = RAND_SSLeay();
    +    meth_rand = RAND_OpenSSL();
     
         /* meth_rand->seed ; */
         /* zencod_rand.seed = meth_rand->seed ; */
    @@ -776,7 +776,7 @@ static int RSA_zencod_rsa_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa)
         if (RSA_size(rsa) * 8 > ZENBRIDGE_MAX_KEYSIZE_RSA_CRT) {
             const RSA_METHOD *meth;
     
    -        meth = RSA_PKCS1_SSLeay();
    +        meth = RSA_PKCS1_OpenSSL();
             return meth->rsa_mod_exp(r0, i, rsa);
         } else {
             zen_nb_t y, x, p, q, dmp1, dmq1, iqmp;
    @@ -827,7 +827,7 @@ static int RSA_zencod_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
         if (BN_num_bits(m) > ZENBRIDGE_MAX_KEYSIZE_RSA) {
             const RSA_METHOD *meth;
     
    -        meth = RSA_PKCS1_SSLeay();
    +        meth = RSA_PKCS1_OpenSSL();
             return meth->bn_mod_exp(r, a, p, m, ctx, m_ctx);
         } else {
             zen_nb_t y, x, e, n;
    diff --git a/demos/pkcs12/pkwrite.c b/demos/pkcs12/pkwrite.c
    index 34e82dd..753fbfe 100644
    --- a/demos/pkcs12/pkwrite.c
    +++ b/demos/pkcs12/pkwrite.c
    @@ -18,7 +18,7 @@ int main(int argc, char **argv)
             fprintf(stderr, "Usage: pkwrite infile password name p12file\n");
             exit(1);
         }
    -    SSLeay_add_all_algorithms();
    +    OpenSSL_add_all_algorithms();
         ERR_load_crypto_strings();
         if ((fp = fopen(argv[1], "r")) == NULL) {
             fprintf(stderr, "Error opening file %s\n", argv[1]);
    diff --git a/demos/sign/sign.c b/demos/sign/sign.c
    index 22f53fb..f6aab25 100644
    --- a/demos/sign/sign.c
    +++ b/demos/sign/sign.c
    @@ -57,7 +57,7 @@
      */
     
     /*
    - * sign-it.cpp - Simple test app using SSLeay envelopes to sign data
    + * sign-it.cpp - Simple test app using EVP envelopes to sign data
      * 29.9.1996, Sampo Kellomaki 
      */
     
    diff --git a/demos/ssl/cli.cpp b/demos/ssl/cli.cpp
    index 3459f0f..fcc4d9d 100644
    --- a/demos/ssl/cli.cpp
    +++ b/demos/ssl/cli.cpp
    @@ -1,7 +1,7 @@
     /* cli.cpp  -  Minimal ssleay client for Unix
        30.9.1996, Sampo Kellomaki  */
     
    -/* mangled to work with SSLeay-0.9.0b and OpenSSL 0.9.2b
    +/* mangled to work with OpenSSL 0.9.2b
        Simplified to be even more minimal
        12/98 - 4/99 Wade Scholine  */
     
    @@ -37,7 +37,7 @@ void main ()
       char     buf [4096];
       SSL_METHOD *meth;
     
    -  SSLeay_add_ssl_algorithms();
    +  OpenSSL_add_ssl_algorithms();
       meth = TLS_client_method();
       SSL_load_error_strings();
       ctx = SSL_CTX_new (meth);                        CHK_NULL(ctx);
    diff --git a/demos/ssl/inetdsrv.cpp b/demos/ssl/inetdsrv.cpp
    index efd70d2..7434030 100644
    --- a/demos/ssl/inetdsrv.cpp
    +++ b/demos/ssl/inetdsrv.cpp
    @@ -7,7 +7,7 @@
     #include 
     #include 
     
    -#include "rsa.h"       /* SSLeay stuff */
    +#include "rsa.h"
     #include 
     #include 
     #include 
    diff --git a/demos/ssl/serv.cpp b/demos/ssl/serv.cpp
    index 9cb77f8..43ff88e 100644
    --- a/demos/ssl/serv.cpp
    +++ b/demos/ssl/serv.cpp
    @@ -2,7 +2,7 @@
        30.9.1996, Sampo Kellomaki  */
     
     
    -/* mangled to work with SSLeay-0.9.0b and OpenSSL 0.9.2b
    +/* mangled to work with OpenSSL 0.9.2b
        Simplified to be even more minimal
        12/98 - 4/99 Wade Scholine  */
     
    @@ -17,7 +17,7 @@
     #include 
     #include 
     
    -#include        /* SSLeay stuff */
    +#include 
     #include 
     #include 
     #include 
    @@ -54,7 +54,7 @@ void main ()
       /* SSL preliminaries. We keep the certificate and key with the context. */
     
       SSL_load_error_strings();
    -  SSLeay_add_ssl_algorithms();
    +  OpenSSL_add_ssl_algorithms();
       meth = TLS_server_method();
       ctx = SSL_CTX_new (meth);
       if (!ctx) {
    diff --git a/doc/apps/dhparam.pod b/doc/apps/dhparam.pod
    index b0a9802..5919935 100644
    --- a/doc/apps/dhparam.pod
    +++ b/doc/apps/dhparam.pod
    @@ -117,7 +117,7 @@ for all available algorithms.
     =head1 WARNINGS
     
     The program B combines the functionality of the programs B and
    -B in previous versions of OpenSSL and SSLeay. The B and B
    +B in previous versions of OpenSSL. The B and B
     programs are retained for now but may have different purposes in future 
     versions of OpenSSL.
     
    diff --git a/doc/apps/enc.pod b/doc/apps/enc.pod
    index 26e678c..8f7e1cb 100644
    --- a/doc/apps/enc.pod
    +++ b/doc/apps/enc.pod
    @@ -62,8 +62,7 @@ use a salt in the key derivation routines. This is the default.
     =item B<-nosalt>
     
     don't use a salt in the key derivation routines. This option B be
    -used except for test purposes or compatibility with ancient versions of OpenSSL
    -and SSLeay.
    +used except for test purposes or compatibility with ancient versions of OpenSSL.
     
     =item B<-e>
     
    @@ -181,7 +180,7 @@ A password will be prompted for to derive the key and IV if necessary.
     
     The B<-salt> option should B be used if the key is being derived
     from a password unless you want compatibility with previous versions of
    -OpenSSL and SSLeay.
    +OpenSSL.
     
     Without the B<-salt> option it is possible to perform efficient dictionary
     attacks on the password and to attack stream cipher encrypted data. The reason
    diff --git a/doc/apps/req.pod b/doc/apps/req.pod
    index ec19192..880061e 100644
    --- a/doc/apps/req.pod
    +++ b/doc/apps/req.pod
    @@ -621,8 +621,7 @@ for more information.
     
     The variable B if defined allows an alternative configuration
     file location to be specified, it will be overridden by the B<-config> command
    -line switch if it is present. For compatibility reasons the B
    -environment variable serves the same purpose but its use is discouraged.
    +line switch if it is present.
     
     =head1 BUGS
     
    diff --git a/doc/apps/verify.pod b/doc/apps/verify.pod
    index c935269..74477e5 100644
    --- a/doc/apps/verify.pod
    +++ b/doc/apps/verify.pod
    @@ -307,7 +307,7 @@ the B section of the B utility.
     
     The third operation is to check the trust settings on the root CA. The root
     CA should be trusted for the supplied purpose. For compatibility with previous
    -versions of SSLeay and OpenSSL a certificate with no trust settings is considered
    +versions of OpenSSL, a certificate with no trust settings is considered
     to be valid for all purposes. 
     
     The final operation is to check the validity of the certificate chain. The validity
    diff --git a/doc/crypto/OPENSSL_VERSION_NUMBER.pod b/doc/crypto/OPENSSL_VERSION_NUMBER.pod
    index c8fed0f..fc16536 100644
    --- a/doc/crypto/OPENSSL_VERSION_NUMBER.pod
    +++ b/doc/crypto/OPENSSL_VERSION_NUMBER.pod
    @@ -2,7 +2,8 @@
     
     =head1 NAME
     
    -OPENSSL_VERSION_NUMBER, OpenSSL_version - get OpenSSL version number
    +OPENSSL_VERSION_NUMBER, OpenSSL_version,
    +OpenSSL_version_num - get OpenSSL version number
     
     =head1 SYNOPSIS
     
    @@ -10,6 +11,8 @@ OPENSSL_VERSION_NUMBER, OpenSSL_version - get OpenSSL version number
      #define OPENSSL_VERSION_NUMBER 0xnnnnnnnnnL
     
      #include 
    +
    + unsigned long OpenSSL_version_num();
      const char *OpenSSL_version(int t);
     
     =head1 DESCRIPTION
    @@ -42,8 +45,7 @@ Version 0.9.5a had an interim interpretation that is like the current one,
     except the patch level got the highest bit set, to keep continuity.  The
     number was therefore 0x0090581f.
     
    -
    -For backward compatibility, OPENSSL_VERSION_NUMBER is also defined.
    +OpenSSL_version_num() returns the version number.
     
     OpenSSL_version() returns different strings depending on B:
     
    diff --git a/doc/crypto/RAND_set_rand_method.pod b/doc/crypto/RAND_set_rand_method.pod
    index fe7f441..533d577 100644
    --- a/doc/crypto/RAND_set_rand_method.pod
    +++ b/doc/crypto/RAND_set_rand_method.pod
    @@ -2,7 +2,7 @@
     
     =head1 NAME
     
    -RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method
    +RAND_set_rand_method, RAND_get_rand_method, RAND_OpenSSL - select RAND method
     
     =head1 SYNOPSIS
     
    @@ -12,7 +12,7 @@ RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method
     
      const RAND_METHOD *RAND_get_rand_method(void);
     
    - RAND_METHOD *RAND_SSLeay(void);
    + RAND_METHOD *RAND_OpenSSL(void);
     
     =head1 DESCRIPTION
     
    @@ -23,7 +23,7 @@ information about how these RAND API functions are affected by the use of
     B API calls.
     
     Initially, the default RAND_METHOD is the OpenSSL internal implementation, as
    -returned by RAND_SSLeay().
    +returned by RAND_OpenSSL().
     
     RAND_set_default_method() makes B the method for PRNG use. B: This is
     true only whilst no ENGINE has been set as a default for RAND, so this function
    @@ -53,7 +53,7 @@ Each component may be NULL if the function is not implemented.
     =head1 RETURN VALUES
     
     RAND_set_rand_method() returns no value. RAND_get_rand_method() and
    -RAND_SSLeay() return pointers to the respective methods.
    +RAND_OpenSSL() return pointers to the respective methods.
     
     =head1 NOTES
     
    diff --git a/doc/crypto/SSLeay_version.pod b/doc/crypto/SSLeay_version.pod
    deleted file mode 100644
    index 4862cd4..0000000
    --- a/doc/crypto/SSLeay_version.pod
    +++ /dev/null
    @@ -1,70 +0,0 @@
    -=pod
    -
    -=head1 NAME
    -
    -SSLeay_version - retrieve version/build information about OpenSSL library
    -
    -=head1 SYNOPSIS
    -
    - #include 
    -
    - const char *SSLeay_version(int type);
    -
    -=head1 DESCRIPTION
    -
    -SSLeay_version() returns a pointer to a constant string describing the
    -version of the OpenSSL library or giving information about the library
    -build.
    -
    -The following B values are supported:
    -
    -=over 4
    -
    -=item SSLEAY_VERSION
    -
    -The version of the OpenSSL library including the release date.
    -
    -=item SSLEAY_CFLAGS
    -
    -The compiler flags set for the compilation process in the form
    -"compiler: ..."  if available or "compiler: information not available"
    -otherwise.
    -
    -=item SSLEAY_BUILT_ON
    -
    -The date of the build process in the form "built on: ..." if available
    -or "built on: date not available" otherwise.
    -
    -=item SSLEAY_PLATFORM
    -
    -The "Configure" target of the library build in the form "platform: ..."
    -if available or "platform: information not available" otherwise.
    -
    -=item SSLEAY_DIR
    -
    -The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "...""
    -if available or "OPENSSLDIR: N/A" otherwise.
    -
    -=back
    -
    -=head1 RETURN VALUES
    -
    -The following return values can occur:
    -
    -=over 4
    -
    -=item "not available"
    -
    -An invalid value for B was given.
    -
    -=item Pointer to constant string
    -
    -Textual description.
    -
    -=back
    -
    -=head1 SEE ALSO
    -
    -L
    -
    -=cut
    diff --git a/doc/ssl/SSL_library_init.pod b/doc/ssl/SSL_library_init.pod
    index ab9d05d..d96d3f0 100644
    --- a/doc/ssl/SSL_library_init.pod
    +++ b/doc/ssl/SSL_library_init.pod
    @@ -2,7 +2,7 @@
     
     =head1 NAME
     
    -SSL_library_init, OpenSSL_add_ssl_algorithms, SSLeay_add_ssl_algorithms
    +SSL_library_init, OpenSSL_add_ssl_algorithms,
     - initialize SSL library by registering algorithms
     
     =head1 SYNOPSIS
    @@ -11,14 +11,12 @@ SSL_library_init, OpenSSL_add_ssl_algorithms, SSLeay_add_ssl_algorithms
     
      int SSL_library_init(void);
      #define OpenSSL_add_ssl_algorithms()    SSL_library_init()
    - #define SSLeay_add_ssl_algorithms()     SSL_library_init()
     
     =head1 DESCRIPTION
     
     SSL_library_init() registers the available SSL/TLS ciphers and digests.
     
    -OpenSSL_add_ssl_algorithms() and SSLeay_add_ssl_algorithms() are synonyms
    -for SSL_library_init().
    +OpenSSL_add_ssl_algorithms() is a synonym for SSL_library_init().
     
     =head1 NOTES
     
    diff --git a/e_os.h b/e_os.h
    index 6aa0f73..8a08099 100644
    --- a/e_os.h
    +++ b/e_os.h
    @@ -328,7 +328,6 @@ extern FILE *_imp___iob;
     #   define R_OK        4
     #  endif
     #  define OPENSSL_CONF  "openssl.cnf"
    -#  define SSLEAY_CONF   OPENSSL_CONF
     #  define NUL_DEV       "nul"
     #  define RFILE         ".rnd"
     #  ifdef OPENSSL_SYS_WINCE
    @@ -361,7 +360,6 @@ extern FILE *_imp___iob;
     #    include 
     #   endif
     #   define OPENSSL_CONF        "openssl.cnf"
    -#   define SSLEAY_CONF         OPENSSL_CONF
     #   define RFILE               ".rnd"
     #   define LIST_SEPARATOR_CHAR ','
     #   define NUL_DEV             "NLA0:"
    @@ -412,7 +410,6 @@ extern int kbhit(void);
     #   define _O_TEXT O_TEXT
     #   define _O_BINARY O_BINARY
     #   define OPENSSL_CONF   "openssl.cnf"
    -#   define SSLEAY_CONF    OPENSSL_CONF
     #   define RFILE    ".rnd"
     #   define LIST_SEPARATOR_CHAR ';'
     #   define EXIT(n)  { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
    @@ -433,14 +430,13 @@ extern int kbhit(void);
     #   endif
     
     #   define OPENSSL_CONF        "openssl.cnf"
    -#   define SSLEAY_CONF         OPENSSL_CONF
     #   define RFILE               ".rnd"
     #   define LIST_SEPARATOR_CHAR ':'
     #   define NUL_DEV             "/dev/null"
     #   define EXIT(n)             exit(n)
     #  endif
     
    -#  define SSLeay_getpid()       getpid()
    +#  define OpenSSL_getpid()       getpid()
     
     # endif
     
    @@ -455,8 +451,8 @@ extern int kbhit(void);
           /* windows world */
     
     #   ifdef OPENSSL_NO_SOCK
    -#    define SSLeay_Write(a,b,c)       (-1)
    -#    define SSLeay_Read(a,b,c)        (-1)
    +#    define OpenSSL_Write(a,b,c)       (-1)
    +#    define OpenSSL_Read(a,b,c)        (-1)
     #    define SHUTDOWN(fd)              close(fd)
     #    define SHUTDOWN2(fd)             close(fd)
     #   elif !defined(__DJGPP__)
    @@ -484,13 +480,13 @@ struct servent *PASCAL getservbyname(const char *, const char *);
     #     define socket(d,t,p)   ((int)socket(d,t,p))
     #     define accept(s,f,l)   ((int)accept(s,f,l))
     #    endif
    -#    define SSLeay_Write(a,b,c)       send((a),(b),(c),0)
    -#    define SSLeay_Read(a,b,c)        recv((a),(b),(c),0)
    +#    define OpenSSL_Write(a,b,c)       send((a),(b),(c),0)
    +#    define OpenSSL_Read(a,b,c)        recv((a),(b),(c),0)
     #    define SHUTDOWN(fd)              { shutdown((fd),0); closesocket(fd); }
     #    define SHUTDOWN2(fd)             { shutdown((fd),2); closesocket(fd); }
     #   else
    -#    define SSLeay_Write(a,b,c)       write_s(a,b,c,0)
    -#    define SSLeay_Read(a,b,c)        read_s(a,b,c)
    +#    define OpenSSL_Write(a,b,c)       write_s(a,b,c,0)
    +#    define OpenSSL_Read(a,b,c)        read_s(a,b,c)
     #    define SHUTDOWN(fd)              close_s(fd)
     #    define SHUTDOWN2(fd)             close_s(fd)
     #   endif
    @@ -513,8 +509,8 @@ struct servent *PASCAL getservbyname(const char *, const char *);
     #   else
     #    include 
     #   endif
    -#   define SSLeay_Write(a,b,c)   send((a),(b),(c),0)
    -#   define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
    +#   define OpenSSL_Write(a,b,c)   send((a),(b),(c),0)
    +#   define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
     #   define SHUTDOWN(fd)    { shutdown((fd),0); closesocket(fd); }
     #   define SHUTDOWN2(fd)      { shutdown((fd),2); closesocket(fd); }
     
    @@ -579,8 +575,8 @@ struct servent *PASCAL getservbyname(const char *, const char *);
     #    endif
     #   endif
     
    -#   define SSLeay_Read(a,b,c)     read((a),(b),(c))
    -#   define SSLeay_Write(a,b,c)    write((a),(b),(c))
    +#   define OpenSSL_Read(a,b,c)     read((a),(b),(c))
    +#   define OpenSSL_Write(a,b,c)    write((a),(b),(c))
     #   define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
     #   define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
     #   ifndef INVALID_SOCKET
    diff --git a/engines/e_capi.c b/engines/e_capi.c
    index 5256768..a38592b 100644
    --- a/engines/e_capi.c
    +++ b/engines/e_capi.c
    @@ -472,7 +472,7 @@ static int capi_init(ENGINE *e)
     
             /* Setup RSA_METHOD */
             rsa_capi_idx = RSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
    -        ossl_rsa_meth = RSA_PKCS1_SSLeay();
    +        ossl_rsa_meth = RSA_PKCS1_OpenSSL();
             capi_rsa_method.rsa_pub_enc = ossl_rsa_meth->rsa_pub_enc;
             capi_rsa_method.rsa_pub_dec = ossl_rsa_meth->rsa_pub_dec;
             capi_rsa_method.rsa_mod_exp = ossl_rsa_meth->rsa_mod_exp;
    diff --git a/engines/e_chil.c b/engines/e_chil.c
    index 0764c01..54c6b91 100644
    --- a/engines/e_chil.c
    +++ b/engines/e_chil.c
    @@ -376,14 +376,14 @@ static int bind_helper(ENGINE *e)
     
     #  ifndef OPENSSL_NO_RSA
         /*
    -     * We know that the "PKCS1_SSLeay()" functions hook properly to the
    +     * We know that the "PKCS1_OpenSSL()" functions hook properly to the
          * cswift-specific mod_exp and mod_exp_crt so we use those functions. NB:
          * We don't use ENGINE_openssl() or anything "more generic" because
          * something like the RSAref code may not hook properly, and if you own
          * one of these cards then you have the right to do RSA operations on it
          * anyway!
          */
    -    meth1 = RSA_PKCS1_SSLeay();
    +    meth1 = RSA_PKCS1_OpenSSL();
         hwcrhk_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
         hwcrhk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
         hwcrhk_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
    diff --git a/engines/e_gmp.c b/engines/e_gmp.c
    index dd72759..7888c2b 100644
    --- a/engines/e_gmp.c
    +++ b/engines/e_gmp.c
    @@ -170,7 +170,7 @@ static int bind_helper(ENGINE *e)
             return 0;
     
     #  ifndef OPENSSL_NO_RSA
    -    meth1 = RSA_PKCS1_SSLeay();
    +    meth1 = RSA_PKCS1_OpenSSL();
         e_gmp_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
         e_gmp_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
         e_gmp_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
    diff --git a/engines/e_ubsec.c b/engines/e_ubsec.c
    index 34be930..ef070b0 100644
    --- a/engines/e_ubsec.c
    +++ b/engines/e_ubsec.c
    @@ -233,14 +233,14 @@ static int bind_helper(ENGINE *e)
     
     #  ifndef OPENSSL_NO_RSA
         /*
    -     * We know that the "PKCS1_SSLeay()" functions hook properly to the
    +     * We know that the "PKCS1_OpenSSL()" functions hook properly to the
          * Broadcom-specific mod_exp and mod_exp_crt so we use those functions.
          * NB: We don't use ENGINE_openssl() or anything "more generic" because
          * something like the RSAref code may not hook properly, and if you own
          * one of these cards then you have the right to do RSA operations on it
          * anyway!
          */
    -    meth1 = RSA_PKCS1_SSLeay();
    +    meth1 = RSA_PKCS1_OpenSSL();
         ubsec_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
         ubsec_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
         ubsec_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
    @@ -611,7 +611,7 @@ static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
             /*
              * Do in software as hardware failed.
              */
    -        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *meth = RSA_PKCS1_OpenSSL();
             to_return = (*meth->rsa_mod_exp) (r0, I, rsa, ctx);
         }
      err:
    @@ -679,7 +679,7 @@ static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
     
         /* Do in software if the key is too large for the hardware. */
         if (BN_num_bits(m) > max_key_len) {
    -        const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
    +        const RSA_METHOD *meth = RSA_PKCS1_OpenSSL();
             ret = (*meth->bn_mod_exp) (r, a, p, m, ctx, m_ctx);
         } else {
             ret = ubsec_mod_exp(r, a, p, m, ctx);
    @@ -978,7 +978,7 @@ static int ubsec_rand_bytes(unsigned char *buf, int num)
             const RAND_METHOD *meth;
             UBSECerr(UBSEC_F_UBSEC_RAND_BYTES, UBSEC_R_UNIT_FAILURE);
             num = p_UBSEC_ubsec_bits_to_bytes(num);
    -        meth = RAND_SSLeay();
    +        meth = RAND_OpenSSL();
             meth->seed(buf, num);
             ret = meth->bytes(buf, num);
             goto err;
    @@ -994,7 +994,7 @@ static int ubsec_rand_bytes(unsigned char *buf, int num)
             p_UBSEC_ubsec_close(fd);
     
             num = p_UBSEC_ubsec_bits_to_bytes(num);
    -        meth = RAND_SSLeay();
    +        meth = RAND_OpenSSL();
             meth->seed(buf, num);
             ret = meth->bytes(buf, num);
     
    diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h
    index 56afc51..5d15515 100644
    --- a/include/openssl/crypto.h
    +++ b/include/openssl/crypto.h
    @@ -145,19 +145,6 @@
     extern "C" {
     #endif
     
    -/* Backward compatibility to SSLeay */
    -/*
    - * This is more to be used to check the correct DLL is being used in the MS
    - * world.
    - */
    -# define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER
    -# define SSLEAY_VERSION          0
    -/* #define SSLEAY_OPTIONS       1 no longer supported */
    -# define SSLEAY_CFLAGS           2
    -# define SSLEAY_BUILT_ON         3
    -# define SSLEAY_PLATFORM         4
    -# define SSLEAY_DIR              5
    -
     /*
      * When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
      * names in cryptlib.c
    @@ -243,7 +230,7 @@ typedef struct {
     } CRYPTO_dynlock;
     
     /*
    - * The following can be used to detect memory leaks in the SSLeay library. It
    + * The following can be used to detect memory leaks in the OpenSSL library. It
      * used, it turns on malloc checking
      */
     
    @@ -350,8 +337,13 @@ int CRYPTO_is_mem_check_on(void);
     
     # define OPENSSL_MALLOC_MAX_NELEMS(type)  (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))
     
    -const char *SSLeay_version(int type);
    -unsigned long SSLeay(void);
    +unsigned long OpenSSL_version_num(void);
    +const char *OpenSSL_version(int type);
    +# define OPENSSL_VERSION          0
    +# define OPENSSL_CFLAGS           1
    +# define OPENSSL_BUILT_ON         2
    +# define OPENSSL_PLATFORM         3
    +# define OPENSSL_DIR              4
     
     int OPENSSL_issetugid(void);
     
    diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h
    index 8fd5596..8e69e2e 100644
    --- a/include/openssl/dsa.h
    +++ b/include/openssl/dsa.h
    @@ -58,9 +58,8 @@
     
     /*
      * The DSS routines are based on patches supplied by
    - * Steven Schoch .  He basically did the
    - * work and I have just tweaked them a little to fit into my
    - * stylistic vision for SSLeay :-) */
    + * Steven Schoch .
    + */
     
     #ifndef HEADER_DSA_H
     # define HEADER_DSA_H
    diff --git a/include/openssl/evp.h b/include/openssl/evp.h
    index c60d178..15796c0 100644
    --- a/include/openssl/evp.h
    +++ b/include/openssl/evp.h
    @@ -959,9 +959,6 @@ void OPENSSL_add_all_algorithms_conf(void);
     
     void OpenSSL_add_all_ciphers(void);
     void OpenSSL_add_all_digests(void);
    -# define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
    -# define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
    -# define SSLeay_add_all_digests() OpenSSL_add_all_digests()
     
     int EVP_add_cipher(const EVP_CIPHER *cipher);
     int EVP_add_digest(const EVP_MD *digest);
    diff --git a/include/openssl/rand.h b/include/openssl/rand.h
    index 0086c07..d7756bb 100644
    --- a/include/openssl/rand.h
    +++ b/include/openssl/rand.h
    @@ -92,7 +92,7 @@ const RAND_METHOD *RAND_get_rand_method(void);
     # ifndef OPENSSL_NO_ENGINE
     int RAND_set_rand_engine(ENGINE *engine);
     # endif
    -RAND_METHOD *RAND_SSLeay(void);
    +RAND_METHOD *RAND_OpenSSL(void);
     void RAND_cleanup(void);
     int RAND_bytes(unsigned char *buf, int num);
     #ifdef OPENSSL_USE_DEPRECATED
    @@ -138,8 +138,8 @@ void ERR_load_RAND_strings(void);
     # define RAND_F_FIPS_SET_PRNG_SEED                        104
     # define RAND_F_FIPS_SET_TEST_MODE                        105
     # define RAND_F_FIPS_X931_SET_DT                          106
    +# define RAND_F_RAND_BYTES                                100
     # define RAND_F_RAND_GET_RAND_METHOD                      101
    -# define RAND_F_SSLEAY_RAND_BYTES                         100
     
     /* Reason codes. */
     # define RAND_R_NOT_IN_TEST_MODE                          101
    diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h
    index 9abb2a1..1b3027d 100644
    --- a/include/openssl/rsa.h
    +++ b/include/openssl/rsa.h
    @@ -365,8 +365,8 @@ int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
     /* This function needs the memory locking malloc callbacks to be installed */
     int RSA_memory_lock(RSA *r);
     
    -/* these are the actual SSLeay RSA functions */
    -const RSA_METHOD *RSA_PKCS1_SSLeay(void);
    +/* these are the actual RSA functions */
    +const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
     
     const RSA_METHOD *RSA_null_method(void);
     
    diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
    index 2e899cd..6dc88c8 100644
    --- a/include/openssl/ssl.h
    +++ b/include/openssl/ssl.h
    @@ -163,7 +163,7 @@
     extern "C" {
     #endif
     
    -/* SSLeay version number for ASN.1 encoding of the session information */
    +/* OpenSSL version number for ASN.1 encoding of the session information */
     /*-
      * Version 0 - initial version
      * Version 1 - added the optional peer certificate
    @@ -438,20 +438,10 @@ typedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type,
     # define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\
             SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2)
     
    -/*
    - * These next two were never actually used for anything since SSLeay zap so
    - * we have some more flags.
    - */
    -/*
    - * The next flag deliberately changes the ciphertest, this is a check for the
    - * PKCS#1 attack
    - */
    +/* Removed from previous versions */
     # define SSL_OP_PKCS1_CHECK_1                            0x0
     # define SSL_OP_PKCS1_CHECK_2                            0x0
    -
    -/* Removed as of OpenSSL 1.1.0 */
     # define SSL_OP_NETSCAPE_CA_DN_BUG                       0x0
    -/* Removed as of OpenSSL 1.1.0 */
     # define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG          0x0L
     /*
      * Make server add server-hello extension from early version of cryptopro
    @@ -1034,7 +1024,6 @@ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);
     # define SSL_VERIFY_CLIENT_ONCE          0x04
     
     # define OpenSSL_add_ssl_algorithms()    SSL_library_init()
    -# define SSLeay_add_ssl_algorithms()     SSL_library_init()
     
     /* More backward compatibility */
     # define SSL_get_cipher(s) \
    diff --git a/include/openssl/x509.h b/include/openssl/x509.h
    index 21a8c5a..32bec25 100644
    --- a/include/openssl/x509.h
    +++ b/include/openssl/x509.h
    @@ -233,8 +233,7 @@ DECLARE_STACK_OF(X509_TRUST)
     
     # define XN_FLAG_SEP_MASK        (0xf << 16)
     
    -# define XN_FLAG_COMPAT          0/* Traditional SSLeay: use old
    -                                   * X509_NAME_print */
    +# define XN_FLAG_COMPAT          0/* Traditional; use old X509_NAME_print */
     # define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */
     # define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */
     # define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */
    diff --git a/test/recipes/80-test_ca.t b/test/recipes/80-test_ca.t
    index f57fb3c..ff6eb65 100644
    --- a/test/recipes/80-test_ca.t
    +++ b/test/recipes/80-test_ca.t
    @@ -21,17 +21,17 @@ remove_tree("demoCA", { safe => 0 });
     
     plan tests => 4;
      SKIP: {
    -     $ENV{SSLEAY_CONFIG} = "-config ".top_file("test", "CAss.cnf");
    +     $ENV{OPENSSL_CONFIG} = "-config ".top_file("test", "CAss.cnf");
          skip "failed creating CA structure", 3
     	 if !is(system("$perl ".$CA_pl." -newca < ".devnull()." 2>&1"), 0,
     		'creating CA structure');
     
    -     $ENV{SSLEAY_CONFIG} = "-config ".top_file("test", "Uss.cnf");
    +     $ENV{OPENSSL_CONFIG} = "-config ".top_file("test", "Uss.cnf");
          skip "failed creating new certificate request", 2
     	 if !is(system("$perl ".$CA_pl." -newreq 2>&1"), 0,
     		'creating new certificate request');
     
    -     $ENV{SSLEAY_CONFIG} = "-config ".$std_openssl_cnf;
    +     $ENV{OPENSSL_CONFIG} = "-config ".$std_openssl_cnf;
          skip "failed to sign certificate request", 1
     	 if !is(yes("$perl ".$CA_pl." -sign 2>&1"), 0,
     		'signing certificate request');
    diff --git a/test/recipes/80-test_tsa.t b/test/recipes/80-test_tsa.t
    index 171592a..8e02a6b 100644
    --- a/test/recipes/80-test_tsa.t
    +++ b/test/recipes/80-test_tsa.t
    @@ -74,7 +74,7 @@ indir "tsa" => sub
     {
         $ENV{OPENSSL_CONF} = top_file("test", "CAtsa.cnf");
         # Because that's what ../apps/CA.pl really looks at
    -    $ENV{SSLEAY_CONFIG} = "-config ".$ENV{OPENSSL_CONF};
    +    $ENV{OPENSSL_CONFIG} = "-config ".$ENV{OPENSSL_CONF};
         $ENV{OPENSSL} = cmdstr(app(["openssl"]));
         $testtsa = top_file("test", "recipes", "80-test_tsa.t");
         $CAtsa = top_file("test", "CAtsa.cnf");
    diff --git a/util/libeay.num b/util/libeay.num
    index 661575f..ddcf594 100755
    --- a/util/libeay.num
    +++ b/util/libeay.num
    @@ -1,5 +1,5 @@
    -SSLeay                                  1	EXIST::FUNCTION:
    -SSLeay_version                          2	EXIST::FUNCTION:
    +OpenSSL_version_num                     1	EXIST::FUNCTION:
    +OpenSSL_version                         2	EXIST::FUNCTION:
     ASN1_BIT_STRING_asn1_meth               3	NOEXIST::FUNCTION:
     ASN1_HEADER_free                        4	NOEXIST::FUNCTION:
     ASN1_HEADER_new                         5	NOEXIST::FUNCTION:
    @@ -472,7 +472,7 @@ RC4_set_key                             479	EXIST::FUNCTION:RC4
     RSAPrivateKey_asn1_meth                 480	NOEXIST::FUNCTION:
     RSAPrivateKey_dup                       481	EXIST::FUNCTION:RSA
     RSAPublicKey_dup                        482	EXIST::FUNCTION:RSA
    -RSA_PKCS1_SSLeay                        483	EXIST::FUNCTION:RSA
    +RSA_PKCS1_OpenSSL                       483	EXIST::FUNCTION:RSA
     RSA_free                                484	EXIST::FUNCTION:RSA
     RSA_generate_key                        485	EXIST::FUNCTION:DEPRECATED,RSA
     RSA_new                                 486	EXIST::FUNCTION:RSA
    @@ -1082,7 +1082,7 @@ BN_MONT_CTX_copy                        1109	EXIST::FUNCTION:
     BIO_new_socks4a_connect                 1110	NOEXIST::FUNCTION:
     BIO_s_socks4a_connect                   1111	NOEXIST::FUNCTION:
     PROXY_set_connect_mode                  1112	NOEXIST::FUNCTION:
    -RAND_SSLeay                             1113	EXIST::FUNCTION:
    +RAND_OpenSSL                            1113	EXIST::FUNCTION:
     RAND_set_rand_method                    1114	EXIST::FUNCTION:
     RSA_memory_lock                         1115	EXIST::FUNCTION:RSA
     bn_sub_words                            1116	NOEXIST::FUNCTION: