|
|
06f80e |
--- sendmail-8.15.2.orig/sendmail/tls.c 2016-12-01 15:20:59.953546417 +0100
|
|
|
06f80e |
+++ sendmail-8.15.2.orig/sendmail/tls.c 2016-12-01 17:26:43.868521378 +0100
|
|
|
06f80e |
@@ -63,14 +63,28 @@ static unsigned char dh512_g[] =
|
|
|
06f80e |
static DH *
|
|
|
06f80e |
get_dh512()
|
|
|
06f80e |
{
|
|
|
06f80e |
- DH *dh = NULL;
|
|
|
06f80e |
+ DH *dh;
|
|
|
06f80e |
+ BIGNUM *p, *g;
|
|
|
06f80e |
|
|
|
06f80e |
if ((dh = DH_new()) == NULL)
|
|
|
06f80e |
return NULL;
|
|
|
06f80e |
- dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
|
|
|
06f80e |
- dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
|
|
|
06f80e |
- if ((dh->p == NULL) || (dh->g == NULL))
|
|
|
06f80e |
+ p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
|
|
|
06f80e |
+ g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
|
|
|
06f80e |
+ if (p == NULL || g == NULL)
|
|
|
06f80e |
+ {
|
|
|
06f80e |
+ BN_free(p);
|
|
|
06f80e |
+ BN_free(g);
|
|
|
06f80e |
+ DH_free(dh);
|
|
|
06f80e |
return NULL;
|
|
|
06f80e |
+ }
|
|
|
06f80e |
+
|
|
|
06f80e |
+#if OPENSSL_VERSION_NUMBER >= 0x10100005L
|
|
|
06f80e |
+ DH_set0_pqg(dh, p, NULL, g);
|
|
|
06f80e |
+#else
|
|
|
06f80e |
+ dh->p = p;
|
|
|
06f80e |
+ dh->g = g;
|
|
|
06f80e |
+#endif
|
|
|
06f80e |
+
|
|
|
06f80e |
return dh;
|
|
|
06f80e |
}
|
|
|
06f80e |
|
|
|
06f80e |
@@ -117,16 +131,27 @@ get_dh2048()
|
|
|
06f80e |
};
|
|
|
06f80e |
static unsigned char dh2048_g[]={ 0x02, };
|
|
|
06f80e |
DH *dh;
|
|
|
06f80e |
+ BIGNUM *p, *g;
|
|
|
06f80e |
|
|
|
06f80e |
if ((dh=DH_new()) == NULL)
|
|
|
06f80e |
return(NULL);
|
|
|
06f80e |
- dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL);
|
|
|
06f80e |
- dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL);
|
|
|
06f80e |
- if ((dh->p == NULL) || (dh->g == NULL))
|
|
|
06f80e |
+ p = BN_bin2bn(dh2048_p, sizeof(dh2048_p), NULL);
|
|
|
06f80e |
+ g = BN_bin2bn(dh2048_g, sizeof(dh2048_g), NULL);
|
|
|
06f80e |
+ if (p == NULL || g == NULL)
|
|
|
06f80e |
{
|
|
|
06f80e |
+ BN_free(p);
|
|
|
06f80e |
+ BN_free(g);
|
|
|
06f80e |
DH_free(dh);
|
|
|
06f80e |
- return(NULL);
|
|
|
06f80e |
+ return NULL;
|
|
|
06f80e |
}
|
|
|
06f80e |
+
|
|
|
06f80e |
+#if OPENSSL_VERSION_NUMBER >= 0x10100005L
|
|
|
06f80e |
+ DH_set0_pqg(dh, p, NULL, g);
|
|
|
06f80e |
+#else
|
|
|
06f80e |
+ dh->p = p;
|
|
|
06f80e |
+ dh->g = g;
|
|
|
06f80e |
+#endif
|
|
|
06f80e |
+
|
|
|
06f80e |
return(dh);
|
|
|
06f80e |
}
|
|
|
06f80e |
# endif /* !NO_DH */
|
|
|
06f80e |
@@ -715,6 +740,54 @@ static char server_session_id_context[]
|
|
|
06f80e |
# define SM_SSL_OP_TLS_BLOCK_PADDING_BUG 0
|
|
|
06f80e |
#endif
|
|
|
06f80e |
|
|
|
06f80e |
+static RSA *
|
|
|
06f80e |
+generate_rsa_key(bits, e)
|
|
|
06f80e |
+ int bits;
|
|
|
06f80e |
+ unsigned long e;
|
|
|
06f80e |
+{
|
|
|
06f80e |
+#if OPENSSL_VERSION_NUMBER < 0x00908000L
|
|
|
06f80e |
+ return RSA_generate_key(bits, e, NULL, NULL);
|
|
|
06f80e |
+#else
|
|
|
06f80e |
+ BIGNUM *bne;
|
|
|
06f80e |
+ RSA *rsa = NULL;
|
|
|
06f80e |
+
|
|
|
06f80e |
+ bne = BN_new();
|
|
|
06f80e |
+ if (bne && BN_set_word(bne, e) != 1)
|
|
|
06f80e |
+ rsa = RSA_new();
|
|
|
06f80e |
+ if (rsa && RSA_generate_key_ex(rsa, bits, bne, NULL) != 1)
|
|
|
06f80e |
+ {
|
|
|
06f80e |
+ RSA_free(rsa);
|
|
|
06f80e |
+ rsa = NULL;
|
|
|
06f80e |
+ }
|
|
|
06f80e |
+ BN_free(bne);
|
|
|
06f80e |
+ return rsa;
|
|
|
06f80e |
+#endif
|
|
|
06f80e |
+}
|
|
|
06f80e |
+
|
|
|
06f80e |
+static DSA *
|
|
|
06f80e |
+generate_dsa_parameters(bits, seed, seed_len, counter_ret, h_ret)
|
|
|
06f80e |
+ int bits;
|
|
|
06f80e |
+ unsigned char *seed;
|
|
|
06f80e |
+ int seed_len;
|
|
|
06f80e |
+ int *counter_ret;
|
|
|
06f80e |
+ unsigned long *h_ret;
|
|
|
06f80e |
+{
|
|
|
06f80e |
+#if OPENSSL_VERSION_NUMBER < 0x00908000L
|
|
|
06f80e |
+ return DSA_generate_parameters(bits, seed, seed_len, counter_ret,
|
|
|
06f80e |
+ h_ret, NULL, NULL);
|
|
|
06f80e |
+#else
|
|
|
06f80e |
+ DSA *dsa = DSA_new();
|
|
|
06f80e |
+
|
|
|
06f80e |
+ if (dsa && DSA_generate_parameters_ex(dsa, bits, seed, seed_len,
|
|
|
06f80e |
+ counter_ret, h_ret, NULL) != 1)
|
|
|
06f80e |
+ {
|
|
|
06f80e |
+ DSA_free(dsa);
|
|
|
06f80e |
+ dsa = NULL;
|
|
|
06f80e |
+ }
|
|
|
06f80e |
+ return dsa;
|
|
|
06f80e |
+#endif
|
|
|
06f80e |
+}
|
|
|
06f80e |
+
|
|
|
06f80e |
bool
|
|
|
06f80e |
inittls(ctx, req, options, srv, certfile, keyfile, cacertpath, cacertfile, dhparam)
|
|
|
06f80e |
SSL_CTX **ctx;
|
|
|
06f80e |
@@ -926,7 +999,7 @@ inittls(ctx, req, options, srv, certfile
|
|
|
06f80e |
{
|
|
|
06f80e |
/* get a pointer to the current certificate validation store */
|
|
|
06f80e |
store = SSL_CTX_get_cert_store(*ctx); /* does not fail */
|
|
|
06f80e |
- crl_file = BIO_new(BIO_s_file_internal());
|
|
|
06f80e |
+ crl_file = BIO_new(BIO_s_file());
|
|
|
06f80e |
if (crl_file != NULL)
|
|
|
06f80e |
{
|
|
|
06f80e |
if (BIO_read_filename(crl_file, CRLFile) >= 0)
|
|
|
06f80e |
@@ -1003,8 +1076,7 @@ inittls(ctx, req, options, srv, certfile
|
|
|
06f80e |
if (bitset(TLS_I_RSA_TMP, req)
|
|
|
06f80e |
# if SM_CONF_SHM
|
|
|
06f80e |
&& ShmId != SM_SHM_NO_ID &&
|
|
|
06f80e |
- (rsa_tmp = RSA_generate_key(RSA_KEYLENGTH, RSA_F4, NULL,
|
|
|
06f80e |
- NULL)) == NULL
|
|
|
06f80e |
+ (rsa_tmp = generate_rsa_key(RSA_KEYLENGTH, RSA_F4)) == NULL
|
|
|
06f80e |
# else /* SM_CONF_SHM */
|
|
|
06f80e |
&& 0 /* no shared memory: no need to generate key now */
|
|
|
06f80e |
# endif /* SM_CONF_SHM */
|
|
|
06f80e |
@@ -1210,8 +1282,8 @@ inittls(ctx, req, options, srv, certfile
|
|
|
06f80e |
sm_dprintf("inittls: Generating %d bit DH parameters\n", bits);
|
|
|
06f80e |
|
|
|
06f80e |
/* this takes a while! */
|
|
|
06f80e |
- dsa = DSA_generate_parameters(bits, NULL, 0, NULL,
|
|
|
06f80e |
- NULL, 0, NULL);
|
|
|
06f80e |
+ dsa = generate_dsa_parameters(bits, NULL, 0, NULL,
|
|
|
06f80e |
+ NULL);
|
|
|
06f80e |
dh = DSA_dup_DH(dsa);
|
|
|
06f80e |
DSA_free(dsa);
|
|
|
06f80e |
}
|
|
|
06f80e |
@@ -1747,7 +1819,7 @@ tmp_rsa_key(s, export, keylength)
|
|
|
06f80e |
|
|
|
06f80e |
if (rsa_tmp != NULL)
|
|
|
06f80e |
RSA_free(rsa_tmp);
|
|
|
06f80e |
- rsa_tmp = RSA_generate_key(RSA_KEYLENGTH, RSA_F4, NULL, NULL);
|
|
|
06f80e |
+ rsa_tmp = generate_rsa_key(RSA_KEYLENGTH, RSA_F4);
|
|
|
06f80e |
if (rsa_tmp == NULL)
|
|
|
06f80e |
{
|
|
|
06f80e |
if (LogLevel > 0)
|
|
|
06f80e |
@@ -1974,11 +2046,20 @@ x509_verify_cb(ok, ctx)
|
|
|
06f80e |
{
|
|
|
06f80e |
if (LogLevel > 13)
|
|
|
06f80e |
tls_verify_log(ok, ctx, "x509");
|
|
|
06f80e |
+#if OPENSSL_VERSION_NUMBER >= 0x10100005L
|
|
|
06f80e |
+ if (X509_STORE_CTX_get_error(ctx) ==
|
|
|
06f80e |
+ X509_V_ERR_UNABLE_TO_GET_CRL)
|
|
|
06f80e |
+ {
|
|
|
06f80e |
+ X509_STORE_CTX_set_error(ctx, 0);
|
|
|
06f80e |
+ return 1; /* override it */
|
|
|
06f80e |
+ }
|
|
|
06f80e |
+#else
|
|
|
06f80e |
if (ctx->error == X509_V_ERR_UNABLE_TO_GET_CRL)
|
|
|
06f80e |
{
|
|
|
06f80e |
ctx->error = 0;
|
|
|
06f80e |
return 1; /* override it */
|
|
|
06f80e |
}
|
|
|
06f80e |
+#endif
|
|
|
06f80e |
}
|
|
|
06f80e |
return ok;
|
|
|
06f80e |
}
|