From patchwork Mon Dec 4 10:05:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Glembotzki X-Patchwork-Id: 1871482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=ZyEs542l; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=dMoHYoTo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23f; helo=mail-lj1-x23f.google.com; envelope-from=swupdate+bncbdy5juxlviebbkwjw2vqmgqe6dv7zhi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23f.google.com (mail-lj1-x23f.google.com [IPv6:2a00:1450:4864:20::23f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SkK8006hFz23nl for ; Mon, 4 Dec 2023 21:06:39 +1100 (AEDT) Received: by mail-lj1-x23f.google.com with SMTP id 38308e7fff4ca-2c9f9389c35sf7992881fa.1 for ; Mon, 04 Dec 2023 02:06:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701684396; cv=pass; d=google.com; s=arc-20160816; b=faUgPEDYUXRecEGMw160a3HUtTxo4Rme9JLNVxPyA6Vi8GIS4OlrlkCaZFhRDLNrwi vSigK6xM7mSeSFxbHjT2v7aUFGHT0CqaPlPMb0lu1W92UcmjmiDaXiW3J0Ik0WpeZ9al oFeJIZerYBLOmewPE/sVMZYCWpG87o+eavsbeR8wx0aPWcFbuVb0teTZf9k6hzJ2lx7P +PpPe8LopwhiHisCpiILkSL8b1YKFsTX0f2ayUWlprs1xcj5Hu1sM//kFRsQC8LmJuO2 h132z0oXhoKPXZ4EvKaViYMuuH7lpKwccT2NCUHJV4WLR7F9Vc4pntZjuGgPBwVyJba/ 3IdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature :dkim-signature; bh=QIMvIUYoCzC8RgktA+96BJ5H79MFuqSFpUG8FME9kAc=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=TW4+Vsy3NpbQX/ihkMTuhwYbiYE8tVI0Hy4t0lco+u4t97VeFHpbieaLk24Cq0wsyF g8oMmCQKpSz5/FQjrXjB1RbGpJbMm0sYJTmROUZAZtPHVogrEU8LJNQOlDi/HmF1JnIE +XopSb2SHydEI6sMjowq2ySKzQioOT/j2jLjYM5CwGA3wXsswyOloemVBDJG1cG2oLyZ K0IwasDrHnsNfWYUsXi40wbKpqInuN5kv8kVbrAtOOYKgo50pZnIKMVR1JYiVBDzCy0k XMPmX567O7DYvk/+2Orrq5kPP358ICa7IGx0YYWFuE1aNW6QlvEtJs/uEn0OqAQlV2zx naIA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MajbmvXJ; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62e as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1701684396; x=1702289196; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=QIMvIUYoCzC8RgktA+96BJ5H79MFuqSFpUG8FME9kAc=; b=ZyEs542lLvNWSAN4f2pLiMPlwsyRH+2Su5EfHraa7/fB9itR8WErvJbxMNlGUYiMVc H+GgrxNZZPpHdljRERjRaWykItv3jD8Jgn/k/NDVAXHLxQUbPigMzP46vEeXq1HPxy0h ACkRpohj7pp19hhMd6MFL+Fe9eEJJAbXTAXqZa5RxDh0c3b5MZ75Pm73BJKspPG/Qm1o vaKjuHNAuOxN8EQFAxV2o+leHVKjlKNx8wETmJuwMhdKXKZ7J/EmGUfgMOyam8jnU0Oj Ubv7wiWeW0wXf6cDMQ7SLIj5Q9x6Xj3WElR72eKyFu7KHu9cyOkA6y7VPs+ig4lw0g2V VyTQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701684396; x=1702289196; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=QIMvIUYoCzC8RgktA+96BJ5H79MFuqSFpUG8FME9kAc=; b=dMoHYoTo2blf5YjoqkSEvUBtlrHMdu7mcPJYGXyjJYmx21pQ7Bc6wANHeyf+yzlcbn DW0ISW1tWo2/PqkI3ms9oQRHJ56BDL0dizy6pKJCCebCeIbKkVc+NClzS7rWAjLVuKRh AmGO/Us5B79G3lNr1lo45pyqQ1jo3Jb/pzYGTdGZyVUtmxU3CVSVFjY+Q/u1/mN07Tcu z8Dw2L0EdSnmRE1m1caXQ/a/mXEVsWE4Ala4og+W4I9S2LEvreIuzzjoyee5ivJmiy8f I02tHa7exBVAnan03muXcA/6JXQ9JclIsooth7IqopwiYDifxweVaFcDYM2k+KNn9vQN lamg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701684396; x=1702289196; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=QIMvIUYoCzC8RgktA+96BJ5H79MFuqSFpUG8FME9kAc=; b=IQXcixEAkoI0K3EvVW7yt8dBJ/jJmndcZPQ92MFfOZfJ+THr2wf9PwGK8wMTgnfNlk +zS0zfwovvb5UxIqWmPPL60Q3xAxusUg9QZjdWhZH4qJagdSaRnp8CmsG+1iilsUvqNy 6JTeaoctkaso+bQUO/quecIOzyCs4rwmVsbAgMWKsjwC55qoYrhRFzaVDsZwe7kCv7jH k3WSAN+pyBc7kZXuix2gr9+ISjXZKzRgGH5Qgbxnlly5xHUQrabyyvZA9qGugqG9tlY5 PdqAb8ykhghzPryeJ3KuMzE/lYgDqZPGdWLvmoaXatzYVrB7FD2u0AZpeXuEKSTtEitM r7DA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YwAkE7+gYVNluvMdoeVwlb+XFZYJslwr31GzYH4OMT3v+d2NG8B 495LTQ/UU6Oet5uXNEI3qPg= X-Google-Smtp-Source: AGHT+IFEbZEvFpmPX0n2Xu77T5s6cnpqLDT7r4yJQ5WYB06MRHjUI4HQWfm/MIPuIoJ8yRT/TmVg6g== X-Received: by 2002:a2e:780f:0:b0:2c9:f94a:8aac with SMTP id t15-20020a2e780f000000b002c9f94a8aacmr618178ljc.81.1701684395222; Mon, 04 Dec 2023 02:06:35 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:bcc3:0:b0:2c9:bc63:abcd with SMTP id z3-20020a2ebcc3000000b002c9bc63abcdls1391839ljp.0.-pod-prod-02-eu; Mon, 04 Dec 2023 02:06:33 -0800 (PST) X-Received: by 2002:a2e:a202:0:b0:2c9:d874:4b51 with SMTP id h2-20020a2ea202000000b002c9d8744b51mr2494450ljm.65.1701684392678; Mon, 04 Dec 2023 02:06:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701684392; cv=none; d=google.com; s=arc-20160816; b=VasTybUMllEtDLdtKBuE/AnGQkMRztMlcJeZ5obXVocCgBE+YV+Nwf5tXISvq5Jmuy Ql04M19/kUI2/rmgsyxSPpJMwR1Omg12XAVhsl/O6oKov8+Zai7hWajj+OKnvigiTI6D AZgER7xpaAGyua7ZrfW5ctRNwNJZl/vbDZI11UB3WqdtFJXAjrgbsce53rvxyenozBzo Yu2ozjrUYfRvZsPyKPf9SecTN1tN5vvWCvzOYjicFJAU/50nrtJfJfZMdTHeP+53S3y4 VZrIVHc4quJytKIGxJMy7QVG9FDc3IiuKujCC106+tp8BT7LeQuy9GrfDgYL1jkkOxpj ShNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=es4kiLO8CPaPvzRP1fd5qa/rUvF6hXdpRoP9KHQGIIE=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=lItL81vuFKknZenCq7ZarWm91jLSplmmbCtWw1RXhY+a/jpyEfrWivGe83xu8/N+7T wfmYkNUxUCDFOIMCcT8NFqW/Vd+l5xMpwWBbrvXCFGiu3AO7Qp+z5zDabxEDt8aAQ5u+ UpCPjqmcxJXxNca3Q2Z+DXQ7i65wCXoFFm0MF2hhr220u3CHwjbjCYb/60Td3yZOz7yB p5UNBSeIk+Sxi9joTrUXCX7yhqsY2RjC7qPts2MlPidM3eWvwyFX1Q/ffMsPZS1mAnaE cheI7usW0L0+Adbetrpy1CkRcROe3wUDHYDkAJzi2bRor4cQUnWd8zHTKTgz6DEi6ygD RAvw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MajbmvXJ; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62e as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com. [2a00:1450:4864:20::62e]) by gmr-mx.google.com with ESMTPS id v23-20020a2e9f57000000b002c9f6a36a65si212878ljk.1.2023.12.04.02.06.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Dec 2023 02:06:32 -0800 (PST) Received-SPF: pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62e as permitted sender) client-ip=2a00:1450:4864:20::62e; Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a1b6b65923eso109849466b.3 for ; Mon, 04 Dec 2023 02:06:32 -0800 (PST) X-Received: by 2002:a17:906:8da:b0:a18:8757:fa79 with SMTP id o26-20020a17090608da00b00a188757fa79mr2063220eje.63.1701684391558; Mon, 04 Dec 2023 02:06:31 -0800 (PST) Received: from PC-2635.irisgmbh.local (dslb-002-203-161-041.002.203.pools.vodafone-ip.de. [2.203.161.41]) by smtp.gmail.com with ESMTPSA id js22-20020a17090797d600b00a1b32663d7csm2032919ejc.102.2023.12.04.02.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 02:06:31 -0800 (PST) From: Michael Glembotzki To: swupdate@googlegroups.com Cc: Michael Glembotzki Subject: [swupdate] [V2][PATCH 08/10] cpio_utils: Add argument imgaeskey to __swupdate_copy interface Date: Mon, 4 Dec 2023 11:05:40 +0100 Message-ID: <20231204100620.27789-9-Michael.Glembotzki@iris-sensing.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204100620.27789-1-Michael.Glembotzki@iris-sensing.com> References: <20231204100620.27789-1-Michael.Glembotzki@iris-sensing.com> MIME-Version: 1.0 X-Original-Sender: m.glembo@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MajbmvXJ; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62e as permitted sender) smtp.mailfrom=m.glembo@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Michael Glembotzki --- core/cpio_utils.c | 13 +++++++++---- core/installer.c | 1 + core/stream_interface.c | 6 +++--- corelib/lua_interface.c | 2 ++ handlers/copy_handler.c | 1 + handlers/delta_handler.c | 1 + handlers/rdiff_handler.c | 1 + handlers/readback_handler.c | 1 + include/util.h | 6 ++++-- 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 0a6ebc1..4556033 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -431,7 +431,8 @@ static int zstd_step(void* state, void* buffer, size_t size) static int __swupdate_copy(int fdin, unsigned char *inbuf, void *out, size_t nbytes, unsigned long *offs, unsigned long long seek, int skip_file, int __attribute__ ((__unused__)) compressed, - uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) + uint32_t *checksum, unsigned char *hash, bool encrypted, + const char __attribute__ ((__unused__)) *imgaeskey, const char *imgivt, writeimage callback) { unsigned int percent, prevpercent = 0; int ret = 0; @@ -707,7 +708,8 @@ copyfile_exit: int copyfile(int fdin, void *out, size_t nbytes, unsigned long *offs, unsigned long long seek, int skip_file, int __attribute__ ((__unused__)) compressed, - uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) + uint32_t *checksum, unsigned char *hash, bool encrypted, + const char *imgaeskey, const char *imgivt, writeimage callback) { return __swupdate_copy(fdin, NULL, @@ -720,12 +722,13 @@ int copyfile(int fdin, void *out, size_t nbytes, unsigned long *offs, unsigned l checksum, hash, encrypted, + imgaeskey, imgivt, callback); } int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int __attribute__ ((__unused__)) compressed, - unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) + unsigned char *hash, bool encrypted, const char *imgaeskey, const char *imgivt, writeimage callback) { return __swupdate_copy(-1, inbuf, @@ -738,6 +741,7 @@ int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int __attribute__ NULL, hash, encrypted, + imgaeskey, imgivt, callback); } @@ -754,6 +758,7 @@ int copyimage(void *out, struct img_type *img, writeimage callback) &img->checksum, img->sha256, img->is_encrypted, + img->aeskey_ascii, img->ivt_ascii, callback); } @@ -839,7 +844,7 @@ int cpio_scan(int fd, struct swupdate_cfg *cfg, off_t start) * we do not have to provide fdout */ if (copyfile(fd, NULL, fdh.size, &offset, 0, 1, 0, &checksum, img ? img->sha256 : NULL, - false, NULL, NULL) != 0) { + false, NULL, NULL, NULL) != 0) { ERROR("invalid archive"); return -1; } diff --git a/core/installer.c b/core/installer.c index 20b5b51..db86075 100644 --- a/core/installer.c +++ b/core/installer.c @@ -145,6 +145,7 @@ static int extract_scripts(struct imglist *head) &checksum, script->sha256, script->is_encrypted, + script->aeskey_ascii, script->ivt_ascii, NULL); close(fdin); diff --git a/core/stream_interface.c b/core/stream_interface.c index 0b78329..bfafa30 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -104,7 +104,7 @@ static int extract_file_to_tmp(int fd, const char *fname, unsigned long *poffs, return -1; if (copyfile(fd, &fdout, fdh.size, poffs, 0, 0, 0, &checksum, NULL, - encrypted, NULL, NULL) < 0) { + encrypted, NULL, NULL, NULL) < 0) { close(fdout); return -1; } @@ -243,7 +243,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) close(fdout); return -1; } - if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, false, NULL, NULL) < 0) { + if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, false, NULL, NULL, NULL) < 0) { close(fdout); return -1; } @@ -255,7 +255,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) break; case SKIP_FILE: - if (copyfile(fd, &fdout, fdh.size, &offset, 0, skip, 0, &checksum, NULL, false, NULL, NULL) < 0) { + if (copyfile(fd, &fdout, fdh.size, &offset, 0, skip, 0, &checksum, NULL, false, NULL, NULL, NULL) < 0) { return -1; } if (!swupdate_verify_chksum(checksum, &fdh)) { diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index af7b554..1533e9d 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -401,6 +401,7 @@ static int l_copy2file(lua_State *L) &checksum, img.sha256, img.is_encrypted, + img.aeskey_ascii, img.ivt_ascii, NULL); update_table(L, &img); @@ -473,6 +474,7 @@ static int l_istream_read(lua_State* L) &checksum, img.sha256, img.is_encrypted, + img.aeskey_ascii, img.ivt_ascii, istream_read_callback); diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c index e463bb5..d09ca52 100644 --- a/handlers/copy_handler.c +++ b/handlers/copy_handler.c @@ -131,6 +131,7 @@ static int copy_single_file(const char *path, ssize_t size, struct img_type *img &checksum, 0, /* no sha256 */ false, /* no encrypted */ + NULL, /* no AES Key */ NULL, /* no IVT */ NULL); diff --git a/handlers/delta_handler.c b/handlers/delta_handler.c index d1ff783..a5ee2a6 100644 --- a/handlers/delta_handler.c +++ b/handlers/delta_handler.c @@ -169,6 +169,7 @@ static int network_process_data(multipart_parser* p, const char *at, size_t leng hash, 0, NULL, + NULL, NULL); } else ret = 0; /* skipping, nothing to be copied */ diff --git a/handlers/rdiff_handler.c b/handlers/rdiff_handler.c index e01a127..3f09ec2 100644 --- a/handlers/rdiff_handler.c +++ b/handlers/rdiff_handler.c @@ -347,6 +347,7 @@ static int apply_rdiff_patch(struct img_type *img, &img->checksum, img->sha256, img->is_encrypted, + img->aeskey_ascii, img->ivt_ascii, apply_rdiff_chunk_cb); if (ret != 0) { diff --git a/handlers/readback_handler.c b/handlers/readback_handler.c index 4b910bd..6d2eefa 100644 --- a/handlers/readback_handler.c +++ b/handlers/readback_handler.c @@ -113,6 +113,7 @@ static int readback_postinst(struct img_type *img) NULL, /* no checksum */ hash, false, /* no encrypted */ + NULL, /* no AES Key */ NULL, /* no IVT */ NULL); /* no callback */ if (status == 0) { diff --git a/include/util.h b/include/util.h index 958274c..7ad588d 100644 --- a/include/util.h +++ b/include/util.h @@ -203,10 +203,12 @@ strlcpy(char *dst, const char * src, size_t size); int copyfile(int fdin, void *out, size_t nbytes, unsigned long *offs, unsigned long long seek, int skip_file, int compressed, uint32_t *checksum, - unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback); + unsigned char *hash, bool encrypted, const char *imgaeskey, const char *imgivt, + writeimage callback); int copyimage(void *out, struct img_type *img, writeimage callback); int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int compressed, - unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback); + unsigned char *hash, bool encrypted, const char *imgaeskey, const char *imgivt, + writeimage callback); int openfileoutput(const char *filename); int mkpath(char *dir, mode_t mode); int swupdate_file_setnonblock(int fd, bool block);