libotutil/checksum-utils: fix openssl compilation

Closes: #1261
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2017-10-11 14:52:56 +00:00 committed by Atomic Bot
parent a5b7660c94
commit 3604b8152a

View File

@ -73,7 +73,7 @@ ot_checksum_init (OtChecksum *checksum)
real->checksum = EVP_MD_CTX_create ();
g_assert (real->checksum);
g_assert (EVP_DigestInit_ex (real->checksum, EVP_sha256 (), NULL));
real->digest_len = EVP_MAX_MD_SIZE;
real->digest_len = EVP_MD_CTX_size (real->checksum);
#elif defined(HAVE_GNUTLS)
g_assert (!gnutls_hash_init (&real->checksum, GNUTLS_DIG_SHA256));
real->digest_len = gnutls_hash_get_len (GNUTLS_DIG_SHA256);
@ -81,6 +81,7 @@ ot_checksum_init (OtChecksum *checksum)
real->checksum = g_checksum_new (G_CHECKSUM_SHA256);
real->digest_len = g_checksum_type_get_length (G_CHECKSUM_SHA256);
#endif
g_assert_cmpint (real->digest_len, ==, _OSTREE_SHA256_DIGEST_LEN);
real->initialized = TRUE;
}
@ -109,7 +110,7 @@ ot_checksum_get_digest_internal (OtRealChecksum *real,
g_assert_cmpint (buflen, ==, _OSTREE_SHA256_DIGEST_LEN);
#if defined(HAVE_OPENSSL)
guint digest_len = buflen;
g_assert (EVP_DigestFinal_ex (real->checksum, digest_buf, &digest_len));
g_assert (EVP_DigestFinal_ex (real->checksum, buf, &digest_len));
g_assert_cmpint (digest_len, ==, buflen);
#elif defined(HAVE_GNUTLS)
gnutls_hash_output (real->checksum, buf);