X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=keccak%2Fkeccak-asm.S;h=459994ae31d122f9ba135fe1135360f300f00f1b;hp=db8548cb4f44383a9caced05b95c32198d43860f;hb=eb0cafe05ab4cdf60878dbd81e4ff3712d5150f2;hpb=ae1ab232c9964531bcf50cd6580ff8081ef86990 diff --git a/keccak/keccak-asm.S b/keccak/keccak-asm.S index db8548c..459994a 100644 --- a/keccak/keccak-asm.S +++ b/keccak/keccak-asm.S @@ -34,8 +34,8 @@ /* typedef struct{ uint64_t a[5][5]; - uint16_t r, c; - uint8_t d, bs; + uint16_t r; + uint8_t bs; } keccak_ctx_t; */ .struct 0 @@ -429,8 +429,6 @@ keccak_f1600: subi XL, lo8(4 * 5 * 8 + 8) sbci XH, hi8(4 * 5 * 8 + 8) rcall theta_2b - -; ret /* -- rho & pi -- for(i = 0; i < 5; ++i){ @@ -442,8 +440,8 @@ keccak_f1600: -- or -- - const uint8_t* rot_code = (const uint8_t*)keccak_rotate_codes; - const uint8_t* idx_idx = (const uint8_t*)rho_pi_idx_table; + const uint8_t *rot_code = (const uint8_t*)keccak_rotate_codes; + const uint8_t *idx_idx = (const uint8_t*)rho_pi_idx_table; uint64_t *a_tmp = (uint64_t*)a; for(i = 0; i < 25; ++i){ *((uint64_t*)(((uint8_t*)b) + pgm_read_byte(idx_idx++))) = @@ -659,7 +657,7 @@ keccak256_ctx2hash: .endfunc /* -void keccak_ctx2hash(void* dest, uint16_t length_b, keccak_ctx_t* ctx){ +void keccak_ctx2hash(void *dest, uint16_t length_b, keccak_ctx_t *ctx){ while(length_b>=ctx->r){ memcpy(dest, ctx->a, ctx->bs); dest = (uint8_t*)dest + ctx->bs; @@ -686,7 +684,6 @@ keccak_ctx2hash: ; length_b = (r9:r8) ; r = (r3:r2) ; (H:L) cp r2, r8 cpc r3, r9 -; rjmp 40f brsh 40f movw XL, r4 movw ZL, r6 @@ -761,7 +758,7 @@ keccak256_init: ldi r25, hi8(1088) .endfunc /* -void keccak_init(uint16_t r, keccak_ctx_t* ctx){ +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); @@ -790,7 +787,7 @@ keccak_init_1: .endfunc /* -void keccak_lastBlock(keccak_ctx_t* ctx, const void* block, uint16_t length_b){ +void keccak_lastBlock(keccak_ctx_t *ctx, const void *block, uint16_t length_b){ uint8_t length_B; uint8_t t; while(length_b >= ctx->r){ @@ -842,14 +839,14 @@ keccak_lastBlock: movw r24, ctx_l movw r22, r4 rcall keccak_nextBlock - sub r4, pbs - sbc r5, __zero_reg__ + add r4, pbs + adc r5, __zero_reg__ sub length_b_l, pr_l - sbc length_b_l, pr_h + sbc length_b_h, pr_h rjmp 10b 20: - movw XL, r4 movw ZL, ctx_l + movw XL, r4 movw r22, length_b_l lsr r23 ror r22 @@ -867,12 +864,12 @@ keccak_lastBlock: dec r23 brne 10b 20: + ldi r25, 1 mov r18, length_b_l andi r18, 7 - mov r19, r18 - ldi r25, 1 breq 30f /* we have trailing bits */ + mov r19, r18 ld r24, X+ subi r18, 8 neg r18