aboutsummaryrefslogtreecommitdiff
path: root/crypto/dh/dh_key.c
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2025-05-07 21:18:24 +0000
committerEnji Cooper <ngie@FreeBSD.org>2025-05-07 22:37:22 +0000
commit29536654cc41bf41b92dc836c47496dc6fe0b00c (patch)
tree368a3c5b14e610bb5f6b71657f61a41e373eaf97 /crypto/dh/dh_key.c
parent1c34280346af8284acdc0eae39496811d37df25d (diff)
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r--crypto/dh/dh_key.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index afc49f5cdc87..7132b9b68e53 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -190,7 +190,11 @@ static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
{
+#ifdef S390X_MOD_EXP
+ return s390x_mod_exp(r, a, p, m, ctx, m_ctx);
+#else
return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
+#endif
}
static int dh_init(DH *dh)
@@ -429,14 +433,15 @@ size_t ossl_dh_key2buf(const DH *dh, unsigned char **pbuf_out, size_t size,
if (!alloc) {
if (size >= (size_t)p_size)
pbuf = *pbuf_out;
+ if (pbuf == NULL)
+ ERR_raise(ERR_LIB_DH, DH_R_INVALID_SIZE);
} else {
pbuf = OPENSSL_malloc(p_size);
}
- if (pbuf == NULL) {
- ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE);
+ /* Errors raised above */
+ if (pbuf == NULL)
return 0;
- }
/*
* As per Section 4.2.8.1 of RFC 8446 left pad public
* key with zeros to the size of p