@@ -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;
}
@@ -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);
@@ -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)) {
@@ -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);
@@ -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);
@@ -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 */
@@ -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) {
@@ -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) {
@@ -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);
Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com> --- 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(-)