sha256: add sha256_direct_hex() helper
A various places we need a SHA256SUM of something as a string. Let's add a simple helper for this that does this generically.
This commit is contained in:
@@ -358,7 +358,7 @@ int pcrextend_imds_userdata_word(const struct iovec *data, char **ret) {
|
||||
/* We include both a hash of the complete user data, and a truncated version of the data in the word
|
||||
* we measure. The former protects the actual data, the latter is useful for debugging. */
|
||||
|
||||
_cleanup_free_ char *hash = hexmem(SHA256_DIRECT(data->iov_base, data->iov_len), SHA256_DIGEST_SIZE);
|
||||
_cleanup_free_ char *hash = sha256_direct_hex(data->iov_base, data->iov_len);
|
||||
if (!hash)
|
||||
return log_oom();
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "chattr-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "hexdecoct.h"
|
||||
#include "iovec-util.h"
|
||||
#include "libarchive-util.h"
|
||||
#include "mountpoint-util.h"
|
||||
@@ -1184,7 +1183,7 @@ static int hardlink_lookup(
|
||||
else
|
||||
assert(d->have_unique_mount_id == (r > 0));
|
||||
|
||||
m = hexmem(SHA256_DIRECT(handle->f_handle, handle->handle_bytes), SHA256_DIGEST_SIZE);
|
||||
m = sha256_direct_hex(handle->f_handle, handle->handle_bytes);
|
||||
if (!m)
|
||||
return log_oom();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user