diff mbox series

[v5,09/16] util.h: Propagate cipher and image aes key to copy pipeline

Message ID 20250904115704.58413-10-Michael.Glembotzki@iris-sensing.com
State Changes Requested
Delegated to: Stefano Babic
Headers show
Series Add support for asymmetric decryption | expand

Commit Message

Michael Glembotzki Sept. 4, 2025, 11:49 a.m. UTC
Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---
 core/cpio_utils.c       | 2 ++
 core/installer.c        | 2 ++
 core/stream_interface.c | 2 ++
 include/util.h          | 3 +++
 4 files changed, 9 insertions(+)

Comments

Stefano Babic Sept. 14, 2025, 9:29 a.m. UTC | #1
On 04.09.25 13:49, Michael Glembotzki wrote:
> Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
> ---
>   core/cpio_utils.c       | 2 ++
>   core/installer.c        | 2 ++
>   core/stream_interface.c | 2 ++
>   include/util.h          | 3 +++
>   4 files changed, 9 insertions(+)
> 
> diff --git a/core/cpio_utils.c b/core/cpio_utils.c
> index e3a94c50..6fb7a984 100644
> --- a/core/cpio_utils.c
> +++ b/core/cpio_utils.c
> @@ -801,6 +801,8 @@ int copyimage(void *out, struct img_type *img, writeimage callback)
>   		.hash = img->sha256,
>   		.encrypted = img->is_encrypted,
>   		.imgivt = img->ivt_ascii,
> +		.imgaes = img->aes_ascii,
> +		.cipher = img->cipher,
>   	};
>   	return copyfile(&copy);
>   }
> diff --git a/core/installer.c b/core/installer.c
> index da063938..8cba1790 100644
> --- a/core/installer.c
> +++ b/core/installer.c
> @@ -157,6 +157,8 @@ static int extract_scripts(struct imglist *head)
>   			.hash = script->sha256,
>   			.encrypted = script->is_encrypted,
>   			.imgivt = script->ivt_ascii,
> +			.imgaes = script->aes_ascii,
> +			.cipher = script->cipher,
>   		};
>   		ret = copyfile(&copy);
>   		close(fdin);
> diff --git a/core/stream_interface.c b/core/stream_interface.c
> index 10359c30..ba6fb8a4 100644
> --- a/core/stream_interface.c
> +++ b/core/stream_interface.c
> @@ -91,6 +91,7 @@ static int extract_file_to_tmp(int fd, const char *fname, unsigned long *poffs,
>   	int fdout;
>   	uint32_t checksum;
>   	const char* TMPDIR = get_tmpdir();
> +	cipher_t cipher = AES_CBC;
>   
>   	if (extract_cpio_header(fd, &fdh, poffs)) {
>   		return -1;
> @@ -126,6 +127,7 @@ static int extract_file_to_tmp(int fd, const char *fname, unsigned long *poffs,
>   		.offs = poffs,
>   		.checksum = &checksum,
>   		.encrypted = encrypted,
> +		.cipher = cipher,
>   	};
>   	if (copyfile(&copy) < 0) {
>   		close(fdout);
> diff --git a/include/util.h b/include/util.h
> index 36c68b9d..e9704743 100644
> --- a/include/util.h
> +++ b/include/util.h
> @@ -23,6 +23,7 @@
>   #include "swupdate_status.h"
>   #include "swupdate_dict.h"
>   #include "compat.h"
> +#include "swupdate_aes.h"
>   
>   #define NOTIFY_BUF_SIZE 	2048
>   #define ENOMEM_ASPRINTF		-1
> @@ -92,6 +93,8 @@ struct swupdate_copy {
>   	/* encryption */
>   	bool encrypted;
>   	const char *imgivt;
> +	const char *imgaes;
> +	cipher_t cipher;
>   };
>   
>   /*

Reviewed-by: Stefano Babic <stefano.babic@swupdate.org>
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index e3a94c50..6fb7a984 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -801,6 +801,8 @@  int copyimage(void *out, struct img_type *img, writeimage callback)
 		.hash = img->sha256,
 		.encrypted = img->is_encrypted,
 		.imgivt = img->ivt_ascii,
+		.imgaes = img->aes_ascii,
+		.cipher = img->cipher,
 	};
 	return copyfile(&copy);
 }
diff --git a/core/installer.c b/core/installer.c
index da063938..8cba1790 100644
--- a/core/installer.c
+++ b/core/installer.c
@@ -157,6 +157,8 @@  static int extract_scripts(struct imglist *head)
 			.hash = script->sha256,
 			.encrypted = script->is_encrypted,
 			.imgivt = script->ivt_ascii,
+			.imgaes = script->aes_ascii,
+			.cipher = script->cipher,
 		};
 		ret = copyfile(&copy);
 		close(fdin);
diff --git a/core/stream_interface.c b/core/stream_interface.c
index 10359c30..ba6fb8a4 100644
--- a/core/stream_interface.c
+++ b/core/stream_interface.c
@@ -91,6 +91,7 @@  static int extract_file_to_tmp(int fd, const char *fname, unsigned long *poffs,
 	int fdout;
 	uint32_t checksum;
 	const char* TMPDIR = get_tmpdir();
+	cipher_t cipher = AES_CBC;
 
 	if (extract_cpio_header(fd, &fdh, poffs)) {
 		return -1;
@@ -126,6 +127,7 @@  static int extract_file_to_tmp(int fd, const char *fname, unsigned long *poffs,
 		.offs = poffs,
 		.checksum = &checksum,
 		.encrypted = encrypted,
+		.cipher = cipher,
 	};
 	if (copyfile(&copy) < 0) {
 		close(fdout);
diff --git a/include/util.h b/include/util.h
index 36c68b9d..e9704743 100644
--- a/include/util.h
+++ b/include/util.h
@@ -23,6 +23,7 @@ 
 #include "swupdate_status.h"
 #include "swupdate_dict.h"
 #include "compat.h"
+#include "swupdate_aes.h"
 
 #define NOTIFY_BUF_SIZE 	2048
 #define ENOMEM_ASPRINTF		-1
@@ -92,6 +93,8 @@  struct swupdate_copy {
 	/* encryption */
 	bool encrypted;
 	const char *imgivt;
+	const char *imgaes;
+	cipher_t cipher;
 };
 
 /*