X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=arcfour-asm.S;h=1ef8218ce971a608ffaf096959dc40fb63141804;hb=951a88cde69f595ef2c00ed941e89ccf1567e3a0;hp=05cac9255180b52b5dc5dbb7554a9936631d465e;hpb=c58f43febaefd188708dca010198629c0935728c;p=avr-crypto-lib.git diff --git a/arcfour-asm.S b/arcfour-asm.S index 05cac92..1ef8218 100644 --- a/arcfour-asm.S +++ b/arcfour-asm.S @@ -1,6 +1,6 @@ /* arcfour-asm.S */ /* - This file is part of the Crypto-avr-lib/microcrypt-lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -27,51 +27,7 @@ */ #include - - -.macro push_ p1:req, p2:vararg - push \p1 -.ifnb \p2 - push_ \p2 -.endif -.endm - -.macro pop_ p1:req, p2:vararg - pop \p1 -.ifnb \p2 - pop_ \p2 -.endif -.endm - -.macro push_range from:req, to:req - push \from -.if \to-\from - push_range "(\from+1)",\to -.endif -.endm - -.macro pop_range from:req, to:req - pop \to -.if \to-\from - pop_range \from,"(\to-1)" -.endif -.endm - -.macro stack_alloc size:req, reg1=r30, reg2=r31 - in \reg1, _SFR_IO_ADDR(SPL) - in \reg2, _SFR_IO_ADDR(SPH) - sbiw r30, \size - out _SFR_IO_ADDR(SPH), \reg2 - out _SFR_IO_ADDR(SPL), \reg1 -.endm - -.macro stack_free size:req, reg1=r30, reg2=r31 - in \reg1, _SFR_IO_ADDR(SPL) - in \reg2, _SFR_IO_ADDR(SPH) - adiw r30, \size - out _SFR_IO_ADDR(SPH), \reg2 - out _SFR_IO_ADDR(SPL), \reg1 -.endm +#include "avr-asm-macros.S" /* +---+---+---------------------+ * | i | j | ......<256>........ | @@ -90,7 +46,7 @@ * given in r20:r21 */ arcfour_init: - push_ r2, r28, r29 + push_ r28, r29 movw r26, r20 /* X points to ctx */ movw r30, r24 /* Z points to key */ st X+, r1 @@ -103,29 +59,27 @@ arcfour_init: brne 1b movw r26, r20 - clr r18 /* r18 is keyindex counter */ + add r22, r30 /* r18 is keyindex counter */ clr r0 clr r19 2: ld r23, X - ld r2, Z+ - add r19, r2 + ld r18, Z+ + add r19, r18 add r19, r23 movw r28, r20 /* load pointer to S in Y */ add r28, r19 adc r29, r1 - ld r2, Y + ld r18, Y st Y, r23 - st X+, r2 - inc r18 - cp r18, r22 + st X+, r18 + cp r30, r22 brne 3f movw r30, r24 - clr r18 3: inc r0 brne 2b - pop_ r29, r28, r2 + pop_ r29, r28 ret /*