Message ID | 20230728091731.658930-1-michael.adler@siemens.com |
---|---|
State | Accepted |
Delegated to: | Stefano Babic |
Headers | show |
Series | swupdate_decrypt: add error message for unsupported | expand |
On 28.07.23 11:17, 'Michael Adler' via swupdate wrote: > Whether SWUpdate supports encrypted images or not is a compile-time > option. If SWUpdate was built without support for encrypted images and > an encrypted image is attempted to be installed, SWUpdate fails with an > generic error message: > Applied to -master, thanks ! Best regards, Stefano Babic > [ERROR] : SWUPDATE failed [0] ERROR core/cpio_utils.c : __swupdate_copy : 498 : decrypt initialization failure, aborting > > While this is certainly true, it helps little in finding the root cause. > This commit adds a more descriptive error message, leading directly to > the root cause. > > Signed-off-by: Michael Adler <michael.adler@siemens.com> > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > include/sslapi.h | 14 +++++++++----- > include/util.h | 1 + > 2 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/include/sslapi.h b/include/sslapi.h > index 50f6a96..a24a152 100644 > --- a/include/sslapi.h > +++ b/include/sslapi.h > @@ -9,6 +9,7 @@ > #define _SWUPDATE_SSL_H > > #include <stdint.h> > +#include "util.h" > > #define SHA_DEFAULT "sha256" > > @@ -197,11 +198,14 @@ int swupdate_DECRYPT_final(struct swupdate_digest *dgst, unsigned char *buf, > int *outlen); > void swupdate_DECRYPT_cleanup(struct swupdate_digest *dgst); > #else > -/* > - * Note: macro for swupdate_DECRYPT_init is > - * just to avoid compiler warnings > - */ > -#define swupdate_DECRYPT_init(key, keylen, iv) (((key != NULL) | (ivt != NULL)) ? NULL : NULL) > +UNUSED static inline struct swupdate_digest *swupdate_DECRYPT_init( > + unsigned char UNUSED *key, > + char UNUSED keylen, > + unsigned char UNUSED *iv) > +{ > + ERROR("SWUpdate was built without support for encrypted images"); > + return NULL; > +} > #define swupdate_DECRYPT_update(p, buf, len, cbuf, inlen) (-1) > #define swupdate_DECRYPT_final(p, buf, len) (-1) > #define swupdate_DECRYPT_cleanup(p) > diff --git a/include/util.h b/include/util.h > index 5baab13..3c2a42f 100644 > --- a/include/util.h > +++ b/include/util.h > @@ -151,6 +151,7 @@ void notifier_set_color(int level, char *col); > > > #define IS_STR_EQUAL(s,s1) (s && s1 && !strcmp(s,s1)) > +#define UNUSED __attribute__((__unused__)) > > #define LG_16 4 > #define FROM_HEX(f) from_ascii (f, sizeof f, LG_16)
diff --git a/include/sslapi.h b/include/sslapi.h index 50f6a96..a24a152 100644 --- a/include/sslapi.h +++ b/include/sslapi.h @@ -9,6 +9,7 @@ #define _SWUPDATE_SSL_H #include <stdint.h> +#include "util.h" #define SHA_DEFAULT "sha256" @@ -197,11 +198,14 @@ int swupdate_DECRYPT_final(struct swupdate_digest *dgst, unsigned char *buf, int *outlen); void swupdate_DECRYPT_cleanup(struct swupdate_digest *dgst); #else -/* - * Note: macro for swupdate_DECRYPT_init is - * just to avoid compiler warnings - */ -#define swupdate_DECRYPT_init(key, keylen, iv) (((key != NULL) | (ivt != NULL)) ? NULL : NULL) +UNUSED static inline struct swupdate_digest *swupdate_DECRYPT_init( + unsigned char UNUSED *key, + char UNUSED keylen, + unsigned char UNUSED *iv) +{ + ERROR("SWUpdate was built without support for encrypted images"); + return NULL; +} #define swupdate_DECRYPT_update(p, buf, len, cbuf, inlen) (-1) #define swupdate_DECRYPT_final(p, buf, len) (-1) #define swupdate_DECRYPT_cleanup(p) diff --git a/include/util.h b/include/util.h index 5baab13..3c2a42f 100644 --- a/include/util.h +++ b/include/util.h @@ -151,6 +151,7 @@ void notifier_set_color(int level, char *col); #define IS_STR_EQUAL(s,s1) (s && s1 && !strcmp(s,s1)) +#define UNUSED __attribute__((__unused__)) #define LG_16 4 #define FROM_HEX(f) from_ascii (f, sizeof f, LG_16)