iscsi: use EVP APIs for md5 calculations
OpenSSL 3.0 deprecated the MD5_xxx APIs, so switch
the md5 code in the iscsi library to use the EVP
APIs recommended by OpenSSL instead.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12240 (master)
(cherry picked from commit 92f0be87a0
)
Change-Id: Ic5e3cd6e30ebc8b027f0715434cc3be045f1b770
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12482
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
077c6ee4d6
commit
5311736cd1
@ -33,9 +33,6 @@
|
||||
*/
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#include "iscsi/md5.h"
|
||||
|
||||
int md5init(struct spdk_md5ctx *md5ctx)
|
||||
@ -45,7 +42,18 @@ int md5init(struct spdk_md5ctx *md5ctx)
|
||||
if (md5ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
rc = MD5_Init(&md5ctx->md5ctx);
|
||||
|
||||
md5ctx->md5ctx = EVP_MD_CTX_create();
|
||||
if (md5ctx->md5ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = EVP_DigestInit_ex(md5ctx->md5ctx, EVP_md5(), NULL);
|
||||
/* For EVP_DigestInit_ex, 1 == success, 0 == failure. */
|
||||
if (rc == 0) {
|
||||
EVP_MD_CTX_destroy(md5ctx->md5ctx);
|
||||
md5ctx->md5ctx = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -56,7 +64,9 @@ int md5final(void *md5, struct spdk_md5ctx *md5ctx)
|
||||
if (md5ctx == NULL || md5 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
rc = MD5_Final(md5, &md5ctx->md5ctx);
|
||||
rc = EVP_DigestFinal_ex(md5ctx->md5ctx, md5, NULL);
|
||||
EVP_MD_CTX_destroy(md5ctx->md5ctx);
|
||||
md5ctx->md5ctx = NULL;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -70,6 +80,6 @@ int md5update(struct spdk_md5ctx *md5ctx, const void *data, size_t len)
|
||||
if (data == NULL || len == 0) {
|
||||
return 0;
|
||||
}
|
||||
rc = MD5_Update(&md5ctx->md5ctx, data, len);
|
||||
rc = EVP_DigestUpdate(md5ctx->md5ctx, data, len);
|
||||
return rc;
|
||||
}
|
||||
|
@ -38,11 +38,12 @@
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#define SPDK_MD5DIGEST_LEN MD5_DIGEST_LENGTH
|
||||
|
||||
struct spdk_md5ctx {
|
||||
MD5_CTX md5ctx;
|
||||
EVP_MD_CTX *md5ctx;
|
||||
};
|
||||
|
||||
int md5init(struct spdk_md5ctx *md5ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user