Fixed undefined reference error when "make recover" in EON
In fd233832ef
the linker flag -lgcc might not work on EON as it does not have the
correct library.
The fix was a workaround in sha.c such that we no longer need to import
function __aeabi_llsr from library, by replacing right shift operation
with const argument.
E.g.,
uint64_t a = b >> i // requires __aeabi_llsr from libgcc
uint64_t a = b >> 2 // does not require external library
Resolves: #522
master
parent
c91f038eab
commit
e0dd55841a
|
@ -55,7 +55,7 @@ obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.$(PROJ_NAME).o
|
|||
|
||||
|
||||
obj/bootstub.$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/bootstub.$(PROJ_NAME).o obj/sha.$(PROJ_NAME).o obj/rsa.$(PROJ_NAME).o
|
||||
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^ -lgcc
|
||||
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
|
||||
$(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@
|
||||
|
||||
clean:
|
||||
|
|
34
crypto/sha.c
34
crypto/sha.c
|
@ -127,10 +127,36 @@ const uint8_t* SHA_final(SHA_CTX* ctx) {
|
|||
while ((ctx->count & 63) != 56) {
|
||||
SHA_update(ctx, (uint8_t*)"\0", 1);
|
||||
}
|
||||
for (i = 0; i < 8; ++i) {
|
||||
uint8_t tmp = (uint8_t) (cnt >> ((7 - i) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
}
|
||||
|
||||
/* Hack - right shift operator with non const argument requires
|
||||
* libgcc.a which is missing in EON
|
||||
* thus expanding for loop from
|
||||
|
||||
for (i = 0; i < 8; ++i) {
|
||||
uint8_t tmp = (uint8_t) (cnt >> ((7 - i) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
}
|
||||
|
||||
to
|
||||
*/
|
||||
|
||||
uint8_t tmp = 0;
|
||||
tmp = (uint8_t) (cnt >> ((7 - 0) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 1) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 2) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 3) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 4) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 5) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 6) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
tmp = (uint8_t) (cnt >> ((7 - 7) * 8));
|
||||
SHA_update(ctx, &tmp, 1);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
uint32_t tmp = ctx->state[i];
|
||||
|
|
Loading…
Reference in New Issue