]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
[keccak-asm] *_init in asm
authorbg <daniel.otte@rub.de>
Sat, 12 Jan 2013 22:21:45 +0000 (23:21 +0100)
committerbg <daniel.otte@rub.de>
Sat, 12 Jan 2013 22:21:45 +0000 (23:21 +0100)
keccak/keccak-asm.S
keccak/keccak-stub.c

index f1fc07a10e561159ec9fd74b3b63c4cc139c18b0..393535b1407c1dcb83db25942ccf6778fcab99d4 100644 (file)
@@ -725,3 +725,67 @@ keccak_ctx2hash:
        ret
        .endfunc
 
+
+       .global keccak224_init
+       .func keccak224_init
+keccak224_init:
+       movw XL, r24
+       ldi r24, lo8(1152)
+       ldi r25, hi8(1152)
+       rjmp keccak_init_1
+       .endfunc
+
+       .global keccak384_init
+       .func keccak384_init
+keccak384_init:
+       movw XL, r24
+       ldi r24, lo8( 832)
+       ldi r25, hi8( 832)
+       rjmp keccak_init_1
+       .endfunc
+
+       .global keccak512_init
+       .func keccak512_init
+keccak512_init:
+       movw XL, r24
+       ldi r24, lo8( 576)
+       ldi r25, hi8( 576)
+       rjmp keccak_init_1
+       .endfunc
+
+       .global keccak256_init
+       .func keccak256_init
+keccak256_init:
+       movw r22, r24
+       ldi r24, lo8(1088)
+       ldi r25, hi8(1088)
+       .endfunc
+/*
+void keccak_init(uint16_t r, keccak_ctx_t* ctx){
+       memset(ctx->a, 0x00, 5 * 5 * 8);
+       ctx->r = r;
+       ctx->bs = (uint8_t)(r / 8);
+}
+*/
+       .global keccak_init
+       .func keccak_init
+keccak_init:
+       movw XL, r22
+keccak_init_1:
+       ldi r22, 200
+10:
+       st X+, __zero_reg__
+       dec r22
+       brne 10b
+       st X+, r24
+       st X+, r25
+       lsr r25
+       ror r24
+       lsr r25
+       ror r24
+       lsr r25
+       ror r24
+       st X+, r24
+       ret
+       .endfunc
+
index de93cf81eea23ed1f68631ef7682986d8606a172..c8467460a9ff8ccac2168ec102ba47f8404788f2 100644 (file)
@@ -170,6 +170,7 @@ void keccak512_ctx2hash(void* dest, keccak_ctx_t* ctx){
   3. SHA3-384: ⌊Keccak[r =  832, c =  768, d = 48]⌋384
   4. SHA3-512: ⌊Keccak[r =  576, c = 1024, d = 64]⌋512
 */
+/*
 void keccak_init(uint16_t r, keccak_ctx_t* ctx){
        memset(ctx->a, 0x00, 5 * 5 * 8);
        ctx->r = r;
@@ -191,3 +192,5 @@ void keccak384_init(keccak_ctx_t* ctx){
 void keccak512_init(keccak_ctx_t* ctx){
        keccak_init( 576, ctx);
 }
+
+*/