Fix various incorrect error function codes.
[openssl.git] / crypto / ecdh / ech_ossl.c
index 6a8ed8464437394c5022ba3c7917c4ee77d596c3..b1c634b462876ee5e371f0a0694a3720991a1057 100644 (file)
 #include <openssl/err.h>
 #include <openssl/sha.h>
 #include <openssl/obj_mac.h>
+#include <openssl/bn.h>
 
-static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key, EC_KEY *ecdh,
-                            void *(*KDF)(void *in, size_t inlen, void *out, size_t outlen));
+static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key,
+       EC_KEY *ecdh, 
+       void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
 
 static ECDH_METHOD openssl_ecdh_meth = {
        "OpenSSL ECDH method",
@@ -103,8 +105,9 @@ const ECDH_METHOD *ECDH_OpenSSL(void)
  *  - ECSVDP-DH
  * Finally an optional KDF is applied.
  */
-static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh,
-                            void *(*KDF)(void *in, size_t inlen, void *out, size_t outlen))
+static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
+       EC_KEY *ecdh,
+       void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen))
        {
        BN_CTX *ctx;
        EC_POINT *tmp=NULL;
@@ -173,7 +176,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, E
                }
        
        memset(buf, 0, buflen - len);
-       if (len != BN_bn2bin(x, buf + buflen - len))
+       if (len != (size_t)BN_bn2bin(x, buf + buflen - len))
                {
                ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_BN_LIB);
                goto err;
@@ -181,7 +184,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, E
 
        if (KDF != 0)
                {
-               if (KDF(buf, buflen, out, outlen) == NULL)
+               if (KDF(buf, buflen, out, &outlen) == NULL)
                        {
                        ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_KDF_FAILED);
                        goto err;