diff options
Diffstat (limited to 'crypto/serpent.c')
-rw-r--r-- | crypto/serpent.c | 27 |
1 files changed, 16 insertions, 11 deletions
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]); |