]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
fixing bug in SHA1-C
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Thu, 17 Dec 2009 15:32:52 +0000 (15:32 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Thu, 17 Dec 2009 15:32:52 +0000 (15:32 +0000)
bmw/bmw_small-asm.S
sha1/sha1.c
test_src/main-sha1-test.c

index 0699893601bb604a77e7bb457444200c92c091fa..ce8518d93a6f8f5fa0aa9095b48866c7dbfef435 100644 (file)
@@ -538,12 +538,11 @@ addelement:
        mov j, r24
        movw h0, r20
        movw m0, r22
-       mov r25, r24
-       lsl r25
-       lsl r25
+       lsl r24
+       lsl r24
        ldi r30, lo8(const_lut)
        ldi r31, hi8(const_lut)
-       add r30, r25
+       add r30, r24
        adc r31, r1
        lpm acc0, Z+
        lpm acc1, Z+
index 3e14a3e2b5042a30e931a1534a4911fb26eb52ef..4712e149bd70b51c61cfab3fd3c53cc68ebf94fb 100644 (file)
@@ -209,12 +209,12 @@ void sha1_lastBlock(sha1_ctx_t *state, const void* block, uint16_t length){
 void sha1_ctx2hash (sha1_hash_t *dest, sha1_ctx_t *state){
 #if defined LITTLE_ENDIAN
        uint8_t i;
-       for(i=0; i<8; ++i){
+       for(i=0; i<5; ++i){
                ((uint32_t*)dest)[i] = change_endian32(state->h[i]);
        }
 #elif BIG_ENDIAN
        if (dest != state->h)
-               memcpy(dest, state->h, SHA256_HASH_BITS/8);
+               memcpy(dest, state->h, SHA1_HASH_BITS/8);
 #else
 # error unsupported endian type!
 #endif
index dc6f5315d663b22a771ccfffbede6f466ae57954..e62d6dfe7b2567860f82e69d592c0d039e8cb735 100644 (file)
@@ -106,7 +106,6 @@ void testrun_sha1(void){
        sha1(&hash,"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",448);
 //     cli_putstr_P(PSTR("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t"));
        cli_hexdump(hash,SHA1_HASH_BITS/8);
-/*
        cli_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
        {
                uint8_t block[SHA1_BLOCK_BITS/8];
@@ -121,9 +120,7 @@ void testrun_sha1(void){
                sha1_ctx2hash(&hash, &s);
        }
        cli_hexdump(hash,SHA1_HASH_BITS/8);
-*/
 
-       cli_putstr("\r\nx");
 }