Handle KDF internally.
[openssl.git] / crypto / ec / ec_25519.c
index 3e6609ad9c16aa72f42b5e3992cb6e553f0f5e12..3acb27534431d83c62dd54dc759b4725a9567b20 100644 (file)
@@ -293,10 +293,8 @@ static int x25519_point_cmp(const EC_GROUP *group, const EC_POINT *a,
     return 1;
 }
 
-static int x25519_compute_key(void *out, size_t outlen,
-                              const EC_POINT *pub_key, const EC_KEY *ecdh,
-                              void *(*KDF) (const void *in, size_t inlen,
-                                            void *out, size_t *outlen))
+static int x25519_compute_key(unsigned char **psec, size_t *pseclen,
+                              const EC_POINT *pub_key, const EC_KEY *ecdh)
 {
     unsigned char *key;
     int ret = -1;
@@ -304,19 +302,12 @@ static int x25519_compute_key(void *out, size_t outlen,
         return -1;
     key = OPENSSL_malloc(EC_X25519_KEYLEN);
     if (key == NULL)
-        return -1;
+        return 0;
     if (X25519(key, ecdh->custom_data, pub_key->custom_data) == 0)
         goto err;
-    if (KDF) {
-        if (KDF(key, EC_X25519_KEYLEN, out, &outlen) == NULL)
-            goto err;
-        ret = outlen;
-    } else {
-        if (outlen > EC_X25519_KEYLEN)
-            outlen = EC_X25519_KEYLEN;
-        memcpy(out, key, outlen);
-        ret = outlen;
-    }
+    *psec = key;
+    *pseclen = EC_X25519_KEYLEN;
+    return 1;
 
  err:
     OPENSSL_clear_free(key, EC_X25519_KEYLEN);