lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
PATCH 1/1 lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
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.
--- include/u-boot/sha1.h | 2 +- lib/sha1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/u-boot/sha1.h +1 -1
@@ -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
lib/sha1.c +1 -1
@@ -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 };
Signature · 1 line
2.7.4
PATCH 1/1 lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
Hi Wilson,
Quoted 8 lines · Wilson Lee
uint8_tused insha1_der_prefixarray was not able to recognize by compiler when try to build the tools using 'HOSTCC'. That is because,uint8_tis undefined when 'HOSTCC' is defined becauseasm/type.his not included in that case. Use unsigned char for sha1_der_prefix[] array instead.This commit is to remove and change the
uint8_tto 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
PATCH 1/1 lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
Hi Simon,
Quoted 16 lines · Simon Glass
Hi Wilson,
Quoted 10 lines · Wilson Lee
uint8_tused insha1_der_prefixarray was not able to recognize by compiler when try to build the tools using 'HOSTCC'. That is because,uint8_tis undefined when 'HOSTCC' is defined becauseasm/type.his not
included in that case. Use unsigned char for sha1_der_prefix[] array
instead.Quoted 3 lines
This commit is to remove and change the
uint8_tto unsigned char for
sha1_der_perfix[] array.
Quoted 8 lines
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
PATCH 1/1 lib: sha1: Change uint8_t to unsigned char for sha1_der_prefix array.
Hi Wilson,
Quoted 42 lines · Wilson Lee
Hi Simon,
Quoted 16 lines · Simon Glass
Hi Wilson,
Quoted 10 lines · Wilson Lee
uint8_tused insha1_der_prefixarray was not able to recognize by compiler when try to build the tools using 'HOSTCC'. That is because,uint8_tis undefined when 'HOSTCC' is defined becauseasm/type.his not
included in that case. Use unsigned char for sha1_der_prefix[] array
instead.Quoted 3 lines
This commit is to remove and change the
uint8_tto unsigned char for
sha1_der_perfix[] array.Quoted 8 lines
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,
SimonKindly correct me if I am wrong. I think the
uint8_twas 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*/
Quoted 8 lines
I think there have 2 solution for this:
1. Include the "inttypes.h" header file.
2. Change theuint8_tto 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_tto 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:
Quoted 3 lines
Thanks, Simon.
Regards,
Simon