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> Change-Id: Ic5e3cd6e30ebc8b027f0715434cc3be045f1b770 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12240 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
7778bc3a33
commit
92f0be87a0
@ -33,9 +33,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
#include <openssl/md5.h>
|
|
||||||
|
|
||||||
#include "iscsi/md5.h"
|
#include "iscsi/md5.h"
|
||||||
|
|
||||||
int md5init(struct spdk_md5ctx *md5ctx)
|
int md5init(struct spdk_md5ctx *md5ctx)
|
||||||
@ -45,7 +42,18 @@ int md5init(struct spdk_md5ctx *md5ctx)
|
|||||||
if (md5ctx == NULL) {
|
if (md5ctx == NULL) {
|
||||||
return -1;
|
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;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +64,9 @@ int md5final(void *md5, struct spdk_md5ctx *md5ctx)
|
|||||||
if (md5ctx == NULL || md5 == NULL) {
|
if (md5ctx == NULL || md5 == NULL) {
|
||||||
return -1;
|
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;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +80,6 @@ int md5update(struct spdk_md5ctx *md5ctx, const void *data, size_t len)
|
|||||||
if (data == NULL || len == 0) {
|
if (data == NULL || len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rc = MD5_Update(&md5ctx->md5ctx, data, len);
|
rc = EVP_DigestUpdate(md5ctx->md5ctx, data, len);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,12 @@
|
|||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
#define SPDK_MD5DIGEST_LEN MD5_DIGEST_LENGTH
|
#define SPDK_MD5DIGEST_LEN MD5_DIGEST_LENGTH
|
||||||
|
|
||||||
struct spdk_md5ctx {
|
struct spdk_md5ctx {
|
||||||
MD5_CTX md5ctx;
|
EVP_MD_CTX *md5ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int md5init(struct spdk_md5ctx *md5ctx);
|
int md5init(struct spdk_md5ctx *md5ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user