Introduce public digest getter API

Allow applications to query the digests stored in the MTREE. Which they
can use at a later stage to perform integrity checks as needed.

Note: no digests are wired yet.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
Emil Velikov committed 2020-03-13 19:11:57 +00:00
1 parent eb888e202e
commit cbe26331be
2 files changed
+35

No files matched your search

+22
View File
@@ -1429,6 +1429,28 @@ archive_entry_copy_mac_metadata(struct archive_entry *entry,
}
}
/* Digest handling */
const unsigned char *
archive_entry_digest(struct archive_entry *entry, int type)
{
switch (type) {
case ARCHIVE_ENTRY_DIGEST_MD5:
return entry->digest.md5;
case ARCHIVE_ENTRY_DIGEST_RMD160:
return entry->digest.rmd160;
case ARCHIVE_ENTRY_DIGEST_SHA1:
return entry->digest.sha1;
case ARCHIVE_ENTRY_DIGEST_SHA256:
return entry->digest.sha256;
case ARCHIVE_ENTRY_DIGEST_SHA384:
return entry->digest.sha384;
case ARCHIVE_ENTRY_DIGEST_SHA512:
return entry->digest.sha512;
default:
return NULL;
}
}
/*
* ACL management. The following would, of course, be a lot simpler
* if: 1) the last draft of POSIX.1e were a really thorough and
+13
View File
@@ -396,6 +396,19 @@ __LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat
__LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
__LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
/*
* Digest routine. This is used to query the raw hex digest for the
* given entry. The type of digest is provided as an argument.
*/
#define ARCHIVE_ENTRY_DIGEST_MD5 0x00000001
#define ARCHIVE_ENTRY_DIGEST_RMD160 0x00000002
#define ARCHIVE_ENTRY_DIGEST_SHA1 0x00000003
#define ARCHIVE_ENTRY_DIGEST_SHA256 0x00000004
#define ARCHIVE_ENTRY_DIGEST_SHA384 0x00000005
#define ARCHIVE_ENTRY_DIGEST_SHA512 0x00000006
__LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);
/*
* ACL routines. This used to simply store and return text-format ACL
* strings, but that proved insufficient for a number of reasons: