aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_key.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2011-03-08 19:07:26 +0000
committerDr. Stephen Henson <steve@openssl.org>2011-03-08 19:07:26 +0000
commitbc91494e064ebdcff68f987947f97e404fbca0b5 (patch)
treea2cdc113e234f0886918d9b1e43e4132f1569661 /crypto/dh/dh_key.c
parenta1e7883edb9041aff44700fc9817891c800ac703 (diff)
downloadopenssl-bc91494e064ebdcff68f987947f97e404fbca0b5.tar.gz
New SP 800-56A compliant version of DH_compute_key().
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r--crypto/dh/dh_key.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index bba83be312..6c7a457267 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -86,6 +86,21 @@ 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,