aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tgr192.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/tgr192.c')
-rw-r--r--crypto/tgr192.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/crypto/tgr192.c b/crypto/tgr192.c
index 2d8e44f6fbe9..a0fadf3dd3e2 100644
--- a/crypto/tgr192.c
+++ b/crypto/tgr192.c
@@ -496,11 +496,10 @@ static void tgr192_transform(struct tgr192_ctx *tctx, const u8 * data)
496 tctx->c = c; 496 tctx->c = c;
497} 497}
498 498
499static void tgr192_init(void *ctx) 499static 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 memset (tctx->hash, 0, 64);
504 tctx->a = 0x0123456789abcdefULL; 503 tctx->a = 0x0123456789abcdefULL;
505 tctx->b = 0xfedcba9876543210ULL; 504 tctx->b = 0xfedcba9876543210ULL;
506 tctx->c = 0xf096a5b4c3b2e187ULL; 505 tctx->c = 0xf096a5b4c3b2e187ULL;
@@ -511,9 +510,10 @@ static void tgr192_init(void *ctx)
511 510
512/* Update the message digest with the contents 511/* Update the message digest with the contents
513 * of INBUF with length INLEN. */ 512 * of INBUF with length INLEN. */
514static void tgr192_update(void *ctx, const u8 * inbuf, unsigned int len) 513static void tgr192_update(struct crypto_tfm *tfm, const u8 *inbuf,
514 unsigned int len)
515{ 515{
516 struct tgr192_ctx *tctx = ctx; 516 struct tgr192_ctx *tctx = crypto_tfm_ctx(tfm);
517 517
518 if (tctx->count == 64) { /* flush the buffer */ 518 if (tctx->count == 64) { /* flush the buffer */
519 tgr192_transform(tctx, tctx->hash); 519 tgr192_transform(tctx, tctx->hash);
@@ -527,7 +527,7 @@ static void tgr192_update(void *ctx, const u8 * inbuf, unsigned int len)
527 for (; len && tctx->count < 64; len--) { 527 for (; len && tctx->count < 64; len--) {
528 tctx->hash[tctx->count++] = *inbuf++; 528 tctx->hash[tctx->count++] = *inbuf++;
529 } 529 }
530 tgr192_update(tctx, NULL, 0); 530 tgr192_update(tfm, NULL, 0);
531 if (!len) { 531 if (!len) {
532 return; 532 return;
533 } 533 }
@@ -549,15 +549,15 @@ static void tgr192_update(void *ctx, const u8 * inbuf, unsigned int len)
549 549
550 550
551/* The routine terminates the computation */ 551/* The routine terminates the computation */
552static void tgr192_final(void *ctx, u8 * out) 552static void tgr192_final(struct crypto_tfm *tfm, u8 * out)
553{ 553{
554 struct tgr192_ctx *tctx = ctx; 554 struct tgr192_ctx *tctx = crypto_tfm_ctx(tfm);
555 __be64 *dst = (__be64 *)out; 555 __be64 *dst = (__be64 *)out;
556 __be64 *be64p; 556 __be64 *be64p;
557 __le32 *le32p; 557 __le32 *le32p;
558 u32 t, msb, lsb; 558 u32 t, msb, lsb;
559 559
560 tgr192_update(tctx, NULL, 0); /* flush */ ; 560 tgr192_update(tfm, NULL, 0); /* flush */ ;
561 561
562 msb = 0; 562 msb = 0;
563 t = tctx->nblocks; 563 t = tctx->nblocks;
@@ -585,7 +585,7 @@ static void tgr192_final(void *ctx, u8 * out)
585 while (tctx->count < 64) { 585 while (tctx->count < 64) {
586 tctx->hash[tctx->count++] = 0; 586 tctx->hash[tctx->count++] = 0;
587 } 587 }
588 tgr192_update(tctx, NULL, 0); /* flush */ ; 588 tgr192_update(tfm, NULL, 0); /* flush */ ;
589 memset(tctx->hash, 0, 56); /* fill next block with zeroes */ 589 memset(tctx->hash, 0, 56); /* fill next block with zeroes */
590 } 590 }
591 /* append the 64 bit count */ 591 /* append the 64 bit count */
@@ -601,22 +601,20 @@ static void tgr192_final(void *ctx, u8 * out)
601 dst[2] = be64p[2] = cpu_to_be64(tctx->c); 601 dst[2] = be64p[2] = cpu_to_be64(tctx->c);
602} 602}
603 603
604static void tgr160_final(void *ctx, u8 * out) 604static void tgr160_final(struct crypto_tfm *tfm, u8 * out)
605{ 605{
606 struct tgr192_ctx *wctx = ctx;
607 u8 D[64]; 606 u8 D[64];
608 607
609 tgr192_final(wctx, D); 608 tgr192_final(tfm, D);
610 memcpy(out, D, TGR160_DIGEST_SIZE); 609 memcpy(out, D, TGR160_DIGEST_SIZE);
611 memset(D, 0, TGR192_DIGEST_SIZE); 610 memset(D, 0, TGR192_DIGEST_SIZE);
612} 611}
613 612
614static void tgr128_final(void *ctx, u8 * out) 613static void tgr128_final(struct crypto_tfm *tfm, u8 * out)
615{ 614{
616 struct tgr192_ctx *wctx = ctx;
617 u8 D[64]; 615 u8 D[64];
618 616
619 tgr192_final(wctx, D); 617 tgr192_final(tfm, D);
620 memcpy(out, D, TGR128_DIGEST_SIZE); 618 memcpy(out, D, TGR128_DIGEST_SIZE);
621 memset(D, 0, TGR192_DIGEST_SIZE); 619 memset(D, 0, TGR192_DIGEST_SIZE);
622} 620}
@@ -627,6 +625,7 @@ static struct crypto_alg tgr192 = {
627 .cra_blocksize = TGR192_BLOCK_SIZE, 625 .cra_blocksize = TGR192_BLOCK_SIZE,
628 .cra_ctxsize = sizeof(struct tgr192_ctx), 626 .cra_ctxsize = sizeof(struct tgr192_ctx),
629 .cra_module = THIS_MODULE, 627 .cra_module = THIS_MODULE,
628 .cra_alignmask = 7,
630 .cra_list = LIST_HEAD_INIT(tgr192.cra_list), 629 .cra_list = LIST_HEAD_INIT(tgr192.cra_list),
631 .cra_u = {.digest = { 630 .cra_u = {.digest = {
632 .dia_digestsize = TGR192_DIGEST_SIZE, 631 .dia_digestsize = TGR192_DIGEST_SIZE,
@@ -641,6 +640,7 @@ static struct crypto_alg tgr160 = {
641 .cra_blocksize = TGR192_BLOCK_SIZE, 640 .cra_blocksize = TGR192_BLOCK_SIZE,
642 .cra_ctxsize = sizeof(struct tgr192_ctx), 641 .cra_ctxsize = sizeof(struct tgr192_ctx),
643 .cra_module = THIS_MODULE, 642 .cra_module = THIS_MODULE,
643 .cra_alignmask = 7,
644 .cra_list = LIST_HEAD_INIT(tgr160.cra_list), 644 .cra_list = LIST_HEAD_INIT(tgr160.cra_list),
645 .cra_u = {.digest = { 645 .cra_u = {.digest = {
646 .dia_digestsize = TGR160_DIGEST_SIZE, 646 .dia_digestsize = TGR160_DIGEST_SIZE,
@@ -655,6 +655,7 @@ static struct crypto_alg tgr128 = {
655 .cra_blocksize = TGR192_BLOCK_SIZE, 655 .cra_blocksize = TGR192_BLOCK_SIZE,
656 .cra_ctxsize = sizeof(struct tgr192_ctx), 656 .cra_ctxsize = sizeof(struct tgr192_ctx),
657 .cra_module = THIS_MODULE, 657 .cra_module = THIS_MODULE,
658 .cra_alignmask = 7,
658 .cra_list = LIST_HEAD_INIT(tgr128.cra_list), 659 .cra_list = LIST_HEAD_INIT(tgr128.cra_list),
659 .cra_u = {.digest = { 660 .cra_u = {.digest = {
660 .dia_digestsize = TGR128_DIGEST_SIZE, 661 .dia_digestsize = TGR128_DIGEST_SIZE,