aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 14:03:29 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 14:03:29 -0400
commit972d19e837833b93466c6f6a8ef2a7d653000aa3 (patch)
tree069258492d5347cf440b8240dadfa20621f54842 /arch/x86_64
parentcdf4f383a4b0ffbf458f65380ecffbeee1f79841 (diff)
parentb9d0a25a484a90c1d60b974d115eff2fe580ce16 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6: [CRYPTO] tcrypt: Forbid tcrypt from being built-in [CRYPTO] aes: Add wrappers for assembly routines [CRYPTO] tcrypt: Speed benchmark support for digest algorithms [CRYPTO] tcrypt: Return -EAGAIN from module_init() [CRYPTO] api: Allow replacement when registering new algorithms [CRYPTO] api: Removed const from cra_name/cra_driver_name [CRYPTO] api: Added cra_init/cra_exit [CRYPTO] api: Fixed incorrect passing of context instead of tfm [CRYPTO] padlock: Rearrange context structure to reduce code size [CRYPTO] all: Pass tfm instead of ctx to algorithms [CRYPTO] digest: Remove unnecessary zeroing during init [CRYPTO] aes-i586: Get rid of useless function wrappers [CRYPTO] digest: Add alignment handling [CRYPTO] khazad: Use 32-bit reads on key
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/crypto/aes-x86_64-asm.S22
-rw-r--r--arch/x86_64/crypto/aes.c20
-rw-r--r--arch/x86_64/kernel/asm-offsets.c3
3 files changed, 31 insertions, 14 deletions
diff --git a/arch/x86_64/crypto/aes-x86_64-asm.S b/arch/x86_64/crypto/aes-x86_64-asm.S
index 483cbb23ab8d..26b40de4d0b0 100644
--- a/arch/x86_64/crypto/aes-x86_64-asm.S
+++ b/arch/x86_64/crypto/aes-x86_64-asm.S
@@ -15,6 +15,10 @@
15 15
16.text 16.text
17 17
18#include <asm/asm-offsets.h>
19
20#define BASE crypto_tfm_ctx_offset
21
18#define R1 %rax 22#define R1 %rax
19#define R1E %eax 23#define R1E %eax
20#define R1X %ax 24#define R1X %ax
@@ -46,19 +50,19 @@
46#define R10 %r10 50#define R10 %r10
47#define R11 %r11 51#define R11 %r11
48 52
49#define prologue(FUNC,BASE,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \ 53#define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \
50 .global FUNC; \ 54 .global FUNC; \
51 .type FUNC,@function; \ 55 .type FUNC,@function; \
52 .align 8; \ 56 .align 8; \
53FUNC: movq r1,r2; \ 57FUNC: movq r1,r2; \
54 movq r3,r4; \ 58 movq r3,r4; \
55 leaq BASE+52(r8),r9; \ 59 leaq BASE+KEY+52(r8),r9; \
56 movq r10,r11; \ 60 movq r10,r11; \
57 movl (r7),r5 ## E; \ 61 movl (r7),r5 ## E; \
58 movl 4(r7),r1 ## E; \ 62 movl 4(r7),r1 ## E; \
59 movl 8(r7),r6 ## E; \ 63 movl 8(r7),r6 ## E; \
60 movl 12(r7),r7 ## E; \ 64 movl 12(r7),r7 ## E; \
61 movl (r8),r10 ## E; \ 65 movl BASE(r8),r10 ## E; \
62 xorl -48(r9),r5 ## E; \ 66 xorl -48(r9),r5 ## E; \
63 xorl -44(r9),r1 ## E; \ 67 xorl -44(r9),r1 ## E; \
64 xorl -40(r9),r6 ## E; \ 68 xorl -40(r9),r6 ## E; \
@@ -128,8 +132,8 @@ FUNC: movq r1,r2; \
128 movl r3 ## E,r1 ## E; \ 132 movl r3 ## E,r1 ## E; \
129 movl r4 ## E,r2 ## E; 133 movl r4 ## E,r2 ## E;
130 134
131#define entry(FUNC,BASE,B128,B192) \ 135#define entry(FUNC,KEY,B128,B192) \
132 prologue(FUNC,BASE,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11) 136 prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11)
133 137
134#define return epilogue(R8,R2,R9,R7,R5,R6,R3,R4,R11) 138#define return epilogue(R8,R2,R9,R7,R5,R6,R3,R4,R11)
135 139
@@ -147,9 +151,9 @@ FUNC: movq r1,r2; \
147#define decrypt_final(TAB,OFFSET) \ 151#define decrypt_final(TAB,OFFSET) \
148 round(TAB,OFFSET,R2,R1,R4,R3,R6,R5,R7,R10,R5,R6,R3,R4) 152 round(TAB,OFFSET,R2,R1,R4,R3,R6,R5,R7,R10,R5,R6,R3,R4)
149 153
150/* void aes_encrypt(void *ctx, u8 *out, const u8 *in) */ 154/* void aes_enc_blk(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */
151 155
152 entry(aes_encrypt,0,enc128,enc192) 156 entry(aes_enc_blk,0,enc128,enc192)
153 encrypt_round(aes_ft_tab,-96) 157 encrypt_round(aes_ft_tab,-96)
154 encrypt_round(aes_ft_tab,-80) 158 encrypt_round(aes_ft_tab,-80)
155enc192: encrypt_round(aes_ft_tab,-64) 159enc192: encrypt_round(aes_ft_tab,-64)
@@ -166,9 +170,9 @@ enc128: encrypt_round(aes_ft_tab,-32)
166 encrypt_final(aes_fl_tab,112) 170 encrypt_final(aes_fl_tab,112)
167 return 171 return
168 172
169/* void aes_decrypt(void *ctx, u8 *out, const u8 *in) */ 173/* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in) */
170 174
171 entry(aes_decrypt,240,dec128,dec192) 175 entry(aes_dec_blk,240,dec128,dec192)
172 decrypt_round(aes_it_tab,-96) 176 decrypt_round(aes_it_tab,-96)
173 decrypt_round(aes_it_tab,-80) 177 decrypt_round(aes_it_tab,-80)
174dec192: decrypt_round(aes_it_tab,-64) 178dec192: decrypt_round(aes_it_tab,-64)
diff --git a/arch/x86_64/crypto/aes.c b/arch/x86_64/crypto/aes.c
index 6f77e7700d32..68866fab37aa 100644
--- a/arch/x86_64/crypto/aes.c
+++ b/arch/x86_64/crypto/aes.c
@@ -227,10 +227,10 @@ static void __init gen_tabs(void)
227 t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \ 227 t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \
228} 228}
229 229
230static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, 230static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
231 u32 *flags) 231 unsigned int key_len, u32 *flags)
232{ 232{
233 struct aes_ctx *ctx = ctx_arg; 233 struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
234 const __le32 *key = (const __le32 *)in_key; 234 const __le32 *key = (const __le32 *)in_key;
235 u32 i, j, t, u, v, w; 235 u32 i, j, t, u, v, w;
236 236
@@ -283,8 +283,18 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len,
283 return 0; 283 return 0;
284} 284}
285 285
286extern void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in); 286asmlinkage void aes_enc_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in);
287extern void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in); 287asmlinkage void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in);
288
289static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
290{
291 aes_enc_blk(tfm, dst, src);
292}
293
294static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
295{
296 aes_dec_blk(tfm, dst, src);
297}
288 298
289static struct crypto_alg aes_alg = { 299static struct crypto_alg aes_alg = {
290 .cra_name = "aes", 300 .cra_name = "aes",
diff --git a/arch/x86_64/kernel/asm-offsets.c b/arch/x86_64/kernel/asm-offsets.c
index 38834bbbae11..96687e2beb2c 100644
--- a/arch/x86_64/kernel/asm-offsets.c
+++ b/arch/x86_64/kernel/asm-offsets.c
@@ -4,6 +4,7 @@
4 * and format the required data. 4 * and format the required data.
5 */ 5 */
6 6
7#include <linux/crypto.h>
7#include <linux/sched.h> 8#include <linux/sched.h>
8#include <linux/stddef.h> 9#include <linux/stddef.h>
9#include <linux/errno.h> 10#include <linux/errno.h>
@@ -68,5 +69,7 @@ int main(void)
68 DEFINE(pbe_next, offsetof(struct pbe, next)); 69 DEFINE(pbe_next, offsetof(struct pbe, next));
69 BLANK(); 70 BLANK();
70 DEFINE(TSS_ist, offsetof(struct tss_struct, ist)); 71 DEFINE(TSS_ist, offsetof(struct tss_struct, ist));
72 BLANK();
73 DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
71 return 0; 74 return 0;
72} 75}