summaryrefslogtreecommitdiff
path: root/crypto/dh/dh_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r--crypto/dh/dh_key.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index 9e1d8e58225be..1d80fb2c5f600 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -94,6 +94,20 @@ int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
return dh->meth->compute_key(key, pub_key, dh);
}
+int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh)
+{
+ int rv, pad;
+ rv = dh->meth->compute_key(key, pub_key, dh);
+ if (rv <= 0)
+ return rv;
+ pad = BN_num_bytes(dh->p) - rv;
+ if (pad > 0) {
+ memmove(key + pad, key, rv);
+ memset(key, 0, pad);
+ }
+ return rv + pad;
+}
+
static DH_METHOD dh_ossl = {
"OpenSSL DH Method",
generate_key,