From 2ef97287a9ad083781a540bedf8e86fba17f9265 Mon Sep 17 00:00:00 2001 From: bg Date: Sat, 12 Jan 2013 23:21:45 +0100 Subject: [PATCH] [keccak-asm] *_init in asm --- keccak/keccak-asm.S | 64 ++++++++++++++++++++++++++++++++++++++++++++ keccak/keccak-stub.c | 3 +++ 2 files changed, 67 insertions(+) diff --git a/keccak/keccak-asm.S b/keccak/keccak-asm.S index f1fc07a..393535b 100644 --- a/keccak/keccak-asm.S +++ b/keccak/keccak-asm.S @@ -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 + diff --git a/keccak/keccak-stub.c b/keccak/keccak-stub.c index de93cf8..c846746 100644 --- a/keccak/keccak-stub.c +++ b/keccak/keccak-stub.c @@ -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); } + +*/ -- 2.39.5