]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
x86: Adapted aes assembly to new interface.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 21 May 2013 17:14:43 +0000 (19:14 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 21 May 2013 17:14:43 +0000 (19:14 +0200)
ChangeLog
x86/aes-decrypt-internal.asm
x86/aes-encrypt-internal.asm

index 070f00af7b714d323f1e67446fd28842d7ca6f24..ef0b06b3916238af5f4e9750c82798ddd45fc587 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,12 @@
-2013-05-20  Niels Möller  <nisse@lysator.liu.se>
+2013-05-21  Niels Möller  <nisse@lysator.liu.se>
 
-       * x86_64/aes-decrypt-internal.asm: Likewise.
+       * x86/aes-encrypt-internal.asm: Adapted to new interface.
+       * x86/aes-decrypt-internal.asm: Likewise.
+
+2013-05-20  Niels Möller  <nisse@lysator.liu.se>
 
        * x86_64/aes-encrypt-internal.asm: Adapted to new interface.
+       * x86_64/aes-decrypt-internal.asm: Likewise.
 
 2013-05-17  Niels Möller  <nisse@lysator.liu.se>
 
index 6220c11d3eb5fac2a4602f3bdc9f7ab4a7453fee..61339e2f5a40fd7f28d356a14a0a563f7e6aad69 100644 (file)
@@ -1,6 +1,7 @@
 C nettle, low-level cryptographics library
 C 
 C Copyright (C) 2001, 2002, 2005 Rafael R. Sevilla, Niels Möller
+C Copyright (C) 2013, Niels Möller
 C  
 C The nettle library is free software; you can redistribute it and/or modify
 C it under the terms of the GNU Lesser General Public License as published by
@@ -32,11 +33,12 @@ define(<T>,<%ebp>)
 define(<TMP>,<%edi>)
 define(<KEY>,<%esi>)
 
-define(<FRAME_CTX>,    <40(%esp)>)
-define(<FRAME_TABLE>,  <44(%esp)>)
-define(<FRAME_LENGTH>, <48(%esp)>)
-define(<FRAME_DST>,    <52(%esp)>)
-define(<FRAME_SRC>,    <56(%esp)>)
+define(<PARAM_ROUNDS>, <40(%esp)>)
+define(<PARAM_KEYS>,   <44(%esp)>)
+define(<PARAM_TABLE>,  <48(%esp)>)
+define(<PARAM_LENGTH>, <52(%esp)>)
+define(<PARAM_DST>,    <56(%esp)>)
+define(<PARAM_SRC>,    <60(%esp)>)
 
 define(<FRAME_KEY>,    <16(%esp)>)
 define(<FRAME_COUNT>,  <12(%esp)>)
@@ -55,7 +57,7 @@ C %edi is a temporary, often used as an accumulator.
 
        .file "aes-decrypt-internal.asm"
        
-       C _aes_decrypt(struct aes_context *ctx, 
+       C _aes_decrypt(unsigned rounds, const uint32_t *keys,
        C              const struct aes_table *T,
        C              size_t length, uint8_t *dst,
        C              uint8_t *src)
@@ -70,24 +72,21 @@ PROLOGUE(_nettle_aes_decrypt)
 
        subl    $20, %esp       C  loop counter and save area for the key pointer
 
-       movl    FRAME_LENGTH, %ebp
+       movl    PARAM_LENGTH, %ebp
        testl   %ebp,%ebp
        jz      .Lend
 
-       shrl    $4, FRAME_LENGTH
-
+       shrl    $4, PARAM_LENGTH
+       subl    $1, PARAM_ROUNDS
 .Lblock_loop:
-       movl    FRAME_CTX,KEY   C  address of context struct ctx
+       movl    PARAM_KEYS, KEY C  address of subkeys
        
-       movl    FRAME_SRC,TMP   C  address of plaintext
+       movl    PARAM_SRC, TMP  C  address of plaintext
        AES_LOAD(SA, SB, SC, SD, TMP, KEY)
-       addl    $16, FRAME_SRC  C Increment src pointer
-       movl    FRAME_TABLE, T
-
-       C  get number of rounds to do from ctx struct   
-       movl    AES_NROUNDS (KEY),TMP
-       subl    $1,TMP
+       addl    $16, PARAM_SRC  C Increment src pointer
+       movl    PARAM_TABLE, T
 
+       movl    PARAM_ROUNDS, TMP
        C Loop counter on stack
        movl    TMP, FRAME_COUNT
 
@@ -140,18 +139,18 @@ PROLOGUE(_nettle_aes_decrypt)
        C Inverse S-box substitution
        mov     $3,TMP
 .Lsubst:
-       AES_SUBST_BYTE(SA,SB,SC,SD,T, KEY)
+       AES_SUBST_BYTE(SA,SB,SC,SD, T, KEY)
 
        decl    TMP
        jnz     .Lsubst
 
        C Add last subkey, and store decrypted data
-       movl    FRAME_DST,TMP
+       movl    PARAM_DST,TMP
        movl    FRAME_KEY, KEY
        AES_STORE(SA,SB,SC,SD, KEY, TMP)
        
-       addl    $16, FRAME_DST          C Increment destination pointer
-       decl    FRAME_LENGTH
+       addl    $16, PARAM_DST          C Increment destination pointer
+       decl    PARAM_LENGTH
 
        jnz     .Lblock_loop
 
index 86985ec62c569d3701c9b6c00cda29873cbd31f1..6ddda58dcef5983555615daa6ff05a6a029dfb9c 100644 (file)
@@ -1,6 +1,7 @@
 C nettle, low-level cryptographics library
 C 
 C Copyright (C) 2001, 2002, 2005 Rafael R. Sevilla, Niels Möller
+C Copyright (C) 2013, Niels Möller
 C  
 C The nettle library is free software; you can redistribute it and/or modify
 C it under the terms of the GNU Lesser General Public License as published by
@@ -32,11 +33,12 @@ define(<T>,<%ebp>)
 define(<TMP>,<%edi>)
 define(<KEY>,<%esi>)
 
-define(<FRAME_CTX>,    <40(%esp)>)
-define(<FRAME_TABLE>,  <44(%esp)>)
-define(<FRAME_LENGTH>, <48(%esp)>)
-define(<FRAME_DST>,    <52(%esp)>)
-define(<FRAME_SRC>,    <56(%esp)>)
+define(<PARAM_ROUNDS>, <40(%esp)>)
+define(<PARAM_KEYS>,   <44(%esp)>)
+define(<PARAM_TABLE>,  <48(%esp)>)
+define(<PARAM_LENGTH>, <52(%esp)>)
+define(<PARAM_DST>,    <56(%esp)>)
+define(<PARAM_SRC>,    <60(%esp)>)
 
 define(<FRAME_KEY>,    <16(%esp)>)
 define(<FRAME_COUNT>,  <12(%esp)>)
@@ -55,7 +57,7 @@ C %edi is a temporary, often used as an accumulator.
 
        .file "aes-encrypt-internal.asm"
        
-       C _aes_encrypt(struct aes_context *ctx, 
+       C _aes_encrypt(unsigned rounds, const uint32_t *keys,
        C              const struct aes_table *T,
        C              size_t length, uint8_t *dst,
        C              uint8_t *src)
@@ -70,24 +72,21 @@ PROLOGUE(_nettle_aes_encrypt)
 
        subl    $20, %esp       C  loop counter and save area for the key pointer
 
-       movl    FRAME_LENGTH, %ebp
+       movl    PARAM_LENGTH, %ebp
        testl   %ebp,%ebp
        jz      .Lend
 
-       shrl    $4, FRAME_LENGTH
-
+       shrl    $4, PARAM_LENGTH
+       subl    $1, PARAM_ROUNDS
 .Lblock_loop:
-       movl    FRAME_CTX,KEY   C  address of context struct ctx
+       movl    PARAM_KEYS, KEY C  address of subkeys
        
-       movl    FRAME_SRC,TMP   C  address of plaintext
+       movl    PARAM_SRC, TMP  C  address of plaintext
        AES_LOAD(SA, SB, SC, SD, TMP, KEY)
-       addl    $16, FRAME_SRC  C Increment src pointer
-       movl    FRAME_TABLE, T
-
-       C  get number of rounds to do from ctx struct   
-       movl    AES_NROUNDS (KEY),TMP
-       subl    $1,TMP
+       addl    $16, PARAM_SRC  C Increment src pointer
+       movl    PARAM_TABLE, T
 
+       movl    PARAM_ROUNDS, TMP
        C Loop counter on stack
        movl    TMP, FRAME_COUNT
 
@@ -146,12 +145,12 @@ PROLOGUE(_nettle_aes_encrypt)
        jnz     .Lsubst
 
        C Add last subkey, and store encrypted data
-       movl    FRAME_DST,TMP
+       movl    PARAM_DST,TMP
        movl    FRAME_KEY, KEY
        AES_STORE(SA,SB,SC,SD, KEY, TMP)
        
-       addl    $16, FRAME_DST          C Increment destination pointer
-       decl    FRAME_LENGTH
+       addl    $16, PARAM_DST          C Increment destination pointer
+       decl    PARAM_LENGTH
 
        jnz     .Lblock_loop