aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/wp512.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-05-16 08:09:29 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-06-26 03:34:39 -0400
commit6c2bb98bc33ae33c7a33a133a4cd5a06395fece5 (patch)
tree96684cd2c473cd05d651ce1fa3dd72b1b4b19b09 /crypto/wp512.c
parent43600106e32809a4dead79fec67a63e9860e3d5d (diff)
[CRYPTO] all: Pass tfm instead of ctx to algorithms
Up until now algorithms have been happy to get a context pointer since they know everything that's in the tfm already (e.g., alignment, block size). However, once we have parameterised algorithms, such information will be specific to each tfm. So the algorithm API needs to be changed to pass the tfm structure instead of the context pointer. This patch is basically a text substitution. The only tricky bit is the assembly routines that need to get the context pointer offset through asm-offsets.h. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/wp512.c')
-rw-r--r--crypto/wp512.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/crypto/wp512.c b/crypto/wp512.c
index b226a126cfae..727d05a19ff4 100644
--- a/crypto/wp512.c
+++ b/crypto/wp512.c
@@ -981,9 +981,9 @@ static void wp512_process_buffer(struct wp512_ctx *wctx) {
981 981
982} 982}
983 983
984static void wp512_init (void *ctx) { 984static void wp512_init(struct crypto_tfm *tfm) {
985 struct wp512_ctx *wctx = crypto_tfm_ctx(tfm);
985 int i; 986 int i;
986 struct wp512_ctx *wctx = ctx;
987 987
988 memset(wctx->bitLength, 0, 32); 988 memset(wctx->bitLength, 0, 32);
989 wctx->bufferBits = wctx->bufferPos = 0; 989 wctx->bufferBits = wctx->bufferPos = 0;
@@ -993,10 +993,10 @@ static void wp512_init (void *ctx) {
993 } 993 }
994} 994}
995 995
996static void wp512_update(void *ctx, const u8 *source, unsigned int len) 996static void wp512_update(struct crypto_tfm *tfm, const u8 *source,
997 unsigned int len)
997{ 998{
998 999 struct wp512_ctx *wctx = crypto_tfm_ctx(tfm);
999 struct wp512_ctx *wctx = ctx;
1000 int sourcePos = 0; 1000 int sourcePos = 0;
1001 unsigned int bits_len = len * 8; // convert to number of bits 1001 unsigned int bits_len = len * 8; // convert to number of bits
1002 int sourceGap = (8 - ((int)bits_len & 7)) & 7; 1002 int sourceGap = (8 - ((int)bits_len & 7)) & 7;
@@ -1054,9 +1054,9 @@ static void wp512_update(void *ctx, const u8 *source, unsigned int len)
1054 1054
1055} 1055}
1056 1056
1057static void wp512_final(void *ctx, u8 *out) 1057static void wp512_final(struct crypto_tfm *tfm, u8 *out)
1058{ 1058{
1059 struct wp512_ctx *wctx = ctx; 1059 struct wp512_ctx *wctx = crypto_tfm_ctx(tfm);
1060 int i; 1060 int i;
1061 u8 *buffer = wctx->buffer; 1061 u8 *buffer = wctx->buffer;
1062 u8 *bitLength = wctx->bitLength; 1062 u8 *bitLength = wctx->bitLength;
@@ -1087,22 +1087,20 @@ static void wp512_final(void *ctx, u8 *out)
1087 wctx->bufferPos = bufferPos; 1087 wctx->bufferPos = bufferPos;
1088} 1088}
1089 1089
1090static void wp384_final(void *ctx, u8 *out) 1090static void wp384_final(struct crypto_tfm *tfm, u8 *out)
1091{ 1091{
1092 struct wp512_ctx *wctx = ctx;
1093 u8 D[64]; 1092 u8 D[64];
1094 1093
1095 wp512_final (wctx, D); 1094 wp512_final(tfm, D);
1096 memcpy (out, D, WP384_DIGEST_SIZE); 1095 memcpy (out, D, WP384_DIGEST_SIZE);
1097 memset (D, 0, WP512_DIGEST_SIZE); 1096 memset (D, 0, WP512_DIGEST_SIZE);
1098} 1097}
1099 1098
1100static void wp256_final(void *ctx, u8 *out) 1099static void wp256_final(struct crypto_tfm *tfm, u8 *out)
1101{ 1100{
1102 struct wp512_ctx *wctx = ctx;
1103 u8 D[64]; 1101 u8 D[64];
1104 1102
1105 wp512_final (wctx, D); 1103 wp512_final(tfm, D);
1106 memcpy (out, D, WP256_DIGEST_SIZE); 1104 memcpy (out, D, WP256_DIGEST_SIZE);
1107 memset (D, 0, WP512_DIGEST_SIZE); 1105 memset (D, 0, WP512_DIGEST_SIZE);
1108} 1106}