diff options
37 files changed, 349 insertions, 331 deletions
diff --git a/arch/i386/crypto/aes-i586-asm.S b/arch/i386/crypto/aes-i586-asm.S index 2851f7fe51e6..f942f0c8f630 100644 --- a/arch/i386/crypto/aes-i586-asm.S +++ b/arch/i386/crypto/aes-i586-asm.S | |||
@@ -36,19 +36,19 @@ | |||
36 | .file "aes-i586-asm.S" | 36 | .file "aes-i586-asm.S" |
37 | .text | 37 | .text |
38 | 38 | ||
39 | #define tlen 1024 // length of each of 4 'xor' arrays (256 32-bit words) | 39 | #include <asm/asm-offsets.h> |
40 | |||
41 | // offsets to parameters with one register pushed onto stack | ||
42 | 40 | ||
43 | #define in_blk 16 // input byte array address parameter | 41 | #define tlen 1024 // length of each of 4 'xor' arrays (256 32-bit words) |
44 | #define out_blk 12 // output byte array address parameter | ||
45 | #define ctx 8 // AES context structure | ||
46 | 42 | ||
47 | // offsets in context structure | 43 | /* offsets to parameters with one register pushed onto stack */ |
44 | #define tfm 8 | ||
45 | #define out_blk 12 | ||
46 | #define in_blk 16 | ||
48 | 47 | ||
49 | #define ekey 0 // encryption key schedule base address | 48 | /* offsets in crypto_tfm structure */ |
50 | #define nrnd 256 // number of rounds | 49 | #define ekey (crypto_tfm_ctx_offset + 0) |
51 | #define dkey 260 // decryption key schedule base address | 50 | #define nrnd (crypto_tfm_ctx_offset + 256) |
51 | #define dkey (crypto_tfm_ctx_offset + 260) | ||
52 | 52 | ||
53 | // register mapping for encrypt and decrypt subroutines | 53 | // register mapping for encrypt and decrypt subroutines |
54 | 54 | ||
@@ -217,7 +217,7 @@ | |||
217 | do_col (table, r5,r0,r1,r4, r2,r3); /* idx=r5 */ | 217 | do_col (table, r5,r0,r1,r4, r2,r3); /* idx=r5 */ |
218 | 218 | ||
219 | // AES (Rijndael) Encryption Subroutine | 219 | // AES (Rijndael) Encryption Subroutine |
220 | /* void aes_enc_blk(void *ctx, u8 *out_blk, const u8 *in_blk) */ | 220 | /* void aes_enc_blk(struct crypto_tfm *tfm, u8 *out_blk, const u8 *in_blk) */ |
221 | 221 | ||
222 | .global aes_enc_blk | 222 | .global aes_enc_blk |
223 | 223 | ||
@@ -228,7 +228,7 @@ | |||
228 | 228 | ||
229 | aes_enc_blk: | 229 | aes_enc_blk: |
230 | push %ebp | 230 | push %ebp |
231 | mov ctx(%esp),%ebp // pointer to context | 231 | mov tfm(%esp),%ebp |
232 | 232 | ||
233 | // CAUTION: the order and the values used in these assigns | 233 | // CAUTION: the order and the values used in these assigns |
234 | // rely on the register mappings | 234 | // rely on the register mappings |
@@ -293,7 +293,7 @@ aes_enc_blk: | |||
293 | ret | 293 | ret |
294 | 294 | ||
295 | // AES (Rijndael) Decryption Subroutine | 295 | // AES (Rijndael) Decryption Subroutine |
296 | /* void aes_dec_blk(void *ctx, u8 *out_blk, const u8 *in_blk) */ | 296 | /* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out_blk, const u8 *in_blk) */ |
297 | 297 | ||
298 | .global aes_dec_blk | 298 | .global aes_dec_blk |
299 | 299 | ||
@@ -304,7 +304,7 @@ aes_enc_blk: | |||
304 | 304 | ||
305 | aes_dec_blk: | 305 | aes_dec_blk: |
306 | push %ebp | 306 | push %ebp |
307 | mov ctx(%esp),%ebp // pointer to context | 307 | mov tfm(%esp),%ebp |
308 | 308 | ||
309 | // CAUTION: the order and the values used in these assigns | 309 | // CAUTION: the order and the values used in these assigns |
310 | // rely on the register mappings | 310 | // rely on the register mappings |
diff --git a/arch/i386/crypto/aes.c b/arch/i386/crypto/aes.c index a0e033510a3b..b9c7d99160f1 100644 --- a/arch/i386/crypto/aes.c +++ b/arch/i386/crypto/aes.c | |||
@@ -45,8 +45,8 @@ | |||
45 | #include <linux/crypto.h> | 45 | #include <linux/crypto.h> |
46 | #include <linux/linkage.h> | 46 | #include <linux/linkage.h> |
47 | 47 | ||
48 | asmlinkage void aes_enc_blk(void *ctx, u8 *dst, const u8 *src); | 48 | asmlinkage void aes_enc_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src); |
49 | asmlinkage void aes_dec_blk(void *ctx, u8 *dst, const u8 *src); | 49 | asmlinkage void aes_dec_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src); |
50 | 50 | ||
51 | #define AES_MIN_KEY_SIZE 16 | 51 | #define AES_MIN_KEY_SIZE 16 |
52 | #define AES_MAX_KEY_SIZE 32 | 52 | #define AES_MAX_KEY_SIZE 32 |
@@ -378,12 +378,12 @@ static void gen_tabs(void) | |||
378 | k[8*(i)+11] = ss[3]; \ | 378 | k[8*(i)+11] = ss[3]; \ |
379 | } | 379 | } |
380 | 380 | ||
381 | static int | 381 | static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
382 | aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags) | 382 | unsigned int key_len, u32 *flags) |
383 | { | 383 | { |
384 | int i; | 384 | int i; |
385 | u32 ss[8]; | 385 | u32 ss[8]; |
386 | struct aes_ctx *ctx = ctx_arg; | 386 | struct aes_ctx *ctx = crypto_tfm_ctx(tfm); |
387 | const __le32 *key = (const __le32 *)in_key; | 387 | const __le32 *key = (const __le32 *)in_key; |
388 | 388 | ||
389 | /* encryption schedule */ | 389 | /* encryption schedule */ |
diff --git a/arch/i386/kernel/asm-offsets.c b/arch/i386/kernel/asm-offsets.c index 36d66e2077d0..1c3a809e6421 100644 --- a/arch/i386/kernel/asm-offsets.c +++ b/arch/i386/kernel/asm-offsets.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * to extract and format the required data. | 4 | * to extract 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/signal.h> | 9 | #include <linux/signal.h> |
9 | #include <linux/personality.h> | 10 | #include <linux/personality.h> |
@@ -69,4 +70,6 @@ void foo(void) | |||
69 | 70 | ||
70 | DEFINE(PAGE_SIZE_asm, PAGE_SIZE); | 71 | DEFINE(PAGE_SIZE_asm, PAGE_SIZE); |
71 | DEFINE(VSYSCALL_BASE, __fix_to_virt(FIX_VSYSCALL)); | 72 | DEFINE(VSYSCALL_BASE, __fix_to_virt(FIX_VSYSCALL)); |
73 | |||
74 | OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); | ||
72 | } | 75 | } |
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c index c5ca2dc5d428..5713c7e5bd16 100644 --- a/arch/s390/crypto/aes_s390.c +++ b/arch/s390/crypto/aes_s390.c | |||
@@ -37,10 +37,10 @@ struct s390_aes_ctx { | |||
37 | int key_len; | 37 | int key_len; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static int aes_set_key(void *ctx, const u8 *in_key, unsigned int key_len, | 40 | static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
41 | u32 *flags) | 41 | unsigned int key_len, u32 *flags) |
42 | { | 42 | { |
43 | struct s390_aes_ctx *sctx = ctx; | 43 | struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm); |
44 | 44 | ||
45 | switch (key_len) { | 45 | switch (key_len) { |
46 | case 16: | 46 | case 16: |
@@ -70,9 +70,9 @@ fail: | |||
70 | return -EINVAL; | 70 | return -EINVAL; |
71 | } | 71 | } |
72 | 72 | ||
73 | static void aes_encrypt(void *ctx, u8 *out, const u8 *in) | 73 | static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
74 | { | 74 | { |
75 | const struct s390_aes_ctx *sctx = ctx; | 75 | const struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm); |
76 | 76 | ||
77 | switch (sctx->key_len) { | 77 | switch (sctx->key_len) { |
78 | case 16: | 78 | case 16: |
@@ -90,9 +90,9 @@ static void aes_encrypt(void *ctx, u8 *out, const u8 *in) | |||
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | static void aes_decrypt(void *ctx, u8 *out, const u8 *in) | 93 | static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
94 | { | 94 | { |
95 | const struct s390_aes_ctx *sctx = ctx; | 95 | const struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm); |
96 | 96 | ||
97 | switch (sctx->key_len) { | 97 | switch (sctx->key_len) { |
98 | case 16: | 98 | case 16: |
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c index e3c37aa0a199..b3f7496a79b4 100644 --- a/arch/s390/crypto/des_s390.c +++ b/arch/s390/crypto/des_s390.c | |||
@@ -44,10 +44,10 @@ struct crypt_s390_des3_192_ctx { | |||
44 | u8 key[DES3_192_KEY_SIZE]; | 44 | u8 key[DES3_192_KEY_SIZE]; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, | 47 | static int des_setkey(struct crypto_tfm *tfm, const u8 *key, |
48 | u32 *flags) | 48 | unsigned int keylen, u32 *flags) |
49 | { | 49 | { |
50 | struct crypt_s390_des_ctx *dctx = ctx; | 50 | struct crypt_s390_des_ctx *dctx = crypto_tfm_ctx(tfm); |
51 | int ret; | 51 | int ret; |
52 | 52 | ||
53 | /* test if key is valid (not a weak key) */ | 53 | /* test if key is valid (not a weak key) */ |
@@ -57,16 +57,16 @@ static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, | |||
57 | return ret; | 57 | return ret; |
58 | } | 58 | } |
59 | 59 | ||
60 | static void des_encrypt(void *ctx, u8 *out, const u8 *in) | 60 | static void des_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
61 | { | 61 | { |
62 | struct crypt_s390_des_ctx *dctx = ctx; | 62 | struct crypt_s390_des_ctx *dctx = crypto_tfm_ctx(tfm); |
63 | 63 | ||
64 | crypt_s390_km(KM_DEA_ENCRYPT, dctx->key, out, in, DES_BLOCK_SIZE); | 64 | crypt_s390_km(KM_DEA_ENCRYPT, dctx->key, out, in, DES_BLOCK_SIZE); |
65 | } | 65 | } |
66 | 66 | ||
67 | static void des_decrypt(void *ctx, u8 *out, const u8 *in) | 67 | static void des_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
68 | { | 68 | { |
69 | struct crypt_s390_des_ctx *dctx = ctx; | 69 | struct crypt_s390_des_ctx *dctx = crypto_tfm_ctx(tfm); |
70 | 70 | ||
71 | crypt_s390_km(KM_DEA_DECRYPT, dctx->key, out, in, DES_BLOCK_SIZE); | 71 | crypt_s390_km(KM_DEA_DECRYPT, dctx->key, out, in, DES_BLOCK_SIZE); |
72 | } | 72 | } |
@@ -166,11 +166,11 @@ static struct crypto_alg des_alg = { | |||
166 | * Implementers MUST reject keys that exhibit this property. | 166 | * Implementers MUST reject keys that exhibit this property. |
167 | * | 167 | * |
168 | */ | 168 | */ |
169 | static int des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, | 169 | static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, |
170 | u32 *flags) | 170 | unsigned int keylen, u32 *flags) |
171 | { | 171 | { |
172 | int i, ret; | 172 | int i, ret; |
173 | struct crypt_s390_des3_128_ctx *dctx = ctx; | 173 | struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm); |
174 | const u8* temp_key = key; | 174 | const u8* temp_key = key; |
175 | 175 | ||
176 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { | 176 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { |
@@ -186,17 +186,17 @@ static int des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | static void des3_128_encrypt(void *ctx, u8 *dst, const u8 *src) | 189 | static void des3_128_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
190 | { | 190 | { |
191 | struct crypt_s390_des3_128_ctx *dctx = ctx; | 191 | struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm); |
192 | 192 | ||
193 | crypt_s390_km(KM_TDEA_128_ENCRYPT, dctx->key, dst, (void*)src, | 193 | crypt_s390_km(KM_TDEA_128_ENCRYPT, dctx->key, dst, (void*)src, |
194 | DES3_128_BLOCK_SIZE); | 194 | DES3_128_BLOCK_SIZE); |
195 | } | 195 | } |
196 | 196 | ||
197 | static void des3_128_decrypt(void *ctx, u8 *dst, const u8 *src) | 197 | static void des3_128_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
198 | { | 198 | { |
199 | struct crypt_s390_des3_128_ctx *dctx = ctx; | 199 | struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm); |
200 | 200 | ||
201 | crypt_s390_km(KM_TDEA_128_DECRYPT, dctx->key, dst, (void*)src, | 201 | crypt_s390_km(KM_TDEA_128_DECRYPT, dctx->key, dst, (void*)src, |
202 | DES3_128_BLOCK_SIZE); | 202 | DES3_128_BLOCK_SIZE); |
@@ -302,11 +302,11 @@ static struct crypto_alg des3_128_alg = { | |||
302 | * property. | 302 | * property. |
303 | * | 303 | * |
304 | */ | 304 | */ |
305 | static int des3_192_setkey(void *ctx, const u8 *key, unsigned int keylen, | 305 | static int des3_192_setkey(struct crypto_tfm *tfm, const u8 *key, |
306 | u32 *flags) | 306 | unsigned int keylen, u32 *flags) |
307 | { | 307 | { |
308 | int i, ret; | 308 | int i, ret; |
309 | struct crypt_s390_des3_192_ctx *dctx = ctx; | 309 | struct crypt_s390_des3_192_ctx *dctx = crypto_tfm_ctx(tfm); |
310 | const u8* temp_key = key; | 310 | const u8* temp_key = key; |
311 | 311 | ||
312 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && | 312 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && |
@@ -325,17 +325,17 @@ static int des3_192_setkey(void *ctx, const u8 *key, unsigned int keylen, | |||
325 | return 0; | 325 | return 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | static void des3_192_encrypt(void *ctx, u8 *dst, const u8 *src) | 328 | static void des3_192_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
329 | { | 329 | { |
330 | struct crypt_s390_des3_192_ctx *dctx = ctx; | 330 | struct crypt_s390_des3_192_ctx *dctx = crypto_tfm_ctx(tfm); |
331 | 331 | ||
332 | crypt_s390_km(KM_TDEA_192_ENCRYPT, dctx->key, dst, (void*)src, | 332 | crypt_s390_km(KM_TDEA_192_ENCRYPT, dctx->key, dst, (void*)src, |
333 | DES3_192_BLOCK_SIZE); | 333 | DES3_192_BLOCK_SIZE); |
334 | } | 334 | } |
335 | 335 | ||
336 | static void des3_192_decrypt(void *ctx, u8 *dst, const u8 *src) | 336 | static void des3_192_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
337 | { | 337 | { |
338 | struct crypt_s390_des3_192_ctx *dctx = ctx; | 338 | struct crypt_s390_des3_192_ctx *dctx = crypto_tfm_ctx(tfm); |
339 | 339 | ||
340 | crypt_s390_km(KM_TDEA_192_DECRYPT, dctx->key, dst, (void*)src, | 340 | crypt_s390_km(KM_TDEA_192_DECRYPT, dctx->key, dst, (void*)src, |
341 | DES3_192_BLOCK_SIZE); | 341 | DES3_192_BLOCK_SIZE); |
diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c index 36bb5346a8c4..9d34a35b1aa5 100644 --- a/arch/s390/crypto/sha1_s390.c +++ b/arch/s390/crypto/sha1_s390.c | |||
@@ -40,9 +40,9 @@ struct crypt_s390_sha1_ctx { | |||
40 | u8 buffer[2 * SHA1_BLOCK_SIZE]; | 40 | u8 buffer[2 * SHA1_BLOCK_SIZE]; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | static void sha1_init(void *ctx_arg) | 43 | static void sha1_init(struct crypto_tfm *tfm) |
44 | { | 44 | { |
45 | struct crypt_s390_sha1_ctx *ctx = ctx_arg; | 45 | struct crypt_s390_sha1_ctx *ctx = crypto_tfm_ctx(tfm); |
46 | static const u32 initstate[5] = { | 46 | static const u32 initstate[5] = { |
47 | 0x67452301, | 47 | 0x67452301, |
48 | 0xEFCDAB89, | 48 | 0xEFCDAB89, |
@@ -56,13 +56,13 @@ static void sha1_init(void *ctx_arg) | |||
56 | ctx->buf_len = 0; | 56 | ctx->buf_len = 0; |
57 | } | 57 | } |
58 | 58 | ||
59 | static void | 59 | static void sha1_update(struct crypto_tfm *tfm, const u8 *data, |
60 | sha1_update(void *ctx, const u8 *data, unsigned int len) | 60 | unsigned int len) |
61 | { | 61 | { |
62 | struct crypt_s390_sha1_ctx *sctx; | 62 | struct crypt_s390_sha1_ctx *sctx; |
63 | long imd_len; | 63 | long imd_len; |
64 | 64 | ||
65 | sctx = ctx; | 65 | sctx = crypto_tfm_ctx(tfm); |
66 | sctx->count += len * 8; //message bit length | 66 | sctx->count += len * 8; //message bit length |
67 | 67 | ||
68 | //anything in buffer yet? -> must be completed | 68 | //anything in buffer yet? -> must be completed |
@@ -111,10 +111,9 @@ pad_message(struct crypt_s390_sha1_ctx* sctx) | |||
111 | } | 111 | } |
112 | 112 | ||
113 | /* Add padding and return the message digest. */ | 113 | /* Add padding and return the message digest. */ |
114 | static void | 114 | static void sha1_final(struct crypto_tfm *tfm, u8 *out) |
115 | sha1_final(void* ctx, u8 *out) | ||
116 | { | 115 | { |
117 | struct crypt_s390_sha1_ctx *sctx = ctx; | 116 | struct crypt_s390_sha1_ctx *sctx = crypto_tfm_ctx(tfm); |
118 | 117 | ||
119 | //must perform manual padding | 118 | //must perform manual padding |
120 | pad_message(sctx); | 119 | pad_message(sctx); |
diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c index 2c76e7bee41c..f573df30f31d 100644 --- a/arch/s390/crypto/sha256_s390.c +++ b/arch/s390/crypto/sha256_s390.c | |||
@@ -31,9 +31,9 @@ struct s390_sha256_ctx { | |||
31 | u8 buf[2 * SHA256_BLOCK_SIZE]; | 31 | u8 buf[2 * SHA256_BLOCK_SIZE]; |
32 | }; | 32 | }; |
33 | 33 | ||
34 | static void sha256_init(void *ctx) | 34 | static void sha256_init(struct crypto_tfm *tfm) |
35 | { | 35 | { |
36 | struct s390_sha256_ctx *sctx = ctx; | 36 | struct s390_sha256_ctx *sctx = crypto_tfm_ctx(tfm); |
37 | 37 | ||
38 | sctx->state[0] = 0x6a09e667; | 38 | sctx->state[0] = 0x6a09e667; |
39 | sctx->state[1] = 0xbb67ae85; | 39 | sctx->state[1] = 0xbb67ae85; |
@@ -46,9 +46,10 @@ static void sha256_init(void *ctx) | |||
46 | sctx->count = 0; | 46 | sctx->count = 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | static void sha256_update(void *ctx, const u8 *data, unsigned int len) | 49 | static void sha256_update(struct crypto_tfm *tfm, const u8 *data, |
50 | unsigned int len) | ||
50 | { | 51 | { |
51 | struct s390_sha256_ctx *sctx = ctx; | 52 | struct s390_sha256_ctx *sctx = crypto_tfm_ctx(tfm); |
52 | unsigned int index; | 53 | unsigned int index; |
53 | int ret; | 54 | int ret; |
54 | 55 | ||
@@ -107,9 +108,9 @@ static void pad_message(struct s390_sha256_ctx* sctx) | |||
107 | } | 108 | } |
108 | 109 | ||
109 | /* Add padding and return the message digest */ | 110 | /* Add padding and return the message digest */ |
110 | static void sha256_final(void* ctx, u8 *out) | 111 | static void sha256_final(struct crypto_tfm *tfm, u8 *out) |
111 | { | 112 | { |
112 | struct s390_sha256_ctx *sctx = ctx; | 113 | struct s390_sha256_ctx *sctx = crypto_tfm_ctx(tfm); |
113 | 114 | ||
114 | /* must perform manual padding */ | 115 | /* must perform manual padding */ |
115 | pad_message(sctx); | 116 | pad_message(sctx); |
diff --git a/arch/x86_64/crypto/aes-x86_64-asm.S b/arch/x86_64/crypto/aes-x86_64-asm.S index 483cbb23ab8d..f3ba643e144d 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; \ |
53 | FUNC: movq r1,r2; \ | 57 | FUNC: 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,7 +151,7 @@ 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_encrypt(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */ |
151 | 155 | ||
152 | entry(aes_encrypt,0,enc128,enc192) | 156 | entry(aes_encrypt,0,enc128,enc192) |
153 | encrypt_round(aes_ft_tab,-96) | 157 | encrypt_round(aes_ft_tab,-96) |
@@ -166,7 +170,7 @@ 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_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) */ |
170 | 174 | ||
171 | entry(aes_decrypt,240,dec128,dec192) | 175 | entry(aes_decrypt,240,dec128,dec192) |
172 | decrypt_round(aes_it_tab,-96) | 176 | decrypt_round(aes_it_tab,-96) |
diff --git a/arch/x86_64/crypto/aes.c b/arch/x86_64/crypto/aes.c index 6f77e7700d32..d6f8e0463b5d 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 | ||
230 | static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, | 230 | static 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,8 @@ 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 | ||
286 | extern void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in); | 286 | extern void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in); |
287 | extern void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in); | 287 | extern void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in); |
288 | 288 | ||
289 | static struct crypto_alg aes_alg = { | 289 | static struct crypto_alg aes_alg = { |
290 | .cra_name = "aes", | 290 | .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 | } |
diff --git a/crypto/aes.c b/crypto/aes.c index a5017292e066..a038711831e7 100644 --- a/crypto/aes.c +++ b/crypto/aes.c | |||
@@ -248,10 +248,10 @@ gen_tabs (void) | |||
248 | t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \ | 248 | t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \ |
249 | } | 249 | } |
250 | 250 | ||
251 | static int | 251 | static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
252 | aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags) | 252 | unsigned int key_len, u32 *flags) |
253 | { | 253 | { |
254 | struct aes_ctx *ctx = ctx_arg; | 254 | struct aes_ctx *ctx = crypto_tfm_ctx(tfm); |
255 | const __le32 *key = (const __le32 *)in_key; | 255 | const __le32 *key = (const __le32 *)in_key; |
256 | u32 i, t, u, v, w; | 256 | u32 i, t, u, v, w; |
257 | 257 | ||
@@ -318,9 +318,9 @@ aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags) | |||
318 | f_rl(bo, bi, 2, k); \ | 318 | f_rl(bo, bi, 2, k); \ |
319 | f_rl(bo, bi, 3, k) | 319 | f_rl(bo, bi, 3, k) |
320 | 320 | ||
321 | static void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in) | 321 | static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
322 | { | 322 | { |
323 | const struct aes_ctx *ctx = ctx_arg; | 323 | const struct aes_ctx *ctx = crypto_tfm_ctx(tfm); |
324 | const __le32 *src = (const __le32 *)in; | 324 | const __le32 *src = (const __le32 *)in; |
325 | __le32 *dst = (__le32 *)out; | 325 | __le32 *dst = (__le32 *)out; |
326 | u32 b0[4], b1[4]; | 326 | u32 b0[4], b1[4]; |
@@ -373,9 +373,9 @@ static void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in) | |||
373 | i_rl(bo, bi, 2, k); \ | 373 | i_rl(bo, bi, 2, k); \ |
374 | i_rl(bo, bi, 3, k) | 374 | i_rl(bo, bi, 3, k) |
375 | 375 | ||
376 | static void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in) | 376 | static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
377 | { | 377 | { |
378 | const struct aes_ctx *ctx = ctx_arg; | 378 | const struct aes_ctx *ctx = crypto_tfm_ctx(tfm); |
379 | const __le32 *src = (const __le32 *)in; | 379 | const __le32 *src = (const __le32 *)in; |
380 | __le32 *dst = (__le32 *)out; | 380 | __le32 *dst = (__le32 *)out; |
381 | u32 b0[4], b1[4]; | 381 | u32 b0[4], b1[4]; |
diff --git a/crypto/anubis.c b/crypto/anubis.c index 2c796bdb91a6..7e2e1a29800e 100644 --- a/crypto/anubis.c +++ b/crypto/anubis.c | |||
@@ -460,16 +460,15 @@ static const u32 rc[] = { | |||
460 | 0xf726ffedU, 0xe89d6f8eU, 0x19a0f089U, | 460 | 0xf726ffedU, 0xe89d6f8eU, 0x19a0f089U, |
461 | }; | 461 | }; |
462 | 462 | ||
463 | static int anubis_setkey(void *ctx_arg, const u8 *in_key, | 463 | static int anubis_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
464 | unsigned int key_len, u32 *flags) | 464 | unsigned int key_len, u32 *flags) |
465 | { | 465 | { |
466 | struct anubis_ctx *ctx = crypto_tfm_ctx(tfm); | ||
466 | const __be32 *key = (const __be32 *)in_key; | 467 | const __be32 *key = (const __be32 *)in_key; |
467 | int N, R, i, r; | 468 | int N, R, i, r; |
468 | u32 kappa[ANUBIS_MAX_N]; | 469 | u32 kappa[ANUBIS_MAX_N]; |
469 | u32 inter[ANUBIS_MAX_N]; | 470 | u32 inter[ANUBIS_MAX_N]; |
470 | 471 | ||
471 | struct anubis_ctx *ctx = ctx_arg; | ||
472 | |||
473 | switch (key_len) | 472 | switch (key_len) |
474 | { | 473 | { |
475 | case 16: case 20: case 24: case 28: | 474 | case 16: case 20: case 24: case 28: |
@@ -660,15 +659,15 @@ static void anubis_crypt(u32 roundKey[ANUBIS_MAX_ROUNDS + 1][4], | |||
660 | dst[i] = cpu_to_be32(inter[i]); | 659 | dst[i] = cpu_to_be32(inter[i]); |
661 | } | 660 | } |
662 | 661 | ||
663 | static void anubis_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 662 | static void anubis_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
664 | { | 663 | { |
665 | struct anubis_ctx *ctx = ctx_arg; | 664 | struct anubis_ctx *ctx = crypto_tfm_ctx(tfm); |
666 | anubis_crypt(ctx->E, dst, src, ctx->R); | 665 | anubis_crypt(ctx->E, dst, src, ctx->R); |
667 | } | 666 | } |
668 | 667 | ||
669 | static void anubis_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 668 | static void anubis_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
670 | { | 669 | { |
671 | struct anubis_ctx *ctx = ctx_arg; | 670 | struct anubis_ctx *ctx = crypto_tfm_ctx(tfm); |
672 | anubis_crypt(ctx->D, dst, src, ctx->R); | 671 | anubis_crypt(ctx->D, dst, src, ctx->R); |
673 | } | 672 | } |
674 | 673 | ||
diff --git a/crypto/arc4.c b/crypto/arc4.c index 9efbcaae88a1..5edc6a65b987 100644 --- a/crypto/arc4.c +++ b/crypto/arc4.c | |||
@@ -24,9 +24,10 @@ struct arc4_ctx { | |||
24 | u8 x, y; | 24 | u8 x, y; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | static int arc4_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags) | 27 | static int arc4_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
28 | unsigned int key_len, u32 *flags) | ||
28 | { | 29 | { |
29 | struct arc4_ctx *ctx = ctx_arg; | 30 | struct arc4_ctx *ctx = crypto_tfm_ctx(tfm); |
30 | int i, j = 0, k = 0; | 31 | int i, j = 0, k = 0; |
31 | 32 | ||
32 | ctx->x = 1; | 33 | ctx->x = 1; |
@@ -48,9 +49,9 @@ static int arc4_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u | |||
48 | return 0; | 49 | return 0; |
49 | } | 50 | } |
50 | 51 | ||
51 | static void arc4_crypt(void *ctx_arg, u8 *out, const u8 *in) | 52 | static void arc4_crypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
52 | { | 53 | { |
53 | struct arc4_ctx *ctx = ctx_arg; | 54 | struct arc4_ctx *ctx = crypto_tfm_ctx(tfm); |
54 | 55 | ||
55 | u8 *const S = ctx->S; | 56 | u8 *const S = ctx->S; |
56 | u8 x = ctx->x; | 57 | u8 x = ctx->x; |
diff --git a/crypto/blowfish.c b/crypto/blowfish.c index 7f710b201f20..490265f42b3b 100644 --- a/crypto/blowfish.c +++ b/crypto/blowfish.c | |||
@@ -349,7 +349,7 @@ static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src) | |||
349 | dst[1] = yl; | 349 | dst[1] = yl; |
350 | } | 350 | } |
351 | 351 | ||
352 | static void bf_encrypt(void *ctx, u8 *dst, const u8 *src) | 352 | static void bf_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
353 | { | 353 | { |
354 | const __be32 *in_blk = (const __be32 *)src; | 354 | const __be32 *in_blk = (const __be32 *)src; |
355 | __be32 *const out_blk = (__be32 *)dst; | 355 | __be32 *const out_blk = (__be32 *)dst; |
@@ -357,17 +357,18 @@ static void bf_encrypt(void *ctx, u8 *dst, const u8 *src) | |||
357 | 357 | ||
358 | in32[0] = be32_to_cpu(in_blk[0]); | 358 | in32[0] = be32_to_cpu(in_blk[0]); |
359 | in32[1] = be32_to_cpu(in_blk[1]); | 359 | in32[1] = be32_to_cpu(in_blk[1]); |
360 | encrypt_block(ctx, out32, in32); | 360 | encrypt_block(crypto_tfm_ctx(tfm), out32, in32); |
361 | out_blk[0] = cpu_to_be32(out32[0]); | 361 | out_blk[0] = cpu_to_be32(out32[0]); |
362 | out_blk[1] = cpu_to_be32(out32[1]); | 362 | out_blk[1] = cpu_to_be32(out32[1]); |
363 | } | 363 | } |
364 | 364 | ||
365 | static void bf_decrypt(void *ctx, u8 *dst, const u8 *src) | 365 | static void bf_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
366 | { | 366 | { |
367 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); | ||
367 | const __be32 *in_blk = (const __be32 *)src; | 368 | const __be32 *in_blk = (const __be32 *)src; |
368 | __be32 *const out_blk = (__be32 *)dst; | 369 | __be32 *const out_blk = (__be32 *)dst; |
369 | const u32 *P = ((struct bf_ctx *)ctx)->p; | 370 | const u32 *P = ctx->p; |
370 | const u32 *S = ((struct bf_ctx *)ctx)->s; | 371 | const u32 *S = ctx->s; |
371 | u32 yl = be32_to_cpu(in_blk[0]); | 372 | u32 yl = be32_to_cpu(in_blk[0]); |
372 | u32 yr = be32_to_cpu(in_blk[1]); | 373 | u32 yr = be32_to_cpu(in_blk[1]); |
373 | 374 | ||
@@ -398,12 +399,14 @@ static void bf_decrypt(void *ctx, u8 *dst, const u8 *src) | |||
398 | /* | 399 | /* |
399 | * Calculates the blowfish S and P boxes for encryption and decryption. | 400 | * Calculates the blowfish S and P boxes for encryption and decryption. |
400 | */ | 401 | */ |
401 | static int bf_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 402 | static int bf_setkey(struct crypto_tfm *tfm, const u8 *key, |
403 | unsigned int keylen, u32 *flags) | ||
402 | { | 404 | { |
405 | struct bf_ctx *ctx = crypto_tfm_ctx(tfm); | ||
406 | u32 *P = ctx->p; | ||
407 | u32 *S = ctx->s; | ||
403 | short i, j, count; | 408 | short i, j, count; |
404 | u32 data[2], temp; | 409 | u32 data[2], temp; |
405 | u32 *P = ((struct bf_ctx *)ctx)->p; | ||
406 | u32 *S = ((struct bf_ctx *)ctx)->s; | ||
407 | 410 | ||
408 | /* Copy the initialization s-boxes */ | 411 | /* Copy the initialization s-boxes */ |
409 | for (i = 0, count = 0; i < 256; i++) | 412 | for (i = 0, count = 0; i < 256; i++) |
diff --git a/crypto/cast5.c b/crypto/cast5.c index 8834c8580c04..08eef58c1d3d 100644 --- a/crypto/cast5.c +++ b/crypto/cast5.c | |||
@@ -577,9 +577,9 @@ static const u32 sb8[256] = { | |||
577 | (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]) ) | 577 | (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]) ) |
578 | 578 | ||
579 | 579 | ||
580 | static void cast5_encrypt(void *ctx, u8 * outbuf, const u8 * inbuf) | 580 | static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) |
581 | { | 581 | { |
582 | struct cast5_ctx *c = (struct cast5_ctx *) ctx; | 582 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); |
583 | const __be32 *src = (const __be32 *)inbuf; | 583 | const __be32 *src = (const __be32 *)inbuf; |
584 | __be32 *dst = (__be32 *)outbuf; | 584 | __be32 *dst = (__be32 *)outbuf; |
585 | u32 l, r, t; | 585 | u32 l, r, t; |
@@ -642,9 +642,9 @@ static void cast5_encrypt(void *ctx, u8 * outbuf, const u8 * inbuf) | |||
642 | dst[1] = cpu_to_be32(l); | 642 | dst[1] = cpu_to_be32(l); |
643 | } | 643 | } |
644 | 644 | ||
645 | static void cast5_decrypt(void *ctx, u8 * outbuf, const u8 * inbuf) | 645 | static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) |
646 | { | 646 | { |
647 | struct cast5_ctx *c = (struct cast5_ctx *) ctx; | 647 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); |
648 | const __be32 *src = (const __be32 *)inbuf; | 648 | const __be32 *src = (const __be32 *)inbuf; |
649 | __be32 *dst = (__be32 *)outbuf; | 649 | __be32 *dst = (__be32 *)outbuf; |
650 | u32 l, r, t; | 650 | u32 l, r, t; |
@@ -769,15 +769,15 @@ static void key_schedule(u32 * x, u32 * z, u32 * k) | |||
769 | } | 769 | } |
770 | 770 | ||
771 | 771 | ||
772 | static int | 772 | static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, |
773 | cast5_setkey(void *ctx, const u8 * key, unsigned key_len, u32 * flags) | 773 | unsigned key_len, u32 *flags) |
774 | { | 774 | { |
775 | struct cast5_ctx *c = crypto_tfm_ctx(tfm); | ||
775 | int i; | 776 | int i; |
776 | u32 x[4]; | 777 | u32 x[4]; |
777 | u32 z[4]; | 778 | u32 z[4]; |
778 | u32 k[16]; | 779 | u32 k[16]; |
779 | __be32 p_key[4]; | 780 | __be32 p_key[4]; |
780 | struct cast5_ctx *c = (struct cast5_ctx *) ctx; | ||
781 | 781 | ||
782 | if (key_len < 5 || key_len > 16) { | 782 | if (key_len < 5 || key_len > 16) { |
783 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | 783 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
diff --git a/crypto/cast6.c b/crypto/cast6.c index 9e28740ba775..08e33bfc3ad1 100644 --- a/crypto/cast6.c +++ b/crypto/cast6.c | |||
@@ -381,13 +381,13 @@ static inline void W(u32 *key, unsigned int i) { | |||
381 | key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); | 381 | key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); |
382 | } | 382 | } |
383 | 383 | ||
384 | static int | 384 | static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
385 | cast6_setkey(void *ctx, const u8 * in_key, unsigned key_len, u32 * flags) | 385 | unsigned key_len, u32 *flags) |
386 | { | 386 | { |
387 | int i; | 387 | int i; |
388 | u32 key[8]; | 388 | u32 key[8]; |
389 | __be32 p_key[8]; /* padded key */ | 389 | __be32 p_key[8]; /* padded key */ |
390 | struct cast6_ctx *c = (struct cast6_ctx *) ctx; | 390 | struct cast6_ctx *c = crypto_tfm_ctx(tfm); |
391 | 391 | ||
392 | if (key_len < 16 || key_len > 32 || key_len % 4 != 0) { | 392 | if (key_len < 16 || key_len > 32 || key_len % 4 != 0) { |
393 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | 393 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
@@ -444,8 +444,9 @@ static inline void QBAR (u32 * block, u8 * Kr, u32 * Km) { | |||
444 | block[2] ^= F1(block[3], Kr[0], Km[0]); | 444 | block[2] ^= F1(block[3], Kr[0], Km[0]); |
445 | } | 445 | } |
446 | 446 | ||
447 | static void cast6_encrypt (void * ctx, u8 * outbuf, const u8 * inbuf) { | 447 | static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) |
448 | struct cast6_ctx * c = (struct cast6_ctx *)ctx; | 448 | { |
449 | struct cast6_ctx *c = crypto_tfm_ctx(tfm); | ||
449 | const __be32 *src = (const __be32 *)inbuf; | 450 | const __be32 *src = (const __be32 *)inbuf; |
450 | __be32 *dst = (__be32 *)outbuf; | 451 | __be32 *dst = (__be32 *)outbuf; |
451 | u32 block[4]; | 452 | u32 block[4]; |
@@ -476,8 +477,8 @@ static void cast6_encrypt (void * ctx, u8 * outbuf, const u8 * inbuf) { | |||
476 | dst[3] = cpu_to_be32(block[3]); | 477 | dst[3] = cpu_to_be32(block[3]); |
477 | } | 478 | } |
478 | 479 | ||
479 | static void cast6_decrypt (void * ctx, u8 * outbuf, const u8 * inbuf) { | 480 | static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) { |
480 | struct cast6_ctx * c = (struct cast6_ctx *)ctx; | 481 | struct cast6_ctx * c = crypto_tfm_ctx(tfm); |
481 | const __be32 *src = (const __be32 *)inbuf; | 482 | const __be32 *src = (const __be32 *)inbuf; |
482 | __be32 *dst = (__be32 *)outbuf; | 483 | __be32 *dst = (__be32 *)outbuf; |
483 | u32 block[4]; | 484 | u32 block[4]; |
diff --git a/crypto/cipher.c b/crypto/cipher.c index 65bcea0cd17c..b899eb97abd7 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c | |||
@@ -187,7 +187,7 @@ static unsigned int cbc_process_encrypt(const struct cipher_desc *desc, | |||
187 | void (*xor)(u8 *, const u8 *) = tfm->crt_u.cipher.cit_xor_block; | 187 | void (*xor)(u8 *, const u8 *) = tfm->crt_u.cipher.cit_xor_block; |
188 | int bsize = crypto_tfm_alg_blocksize(tfm); | 188 | int bsize = crypto_tfm_alg_blocksize(tfm); |
189 | 189 | ||
190 | void (*fn)(void *, u8 *, const u8 *) = desc->crfn; | 190 | void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn; |
191 | u8 *iv = desc->info; | 191 | u8 *iv = desc->info; |
192 | unsigned int done = 0; | 192 | unsigned int done = 0; |
193 | 193 | ||
@@ -195,7 +195,7 @@ static unsigned int cbc_process_encrypt(const struct cipher_desc *desc, | |||
195 | 195 | ||
196 | do { | 196 | do { |
197 | xor(iv, src); | 197 | xor(iv, src); |
198 | fn(crypto_tfm_ctx(tfm), dst, iv); | 198 | fn(tfm, dst, iv); |
199 | memcpy(iv, dst, bsize); | 199 | memcpy(iv, dst, bsize); |
200 | 200 | ||
201 | src += bsize; | 201 | src += bsize; |
@@ -218,7 +218,7 @@ static unsigned int cbc_process_decrypt(const struct cipher_desc *desc, | |||
218 | u8 *buf = (u8 *)ALIGN((unsigned long)stack, alignmask + 1); | 218 | u8 *buf = (u8 *)ALIGN((unsigned long)stack, alignmask + 1); |
219 | u8 **dst_p = src == dst ? &buf : &dst; | 219 | u8 **dst_p = src == dst ? &buf : &dst; |
220 | 220 | ||
221 | void (*fn)(void *, u8 *, const u8 *) = desc->crfn; | 221 | void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn; |
222 | u8 *iv = desc->info; | 222 | u8 *iv = desc->info; |
223 | unsigned int done = 0; | 223 | unsigned int done = 0; |
224 | 224 | ||
@@ -227,7 +227,7 @@ static unsigned int cbc_process_decrypt(const struct cipher_desc *desc, | |||
227 | do { | 227 | do { |
228 | u8 *tmp_dst = *dst_p; | 228 | u8 *tmp_dst = *dst_p; |
229 | 229 | ||
230 | fn(crypto_tfm_ctx(tfm), tmp_dst, src); | 230 | fn(tfm, tmp_dst, src); |
231 | xor(tmp_dst, iv); | 231 | xor(tmp_dst, iv); |
232 | memcpy(iv, src, bsize); | 232 | memcpy(iv, src, bsize); |
233 | if (tmp_dst != dst) | 233 | if (tmp_dst != dst) |
@@ -245,13 +245,13 @@ static unsigned int ecb_process(const struct cipher_desc *desc, u8 *dst, | |||
245 | { | 245 | { |
246 | struct crypto_tfm *tfm = desc->tfm; | 246 | struct crypto_tfm *tfm = desc->tfm; |
247 | int bsize = crypto_tfm_alg_blocksize(tfm); | 247 | int bsize = crypto_tfm_alg_blocksize(tfm); |
248 | void (*fn)(void *, u8 *, const u8 *) = desc->crfn; | 248 | void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn; |
249 | unsigned int done = 0; | 249 | unsigned int done = 0; |
250 | 250 | ||
251 | nbytes -= bsize; | 251 | nbytes -= bsize; |
252 | 252 | ||
253 | do { | 253 | do { |
254 | fn(crypto_tfm_ctx(tfm), dst, src); | 254 | fn(tfm, dst, src); |
255 | 255 | ||
256 | src += bsize; | 256 | src += bsize; |
257 | dst += bsize; | 257 | dst += bsize; |
@@ -268,7 +268,7 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | |||
268 | tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | 268 | tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
269 | return -EINVAL; | 269 | return -EINVAL; |
270 | } else | 270 | } else |
271 | return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen, | 271 | return cia->cia_setkey(tfm, key, keylen, |
272 | &tfm->crt_flags); | 272 | &tfm->crt_flags); |
273 | } | 273 | } |
274 | 274 | ||
diff --git a/crypto/compress.c b/crypto/compress.c index eb36d9364da3..c12fc0c41dac 100644 --- a/crypto/compress.c +++ b/crypto/compress.c | |||
@@ -22,8 +22,7 @@ static int crypto_compress(struct crypto_tfm *tfm, | |||
22 | const u8 *src, unsigned int slen, | 22 | const u8 *src, unsigned int slen, |
23 | u8 *dst, unsigned int *dlen) | 23 | u8 *dst, unsigned int *dlen) |
24 | { | 24 | { |
25 | return tfm->__crt_alg->cra_compress.coa_compress(crypto_tfm_ctx(tfm), | 25 | return tfm->__crt_alg->cra_compress.coa_compress(tfm, src, slen, dst, |
26 | src, slen, dst, | ||
27 | dlen); | 26 | dlen); |
28 | } | 27 | } |
29 | 28 | ||
@@ -31,8 +30,7 @@ static int crypto_decompress(struct crypto_tfm *tfm, | |||
31 | const u8 *src, unsigned int slen, | 30 | const u8 *src, unsigned int slen, |
32 | u8 *dst, unsigned int *dlen) | 31 | u8 *dst, unsigned int *dlen) |
33 | { | 32 | { |
34 | return tfm->__crt_alg->cra_compress.coa_decompress(crypto_tfm_ctx(tfm), | 33 | return tfm->__crt_alg->cra_compress.coa_decompress(tfm, src, slen, dst, |
35 | src, slen, dst, | ||
36 | dlen); | 34 | dlen); |
37 | } | 35 | } |
38 | 36 | ||
diff --git a/crypto/crc32c.c b/crypto/crc32c.c index 953362423a5c..f2660123aeb4 100644 --- a/crypto/crc32c.c +++ b/crypto/crc32c.c | |||
@@ -31,9 +31,9 @@ struct chksum_ctx { | |||
31 | * crc using table. | 31 | * crc using table. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | static void chksum_init(void *ctx) | 34 | static void chksum_init(struct crypto_tfm *tfm) |
35 | { | 35 | { |
36 | struct chksum_ctx *mctx = ctx; | 36 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); |
37 | 37 | ||
38 | mctx->crc = ~(u32)0; /* common usage */ | 38 | mctx->crc = ~(u32)0; /* common usage */ |
39 | } | 39 | } |
@@ -43,10 +43,10 @@ static void chksum_init(void *ctx) | |||
43 | * If your algorithm starts with ~0, then XOR with ~0 before you set | 43 | * If your algorithm starts with ~0, then XOR with ~0 before you set |
44 | * the seed. | 44 | * the seed. |
45 | */ | 45 | */ |
46 | static int chksum_setkey(void *ctx, const u8 *key, unsigned int keylen, | 46 | static int chksum_setkey(struct crypto_tfm *tfm, const u8 *key, |
47 | u32 *flags) | 47 | unsigned int keylen, u32 *flags) |
48 | { | 48 | { |
49 | struct chksum_ctx *mctx = ctx; | 49 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); |
50 | 50 | ||
51 | if (keylen != sizeof(mctx->crc)) { | 51 | if (keylen != sizeof(mctx->crc)) { |
52 | if (flags) | 52 | if (flags) |
@@ -57,9 +57,10 @@ static int chksum_setkey(void *ctx, const u8 *key, unsigned int keylen, | |||
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | static void chksum_update(void *ctx, const u8 *data, unsigned int length) | 60 | static void chksum_update(struct crypto_tfm *tfm, const u8 *data, |
61 | unsigned int length) | ||
61 | { | 62 | { |
62 | struct chksum_ctx *mctx = ctx; | 63 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); |
63 | u32 mcrc; | 64 | u32 mcrc; |
64 | 65 | ||
65 | mcrc = crc32c(mctx->crc, data, (size_t)length); | 66 | mcrc = crc32c(mctx->crc, data, (size_t)length); |
@@ -67,9 +68,9 @@ static void chksum_update(void *ctx, const u8 *data, unsigned int length) | |||
67 | mctx->crc = mcrc; | 68 | mctx->crc = mcrc; |
68 | } | 69 | } |
69 | 70 | ||
70 | static void chksum_final(void *ctx, u8 *out) | 71 | static void chksum_final(struct crypto_tfm *tfm, u8 *out) |
71 | { | 72 | { |
72 | struct chksum_ctx *mctx = ctx; | 73 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); |
73 | u32 mcrc = (mctx->crc ^ ~(u32)0); | 74 | u32 mcrc = (mctx->crc ^ ~(u32)0); |
74 | 75 | ||
75 | *(u32 *)out = __le32_to_cpu(mcrc); | 76 | *(u32 *)out = __le32_to_cpu(mcrc); |
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c index 3fcf6e887e87..a0d956b52949 100644 --- a/crypto/crypto_null.c +++ b/crypto/crypto_null.c | |||
@@ -27,8 +27,8 @@ | |||
27 | #define NULL_BLOCK_SIZE 1 | 27 | #define NULL_BLOCK_SIZE 1 |
28 | #define NULL_DIGEST_SIZE 0 | 28 | #define NULL_DIGEST_SIZE 0 |
29 | 29 | ||
30 | static int null_compress(void *ctx, const u8 *src, unsigned int slen, | 30 | static int null_compress(struct crypto_tfm *tfm, const u8 *src, |
31 | u8 *dst, unsigned int *dlen) | 31 | unsigned int slen, u8 *dst, unsigned int *dlen) |
32 | { | 32 | { |
33 | if (slen > *dlen) | 33 | if (slen > *dlen) |
34 | return -EINVAL; | 34 | return -EINVAL; |
@@ -37,20 +37,21 @@ static int null_compress(void *ctx, const u8 *src, unsigned int slen, | |||
37 | return 0; | 37 | return 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | static void null_init(void *ctx) | 40 | static void null_init(struct crypto_tfm *tfm) |
41 | { } | 41 | { } |
42 | 42 | ||
43 | static void null_update(void *ctx, const u8 *data, unsigned int len) | 43 | static void null_update(struct crypto_tfm *tfm, const u8 *data, |
44 | unsigned int len) | ||
44 | { } | 45 | { } |
45 | 46 | ||
46 | static void null_final(void *ctx, u8 *out) | 47 | static void null_final(struct crypto_tfm *tfm, u8 *out) |
47 | { } | 48 | { } |
48 | 49 | ||
49 | static int null_setkey(void *ctx, const u8 *key, | 50 | static int null_setkey(struct crypto_tfm *tfm, const u8 *key, |
50 | unsigned int keylen, u32 *flags) | 51 | unsigned int keylen, u32 *flags) |
51 | { return 0; } | 52 | { return 0; } |
52 | 53 | ||
53 | static void null_crypt(void *ctx, u8 *dst, const u8 *src) | 54 | static void null_crypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
54 | { | 55 | { |
55 | memcpy(dst, src, NULL_BLOCK_SIZE); | 56 | memcpy(dst, src, NULL_BLOCK_SIZE); |
56 | } | 57 | } |
diff --git a/crypto/deflate.c b/crypto/deflate.c index f209368d62ae..5dd2404ae5b2 100644 --- a/crypto/deflate.c +++ b/crypto/deflate.c | |||
@@ -102,8 +102,9 @@ static void deflate_decomp_exit(struct deflate_ctx *ctx) | |||
102 | kfree(ctx->decomp_stream.workspace); | 102 | kfree(ctx->decomp_stream.workspace); |
103 | } | 103 | } |
104 | 104 | ||
105 | static int deflate_init(void *ctx) | 105 | static int deflate_init(struct crypto_tfm *tfm) |
106 | { | 106 | { |
107 | struct deflate_ctx *ctx = crypto_tfm_ctx(tfm); | ||
107 | int ret; | 108 | int ret; |
108 | 109 | ||
109 | ret = deflate_comp_init(ctx); | 110 | ret = deflate_comp_init(ctx); |
@@ -116,17 +117,19 @@ out: | |||
116 | return ret; | 117 | return ret; |
117 | } | 118 | } |
118 | 119 | ||
119 | static void deflate_exit(void *ctx) | 120 | static void deflate_exit(struct crypto_tfm *tfm) |
120 | { | 121 | { |
122 | struct deflate_ctx *ctx = crypto_tfm_ctx(tfm); | ||
123 | |||
121 | deflate_comp_exit(ctx); | 124 | deflate_comp_exit(ctx); |
122 | deflate_decomp_exit(ctx); | 125 | deflate_decomp_exit(ctx); |
123 | } | 126 | } |
124 | 127 | ||
125 | static int deflate_compress(void *ctx, const u8 *src, unsigned int slen, | 128 | static int deflate_compress(struct crypto_tfm *tfm, const u8 *src, |
126 | u8 *dst, unsigned int *dlen) | 129 | unsigned int slen, u8 *dst, unsigned int *dlen) |
127 | { | 130 | { |
128 | int ret = 0; | 131 | int ret = 0; |
129 | struct deflate_ctx *dctx = ctx; | 132 | struct deflate_ctx *dctx = crypto_tfm_ctx(tfm); |
130 | struct z_stream_s *stream = &dctx->comp_stream; | 133 | struct z_stream_s *stream = &dctx->comp_stream; |
131 | 134 | ||
132 | ret = zlib_deflateReset(stream); | 135 | ret = zlib_deflateReset(stream); |
@@ -151,12 +154,12 @@ out: | |||
151 | return ret; | 154 | return ret; |
152 | } | 155 | } |
153 | 156 | ||
154 | static int deflate_decompress(void *ctx, const u8 *src, unsigned int slen, | 157 | static int deflate_decompress(struct crypto_tfm *tfm, const u8 *src, |
155 | u8 *dst, unsigned int *dlen) | 158 | unsigned int slen, u8 *dst, unsigned int *dlen) |
156 | { | 159 | { |
157 | 160 | ||
158 | int ret = 0; | 161 | int ret = 0; |
159 | struct deflate_ctx *dctx = ctx; | 162 | struct deflate_ctx *dctx = crypto_tfm_ctx(tfm); |
160 | struct z_stream_s *stream = &dctx->decomp_stream; | 163 | struct z_stream_s *stream = &dctx->decomp_stream; |
161 | 164 | ||
162 | ret = zlib_inflateReset(stream); | 165 | ret = zlib_inflateReset(stream); |
diff --git a/crypto/des.c b/crypto/des.c index 2d74cab40c3e..a9d3c235a6af 100644 --- a/crypto/des.c +++ b/crypto/des.c | |||
@@ -783,9 +783,10 @@ static void dkey(u32 *pe, const u8 *k) | |||
783 | } | 783 | } |
784 | } | 784 | } |
785 | 785 | ||
786 | static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 786 | static int des_setkey(struct crypto_tfm *tfm, const u8 *key, |
787 | unsigned int keylen, u32 *flags) | ||
787 | { | 788 | { |
788 | struct des_ctx *dctx = ctx; | 789 | struct des_ctx *dctx = crypto_tfm_ctx(tfm); |
789 | u32 tmp[DES_EXPKEY_WORDS]; | 790 | u32 tmp[DES_EXPKEY_WORDS]; |
790 | int ret; | 791 | int ret; |
791 | 792 | ||
@@ -803,9 +804,10 @@ static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | |||
803 | return 0; | 804 | return 0; |
804 | } | 805 | } |
805 | 806 | ||
806 | static void des_encrypt(void *ctx, u8 *dst, const u8 *src) | 807 | static void des_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
807 | { | 808 | { |
808 | const u32 *K = ((struct des_ctx *)ctx)->expkey; | 809 | struct des_ctx *ctx = crypto_tfm_ctx(tfm); |
810 | const u32 *K = ctx->expkey; | ||
809 | const __le32 *s = (const __le32 *)src; | 811 | const __le32 *s = (const __le32 *)src; |
810 | __le32 *d = (__le32 *)dst; | 812 | __le32 *d = (__le32 *)dst; |
811 | u32 L, R, A, B; | 813 | u32 L, R, A, B; |
@@ -825,9 +827,10 @@ static void des_encrypt(void *ctx, u8 *dst, const u8 *src) | |||
825 | d[1] = cpu_to_le32(L); | 827 | d[1] = cpu_to_le32(L); |
826 | } | 828 | } |
827 | 829 | ||
828 | static void des_decrypt(void *ctx, u8 *dst, const u8 *src) | 830 | static void des_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
829 | { | 831 | { |
830 | const u32 *K = ((struct des_ctx *)ctx)->expkey + DES_EXPKEY_WORDS - 2; | 832 | struct des_ctx *ctx = crypto_tfm_ctx(tfm); |
833 | const u32 *K = ctx->expkey + DES_EXPKEY_WORDS - 2; | ||
831 | const __le32 *s = (const __le32 *)src; | 834 | const __le32 *s = (const __le32 *)src; |
832 | __le32 *d = (__le32 *)dst; | 835 | __le32 *d = (__le32 *)dst; |
833 | u32 L, R, A, B; | 836 | u32 L, R, A, B; |
@@ -860,11 +863,11 @@ static void des_decrypt(void *ctx, u8 *dst, const u8 *src) | |||
860 | * property. | 863 | * property. |
861 | * | 864 | * |
862 | */ | 865 | */ |
863 | static int des3_ede_setkey(void *ctx, const u8 *key, | 866 | static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, |
864 | unsigned int keylen, u32 *flags) | 867 | unsigned int keylen, u32 *flags) |
865 | { | 868 | { |
866 | const u32 *K = (const u32 *)key; | 869 | const u32 *K = (const u32 *)key; |
867 | struct des3_ede_ctx *dctx = ctx; | 870 | struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm); |
868 | u32 *expkey = dctx->expkey; | 871 | u32 *expkey = dctx->expkey; |
869 | 872 | ||
870 | if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) || | 873 | if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) || |
@@ -881,9 +884,9 @@ static int des3_ede_setkey(void *ctx, const u8 *key, | |||
881 | return 0; | 884 | return 0; |
882 | } | 885 | } |
883 | 886 | ||
884 | static void des3_ede_encrypt(void *ctx, u8 *dst, const u8 *src) | 887 | static void des3_ede_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
885 | { | 888 | { |
886 | struct des3_ede_ctx *dctx = ctx; | 889 | struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm); |
887 | const u32 *K = dctx->expkey; | 890 | const u32 *K = dctx->expkey; |
888 | const __le32 *s = (const __le32 *)src; | 891 | const __le32 *s = (const __le32 *)src; |
889 | __le32 *d = (__le32 *)dst; | 892 | __le32 *d = (__le32 *)dst; |
@@ -912,9 +915,9 @@ static void des3_ede_encrypt(void *ctx, u8 *dst, const u8 *src) | |||
912 | d[1] = cpu_to_le32(L); | 915 | d[1] = cpu_to_le32(L); |
913 | } | 916 | } |
914 | 917 | ||
915 | static void des3_ede_decrypt(void *ctx, u8 *dst, const u8 *src) | 918 | static void des3_ede_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
916 | { | 919 | { |
917 | struct des3_ede_ctx *dctx = ctx; | 920 | struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm); |
918 | const u32 *K = dctx->expkey + DES3_EDE_EXPKEY_WORDS - 2; | 921 | const u32 *K = dctx->expkey + DES3_EDE_EXPKEY_WORDS - 2; |
919 | const __le32 *s = (const __le32 *)src; | 922 | const __le32 *s = (const __le32 *)src; |
920 | __le32 *d = (__le32 *)dst; | 923 | __le32 *d = (__le32 *)dst; |
diff --git a/crypto/digest.c b/crypto/digest.c index 062d0a5a2c89..2d9d509c2c51 100644 --- a/crypto/digest.c +++ b/crypto/digest.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | static void init(struct crypto_tfm *tfm) | 21 | static void init(struct crypto_tfm *tfm) |
22 | { | 22 | { |
23 | tfm->__crt_alg->cra_digest.dia_init(crypto_tfm_ctx(tfm)); | 23 | tfm->__crt_alg->cra_digest.dia_init(tfm); |
24 | } | 24 | } |
25 | 25 | ||
26 | static void update(struct crypto_tfm *tfm, | 26 | static void update(struct crypto_tfm *tfm, |
@@ -46,16 +46,14 @@ static void update(struct crypto_tfm *tfm, | |||
46 | unsigned int bytes = | 46 | unsigned int bytes = |
47 | alignmask + 1 - (offset & alignmask); | 47 | alignmask + 1 - (offset & alignmask); |
48 | bytes = min(bytes, bytes_from_page); | 48 | bytes = min(bytes, bytes_from_page); |
49 | tfm->__crt_alg->cra_digest.dia_update | 49 | tfm->__crt_alg->cra_digest.dia_update(tfm, p, |
50 | (crypto_tfm_ctx(tfm), p, | 50 | bytes); |
51 | bytes); | ||
52 | p += bytes; | 51 | p += bytes; |
53 | bytes_from_page -= bytes; | 52 | bytes_from_page -= bytes; |
54 | l -= bytes; | 53 | l -= bytes; |
55 | } | 54 | } |
56 | tfm->__crt_alg->cra_digest.dia_update | 55 | tfm->__crt_alg->cra_digest.dia_update(tfm, p, |
57 | (crypto_tfm_ctx(tfm), p, | 56 | bytes_from_page); |
58 | bytes_from_page); | ||
59 | crypto_kunmap(src, 0); | 57 | crypto_kunmap(src, 0); |
60 | crypto_yield(tfm); | 58 | crypto_yield(tfm); |
61 | offset = 0; | 59 | offset = 0; |
@@ -83,8 +81,7 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | |||
83 | u32 flags; | 81 | u32 flags; |
84 | if (tfm->__crt_alg->cra_digest.dia_setkey == NULL) | 82 | if (tfm->__crt_alg->cra_digest.dia_setkey == NULL) |
85 | return -ENOSYS; | 83 | return -ENOSYS; |
86 | return tfm->__crt_alg->cra_digest.dia_setkey(crypto_tfm_ctx(tfm), | 84 | return tfm->__crt_alg->cra_digest.dia_setkey(tfm, key, keylen, &flags); |
87 | key, keylen, &flags); | ||
88 | } | 85 | } |
89 | 86 | ||
90 | static void digest(struct crypto_tfm *tfm, | 87 | static void digest(struct crypto_tfm *tfm, |
diff --git a/crypto/khazad.c b/crypto/khazad.c index 5b8dc9a2d374..d4c9d3657b36 100644 --- a/crypto/khazad.c +++ b/crypto/khazad.c | |||
@@ -754,10 +754,10 @@ static const u64 c[KHAZAD_ROUNDS + 1] = { | |||
754 | 0xccc41d14c363da5dULL, 0x5fdc7dcd7f5a6c5cULL, 0xf726ffede89d6f8eULL | 754 | 0xccc41d14c363da5dULL, 0x5fdc7dcd7f5a6c5cULL, 0xf726ffede89d6f8eULL |
755 | }; | 755 | }; |
756 | 756 | ||
757 | static int khazad_setkey(void *ctx_arg, const u8 *in_key, | 757 | static int khazad_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
758 | unsigned int key_len, u32 *flags) | 758 | unsigned int key_len, u32 *flags) |
759 | { | 759 | { |
760 | struct khazad_ctx *ctx = ctx_arg; | 760 | struct khazad_ctx *ctx = crypto_tfm_ctx(tfm); |
761 | const __be32 *key = (const __be32 *)in_key; | 761 | const __be32 *key = (const __be32 *)in_key; |
762 | int r; | 762 | int r; |
763 | const u64 *S = T7; | 763 | const u64 *S = T7; |
@@ -841,15 +841,15 @@ static void khazad_crypt(const u64 roundKey[KHAZAD_ROUNDS + 1], | |||
841 | *dst = cpu_to_be64(state); | 841 | *dst = cpu_to_be64(state); |
842 | } | 842 | } |
843 | 843 | ||
844 | static void khazad_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 844 | static void khazad_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
845 | { | 845 | { |
846 | struct khazad_ctx *ctx = ctx_arg; | 846 | struct khazad_ctx *ctx = crypto_tfm_ctx(tfm); |
847 | khazad_crypt(ctx->E, dst, src); | 847 | khazad_crypt(ctx->E, dst, src); |
848 | } | 848 | } |
849 | 849 | ||
850 | static void khazad_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 850 | static void khazad_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
851 | { | 851 | { |
852 | struct khazad_ctx *ctx = ctx_arg; | 852 | struct khazad_ctx *ctx = crypto_tfm_ctx(tfm); |
853 | khazad_crypt(ctx->D, dst, src); | 853 | khazad_crypt(ctx->D, dst, src); |
854 | } | 854 | } |
855 | 855 | ||
diff --git a/crypto/md4.c b/crypto/md4.c index a2d6df5c0f8c..c1bc71bdc16b 100644 --- a/crypto/md4.c +++ b/crypto/md4.c | |||
@@ -152,9 +152,9 @@ static inline void md4_transform_helper(struct md4_ctx *ctx) | |||
152 | md4_transform(ctx->hash, ctx->block); | 152 | md4_transform(ctx->hash, ctx->block); |
153 | } | 153 | } |
154 | 154 | ||
155 | static void md4_init(void *ctx) | 155 | static void md4_init(struct crypto_tfm *tfm) |
156 | { | 156 | { |
157 | struct md4_ctx *mctx = ctx; | 157 | struct md4_ctx *mctx = crypto_tfm_ctx(tfm); |
158 | 158 | ||
159 | mctx->hash[0] = 0x67452301; | 159 | mctx->hash[0] = 0x67452301; |
160 | mctx->hash[1] = 0xefcdab89; | 160 | mctx->hash[1] = 0xefcdab89; |
@@ -163,9 +163,9 @@ static void md4_init(void *ctx) | |||
163 | mctx->byte_count = 0; | 163 | mctx->byte_count = 0; |
164 | } | 164 | } |
165 | 165 | ||
166 | static void md4_update(void *ctx, const u8 *data, unsigned int len) | 166 | static void md4_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len) |
167 | { | 167 | { |
168 | struct md4_ctx *mctx = ctx; | 168 | struct md4_ctx *mctx = crypto_tfm_ctx(tfm); |
169 | const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); | 169 | const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); |
170 | 170 | ||
171 | mctx->byte_count += len; | 171 | mctx->byte_count += len; |
@@ -193,9 +193,9 @@ static void md4_update(void *ctx, const u8 *data, unsigned int len) | |||
193 | memcpy(mctx->block, data, len); | 193 | memcpy(mctx->block, data, len); |
194 | } | 194 | } |
195 | 195 | ||
196 | static void md4_final(void *ctx, u8 *out) | 196 | static void md4_final(struct crypto_tfm *tfm, u8 *out) |
197 | { | 197 | { |
198 | struct md4_ctx *mctx = ctx; | 198 | struct md4_ctx *mctx = crypto_tfm_ctx(tfm); |
199 | const unsigned int offset = mctx->byte_count & 0x3f; | 199 | const unsigned int offset = mctx->byte_count & 0x3f; |
200 | char *p = (char *)mctx->block + offset; | 200 | char *p = (char *)mctx->block + offset; |
201 | int padding = 56 - (offset + 1); | 201 | int padding = 56 - (offset + 1); |
diff --git a/crypto/md5.c b/crypto/md5.c index 7f041aef5da2..93d18e8b3d53 100644 --- a/crypto/md5.c +++ b/crypto/md5.c | |||
@@ -147,9 +147,9 @@ static inline void md5_transform_helper(struct md5_ctx *ctx) | |||
147 | md5_transform(ctx->hash, ctx->block); | 147 | md5_transform(ctx->hash, ctx->block); |
148 | } | 148 | } |
149 | 149 | ||
150 | static void md5_init(void *ctx) | 150 | static void md5_init(struct crypto_tfm *tfm) |
151 | { | 151 | { |
152 | struct md5_ctx *mctx = ctx; | 152 | struct md5_ctx *mctx = crypto_tfm_ctx(tfm); |
153 | 153 | ||
154 | mctx->hash[0] = 0x67452301; | 154 | mctx->hash[0] = 0x67452301; |
155 | mctx->hash[1] = 0xefcdab89; | 155 | mctx->hash[1] = 0xefcdab89; |
@@ -158,9 +158,9 @@ static void md5_init(void *ctx) | |||
158 | mctx->byte_count = 0; | 158 | mctx->byte_count = 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static void md5_update(void *ctx, const u8 *data, unsigned int len) | 161 | static void md5_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len) |
162 | { | 162 | { |
163 | struct md5_ctx *mctx = ctx; | 163 | struct md5_ctx *mctx = crypto_tfm_ctx(tfm); |
164 | const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); | 164 | const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); |
165 | 165 | ||
166 | mctx->byte_count += len; | 166 | mctx->byte_count += len; |
@@ -188,9 +188,9 @@ static void md5_update(void *ctx, const u8 *data, unsigned int len) | |||
188 | memcpy(mctx->block, data, len); | 188 | memcpy(mctx->block, data, len); |
189 | } | 189 | } |
190 | 190 | ||
191 | static void md5_final(void *ctx, u8 *out) | 191 | static void md5_final(struct crypto_tfm *tfm, u8 *out) |
192 | { | 192 | { |
193 | struct md5_ctx *mctx = ctx; | 193 | struct md5_ctx *mctx = crypto_tfm_ctx(tfm); |
194 | const unsigned int offset = mctx->byte_count & 0x3f; | 194 | const unsigned int offset = mctx->byte_count & 0x3f; |
195 | char *p = (char *)mctx->block + offset; | 195 | char *p = (char *)mctx->block + offset; |
196 | int padding = 56 - (offset + 1); | 196 | int padding = 56 - (offset + 1); |
diff --git a/crypto/michael_mic.c b/crypto/michael_mic.c index 701f859ed767..d061da21cfda 100644 --- a/crypto/michael_mic.c +++ b/crypto/michael_mic.c | |||
@@ -45,16 +45,17 @@ do { \ | |||
45 | } while (0) | 45 | } while (0) |
46 | 46 | ||
47 | 47 | ||
48 | static void michael_init(void *ctx) | 48 | static void michael_init(struct crypto_tfm *tfm) |
49 | { | 49 | { |
50 | struct michael_mic_ctx *mctx = ctx; | 50 | struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm); |
51 | mctx->pending_len = 0; | 51 | mctx->pending_len = 0; |
52 | } | 52 | } |
53 | 53 | ||
54 | 54 | ||
55 | static void michael_update(void *ctx, const u8 *data, unsigned int len) | 55 | static void michael_update(struct crypto_tfm *tfm, const u8 *data, |
56 | unsigned int len) | ||
56 | { | 57 | { |
57 | struct michael_mic_ctx *mctx = ctx; | 58 | struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm); |
58 | const __le32 *src; | 59 | const __le32 *src; |
59 | 60 | ||
60 | if (mctx->pending_len) { | 61 | if (mctx->pending_len) { |
@@ -90,9 +91,9 @@ static void michael_update(void *ctx, const u8 *data, unsigned int len) | |||
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
93 | static void michael_final(void *ctx, u8 *out) | 94 | static void michael_final(struct crypto_tfm *tfm, u8 *out) |
94 | { | 95 | { |
95 | struct michael_mic_ctx *mctx = ctx; | 96 | struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm); |
96 | u8 *data = mctx->pending; | 97 | u8 *data = mctx->pending; |
97 | __le32 *dst = (__le32 *)out; | 98 | __le32 *dst = (__le32 *)out; |
98 | 99 | ||
@@ -121,10 +122,10 @@ static void michael_final(void *ctx, u8 *out) | |||
121 | } | 122 | } |
122 | 123 | ||
123 | 124 | ||
124 | static int michael_setkey(void *ctx, const u8 *key, unsigned int keylen, | 125 | static int michael_setkey(struct crypto_tfm *tfm, const u8 *key, |
125 | u32 *flags) | 126 | unsigned int keylen, u32 *flags) |
126 | { | 127 | { |
127 | struct michael_mic_ctx *mctx = ctx; | 128 | struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm); |
128 | const __le32 *data = (const __le32 *)key; | 129 | const __le32 *data = (const __le32 *)key; |
129 | 130 | ||
130 | if (keylen != 8) { | 131 | if (keylen != 8) { |
diff --git a/crypto/serpent.c b/crypto/serpent.c index e366406ab49d..de60cdddbf4a 100644 --- a/crypto/serpent.c +++ b/crypto/serpent.c | |||
@@ -215,9 +215,11 @@ struct serpent_ctx { | |||
215 | }; | 215 | }; |
216 | 216 | ||
217 | 217 | ||
218 | static int serpent_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 218 | static int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, |
219 | unsigned int keylen, u32 *flags) | ||
219 | { | 220 | { |
220 | u32 *k = ((struct serpent_ctx *)ctx)->expkey; | 221 | struct serpent_ctx *ctx = crypto_tfm_ctx(tfm); |
222 | u32 *k = ctx->expkey; | ||
221 | u8 *k8 = (u8 *)k; | 223 | u8 *k8 = (u8 *)k; |
222 | u32 r0,r1,r2,r3,r4; | 224 | u32 r0,r1,r2,r3,r4; |
223 | int i; | 225 | int i; |
@@ -365,10 +367,11 @@ static int serpent_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *fl | |||
365 | return 0; | 367 | return 0; |
366 | } | 368 | } |
367 | 369 | ||
368 | static void serpent_encrypt(void *ctx, u8 *dst, const u8 *src) | 370 | static void serpent_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
369 | { | 371 | { |
372 | struct serpent_ctx *ctx = crypto_tfm_ctx(tfm); | ||
370 | const u32 | 373 | const u32 |
371 | *k = ((struct serpent_ctx *)ctx)->expkey, | 374 | *k = ctx->expkey, |
372 | *s = (const u32 *)src; | 375 | *s = (const u32 *)src; |
373 | u32 *d = (u32 *)dst, | 376 | u32 *d = (u32 *)dst, |
374 | r0, r1, r2, r3, r4; | 377 | r0, r1, r2, r3, r4; |
@@ -423,8 +426,9 @@ static void serpent_encrypt(void *ctx, u8 *dst, const u8 *src) | |||
423 | d[3] = cpu_to_le32(r3); | 426 | d[3] = cpu_to_le32(r3); |
424 | } | 427 | } |
425 | 428 | ||
426 | static void serpent_decrypt(void *ctx, u8 *dst, const u8 *src) | 429 | static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
427 | { | 430 | { |
431 | struct serpent_ctx *ctx = crypto_tfm_ctx(tfm); | ||
428 | const u32 | 432 | const u32 |
429 | *k = ((struct serpent_ctx *)ctx)->expkey, | 433 | *k = ((struct serpent_ctx *)ctx)->expkey, |
430 | *s = (const u32 *)src; | 434 | *s = (const u32 *)src; |
@@ -492,7 +496,8 @@ static struct crypto_alg serpent_alg = { | |||
492 | .cia_decrypt = serpent_decrypt } } | 496 | .cia_decrypt = serpent_decrypt } } |
493 | }; | 497 | }; |
494 | 498 | ||
495 | static int tnepres_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 499 | static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, |
500 | unsigned int keylen, u32 *flags) | ||
496 | { | 501 | { |
497 | u8 rev_key[SERPENT_MAX_KEY_SIZE]; | 502 | u8 rev_key[SERPENT_MAX_KEY_SIZE]; |
498 | int i; | 503 | int i; |
@@ -506,10 +511,10 @@ static int tnepres_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *fl | |||
506 | for (i = 0; i < keylen; ++i) | 511 | for (i = 0; i < keylen; ++i) |
507 | rev_key[keylen - i - 1] = key[i]; | 512 | rev_key[keylen - i - 1] = key[i]; |
508 | 513 | ||
509 | return serpent_setkey(ctx, rev_key, keylen, flags); | 514 | return serpent_setkey(tfm, rev_key, keylen, flags); |
510 | } | 515 | } |
511 | 516 | ||
512 | static void tnepres_encrypt(void *ctx, u8 *dst, const u8 *src) | 517 | static void tnepres_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
513 | { | 518 | { |
514 | const u32 * const s = (const u32 * const)src; | 519 | const u32 * const s = (const u32 * const)src; |
515 | u32 * const d = (u32 * const)dst; | 520 | u32 * const d = (u32 * const)dst; |
@@ -521,7 +526,7 @@ static void tnepres_encrypt(void *ctx, u8 *dst, const u8 *src) | |||
521 | rs[2] = swab32(s[1]); | 526 | rs[2] = swab32(s[1]); |
522 | rs[3] = swab32(s[0]); | 527 | rs[3] = swab32(s[0]); |
523 | 528 | ||
524 | serpent_encrypt(ctx, (u8 *)rd, (u8 *)rs); | 529 | serpent_encrypt(tfm, (u8 *)rd, (u8 *)rs); |
525 | 530 | ||
526 | d[0] = swab32(rd[3]); | 531 | d[0] = swab32(rd[3]); |
527 | d[1] = swab32(rd[2]); | 532 | d[1] = swab32(rd[2]); |
@@ -529,7 +534,7 @@ static void tnepres_encrypt(void *ctx, u8 *dst, const u8 *src) | |||
529 | d[3] = swab32(rd[0]); | 534 | d[3] = swab32(rd[0]); |
530 | } | 535 | } |
531 | 536 | ||
532 | static void tnepres_decrypt(void *ctx, u8 *dst, const u8 *src) | 537 | static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
533 | { | 538 | { |
534 | const u32 * const s = (const u32 * const)src; | 539 | const u32 * const s = (const u32 * const)src; |
535 | u32 * const d = (u32 * const)dst; | 540 | u32 * const d = (u32 * const)dst; |
@@ -541,7 +546,7 @@ static void tnepres_decrypt(void *ctx, u8 *dst, const u8 *src) | |||
541 | rs[2] = swab32(s[1]); | 546 | rs[2] = swab32(s[1]); |
542 | rs[3] = swab32(s[0]); | 547 | rs[3] = swab32(s[0]); |
543 | 548 | ||
544 | serpent_decrypt(ctx, (u8 *)rd, (u8 *)rs); | 549 | serpent_decrypt(tfm, (u8 *)rd, (u8 *)rs); |
545 | 550 | ||
546 | d[0] = swab32(rd[3]); | 551 | d[0] = swab32(rd[3]); |
547 | d[1] = swab32(rd[2]); | 552 | d[1] = swab32(rd[2]); |
diff --git a/crypto/sha1.c b/crypto/sha1.c index b96f57d95a82..6c77b689f87e 100644 --- a/crypto/sha1.c +++ b/crypto/sha1.c | |||
@@ -34,9 +34,9 @@ struct sha1_ctx { | |||
34 | u8 buffer[64]; | 34 | u8 buffer[64]; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static void sha1_init(void *ctx) | 37 | static void sha1_init(struct crypto_tfm *tfm) |
38 | { | 38 | { |
39 | struct sha1_ctx *sctx = ctx; | 39 | struct sha1_ctx *sctx = crypto_tfm_ctx(tfm); |
40 | static const struct sha1_ctx initstate = { | 40 | static const struct sha1_ctx initstate = { |
41 | 0, | 41 | 0, |
42 | { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }, | 42 | { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }, |
@@ -46,9 +46,10 @@ static void sha1_init(void *ctx) | |||
46 | *sctx = initstate; | 46 | *sctx = initstate; |
47 | } | 47 | } |
48 | 48 | ||
49 | static void sha1_update(void *ctx, const u8 *data, unsigned int len) | 49 | static void sha1_update(struct crypto_tfm *tfm, const u8 *data, |
50 | unsigned int len) | ||
50 | { | 51 | { |
51 | struct sha1_ctx *sctx = ctx; | 52 | struct sha1_ctx *sctx = crypto_tfm_ctx(tfm); |
52 | unsigned int partial, done; | 53 | unsigned int partial, done; |
53 | const u8 *src; | 54 | const u8 *src; |
54 | 55 | ||
@@ -80,9 +81,9 @@ static void sha1_update(void *ctx, const u8 *data, unsigned int len) | |||
80 | 81 | ||
81 | 82 | ||
82 | /* Add padding and return the message digest. */ | 83 | /* Add padding and return the message digest. */ |
83 | static void sha1_final(void* ctx, u8 *out) | 84 | static void sha1_final(struct crypto_tfm *tfm, u8 *out) |
84 | { | 85 | { |
85 | struct sha1_ctx *sctx = ctx; | 86 | struct sha1_ctx *sctx = crypto_tfm_ctx(tfm); |
86 | __be32 *dst = (__be32 *)out; | 87 | __be32 *dst = (__be32 *)out; |
87 | u32 i, index, padlen; | 88 | u32 i, index, padlen; |
88 | __be64 bits; | 89 | __be64 bits; |
@@ -93,10 +94,10 @@ static void sha1_final(void* ctx, u8 *out) | |||
93 | /* Pad out to 56 mod 64 */ | 94 | /* Pad out to 56 mod 64 */ |
94 | index = sctx->count & 0x3f; | 95 | index = sctx->count & 0x3f; |
95 | padlen = (index < 56) ? (56 - index) : ((64+56) - index); | 96 | padlen = (index < 56) ? (56 - index) : ((64+56) - index); |
96 | sha1_update(sctx, padding, padlen); | 97 | sha1_update(tfm, padding, padlen); |
97 | 98 | ||
98 | /* Append length */ | 99 | /* Append length */ |
99 | sha1_update(sctx, (const u8 *)&bits, sizeof(bits)); | 100 | sha1_update(tfm, (const u8 *)&bits, sizeof(bits)); |
100 | 101 | ||
101 | /* Store state in digest */ | 102 | /* Store state in digest */ |
102 | for (i = 0; i < 5; i++) | 103 | for (i = 0; i < 5; i++) |
diff --git a/crypto/sha256.c b/crypto/sha256.c index 4533a0564895..bc71d85a7d02 100644 --- a/crypto/sha256.c +++ b/crypto/sha256.c | |||
@@ -230,9 +230,9 @@ static void sha256_transform(u32 *state, const u8 *input) | |||
230 | memset(W, 0, 64 * sizeof(u32)); | 230 | memset(W, 0, 64 * sizeof(u32)); |
231 | } | 231 | } |
232 | 232 | ||
233 | static void sha256_init(void *ctx) | 233 | static void sha256_init(struct crypto_tfm *tfm) |
234 | { | 234 | { |
235 | struct sha256_ctx *sctx = ctx; | 235 | struct sha256_ctx *sctx = crypto_tfm_ctx(tfm); |
236 | sctx->state[0] = H0; | 236 | sctx->state[0] = H0; |
237 | sctx->state[1] = H1; | 237 | sctx->state[1] = H1; |
238 | sctx->state[2] = H2; | 238 | sctx->state[2] = H2; |
@@ -244,9 +244,10 @@ static void sha256_init(void *ctx) | |||
244 | sctx->count[0] = sctx->count[1] = 0; | 244 | sctx->count[0] = sctx->count[1] = 0; |
245 | } | 245 | } |
246 | 246 | ||
247 | static void sha256_update(void *ctx, const u8 *data, unsigned int len) | 247 | static void sha256_update(struct crypto_tfm *tfm, const u8 *data, |
248 | unsigned int len) | ||
248 | { | 249 | { |
249 | struct sha256_ctx *sctx = ctx; | 250 | struct sha256_ctx *sctx = crypto_tfm_ctx(tfm); |
250 | unsigned int i, index, part_len; | 251 | unsigned int i, index, part_len; |
251 | 252 | ||
252 | /* Compute number of bytes mod 128 */ | 253 | /* Compute number of bytes mod 128 */ |
@@ -276,9 +277,9 @@ static void sha256_update(void *ctx, const u8 *data, unsigned int len) | |||
276 | memcpy(&sctx->buf[index], &data[i], len-i); | 277 | memcpy(&sctx->buf[index], &data[i], len-i); |
277 | } | 278 | } |
278 | 279 | ||
279 | static void sha256_final(void* ctx, u8 *out) | 280 | static void sha256_final(struct crypto_tfm *tfm, u8 *out) |
280 | { | 281 | { |
281 | struct sha256_ctx *sctx = ctx; | 282 | struct sha256_ctx *sctx = crypto_tfm_ctx(tfm); |
282 | __be32 *dst = (__be32 *)out; | 283 | __be32 *dst = (__be32 *)out; |
283 | __be32 bits[2]; | 284 | __be32 bits[2]; |
284 | unsigned int index, pad_len; | 285 | unsigned int index, pad_len; |
@@ -292,10 +293,10 @@ static void sha256_final(void* ctx, u8 *out) | |||
292 | /* Pad out to 56 mod 64. */ | 293 | /* Pad out to 56 mod 64. */ |
293 | index = (sctx->count[0] >> 3) & 0x3f; | 294 | index = (sctx->count[0] >> 3) & 0x3f; |
294 | pad_len = (index < 56) ? (56 - index) : ((64+56) - index); | 295 | pad_len = (index < 56) ? (56 - index) : ((64+56) - index); |
295 | sha256_update(sctx, padding, pad_len); | 296 | sha256_update(tfm, padding, pad_len); |
296 | 297 | ||
297 | /* Append length (before padding) */ | 298 | /* Append length (before padding) */ |
298 | sha256_update(sctx, (const u8 *)bits, sizeof(bits)); | 299 | sha256_update(tfm, (const u8 *)bits, sizeof(bits)); |
299 | 300 | ||
300 | /* Store state in digest */ | 301 | /* Store state in digest */ |
301 | for (i = 0; i < 8; i++) | 302 | for (i = 0; i < 8; i++) |
diff --git a/crypto/sha512.c b/crypto/sha512.c index bc77a66d9de2..2dfe7f170b48 100644 --- a/crypto/sha512.c +++ b/crypto/sha512.c | |||
@@ -161,9 +161,9 @@ sha512_transform(u64 *state, u64 *W, const u8 *input) | |||
161 | } | 161 | } |
162 | 162 | ||
163 | static void | 163 | static void |
164 | sha512_init(void *ctx) | 164 | sha512_init(struct crypto_tfm *tfm) |
165 | { | 165 | { |
166 | struct sha512_ctx *sctx = ctx; | 166 | struct sha512_ctx *sctx = crypto_tfm_ctx(tfm); |
167 | sctx->state[0] = H0; | 167 | sctx->state[0] = H0; |
168 | sctx->state[1] = H1; | 168 | sctx->state[1] = H1; |
169 | sctx->state[2] = H2; | 169 | sctx->state[2] = H2; |
@@ -176,9 +176,9 @@ sha512_init(void *ctx) | |||
176 | } | 176 | } |
177 | 177 | ||
178 | static void | 178 | static void |
179 | sha384_init(void *ctx) | 179 | sha384_init(struct crypto_tfm *tfm) |
180 | { | 180 | { |
181 | struct sha512_ctx *sctx = ctx; | 181 | struct sha512_ctx *sctx = crypto_tfm_ctx(tfm); |
182 | sctx->state[0] = HP0; | 182 | sctx->state[0] = HP0; |
183 | sctx->state[1] = HP1; | 183 | sctx->state[1] = HP1; |
184 | sctx->state[2] = HP2; | 184 | sctx->state[2] = HP2; |
@@ -191,9 +191,9 @@ sha384_init(void *ctx) | |||
191 | } | 191 | } |
192 | 192 | ||
193 | static void | 193 | static void |
194 | sha512_update(void *ctx, const u8 *data, unsigned int len) | 194 | sha512_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len) |
195 | { | 195 | { |
196 | struct sha512_ctx *sctx = ctx; | 196 | struct sha512_ctx *sctx = crypto_tfm_ctx(tfm); |
197 | 197 | ||
198 | unsigned int i, index, part_len; | 198 | unsigned int i, index, part_len; |
199 | 199 | ||
@@ -231,9 +231,9 @@ sha512_update(void *ctx, const u8 *data, unsigned int len) | |||
231 | } | 231 | } |
232 | 232 | ||
233 | static void | 233 | static void |
234 | sha512_final(void *ctx, u8 *hash) | 234 | sha512_final(struct crypto_tfm *tfm, u8 *hash) |
235 | { | 235 | { |
236 | struct sha512_ctx *sctx = ctx; | 236 | struct sha512_ctx *sctx = crypto_tfm_ctx(tfm); |
237 | static u8 padding[128] = { 0x80, }; | 237 | static u8 padding[128] = { 0x80, }; |
238 | __be64 *dst = (__be64 *)hash; | 238 | __be64 *dst = (__be64 *)hash; |
239 | __be32 bits[4]; | 239 | __be32 bits[4]; |
@@ -249,10 +249,10 @@ sha512_final(void *ctx, u8 *hash) | |||
249 | /* Pad out to 112 mod 128. */ | 249 | /* Pad out to 112 mod 128. */ |
250 | index = (sctx->count[0] >> 3) & 0x7f; | 250 | index = (sctx->count[0] >> 3) & 0x7f; |
251 | pad_len = (index < 112) ? (112 - index) : ((128+112) - index); | 251 | pad_len = (index < 112) ? (112 - index) : ((128+112) - index); |
252 | sha512_update(sctx, padding, pad_len); | 252 | sha512_update(tfm, padding, pad_len); |
253 | 253 | ||
254 | /* Append length (before padding) */ | 254 | /* Append length (before padding) */ |
255 | sha512_update(sctx, (const u8 *)bits, sizeof(bits)); | 255 | sha512_update(tfm, (const u8 *)bits, sizeof(bits)); |
256 | 256 | ||
257 | /* Store state in digest */ | 257 | /* Store state in digest */ |
258 | for (i = 0; i < 8; i++) | 258 | for (i = 0; i < 8; i++) |
@@ -262,12 +262,11 @@ sha512_final(void *ctx, u8 *hash) | |||
262 | memset(sctx, 0, sizeof(struct sha512_ctx)); | 262 | memset(sctx, 0, sizeof(struct sha512_ctx)); |
263 | } | 263 | } |
264 | 264 | ||
265 | static void sha384_final(void *ctx, u8 *hash) | 265 | static void sha384_final(struct crypto_tfm *tfm, u8 *hash) |
266 | { | 266 | { |
267 | struct sha512_ctx *sctx = ctx; | ||
268 | u8 D[64]; | 267 | u8 D[64]; |
269 | 268 | ||
270 | sha512_final(sctx, D); | 269 | sha512_final(tfm, D); |
271 | 270 | ||
272 | memcpy(hash, D, 48); | 271 | memcpy(hash, D, 48); |
273 | memset(D, 0, 64); | 272 | memset(D, 0, 64); |
diff --git a/crypto/tea.c b/crypto/tea.c index a6a02b30e470..5367adc82fc9 100644 --- a/crypto/tea.c +++ b/crypto/tea.c | |||
@@ -45,10 +45,10 @@ struct xtea_ctx { | |||
45 | u32 KEY[4]; | 45 | u32 KEY[4]; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static int tea_setkey(void *ctx_arg, const u8 *in_key, | 48 | static int tea_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
49 | unsigned int key_len, u32 *flags) | 49 | unsigned int key_len, u32 *flags) |
50 | { | 50 | { |
51 | struct tea_ctx *ctx = ctx_arg; | 51 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
52 | const __le32 *key = (const __le32 *)in_key; | 52 | const __le32 *key = (const __le32 *)in_key; |
53 | 53 | ||
54 | if (key_len != 16) | 54 | if (key_len != 16) |
@@ -66,12 +66,11 @@ static int tea_setkey(void *ctx_arg, const u8 *in_key, | |||
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | static void tea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 69 | static void tea_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
70 | { | 70 | { |
71 | u32 y, z, n, sum = 0; | 71 | u32 y, z, n, sum = 0; |
72 | u32 k0, k1, k2, k3; | 72 | u32 k0, k1, k2, k3; |
73 | 73 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); | |
74 | struct tea_ctx *ctx = ctx_arg; | ||
75 | const __le32 *in = (const __le32 *)src; | 74 | const __le32 *in = (const __le32 *)src; |
76 | __le32 *out = (__le32 *)dst; | 75 | __le32 *out = (__le32 *)dst; |
77 | 76 | ||
@@ -95,11 +94,11 @@ static void tea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
95 | out[1] = cpu_to_le32(z); | 94 | out[1] = cpu_to_le32(z); |
96 | } | 95 | } |
97 | 96 | ||
98 | static void tea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 97 | static void tea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
99 | { | 98 | { |
100 | u32 y, z, n, sum; | 99 | u32 y, z, n, sum; |
101 | u32 k0, k1, k2, k3; | 100 | u32 k0, k1, k2, k3; |
102 | struct tea_ctx *ctx = ctx_arg; | 101 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
103 | const __le32 *in = (const __le32 *)src; | 102 | const __le32 *in = (const __le32 *)src; |
104 | __le32 *out = (__le32 *)dst; | 103 | __le32 *out = (__le32 *)dst; |
105 | 104 | ||
@@ -125,10 +124,10 @@ static void tea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
125 | out[1] = cpu_to_le32(z); | 124 | out[1] = cpu_to_le32(z); |
126 | } | 125 | } |
127 | 126 | ||
128 | static int xtea_setkey(void *ctx_arg, const u8 *in_key, | 127 | static int xtea_setkey(struct crypto_tfm *tfm, const u8 *in_key, |
129 | unsigned int key_len, u32 *flags) | 128 | unsigned int key_len, u32 *flags) |
130 | { | 129 | { |
131 | struct xtea_ctx *ctx = ctx_arg; | 130 | struct xtea_ctx *ctx = crypto_tfm_ctx(tfm); |
132 | const __le32 *key = (const __le32 *)in_key; | 131 | const __le32 *key = (const __le32 *)in_key; |
133 | 132 | ||
134 | if (key_len != 16) | 133 | if (key_len != 16) |
@@ -146,12 +145,11 @@ static int xtea_setkey(void *ctx_arg, const u8 *in_key, | |||
146 | 145 | ||
147 | } | 146 | } |
148 | 147 | ||
149 | static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 148 | static void xtea_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
150 | { | 149 | { |
151 | u32 y, z, sum = 0; | 150 | u32 y, z, sum = 0; |
152 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; | 151 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; |
153 | 152 | struct xtea_ctx *ctx = crypto_tfm_ctx(tfm); | |
154 | struct xtea_ctx *ctx = ctx_arg; | ||
155 | const __le32 *in = (const __le32 *)src; | 153 | const __le32 *in = (const __le32 *)src; |
156 | __le32 *out = (__le32 *)dst; | 154 | __le32 *out = (__le32 *)dst; |
157 | 155 | ||
@@ -168,10 +166,10 @@ static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
168 | out[1] = cpu_to_le32(z); | 166 | out[1] = cpu_to_le32(z); |
169 | } | 167 | } |
170 | 168 | ||
171 | static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 169 | static void xtea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
172 | { | 170 | { |
173 | u32 y, z, sum; | 171 | u32 y, z, sum; |
174 | struct tea_ctx *ctx = ctx_arg; | 172 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
175 | const __le32 *in = (const __le32 *)src; | 173 | const __le32 *in = (const __le32 *)src; |
176 | __le32 *out = (__le32 *)dst; | 174 | __le32 *out = (__le32 *)dst; |
177 | 175 | ||
@@ -191,12 +189,11 @@ static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
191 | } | 189 | } |
192 | 190 | ||
193 | 191 | ||
194 | static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | 192 | static void xeta_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
195 | { | 193 | { |
196 | u32 y, z, sum = 0; | 194 | u32 y, z, sum = 0; |
197 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; | 195 | u32 limit = XTEA_DELTA * XTEA_ROUNDS; |
198 | 196 | struct xtea_ctx *ctx = crypto_tfm_ctx(tfm); | |
199 | struct xtea_ctx *ctx = ctx_arg; | ||
200 | const __le32 *in = (const __le32 *)src; | 197 | const __le32 *in = (const __le32 *)src; |
201 | __le32 *out = (__le32 *)dst; | 198 | __le32 *out = (__le32 *)dst; |
202 | 199 | ||
@@ -213,10 +210,10 @@ static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src) | |||
213 | out[1] = cpu_to_le32(z); | 210 | out[1] = cpu_to_le32(z); |
214 | } | 211 | } |
215 | 212 | ||
216 | static void xeta_decrypt(void *ctx_arg, u8 *dst, const u8 *src) | 213 | static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
217 | { | 214 | { |
218 | u32 y, z, sum; | 215 | u32 y, z, sum; |
219 | struct tea_ctx *ctx = ctx_arg; | 216 | struct tea_ctx *ctx = crypto_tfm_ctx(tfm); |
220 | const __le32 *in = (const __le32 *)src; | 217 | const __le32 *in = (const __le32 *)src; |
221 | __le32 *out = (__le32 *)dst; | 218 | __le32 *out = (__le32 *)dst; |
222 | 219 | ||
diff --git a/crypto/tgr192.c b/crypto/tgr192.c index 004bb841cc5b..a0fadf3dd3e2 100644 --- a/crypto/tgr192.c +++ b/crypto/tgr192.c | |||
@@ -496,9 +496,9 @@ static void tgr192_transform(struct tgr192_ctx *tctx, const u8 * data) | |||
496 | tctx->c = c; | 496 | tctx->c = c; |
497 | } | 497 | } |
498 | 498 | ||
499 | static void tgr192_init(void *ctx) | 499 | static void tgr192_init(struct crypto_tfm *tfm) |
500 | { | 500 | { |
501 | struct tgr192_ctx *tctx = ctx; | 501 | struct tgr192_ctx *tctx = crypto_tfm_ctx(tfm); |
502 | 502 | ||
503 | tctx->a = 0x0123456789abcdefULL; | 503 | tctx->a = 0x0123456789abcdefULL; |
504 | tctx->b = 0xfedcba9876543210ULL; | 504 | tctx->b = 0xfedcba9876543210ULL; |
@@ -510,9 +510,10 @@ static void tgr192_init(void *ctx) | |||
510 | 510 | ||
511 | /* Update the message digest with the contents | 511 | /* Update the message digest with the contents |
512 | * of INBUF with length INLEN. */ | 512 | * of INBUF with length INLEN. */ |
513 | static void tgr192_update(void *ctx, const u8 * inbuf, unsigned int len) | 513 | static void tgr192_update(struct crypto_tfm *tfm, const u8 *inbuf, |
514 | unsigned int len) | ||
514 | { | 515 | { |
515 | struct tgr192_ctx *tctx = ctx; | 516 | struct tgr192_ctx *tctx = crypto_tfm_ctx(tfm); |
516 | 517 | ||
517 | if (tctx->count == 64) { /* flush the buffer */ | 518 | if (tctx->count == 64) { /* flush the buffer */ |
518 | tgr192_transform(tctx, tctx->hash); | 519 | tgr192_transform(tctx, tctx->hash); |
@@ -526,7 +527,7 @@ static void tgr192_update(void *ctx, const u8 * inbuf, unsigned int len) | |||
526 | for (; len && tctx->count < 64; len--) { | 527 | for (; len && tctx->count < 64; len--) { |
527 | tctx->hash[tctx->count++] = *inbuf++; | 528 | tctx->hash[tctx->count++] = *inbuf++; |
528 | } | 529 | } |
529 | tgr192_update(tctx, NULL, 0); | 530 | tgr192_update(tfm, NULL, 0); |
530 | if (!len) { | 531 | if (!len) { |
531 | return; | 532 | return; |
532 | } | 533 | } |
@@ -548,15 +549,15 @@ static void tgr192_update(void *ctx, const u8 * inbuf, unsigned int len) | |||
548 | 549 | ||
549 | 550 | ||
550 | /* The routine terminates the computation */ | 551 | /* The routine terminates the computation */ |
551 | static void tgr192_final(void *ctx, u8 * out) | 552 | static void tgr192_final(struct crypto_tfm *tfm, u8 * out) |
552 | { | 553 | { |
553 | struct tgr192_ctx *tctx = ctx; | 554 | struct tgr192_ctx *tctx = crypto_tfm_ctx(tfm); |
554 | __be64 *dst = (__be64 *)out; | 555 | __be64 *dst = (__be64 *)out; |
555 | __be64 *be64p; | 556 | __be64 *be64p; |
556 | __le32 *le32p; | 557 | __le32 *le32p; |
557 | u32 t, msb, lsb; | 558 | u32 t, msb, lsb; |
558 | 559 | ||
559 | tgr192_update(tctx, NULL, 0); /* flush */ ; | 560 | tgr192_update(tfm, NULL, 0); /* flush */ ; |
560 | 561 | ||
561 | msb = 0; | 562 | msb = 0; |
562 | t = tctx->nblocks; | 563 | t = tctx->nblocks; |
@@ -584,7 +585,7 @@ static void tgr192_final(void *ctx, u8 * out) | |||
584 | while (tctx->count < 64) { | 585 | while (tctx->count < 64) { |
585 | tctx->hash[tctx->count++] = 0; | 586 | tctx->hash[tctx->count++] = 0; |
586 | } | 587 | } |
587 | tgr192_update(tctx, NULL, 0); /* flush */ ; | 588 | tgr192_update(tfm, NULL, 0); /* flush */ ; |
588 | memset(tctx->hash, 0, 56); /* fill next block with zeroes */ | 589 | memset(tctx->hash, 0, 56); /* fill next block with zeroes */ |
589 | } | 590 | } |
590 | /* append the 64 bit count */ | 591 | /* append the 64 bit count */ |
@@ -600,22 +601,20 @@ static void tgr192_final(void *ctx, u8 * out) | |||
600 | dst[2] = be64p[2] = cpu_to_be64(tctx->c); | 601 | dst[2] = be64p[2] = cpu_to_be64(tctx->c); |
601 | } | 602 | } |
602 | 603 | ||
603 | static void tgr160_final(void *ctx, u8 * out) | 604 | static void tgr160_final(struct crypto_tfm *tfm, u8 * out) |
604 | { | 605 | { |
605 | struct tgr192_ctx *wctx = ctx; | ||
606 | u8 D[64]; | 606 | u8 D[64]; |
607 | 607 | ||
608 | tgr192_final(wctx, D); | 608 | tgr192_final(tfm, D); |
609 | memcpy(out, D, TGR160_DIGEST_SIZE); | 609 | memcpy(out, D, TGR160_DIGEST_SIZE); |
610 | memset(D, 0, TGR192_DIGEST_SIZE); | 610 | memset(D, 0, TGR192_DIGEST_SIZE); |
611 | } | 611 | } |
612 | 612 | ||
613 | static void tgr128_final(void *ctx, u8 * out) | 613 | static void tgr128_final(struct crypto_tfm *tfm, u8 * out) |
614 | { | 614 | { |
615 | struct tgr192_ctx *wctx = ctx; | ||
616 | u8 D[64]; | 615 | u8 D[64]; |
617 | 616 | ||
618 | tgr192_final(wctx, D); | 617 | tgr192_final(tfm, D); |
619 | memcpy(out, D, TGR128_DIGEST_SIZE); | 618 | memcpy(out, D, TGR128_DIGEST_SIZE); |
620 | memset(D, 0, TGR192_DIGEST_SIZE); | 619 | memset(D, 0, TGR192_DIGEST_SIZE); |
621 | } | 620 | } |
diff --git a/crypto/twofish.c b/crypto/twofish.c index ddfd5a3fcc5f..ec2488242e2d 100644 --- a/crypto/twofish.c +++ b/crypto/twofish.c | |||
@@ -643,11 +643,11 @@ struct twofish_ctx { | |||
643 | }; | 643 | }; |
644 | 644 | ||
645 | /* Perform the key setup. */ | 645 | /* Perform the key setup. */ |
646 | static int twofish_setkey(void *cx, const u8 *key, | 646 | static int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, |
647 | unsigned int key_len, u32 *flags) | 647 | unsigned int key_len, u32 *flags) |
648 | { | 648 | { |
649 | 649 | ||
650 | struct twofish_ctx *ctx = cx; | 650 | struct twofish_ctx *ctx = crypto_tfm_ctx(tfm); |
651 | 651 | ||
652 | int i, j, k; | 652 | int i, j, k; |
653 | 653 | ||
@@ -802,9 +802,9 @@ static int twofish_setkey(void *cx, const u8 *key, | |||
802 | } | 802 | } |
803 | 803 | ||
804 | /* Encrypt one block. in and out may be the same. */ | 804 | /* Encrypt one block. in and out may be the same. */ |
805 | static void twofish_encrypt(void *cx, u8 *out, const u8 *in) | 805 | static void twofish_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
806 | { | 806 | { |
807 | struct twofish_ctx *ctx = cx; | 807 | struct twofish_ctx *ctx = crypto_tfm_ctx(tfm); |
808 | const __le32 *src = (const __le32 *)in; | 808 | const __le32 *src = (const __le32 *)in; |
809 | __le32 *dst = (__le32 *)out; | 809 | __le32 *dst = (__le32 *)out; |
810 | 810 | ||
@@ -839,9 +839,9 @@ static void twofish_encrypt(void *cx, u8 *out, const u8 *in) | |||
839 | } | 839 | } |
840 | 840 | ||
841 | /* Decrypt one block. in and out may be the same. */ | 841 | /* Decrypt one block. in and out may be the same. */ |
842 | static void twofish_decrypt(void *cx, u8 *out, const u8 *in) | 842 | static void twofish_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
843 | { | 843 | { |
844 | struct twofish_ctx *ctx = cx; | 844 | struct twofish_ctx *ctx = crypto_tfm_ctx(tfm); |
845 | const __le32 *src = (const __le32 *)in; | 845 | const __le32 *src = (const __le32 *)in; |
846 | __le32 *dst = (__le32 *)out; | 846 | __le32 *dst = (__le32 *)out; |
847 | 847 | ||
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 | ||
984 | static void wp512_init (void *ctx) { | 984 | static 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 | ||
996 | static void wp512_update(void *ctx, const u8 *source, unsigned int len) | 996 | static 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 | ||
1057 | static void wp512_final(void *ctx, u8 *out) | 1057 | static 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 | ||
1090 | static void wp384_final(void *ctx, u8 *out) | 1090 | static 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 | ||
1100 | static void wp256_final(void *ctx, u8 *out) | 1099 | static 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 | } |
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c index 5158a9db4bc5..b98ad203d6cb 100644 --- a/drivers/crypto/padlock-aes.c +++ b/drivers/crypto/padlock-aes.c | |||
@@ -282,19 +282,20 @@ aes_hw_extkey_available(uint8_t key_len) | |||
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | static inline struct aes_ctx *aes_ctx(void *ctx) | 285 | static inline struct aes_ctx *aes_ctx(struct crypto_tfm *tfm) |
286 | { | 286 | { |
287 | unsigned long addr = (unsigned long)crypto_tfm_ctx(tfm); | ||
287 | unsigned long align = PADLOCK_ALIGNMENT; | 288 | unsigned long align = PADLOCK_ALIGNMENT; |
288 | 289 | ||
289 | if (align <= crypto_tfm_ctx_alignment()) | 290 | if (align <= crypto_tfm_ctx_alignment()) |
290 | align = 1; | 291 | align = 1; |
291 | return (struct aes_ctx *)ALIGN((unsigned long)ctx, align); | 292 | return (struct aes_ctx *)ALIGN(addr, align); |
292 | } | 293 | } |
293 | 294 | ||
294 | static int | 295 | static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, |
295 | aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags) | 296 | unsigned int key_len, u32 *flags) |
296 | { | 297 | { |
297 | struct aes_ctx *ctx = aes_ctx(ctx_arg); | 298 | struct aes_ctx *ctx = aes_ctx(tfm); |
298 | const __le32 *key = (const __le32 *)in_key; | 299 | const __le32 *key = (const __le32 *)in_key; |
299 | uint32_t i, t, u, v, w; | 300 | uint32_t i, t, u, v, w; |
300 | uint32_t P[AES_EXTENDED_KEY_SIZE]; | 301 | uint32_t P[AES_EXTENDED_KEY_SIZE]; |
@@ -414,24 +415,22 @@ static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key, | |||
414 | return iv; | 415 | return iv; |
415 | } | 416 | } |
416 | 417 | ||
417 | static void | 418 | static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
418 | aes_encrypt(void *ctx_arg, uint8_t *out, const uint8_t *in) | ||
419 | { | 419 | { |
420 | struct aes_ctx *ctx = aes_ctx(ctx_arg); | 420 | struct aes_ctx *ctx = aes_ctx(tfm); |
421 | padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt, 1); | 421 | padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt, 1); |
422 | } | 422 | } |
423 | 423 | ||
424 | static void | 424 | static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) |
425 | aes_decrypt(void *ctx_arg, uint8_t *out, const uint8_t *in) | ||
426 | { | 425 | { |
427 | struct aes_ctx *ctx = aes_ctx(ctx_arg); | 426 | struct aes_ctx *ctx = aes_ctx(tfm); |
428 | padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt, 1); | 427 | padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt, 1); |
429 | } | 428 | } |
430 | 429 | ||
431 | static unsigned int aes_encrypt_ecb(const struct cipher_desc *desc, u8 *out, | 430 | static unsigned int aes_encrypt_ecb(const struct cipher_desc *desc, u8 *out, |
432 | const u8 *in, unsigned int nbytes) | 431 | const u8 *in, unsigned int nbytes) |
433 | { | 432 | { |
434 | struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm)); | 433 | struct aes_ctx *ctx = aes_ctx(desc->tfm); |
435 | padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt, | 434 | padlock_xcrypt_ecb(in, out, ctx->E, &ctx->cword.encrypt, |
436 | nbytes / AES_BLOCK_SIZE); | 435 | nbytes / AES_BLOCK_SIZE); |
437 | return nbytes & ~(AES_BLOCK_SIZE - 1); | 436 | return nbytes & ~(AES_BLOCK_SIZE - 1); |
@@ -440,7 +439,7 @@ static unsigned int aes_encrypt_ecb(const struct cipher_desc *desc, u8 *out, | |||
440 | static unsigned int aes_decrypt_ecb(const struct cipher_desc *desc, u8 *out, | 439 | static unsigned int aes_decrypt_ecb(const struct cipher_desc *desc, u8 *out, |
441 | const u8 *in, unsigned int nbytes) | 440 | const u8 *in, unsigned int nbytes) |
442 | { | 441 | { |
443 | struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm)); | 442 | struct aes_ctx *ctx = aes_ctx(desc->tfm); |
444 | padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt, | 443 | padlock_xcrypt_ecb(in, out, ctx->D, &ctx->cword.decrypt, |
445 | nbytes / AES_BLOCK_SIZE); | 444 | nbytes / AES_BLOCK_SIZE); |
446 | return nbytes & ~(AES_BLOCK_SIZE - 1); | 445 | return nbytes & ~(AES_BLOCK_SIZE - 1); |
@@ -449,7 +448,7 @@ static unsigned int aes_decrypt_ecb(const struct cipher_desc *desc, u8 *out, | |||
449 | static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out, | 448 | static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out, |
450 | const u8 *in, unsigned int nbytes) | 449 | const u8 *in, unsigned int nbytes) |
451 | { | 450 | { |
452 | struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm)); | 451 | struct aes_ctx *ctx = aes_ctx(desc->tfm); |
453 | u8 *iv; | 452 | u8 *iv; |
454 | 453 | ||
455 | iv = padlock_xcrypt_cbc(in, out, ctx->E, desc->info, | 454 | iv = padlock_xcrypt_cbc(in, out, ctx->E, desc->info, |
@@ -462,7 +461,7 @@ static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out, | |||
462 | static unsigned int aes_decrypt_cbc(const struct cipher_desc *desc, u8 *out, | 461 | static unsigned int aes_decrypt_cbc(const struct cipher_desc *desc, u8 *out, |
463 | const u8 *in, unsigned int nbytes) | 462 | const u8 *in, unsigned int nbytes) |
464 | { | 463 | { |
465 | struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm)); | 464 | struct aes_ctx *ctx = aes_ctx(desc->tfm); |
466 | padlock_xcrypt_cbc(in, out, ctx->D, desc->info, &ctx->cword.decrypt, | 465 | padlock_xcrypt_cbc(in, out, ctx->D, desc->info, &ctx->cword.decrypt, |
467 | nbytes / AES_BLOCK_SIZE); | 466 | nbytes / AES_BLOCK_SIZE); |
468 | return nbytes & ~(AES_BLOCK_SIZE - 1); | 467 | return nbytes & ~(AES_BLOCK_SIZE - 1); |
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 5a0470e36111..ef918803ec30 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -66,7 +66,7 @@ struct crypto_tfm; | |||
66 | 66 | ||
67 | struct cipher_desc { | 67 | struct cipher_desc { |
68 | struct crypto_tfm *tfm; | 68 | struct crypto_tfm *tfm; |
69 | void (*crfn)(void *ctx, u8 *dst, const u8 *src); | 69 | void (*crfn)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); |
70 | unsigned int (*prfn)(const struct cipher_desc *desc, u8 *dst, | 70 | unsigned int (*prfn)(const struct cipher_desc *desc, u8 *dst, |
71 | const u8 *src, unsigned int nbytes); | 71 | const u8 *src, unsigned int nbytes); |
72 | void *info; | 72 | void *info; |
@@ -79,10 +79,10 @@ struct cipher_desc { | |||
79 | struct cipher_alg { | 79 | struct cipher_alg { |
80 | unsigned int cia_min_keysize; | 80 | unsigned int cia_min_keysize; |
81 | unsigned int cia_max_keysize; | 81 | unsigned int cia_max_keysize; |
82 | int (*cia_setkey)(void *ctx, const u8 *key, | 82 | int (*cia_setkey)(struct crypto_tfm *tfm, const u8 *key, |
83 | unsigned int keylen, u32 *flags); | 83 | unsigned int keylen, u32 *flags); |
84 | void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); | 84 | void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); |
85 | void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); | 85 | void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); |
86 | 86 | ||
87 | unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc, | 87 | unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc, |
88 | u8 *dst, const u8 *src, | 88 | u8 *dst, const u8 *src, |
@@ -100,20 +100,21 @@ struct cipher_alg { | |||
100 | 100 | ||
101 | struct digest_alg { | 101 | struct digest_alg { |
102 | unsigned int dia_digestsize; | 102 | unsigned int dia_digestsize; |
103 | void (*dia_init)(void *ctx); | 103 | void (*dia_init)(struct crypto_tfm *tfm); |
104 | void (*dia_update)(void *ctx, const u8 *data, unsigned int len); | 104 | void (*dia_update)(struct crypto_tfm *tfm, const u8 *data, |
105 | void (*dia_final)(void *ctx, u8 *out); | 105 | unsigned int len); |
106 | int (*dia_setkey)(void *ctx, const u8 *key, | 106 | void (*dia_final)(struct crypto_tfm *tfm, u8 *out); |
107 | int (*dia_setkey)(struct crypto_tfm *tfm, const u8 *key, | ||
107 | unsigned int keylen, u32 *flags); | 108 | unsigned int keylen, u32 *flags); |
108 | }; | 109 | }; |
109 | 110 | ||
110 | struct compress_alg { | 111 | struct compress_alg { |
111 | int (*coa_init)(void *ctx); | 112 | int (*coa_init)(struct crypto_tfm *tfm); |
112 | void (*coa_exit)(void *ctx); | 113 | void (*coa_exit)(struct crypto_tfm *tfm); |
113 | int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen, | 114 | int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src, |
114 | u8 *dst, unsigned int *dlen); | 115 | unsigned int slen, u8 *dst, unsigned int *dlen); |
115 | int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen, | 116 | int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src, |
116 | u8 *dst, unsigned int *dlen); | 117 | unsigned int slen, u8 *dst, unsigned int *dlen); |
117 | }; | 118 | }; |
118 | 119 | ||
119 | #define cra_cipher cra_u.cipher | 120 | #define cra_cipher cra_u.cipher |