EVP_BytesToKey is supposed to return 0 on failure; and the number of
bytes derived on success.

The initial test for the 'data' parameter crossed its wires.

*****

$ git diff crypto/evp/evp_key.c
diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c
index 7961fbe..c94de05 100644
--- a/crypto/evp/evp_key.c
+++ b/crypto/evp/evp_key.c
@@ -126,7 +126,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
        OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH);
        OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH);

-       if (data == NULL) return(nkey);
+       if (data == NULL) return(0);

        EVP_MD_CTX_init(&c);
        for (;;)

diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c
index 7961fbe..c94de05 100644
--- a/crypto/evp/evp_key.c
+++ b/crypto/evp/evp_key.c
@@ -126,7 +126,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
        OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH);
        OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH);
 
-       if (data == NULL) return(nkey);
+       if (data == NULL) return(0);
 
        EVP_MD_CTX_init(&c);
        for (;;)

Reply via email to