From abf3017eb2b00426156a5002cc63aa2fc27dff0c Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 14 Nov 2016 00:08:41 +0100 Subject: [PATCH] Fix epic fail --- source/crypto.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/crypto.c b/source/crypto.c index 373fbea..a1a42ec 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -299,11 +299,9 @@ static void sha(void *res, const void *src, u32 size, u32 mode) /*****************************************************************/ -__attribute__((aligned(4))) static u8 nandCtr[AES_BLOCK_SIZE], - shaHashBackup[SHA_256_HASH_SIZE]; +__attribute__((aligned(4))) static u8 nandCtr[AES_BLOCK_SIZE]; static u8 nandSlot; static u32 fatStart; -static bool didShaHashBackup = false; FirmwareSource firmSource; @@ -552,12 +550,19 @@ void computePinHash(u8 *outbuf, const u8 *inbuf) void backupAndRestoreShaHash(bool isRestore) { + static bool didShaHashBackup = false; + __attribute__((aligned(4))) static u8 shaHashBackup[SHA_256_HASH_SIZE]; + if(ISA9LH) { if(isRestore) { if(didShaHashBackup) memcpy((void *)REG_SHA_HASH, shaHashBackup, sizeof(shaHashBackup)); } - else if(!didShaHashBackup) memcpy(shaHashBackup, (void *)REG_SHA_HASH, sizeof(shaHashBackup)); + else if(!didShaHashBackup) + { + memcpy(shaHashBackup, (void *)REG_SHA_HASH, sizeof(shaHashBackup)); + didShaHashBackup = true; + } } } \ No newline at end of file