Commit 91d41f15 authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Herbert Xu

crypto: twofish-x86-asm - make assembler functions use twofish_ctx instead of crypto_tfm

This needed by 3-way twofish patch to be able to easily use one block
assembler functions. As glue code is shared between i586/x86_64 apply
change to i586 assembler too. Also export assembler functions for
3-way parallel twofish module.

CC: Joachim Fritschi <jfritschi@freenet.de>
Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent ee5002a5
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define in_blk 12 /* input byte array address parameter*/ #define in_blk 12 /* input byte array address parameter*/
#define out_blk 8 /* output byte array address parameter*/ #define out_blk 8 /* output byte array address parameter*/
#define tfm 4 /* Twofish context structure */ #define ctx 4 /* Twofish context structure */
#define a_offset 0 #define a_offset 0
#define b_offset 4 #define b_offset 4
...@@ -229,8 +229,8 @@ twofish_enc_blk: ...@@ -229,8 +229,8 @@ twofish_enc_blk:
push %esi push %esi
push %edi push %edi
mov tfm + 16(%esp), %ebp /* abuse the base pointer: set new base bointer to the crypto tfm */ mov ctx + 16(%esp), %ebp /* abuse the base pointer: set new base
add $crypto_tfm_ctx_offset, %ebp /* ctx address */ * pointer to the ctx address */
mov in_blk+16(%esp),%edi /* input address in edi */ mov in_blk+16(%esp),%edi /* input address in edi */
mov (%edi), %eax mov (%edi), %eax
...@@ -285,8 +285,8 @@ twofish_dec_blk: ...@@ -285,8 +285,8 @@ twofish_dec_blk:
push %edi push %edi
mov tfm + 16(%esp), %ebp /* abuse the base pointer: set new base bointer to the crypto tfm */ mov ctx + 16(%esp), %ebp /* abuse the base pointer: set new base
add $crypto_tfm_ctx_offset, %ebp /* ctx address */ * pointer to the ctx address */
mov in_blk+16(%esp),%edi /* input address in edi */ mov in_blk+16(%esp),%edi /* input address in edi */
mov (%edi), %eax mov (%edi), %eax
......
...@@ -221,10 +221,9 @@ ...@@ -221,10 +221,9 @@
twofish_enc_blk: twofish_enc_blk:
pushq R1 pushq R1
/* %rdi contains the crypto tfm address */ /* %rdi contains the ctx address */
/* %rsi contains the output address */ /* %rsi contains the output address */
/* %rdx contains the input address */ /* %rdx contains the input address */
add $crypto_tfm_ctx_offset, %rdi /* set ctx address */
/* ctx address is moved to free one non-rex register /* ctx address is moved to free one non-rex register
as target for the 8bit high operations */ as target for the 8bit high operations */
mov %rdi, %r11 mov %rdi, %r11
...@@ -274,10 +273,9 @@ twofish_enc_blk: ...@@ -274,10 +273,9 @@ twofish_enc_blk:
twofish_dec_blk: twofish_dec_blk:
pushq R1 pushq R1
/* %rdi contains the crypto tfm address */ /* %rdi contains the ctx address */
/* %rsi contains the output address */ /* %rsi contains the output address */
/* %rdx contains the input address */ /* %rdx contains the input address */
add $crypto_tfm_ctx_offset, %rdi /* set ctx address */
/* ctx address is moved to free one non-rex register /* ctx address is moved to free one non-rex register
as target for the 8bit high operations */ as target for the 8bit high operations */
mov %rdi, %r11 mov %rdi, %r11
......
...@@ -44,17 +44,21 @@ ...@@ -44,17 +44,21 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
asmlinkage void twofish_enc_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src); asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst,
asmlinkage void twofish_dec_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src); const u8 *src);
EXPORT_SYMBOL_GPL(twofish_enc_blk);
asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst,
const u8 *src);
EXPORT_SYMBOL_GPL(twofish_dec_blk);
static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
{ {
twofish_enc_blk(tfm, dst, src); twofish_enc_blk(crypto_tfm_ctx(tfm), dst, src);
} }
static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
{ {
twofish_dec_blk(tfm, dst, src); twofish_dec_blk(crypto_tfm_ctx(tfm), dst, src);
} }
static struct crypto_alg alg = { static struct crypto_alg alg = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment