* [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
@ 2017-11-08 2:30 Wilson Lee
2017-11-20 15:38 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Wilson Lee @ 2017-11-08 2:30 UTC (permalink / raw)
To: u-boot
uint8_t used in sha1_der_prefix array was not able to recognize by
compiler when try to build the tools using 'HOSTCC'. That is because,
uint8_t is undefined when 'HOSTCC' is defined because asm/type.h is not
included in that case. Use unsigned char for sha1_der_prefix[] array
instead.
This commit is to remove and change the uint8_t to unsigned char for
sha1_der_perfix[] array.
Signed-off-by: Wilson Lee <wilson.lee@ni.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Keng Soon Cheah <keng.soon.cheah@ni.com>
Cc: Chen Yee Chew <chen.yee.chew@ni.com>
Cc: Andrew Duda <aduda@meraki.com>
Cc: Simon Glass <sjg@chromium.org>
---
include/u-boot/sha1.h | 2 +-
lib/sha1.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/u-boot/sha1.h b/include/u-boot/sha1.h
index 2634a29..b5e55fe 100644
--- a/include/u-boot/sha1.h
+++ b/include/u-boot/sha1.h
@@ -23,7 +23,7 @@ extern "C" {
#define SHA1_SUM_LEN 20
#define SHA1_DER_LEN 15
-extern const uint8_t sha1_der_prefix[];
+extern const unsigned char sha1_der_prefix[];
/**
* \brief SHA-1 context structure
diff --git a/lib/sha1.c b/lib/sha1.c
index f54bb5b..d5d58c4 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -26,7 +26,7 @@
#include <watchdog.h>
#include <u-boot/sha1.h>
-const uint8_t sha1_der_prefix[SHA1_DER_LEN] = {
+const unsigned char sha1_der_prefix[SHA1_DER_LEN] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
};
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
2017-11-08 2:30 [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array Wilson Lee
@ 2017-11-20 15:38 ` Simon Glass
2017-11-23 8:29 ` Wilson Lee
0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2017-11-20 15:38 UTC (permalink / raw)
To: u-boot
Hi Wilson,
On 7 November 2017 at 19:30, Wilson Lee <wilson.lee@ni.com> wrote:
> uint8_t used in sha1_der_prefix array was not able to recognize by
> compiler when try to build the tools using 'HOSTCC'. That is because,
> uint8_t is undefined when 'HOSTCC' is defined because asm/type.h is not
> included in that case. Use unsigned char for sha1_der_prefix[] array
> instead.
>
> This commit is to remove and change the uint8_t to unsigned char for
> sha1_der_perfix[] array.
nit: prefix
This change is OK I suppose. But I'm not sure what compiler you are
using. This type should be provided in stdint.h - can you take a look
at why it is not?
Regards,
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
2017-11-20 15:38 ` Simon Glass
@ 2017-11-23 8:29 ` Wilson Lee
2017-11-26 11:38 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Wilson Lee @ 2017-11-23 8:29 UTC (permalink / raw)
To: u-boot
Hi Simon,
On Mon, 2017-11-20 at 08:38 -0700, Simon Glass wrote:
> Hi Wilson,
>
> On 7 November 2017 at 19:30, Wilson Lee <wilson.lee@ni.com> wrote:
> >
> > uint8_t used in sha1_der_prefix array was not able to recognize by
> > compiler when try to build the tools using 'HOSTCC'. That is
> > because,
> > uint8_t is undefined when 'HOSTCC' is defined because asm/type.h is
> > not
> > included in that case. Use unsigned char for sha1_der_prefix[]
> > array
> > instead.
> >
> > This commit is to remove and change the uint8_t to unsigned char
> > for
> > sha1_der_perfix[] array.
> nit: prefix
>
> This change is OK I suppose. But I'm not sure what compiler you are
> using. This type should be provided in stdint.h - can you take a look
> at why it is not?
>
> Regards,
> Simon
Kindly correct me if I am wrong. I think the uint8_t was provided in
the "inttypes.h" header file. However, when we using HOSTCC to compile
the code, the "common.h" (which include "inttypes.h") does not included
and cause compilation to fail. The summary version of the code shown
below:
#ifndef USE_HOSTCC
#include <common.h>
#include <linux/string.h>
#else
#include <string.h>
#endif /* USE_HOSTCC */
I think there have 2 solution for this:
1. Include the "inttypes.h" header file.
2. Change the uint8_t to unsigned char.
However, I would like to proceed with 2nd option. Because, in existing
sha1 library, variable data type was declare as unsigned char, unsigned
long... and I am thinking convert uint8_t to unsigned char will make
the variable data type more consistent in sha1 library code.
Thanks, Simon.
Best Regards,
Wilson Lee
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
2017-11-23 8:29 ` Wilson Lee
@ 2017-11-26 11:38 ` Simon Glass
0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2017-11-26 11:38 UTC (permalink / raw)
To: u-boot
Hi Wilson,
On 23 November 2017 at 01:29, Wilson Lee <wilson.lee@ni.com> wrote:
> Hi Simon,
>
> On Mon, 2017-11-20 at 08:38 -0700, Simon Glass wrote:
>> Hi Wilson,
>>
>> On 7 November 2017 at 19:30, Wilson Lee <wilson.lee@ni.com> wrote:
>> >
>> > uint8_t used in sha1_der_prefix array was not able to recognize by
>> > compiler when try to build the tools using 'HOSTCC'. That is
>> > because,
>> > uint8_t is undefined when 'HOSTCC' is defined because asm/type.h is
>> > not
>> > included in that case. Use unsigned char for sha1_der_prefix[]
>> > array
>> > instead.
>> >
>> > This commit is to remove and change the uint8_t to unsigned char
>> > for
>> > sha1_der_perfix[] array.
>> nit: prefix
>>
>> This change is OK I suppose. But I'm not sure what compiler you are
>> using. This type should be provided in stdint.h - can you take a look
>> at why it is not?
>>
>> Regards,
>> Simon
>
> Kindly correct me if I am wrong. I think the uint8_t was provided in
> the "inttypes.h" header file. However, when we using HOSTCC to compile
> the code, the "common.h" (which include "inttypes.h") does not included
> and cause compilation to fail. The summary version of the code shown
> below:
>
> #ifndef USE_HOSTCC
> #include <common.h>
> #include <linux/string.h>
> #else
> #include <string.h>
> #endif /* USE_HOSTCC */
>
>
> I think there have 2 solution for this:
> 1. Include the "inttypes.h" header file.
> 2. Change the uint8_t to unsigned char.
>
> However, I would like to proceed with 2nd option. Because, in existing
> sha1 library, variable data type was declare as unsigned char, unsigned
> long... and I am thinking convert uint8_t to unsigned char will make
> the variable data type more consistent in sha1 library code.
OK I see. Yes that seems best considering only sha1, but I see that
sha256 uses uint8_t pretty consistently. I see that hash_block() uses
uint8_t also. But crc.h uses unsigned char.
Can you try option 1 and see if it works? I feel it is better to use
uint8_t and you would have this same problems with sha256.
But if you want to stick with this patch, it is a a small local change
that does not affect the API, so:
Reviewed-by: Simon Glass <sjg@chromium.org>
>
>
> Thanks, Simon.
Regards,
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-26 11:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-08 2:30 [U-Boot] [PATCH] lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array Wilson Lee
2017-11-20 15:38 ` Simon Glass
2017-11-23 8:29 ` Wilson Lee
2017-11-26 11:38 ` Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox