Revert "EVP_PKEY_asn1_add0(): Check that this method isn't already registered"
[openssl.git] / crypto / ec / ecdh_ossl.c
index 715465c5fbf338d4f16de2592e3dffd16aa09b6b..3302050c87a5144dae97299b82581e7c77d0f0d8 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -7,21 +8,6 @@
  * https://www.openssl.org/source/license.html
  */
 
-/* ====================================================================
- * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
- *
- * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
- * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
- * to the OpenSSL project.
- *
- * The ECC Code is licensed pursuant to the OpenSSL open source
- * license provided below.
- *
- * The ECDH software is originally written by Douglas Stebila of
- * Sun Microsystems Laboratories.
- *
- */
-
 #include <string.h>
 #include <limits.h>
 
@@ -38,7 +24,7 @@ int ossl_ecdh_compute_key(unsigned char **psec, size_t *pseclen,
 {
     if (ecdh->group->meth->ecdh_compute_key == NULL) {
         ECerr(EC_F_OSSL_ECDH_COMPUTE_KEY, EC_R_CURVE_DOES_NOT_SUPPORT_ECDH);
-        return -1;
+        return 0;
     }
 
     return ecdh->group->meth->ecdh_compute_key(psec, pseclen, pub_key, ecdh);
@@ -66,6 +52,10 @@ int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,
     BN_CTX_start(ctx);
     x = BN_CTX_get(ctx);
     y = BN_CTX_get(ctx);
+    if (y == NULL) {
+        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
+        goto err;
+    }
 
     priv_key = EC_KEY_get0_private_key(ecdh);
     if (priv_key == NULL) {