From owner-svn-src-projects@freebsd.org Mon Oct 1 20:51:27 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E91B410AA351 for ; Mon, 1 Oct 2018 20:51:26 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F0208C9C1; Mon, 1 Oct 2018 20:51:26 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 99F4826177; Mon, 1 Oct 2018 20:51:26 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w91KpQGt094483; Mon, 1 Oct 2018 20:51:26 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w91KpQdk094482; Mon, 1 Oct 2018 20:51:26 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201810012051.w91KpQdk094482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Mon, 1 Oct 2018 20:51:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r339078 - projects/openssl111/contrib/sendmail/src X-SVN-Group: projects X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: projects/openssl111/contrib/sendmail/src X-SVN-Commit-Revision: 339078 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2018 20:51:27 -0000 Author: jkim Date: Mon Oct 1 20:51:26 2018 New Revision: 339078 URL: https://svnweb.freebsd.org/changeset/base/339078 Log: Revert r338773. A patch from the ports tree will be committed. Requested by: gshapiro Modified: projects/openssl111/contrib/sendmail/src/tls.c Modified: projects/openssl111/contrib/sendmail/src/tls.c ============================================================================== --- projects/openssl111/contrib/sendmail/src/tls.c Mon Oct 1 20:39:17 2018 (r339077) +++ projects/openssl111/contrib/sendmail/src/tls.c Mon Oct 1 20:51:26 2018 (r339078) @@ -60,58 +60,18 @@ static unsigned char dh512_g[] = 0x02 }; -#if OPENSSL_VERSION_NUMBER < 0x10100000 - -static inline int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) -{ - /* If the fields p and g in d are NULL, the corresponding input - * parameters MUST be non-NULL. q may remain NULL. - */ - if ((dh->p == NULL && p == NULL) - || (dh->g == NULL && g == NULL)) - return 0; - - if (p != NULL) { - BN_free(dh->p); - dh->p = p; - } - if (q != NULL) { - BN_free(dh->q); - dh->q = q; - } - if (g != NULL) { - BN_free(dh->g); - dh->g = g; - } - - if (q != NULL) { - dh->length = BN_num_bits(q); - } - - return 1; -} -#endif - static DH * get_dh512() { DH *dh = NULL; - BIGNUM *p; - BIGNUM *g; - dh = DH_new(); - p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL); - g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL); - if (!dh || !p || !g) - goto err; - if (!DH_set0_pqg(dh, p, NULL, g)) - goto err; + if ((dh = DH_new()) == NULL) + return NULL; + dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL); + dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL); + if ((dh->p == NULL) || (dh->g == NULL)) + return NULL; return dh; -err: - DH_free(dh); - BN_free(p); - BN_free(g); - return NULL; } # if 0 @@ -157,22 +117,17 @@ get_dh2048() }; static unsigned char dh2048_g[]={ 0x02, }; DH *dh; - BIGNUM *p; - BIGNUM *g; - dh = DH_new(); - p = BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL); - g = BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL); - if (!dh || !p || !g) - goto err; - if (!DH_set0_pqg(dh, p, NULL, g)) - goto err; + if ((dh=DH_new()) == NULL) + return(NULL); + dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL); + dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL); + if ((dh->p == NULL) || (dh->g == NULL)) + { + DH_free(dh); + return(NULL); + } return(dh); -err: - DH_free(dh); - BN_free(p); - BN_free(g); - return NULL; } # endif /* !NO_DH */ @@ -971,7 +926,7 @@ inittls(ctx, req, options, srv, certfile, keyfile, cac { /* get a pointer to the current certificate validation store */ store = SSL_CTX_get_cert_store(*ctx); /* does not fail */ - crl_file = BIO_new(BIO_s_file()); + crl_file = BIO_new(BIO_s_file_internal()); if (crl_file != NULL) { if (BIO_read_filename(crl_file, CRLFile) >= 0) @@ -1045,41 +1000,26 @@ inittls(ctx, req, options, srv, certfile, keyfile, cac ** maybe we should do it only on demand... */ -# if SM_CONF_SHM if (bitset(TLS_I_RSA_TMP, req) - && ShmId != SM_SHM_NO_ID) +# if SM_CONF_SHM + && ShmId != SM_SHM_NO_ID && + (rsa_tmp = RSA_generate_key(RSA_KEYLENGTH, RSA_F4, NULL, + NULL)) == NULL +# else /* SM_CONF_SHM */ + && 0 /* no shared memory: no need to generate key now */ +# endif /* SM_CONF_SHM */ + ) { - BIGNUM *bn; - - bn = BN_new(); - rsa_tmp = RSA_new(); - if (!bn || !rsa_tmp || !BN_set_word(bn, RSA_F4)) { - RSA_free(rsa_tmp); - rsa_tmp = NULL; - } - if (rsa_tmp) + if (LogLevel > 7) { - if (!RSA_generate_key_ex(rsa_tmp, RSA_KEYLENGTH, bn, NULL)) - { - RSA_free(rsa_tmp); - rsa_tmp = NULL; - } + sm_syslog(LOG_WARNING, NOQID, + "STARTTLS=%s, error: RSA_generate_key failed", + who); + if (LogLevel > 9) + tlslogerr(LOG_WARNING, who); } - BN_free(bn); - if (!rsa_tmp) - { - if (LogLevel > 7) - { - sm_syslog(LOG_WARNING, NOQID, - "STARTTLS=%s, error: RSA_generate_key failed", - who); - if (LogLevel > 9) - tlslogerr(LOG_WARNING, who); - } - return false; - } + return false; } -# endif /* SM_CONF_SHM */ # endif /* !TLS_NO_RSA */ /* @@ -1270,15 +1210,9 @@ inittls(ctx, req, options, srv, certfile, keyfile, cac sm_dprintf("inittls: Generating %d bit DH parameters\n", bits); /* this takes a while! */ - dsa = DSA_new(); - if (dsa) { - int r; - - r = DSA_generate_parameters_ex(dsa, bits, NULL, 0, - NULL, NULL, NULL); - if (r != 0) - dh = DSA_dup_DH(dsa); - } + dsa = DSA_generate_parameters(bits, NULL, 0, NULL, + NULL, 0, NULL); + dh = DSA_dup_DH(dsa); DSA_free(dsa); } else if (dh == NULL && bitset(TLS_I_DHFIXED, req)) @@ -1799,9 +1733,6 @@ tmp_rsa_key(s, export, keylength) int export; int keylength; { - BIGNUM *bn; - int ret; - # if SM_CONF_SHM extern int ShmId; extern int *PRSATmpCnt; @@ -1811,22 +1742,10 @@ tmp_rsa_key(s, export, keylength) return rsa_tmp; # endif /* SM_CONF_SHM */ - if (rsa_tmp == NULL) { - rsa_tmp = RSA_new(); - if (!rsa_tmp) - return NULL; - } - - bn = BN_new(); - if (!bn) - return NULL; - if (!BN_set_word(bn, RSA_F4)) { - BN_free(bn); - return NULL; - } - ret = RSA_generate_key_ex(rsa_tmp, RSA_KEYLENGTH, bn, NULL); - BN_free(bn); - if (!ret) + if (rsa_tmp != NULL) + RSA_free(rsa_tmp); + rsa_tmp = RSA_generate_key(RSA_KEYLENGTH, RSA_F4, NULL, NULL); + if (rsa_tmp == NULL) { if (LogLevel > 0) sm_syslog(LOG_ERR, NOQID, @@ -2052,9 +1971,9 @@ x509_verify_cb(ok, ctx) { if (LogLevel > 13) tls_verify_log(ok, ctx, "x509"); - if (X509_STORE_CTX_get_error(ctx) == X509_V_ERR_UNABLE_TO_GET_CRL) + if (ctx->error == X509_V_ERR_UNABLE_TO_GET_CRL) { - X509_STORE_CTX_set_error(ctx, 0); + ctx->error = 0; return 1; /* override it */ } }