From eb888e202e36d45a006a947a3190eb48f50b052a Mon Sep 17 00:00:00 2001 From: Justin Brewer Date: Wed, 14 Nov 2018 18:36:56 -0600 Subject: [PATCH] Introduce internal storage for entry digests This commits introduces the basic internal storage for digests. Those will be used to expose a set/get API, which users can utilise for integrity checking. Signed-off-by: Emil Velikov --- libarchive/archive_entry.c | 13 +++++++++++++ libarchive/archive_entry_private.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c index a15e98c28..6db1eef7e 100644 --- a/libarchive/archive_entry.c +++ b/libarchive/archive_entry.c @@ -208,6 +208,19 @@ archive_entry_clone(struct archive_entry *entry) /* Copy encryption status */ entry2->encryption = entry->encryption; + + /* Copy digests */ +#define copy_digest(_e2, _e, _t) \ + memcpy(_e2->digest._t, _e->digest._t, sizeof(_e2->digest._t)) + + copy_digest(entry2, entry, md5); + copy_digest(entry2, entry, rmd160); + copy_digest(entry2, entry, sha1); + copy_digest(entry2, entry, sha256); + copy_digest(entry2, entry, sha384); + copy_digest(entry2, entry, sha512); + +#undef copy_digest /* Copy ACL data over. */ archive_acl_copy(&entry2->acl, &entry->acl); diff --git a/libarchive/archive_entry_private.h b/libarchive/archive_entry_private.h index a66804aa0..abd89b591 100644 --- a/libarchive/archive_entry_private.h +++ b/libarchive/archive_entry_private.h @@ -171,6 +171,9 @@ struct archive_entry { void *mac_metadata; size_t mac_metadata_size; + /* Digest support. */ + struct ae_digest digest; + /* ACL support. */ struct archive_acl acl; -- 2.47.2