summaryrefslogtreecommitdiff
path: root/src/app_add.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/app_add.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/app_add.c')
-rw-r--r--src/app_add.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/app_add.c b/src/app_add.c
index 655d2d1..559475e 100644
--- a/src/app_add.c
+++ b/src/app_add.c
@@ -82,8 +82,9 @@ static struct apk_package *create_virtual_package(struct apk_database *db, struc
{
char ver[32];
struct apk_package *virtpkg;
+ struct apk_digest_ctx dctx;
+ struct apk_digest d;
struct tm tm;
- EVP_MD_CTX *mdctx;
time_t now = time(NULL);
pid_t pid = getpid();
@@ -98,14 +99,13 @@ static struct apk_package *create_virtual_package(struct apk_database *db, struc
virtpkg->description = strdup("virtual meta package");
virtpkg->arch = apk_atomize(&db->atoms, APK_BLOB_STR("noarch"));
- mdctx = EVP_MD_CTX_new();
- EVP_DigestInit_ex(mdctx, apk_checksum_default(), NULL);
- EVP_DigestUpdate(mdctx, &tm, sizeof tm);
- EVP_DigestUpdate(mdctx, &pid, sizeof pid);
- EVP_DigestUpdate(mdctx, virtpkg->name->name, strlen(virtpkg->name->name) + 1);
- virtpkg->csum.type = EVP_MD_CTX_size(mdctx);
- EVP_DigestFinal_ex(mdctx, virtpkg->csum.data, NULL);
- EVP_MD_CTX_free(mdctx);
+ apk_digest_ctx_init(&dctx, APK_DIGEST_SHA1);
+ apk_digest_ctx_update(&dctx, &tm, sizeof tm);
+ apk_digest_ctx_update(&dctx, &pid, sizeof pid);
+ apk_digest_ctx_update(&dctx, virtpkg->name->name, strlen(virtpkg->name->name) + 1);
+ apk_digest_ctx_final(&dctx, &d);
+ apk_digest_ctx_free(&dctx);
+ apk_checksum_from_digest(&virtpkg->csum, &d);
return virtpkg;
}