summaryrefslogtreecommitdiff
path: root/poly1305-internal.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2014-01-20 21:49:47 +0100
committerNiels Möller <nisse@lysator.liu.se>2014-01-20 21:49:47 +0100
commitdca9abf1c41fb1c0b51c75ca8decac4b27c26671 (patch)
tree8d83cb1447310bdbc82891432439478b75c784ed /poly1305-internal.c
parentefdf4f4b86dc166ecd4fd0d2847eaf10202cee53 (diff)
downloadnettle-dca9abf1c41fb1c0b51c75ca8decac4b27c26671.tar.gz
poly1305_digest: Use union nettle_block16.
Diffstat (limited to 'poly1305-internal.c')
-rw-r--r--poly1305-internal.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/poly1305-internal.c b/poly1305-internal.c
index b33a3c9d..8c5a7496 100644
--- a/poly1305-internal.c
+++ b/poly1305-internal.c
@@ -86,7 +86,7 @@ poly1305_set_key(struct poly1305_ctx *ctx, const uint8_t key[16])
}
void
-_poly1305_block (struct poly1305_ctx *ctx, const uint8_t m[16], unsigned t4)
+_poly1305_block (struct poly1305_ctx *ctx, const uint8_t *m, unsigned t4)
{
uint32_t t0,t1,t2,t3;
uint32_t b;
@@ -121,7 +121,7 @@ _poly1305_block (struct poly1305_ctx *ctx, const uint8_t m[16], unsigned t4)
/* Adds digest to the nonce */
void
-poly1305_digest (struct poly1305_ctx *ctx, uint8_t *s)
+poly1305_digest (struct poly1305_ctx *ctx, union nettle_block16 *s)
{
uint32_t b, nb;
uint64_t f0,f1,f2,f3;
@@ -149,18 +149,19 @@ poly1305_digest (struct poly1305_ctx *ctx, uint8_t *s)
ctx->h3 = (ctx->h3 & nb) | (g3 & b);
ctx->h4 = (ctx->h4 & nb) | (g4 & b);
- f0 = ((ctx->h0 ) | (ctx->h1 << 26)) + (uint64_t)LE_READ_UINT32(s);
- f1 = ((ctx->h1 >> 6) | (ctx->h2 << 20)) + (uint64_t)LE_READ_UINT32(s+4);
- f2 = ((ctx->h2 >> 12) | (ctx->h3 << 14)) + (uint64_t)LE_READ_UINT32(s+8);
- f3 = ((ctx->h3 >> 18) | (ctx->h4 << 8)) + (uint64_t)LE_READ_UINT32(s+12);
+ /* FIXME: Take advantage of s being aligned as an unsigned long. */
+ f0 = ((ctx->h0 )|(ctx->h1<<26)) + (uint64_t)LE_READ_UINT32(s->b);
+ f1 = ((ctx->h1>> 6)|(ctx->h2<<20)) + (uint64_t)LE_READ_UINT32(s->b+4);
+ f2 = ((ctx->h2>>12)|(ctx->h3<<14)) + (uint64_t)LE_READ_UINT32(s->b+8);
+ f3 = ((ctx->h3>>18)|(ctx->h4<< 8)) + (uint64_t)LE_READ_UINT32(s->b+12);
- LE_WRITE_UINT32(s, f0);
+ LE_WRITE_UINT32(s->b, f0);
f1 += (f0 >> 32);
- LE_WRITE_UINT32(s+4, f1);
+ LE_WRITE_UINT32(s->b+4, f1);
f2 += (f1 >> 32);
- LE_WRITE_UINT32(s+8, f2);
+ LE_WRITE_UINT32(s->b+8, f2);
f3 += (f2 >> 32);
- LE_WRITE_UINT32(s+12, f3);
+ LE_WRITE_UINT32(s->b+12, f3);
ctx->h0 = 0;
ctx->h1 = 0;