]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - skein/threefish256_enc_small.S
switch gcm-test from aes to aes-enconly
[avr-crypto-lib.git] / skein / threefish256_enc_small.S
index f7392bac90443374055987adf417ed133beee47b..c98f37fa0b7698b294dcd75f3999f284300896a9 100644 (file)
@@ -40,7 +40,7 @@ A7 = 21
 #define K(s) (((uint64_t*)key)[(s)])
 #define T(s) (((uint64_t*)tweak)[(s)])
 
 #define K(s) (((uint64_t*)key)[(s)])
 #define T(s) (((uint64_t*)tweak)[(s)])
 
-void threefish256_init(void* key, void* tweak, threefish256_ctx_t* ctx){
+void threefish256_init(void *key, void *tweak, threefish256_ctx_t *ctx){
        memcpy(ctx->k, key, 4*8);
        memcpy(ctx->t, tweak, 2*8);
        uint8_t i;
        memcpy(ctx->k, key, 4*8);
        memcpy(ctx->t, tweak, 2*8);
        uint8_t i;
@@ -62,11 +62,20 @@ threefish256_init:
        movw r30, r20
        movw r26, r24
        ldi r24, 4
        movw r30, r20
        movw r26, r24
        ldi r24, 4
-       ldi A7, 0x55
-       mov A6, A7
-       movw A4, A6
-       movw A2, A6
+;      ldi A7, 0x55
+;      mov A6, A7
+;      movw A4, A6
+;      movw A2, A6
+;      movw A0, A6
+       ldi A6, 0x22 ; 0x1BD1.1BDA.A9FC.1A22
+       ldi A7, 0x1A
        movw A0, A6
        movw A0, A6
+       ldi A2, 0xFC
+       ldi A3, 0xA9
+       ldi A4, 0xDA
+       ldi A5, 0x1B
+       ldi A6, 0xD1
+       ldi A7, 0x1B
 1:
        ld r0, X+
        st Z+, r0
 1:
        ld r0, X+
        st Z+, r0
@@ -170,19 +179,19 @@ threefish256_init:
 /******************************************************************************/
 /*
 #define X(a) (((uint64_t*)data)[(a)])
 /******************************************************************************/
 /*
 #define X(a) (((uint64_t*)data)[(a)])
-void permute_4(voiddata){
+void permute_4(void *data){
        uint64_t t;
        t = X(1);
        X(1) = X(3);
        X(3) = t;
 }
        uint64_t t;
        t = X(1);
        X(1) = X(3);
        X(3) = t;
 }
-void add_key_4(void* data, threefish256_ctx_t* ctx, uint8_t s){ / * s: 0..19 * /
+void add_key_4(void *data, threefish256_ctx_t *ctx, uint8_t s){ / * s: 0..19 * /
        X(0) += ctx->k[(s+0)%5];
        X(1) += ctx->k[(s+1)%5] + ctx->t[s%3];
        X(2) += ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
        X(3) += ctx->k[(s+3)%5] + s;
 }
        X(0) += ctx->k[(s+0)%5];
        X(1) += ctx->k[(s+1)%5] + ctx->t[s%3];
        X(2) += ctx->k[(s+2)%5] + ctx->t[(s+1)%3];
        X(3) += ctx->k[(s+3)%5] + s;
 }
-void threefish256_enc(void* data, threefish256_ctx_t* ctx){
+void threefish256_enc(void *data, threefish256_ctx_t *ctx){
        uint8_t i=0,s=0;
        uint8_t r0[8] = { 5, 36, 13, 58, 26, 53, 11, 59};
        uint8_t r1[8] = {56, 28, 46, 44, 20, 35, 42, 50};
        uint8_t i=0,s=0;
        uint8_t r0[8] = { 5, 36, 13, 58, 26, 53, 11, 59};
        uint8_t r1[8] = {56, 28, 46, 44, 20, 35, 42, 50};
@@ -332,8 +341,12 @@ threefish256_slut3:
        .byte 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00, 0x08
        .byte 0x10, 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00
        .byte 0x08, 0x10, 0x00, 0x08, 0x10, 0x00, 0x08
        .byte 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00, 0x08
        .byte 0x10, 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00
        .byte 0x08, 0x10, 0x00, 0x08, 0x10, 0x00, 0x08
+/* old round contants
 threefish256_rc0: .byte 0x1b, 0x44, 0x2b, 0x72, 0x32, 0x7b, 0x13, 0x73
 threefish256_rc1: .byte 0x70, 0x34, 0x6a, 0x54, 0x24, 0x43, 0x52, 0x62
 threefish256_rc0: .byte 0x1b, 0x44, 0x2b, 0x72, 0x32, 0x7b, 0x13, 0x73
 threefish256_rc1: .byte 0x70, 0x34, 0x6a, 0x54, 0x24, 0x43, 0x52, 0x62
+*/
+threefish256_rc0:  .byte 0x2a, 0x64, 0x39, 0x1b, 0x31, 0x6a, 0x72, 0x40
+threefish256_rc1:  .byte 0x20, 0x71, 0x50, 0x5b, 0x41, 0x14, 0x3a, 0x40
 
 add_z_to_x8:
        ld r0, Z+
 
 add_z_to_x8:
        ld r0, Z+