summaryrefslogtreecommitdiff
path: root/src/io_archive.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-06-09 18:21:40 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-06-11 13:35:32 +0300
commit7ce4cc4b739127c0b4b36ffcabc007e5781b13c9 (patch)
tree1f751b9dc62c59a1fa1e05d34550961f39719137 /src/io_archive.c
parent7c9f001cda932c74164e8aaa6740dcb6d24aa62f (diff)
downloadapk-tools-7ce4cc4b739127c0b4b36ffcabc007e5781b13c9.tar.gz
apk-tools-7ce4cc4b739127c0b4b36ffcabc007e5781b13c9.tar.bz2
apk-tools-7ce4cc4b739127c0b4b36ffcabc007e5781b13c9.tar.xz
apk-tools-7ce4cc4b739127c0b4b36ffcabc007e5781b13c9.zip
add basic abstraction for cryptographic operations
- basic digesting and signing apis (subject still to fine tuning) - update digest code, and adb signing for the thin wrapping layer - old v1 package and database handling not updated - default mkpkg file hash to sha256 ref #10744
Diffstat (limited to 'src/io_archive.c')
-rw-r--r--src/io_archive.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/io_archive.c b/src/io_archive.c
index ad4f621..5e1498a 100644
--- a/src/io_archive.c
+++ b/src/io_archive.c
@@ -112,15 +112,15 @@ static void handle_extended_header(struct apk_file_info *fi, apk_blob_t hdr)
.value = value,
};
} else if (apk_blob_pull_blob_match(&name, APK_BLOB_STR("APK-TOOLS.checksum."))) {
- int type = APK_CHECKSUM_NONE;
+ int alg = APK_DIGEST_NONE;
if (apk_blob_compare(name, APK_BLOB_STR("SHA1")) == 0)
- type = APK_CHECKSUM_SHA1;
+ alg = APK_DIGEST_SHA1;
else if (apk_blob_compare(name, APK_BLOB_STR("MD5")) == 0)
- type = APK_CHECKSUM_MD5;
- if (type > fi->csum.type) {
- fi->csum.type = type;
- apk_blob_pull_hexdump(&value, APK_BLOB_CSUM(fi->csum));
- if (APK_BLOB_IS_NULL(value)) fi->csum.type = APK_CHECKSUM_NONE;
+ alg = APK_DIGEST_MD5;
+ if (alg > fi->digest.alg) {
+ apk_digest_set(&fi->digest, alg);
+ apk_blob_pull_hexdump(&value, APK_DIGEST_BLOB(fi->digest));
+ if (APK_BLOB_IS_NULL(value)) apk_digest_reset(&fi->digest);
}
}
}
@@ -175,7 +175,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
if (paxlen) {
handle_extended_header(&entry, APK_BLOB_PTR_LEN(pax.ptr, paxlen));
- apk_fileinfo_hash_xattr(&entry);
+ apk_fileinfo_hash_xattr(&entry, APK_DIGEST_SHA1);
}
toskip = (entry.size + 511) & -512;