diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-05-16 08:09:29 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-06-26 03:34:39 -0400 |
commit | 6c2bb98bc33ae33c7a33a133a4cd5a06395fece5 (patch) | |
tree | 96684cd2c473cd05d651ce1fa3dd72b1b4b19b09 /crypto/tgr192.c | |
parent | 43600106e32809a4dead79fec67a63e9860e3d5d (diff) |
[CRYPTO] all: Pass tfm instead of ctx to algorithms
Up until now algorithms have been happy to get a context pointer since
they know everything that's in the tfm already (e.g., alignment, block
size).
However, once we have parameterised algorithms, such information will
be specific to each tfm. So the algorithm API needs to be changed to
pass the tfm structure instead of the context pointer.
This patch is basically a text substitution. The only tricky bit is
the assembly routines that need to get the context pointer offset
through asm-offsets.h.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tgr192.c')
-rw-r--r-- | crypto/tgr192.c | 29 |
1 files changed, 14 insertions, 15 deletions
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 | } |