From patchwork Fri Dec 15 14:19:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Glembotzki X-Patchwork-Id: 1876659 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=pmwgZiy2; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BHwPsLh9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbdy5juxlviebbt6c6gvqmgqe4tdtu4q@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (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 4SsBK06Yshz23p1 for ; Sat, 16 Dec 2023 01:23:16 +1100 (AEDT) Received: by mail-lj1-x23d.google.com with SMTP id 38308e7fff4ca-2c9ef4b6ce4sf5371181fa.1 for ; Fri, 15 Dec 2023 06:23:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702650192; cv=pass; d=google.com; s=arc-20160816; b=jzBnXHmxStUPUYxcftQBigCLnFEwNhTbKyZRPXPHqC1ePb/QTp8Uuft1aHkAycuGkh YUXEpw/kqir++zVSwOyNj57wMP9FjZFPw6H0ntLaKkmblo6ZRQgDfZD6oMZ1MIN8yEj1 fIbpxLRZHtZtgWOPbPsMMcagDf8ggh5xb4stxw5mHbhgXaAGYtomp8gFjRZcDHCGK4n9 figFcVSE0T2CBkTKDLtjj5gR0rgGO3Dt89IVRyznrFjTvUCWVjDtTzJbQjNGMNXzf5QK 07vr+Ba3Gdg/9TBY5cEEwWeTOjKN6HAZ8UC3Q4glBctMR+EaxwCTy7yK6jxKXrij0XG7 pLjw== 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=Csi75JLJkhoaG2mzb/NXiUj/StxlG9wpBuFvaW4x1Ns=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=zUi9ta3hWa7iCdsjeweurorX9BfPscnSWUEAxrd1d3nQ3wSRGWrW/5LBapffNxkObS GUswaQGo6WU9vROGLldr+h7vby7OpFP2/nEYyMLgUFSOF/XV3UjXAz9XziM3pj7LEiA8 cZ56AOtWhZKi+VFC6RjN/zWUriu4fo5buMdCpBeox48ftFmLL0pk85FmVrzPaEQK8EuY Zi0t5zkL2sf2A1pm8oLKAz0YpCcFitrHoBuySuRxkC05gab41qpprrR9XMDyAT+KycFZ nlUFON4BTaHVfKlfzTpF/GvjwSm3orpeBz40lP3dNmsYnDVOyBaBOOZ4LHBPED9wJ9rY tuTQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mGlDN3ph; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62f 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=1702650192; x=1703254992; 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=Csi75JLJkhoaG2mzb/NXiUj/StxlG9wpBuFvaW4x1Ns=; b=pmwgZiy2ehEwGQHyGuCyxJJd+QQwx/UkQL9D/aVeyfv9rQMvDAgnKXqUnLx5L6juNq 5q7OM7OdLsCXm0CAkE9StLE8TwvwLNJ6bQwEaU7fGLkG0ZnaFrQOk7f5ZwE+hbBgnyPj AQ/BxyZMFQDjv2TpTnSAymGMFDcKnTcZ0iJkJhPrtTucFYKrgIFgYdqMIlOPHyB6QZPI H5sSCK234PNXOxh46/vVVrUGNef2zyrKZc6FLJGtC6lvRHs8taaeSQSHkfbqxwPj+uTh HJddzNnPXRe9IwnZHEbNGlcxt+yyigD8l4wNr1qowhN39daG36qlJksw7rB5NwDalIxw uk4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702650192; x=1703254992; 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=Csi75JLJkhoaG2mzb/NXiUj/StxlG9wpBuFvaW4x1Ns=; b=BHwPsLh9ZCQY2mBr15rOYoEu7G6WKAjF/S+/mJM6Ny+YDoXP4n6elSggXynobjGXVA YQJ++aFTGhR9P+gxJKNdbH8/xMisCj7juZwLxC8fINdayr+/6WqOOWFFfZnUOdzy5OHu XJ2NuGLwn4YgEGBLjjefPy3rq/gDQJxu3F1HMEoI1DsqzoBLxoMK+AEiqt5E+GfWR+cW fjhx2w3MEO/2bnNAmfsMJT/+qY8FHNZJLOBiN/yMVWLZCSZn5D46G2jkVsK99T0k8Uii 5Aur0OV73rsdU9CA5s+vIy2wydOkD1ioWNS+p5kbjKyw3ZzzI5wtTkAuV57kjVfc6t5s LF+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702650192; x=1703254992; 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=Csi75JLJkhoaG2mzb/NXiUj/StxlG9wpBuFvaW4x1Ns=; b=vmjyg7eHz/kaHd3u2LJK2IYf8aPetaePLU+Wd7aAQVv25DKeeDKNjfAYM27BKZkQkl fSCRJ+hH1UOXgT2LtlVOUHAFreqlefPBa6zTlQISE98GC0l4mX7IuAnJPYmXA+VEHc0v kdrlJBaZ9g9BfjyIwpmMbksHiKFBFJHQkbXX3hgw+mujlhyQc2TEp+7xeZFnIx2GeOK7 OUd6gK3D6VE128WU/v68npcLswnZnED/CXFgHhTZ3vhJpKl0YaUmT8R6U0ifhe5pTU/Q hYQ/6oqjLrElMOPooUR/zh6Z7nNcAaPpiujf8fDZB2eosNWAeHHazzBfnx394uvV2eTc fbJg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YxCB6LasaIGZU1mFCIilLKNGhZSMSobmDoahLIWTFM8qIzZJCqP sT6CzbQAnm/MOAeb9c6wBok= X-Google-Smtp-Source: AGHT+IE+Va+4YyIR4kl63yfBoHetHnx6HtRWrA34bfU/mwYO5HQgPf0s/5mnhORIkBHlKVZx1M90Hw== X-Received: by 2002:a05:651c:201c:b0:2cc:3f92:e9ca with SMTP id s28-20020a05651c201c00b002cc3f92e9camr1465938ljo.103.1702650192244; Fri, 15 Dec 2023 06:23:12 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:a7d6:0:b0:2cb:2828:b1e0 with SMTP id x22-20020a2ea7d6000000b002cb2828b1e0ls380407ljp.2.-pod-prod-09-eu; Fri, 15 Dec 2023 06:23:10 -0800 (PST) X-Received: by 2002:a2e:a0d3:0:b0:2cc:5780:6915 with SMTP id f19-20020a2ea0d3000000b002cc57806915mr17198ljm.10.1702650189560; Fri, 15 Dec 2023 06:23:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702650189; cv=none; d=google.com; s=arc-20160816; b=cLnJeAfY079o6s1vkUSTmsyEgQjvc7t7VGkdiNM9uiecZMxKxxeSPa+CG84/cfYthN af5o+oWTaCkvx1TefXfUsx2b+sTdBr7E2+fF8488vYtLL/yoAWqp5J2t9QZafmMI00Hf iC9m8NxRWs0L6NNpUTDrQzXC4SvEkyn6jECx67u69UPpHG0RSEpTY7/DDZ14Q3wYeeyM SPkmzNKYlNm23gX/pfC3C4JGvAQCuIZXDKk8m9o2wLRP0VqNJDz5aKORYFRI0bjxctFA A+HLhHtbmlUXTBb2XZ8R1Ogy6cMnbvZFTa/stW3/XTsB6Kkx6fhUQ86Rm0kQrlx7U0jF ziaw== 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=n0SOzHDe1ni8yXIoq+nyAHc6bMWfdyobYuUzHNtl3ww=; fh=zydHuzCQWrku2OPQyZfraJZFcOpEXLQ/YBcu3QNiBd0=; b=DjbFdqws+hIe9UY7lwEAc9FjwkdCA06U0OCHHwcj17ccDOWePZSg1QVOsW5roS9ayM zkjRDISBLEQ/3cyzHj4zCnM3xLskIka5Ar2Tc1Rul4nscxjE0C3wRBSNj+TBIQknOoLM M+0pzKdmK6Ps6Y87IB4/8e97A4w1NBgRik78jVScF6/OygSp5fC5cmi0lJ17ROUzMDNS vvLyX1VSCamWo7sU+6JXvbeJkhBfbMeQTmPGcFtblpywxlCBP7DBTiZ4C1qKaE8j0DCr U2yalf3s3PQxsHPNncG28KaV2WeCvHDjREjSFb5svHfqbhaa9EQBSMPbCleSfLLp83RN BCmw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mGlDN3ph; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62f 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-x62f.google.com (mail-ej1-x62f.google.com. [2a00:1450:4864:20::62f]) by gmr-mx.google.com with ESMTPS id y21-20020a2e95d5000000b002cc5335f4e8si5568ljh.5.2023.12.15.06.23.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Dec 2023 06:23:09 -0800 (PST) Received-SPF: pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62f as permitted sender) client-ip=2a00:1450:4864:20::62f; Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a1e35c2807fso85534266b.3 for ; Fri, 15 Dec 2023 06:23:09 -0800 (PST) X-Received: by 2002:a17:907:94d5:b0:9dc:2291:d384 with SMTP id dn21-20020a17090794d500b009dc2291d384mr6954254ejc.22.1702650188455; Fri, 15 Dec 2023 06:23:08 -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 vx6-20020a170907a78600b00a1e852ab3f0sm10944029ejc.15.2023.12.15.06.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 06:23:08 -0800 (PST) From: Michael Glembotzki To: swupdate@googlegroups.com Cc: Michael Glembotzki Subject: [swupdate] [V3][PATCH 08/10] cpio_utils: Add argument imgaeskey to __swupdate_copy interface Date: Fri, 15 Dec 2023 15:19:45 +0100 Message-ID: <20231215142251.52393-9-Michael.Glembotzki@iris-sensing.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231215142251.52393-1-Michael.Glembotzki@iris-sensing.com> References: <20231215142251.52393-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=mGlDN3ph; spf=pass (google.com: domain of m.glembo@gmail.com designates 2a00:1450:4864:20::62f 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 5b99904..6e2c239 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; @@ -705,7 +706,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, @@ -718,12 +720,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, @@ -736,6 +739,7 @@ int copybuffer(unsigned char *inbuf, void *out, size_t nbytes, int __attribute__ NULL, hash, encrypted, + imgaeskey, imgivt, callback); } @@ -752,6 +756,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); } @@ -837,7 +842,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 062840f..0c5564c 100644 --- a/include/util.h +++ b/include/util.h @@ -204,10 +204,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);