BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(tcore)
BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(openssl1.1)
+BuildRequires: pkgconfig(openssl3)
BuildRequires: pkgconfig(tfeature)
BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-session)
#include <manager.h>
#include <core_object.h>
#include <co_sim.h>
-#include <openssl/sha.h>
+#include <openssl/evp.h>
#include "storage.h"
#include "manager_core.h"
static gchar* __generate_hash(gchar *txt)
{
gchar *txt_hash = NULL;
- SHA256_CTX ctx;
- unsigned char md[SHA256_DIGEST_LENGTH];
- int i;
+ EVP_MD_CTX *md_ctx;
+ const EVP_MD *sha256;
+ unsigned char md[EVP_MAX_MD_SIZE];
+ unsigned int md_len;
+ unsigned int i;
if (g_strcmp0((const char *)txt, "") == 0) {
return txt_hash;
}
- SHA256_Init(&ctx);
- SHA256_Update(&ctx, txt, strlen(txt));
- SHA256_Final(md, &ctx);
- txt_hash = g_malloc0(SHA256_DIGEST_LENGTH * 2 + 1);
- for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
+
+ md_ctx = EVP_MD_CTX_new();
+ sha256 = EVP_sha256();
+
+ EVP_DigestInit_ex(md_ctx, sha256, NULL);
+ EVP_DigestUpdate(md_ctx, txt, strlen(txt));
+ EVP_DigestFinal_ex(md_ctx, md, &md_len);
+
+ txt_hash = g_malloc0(md_len * 2 + 1);
+ for (i = 0; i < md_len; i++)
snprintf(txt_hash + (i * 2), 3, "%02x", md[i]);
+ EVP_MD_CTX_free(md_ctx);
return txt_hash;
}