Add compute key support to EC_KEY_METHOD
[openssl.git] / crypto / ec / ec_kmeth.c
index ba6db6e1dfc3d50af401d188cb4d4fee56250167..6be99c2265304155c6be3e6a5e06a8d0916b851c 100644 (file)
@@ -61,7 +61,8 @@
 static const EC_KEY_METHOD openssl_ec_key_method = {
     "OpenSSL EC_KEY method",
     0,
-    ossl_ec_key_gen
+    ossl_ec_key_gen,
+    ossl_ecdh_compute_key
 };
 
 const EC_KEY_METHOD *default_ec_key_meth = &openssl_ec_key_method;
@@ -119,3 +120,14 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
     ret->references = 1;
     return (ret);
 }
+
+int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
+                     EC_KEY *eckey,
+                     void *(*KDF) (const void *in, size_t inlen, void *out,
+                                   size_t *outlen))
+{
+    if (eckey->meth->compute_key)
+        return eckey->meth->compute_key(out, outlen, pub_key, eckey, KDF);
+    ECerr(EC_F_ECDH_COMPUTE_KEY, EC_R_OPERATION_NOT_SUPPORTED);
+    return 0;
+}