Browse files

correctly processed full buffer in skein{256|512}

  • Loading branch information...
1 parent c926c40 commit 15a1ae5edda1d0d6749c90e093f8988fe66e6580 @vincenthz committed Aug 11, 2010
Showing with 12 additions and 2 deletions.
  1. +6 −1 cbits/skein256.c
  2. +6 −1 cbits/skein512.c
View
7 cbits/skein256.c
@@ -126,8 +126,13 @@ void skein256_update(struct skein256_ctx *ctx, uint8_t *data, uint32_t len)
to_fill = 32 - ctx->bufindex;
+ if (ctx->bufindex == 32) {
+ skein256_do_chunk(ctx, (uint64_t *) ctx->buf, 32);
+ ctx->bufindex = 0;
+ }
+
/* process partial buffer if there's enough data to make a block */
- if ((ctx->bufindex & 0x1f) && len >= to_fill) {
+ if (ctx->bufindex && len >= to_fill) {
memcpy(ctx->buf + ctx->bufindex, data, to_fill);
skein256_do_chunk(ctx, (uint64_t *) ctx->buf, 32);
len -= to_fill;
View
7 cbits/skein512.c
@@ -144,8 +144,13 @@ void skein512_update(struct skein512_ctx *ctx, uint8_t *data, uint32_t len)
to_fill = 64 - ctx->bufindex;
+ if (ctx->bufindex == 64) {
+ skein512_do_chunk(ctx, (uint64_t *) ctx->buf, 64);
+ ctx->bufindex = 0;
+ }
+
/* process partial buffer if there's enough data to make a block */
- if ((ctx->bufindex & 0x3f) && len >= to_fill) {
+ if (ctx->bufindex && len >= to_fill) {
memcpy(ctx->buf + ctx->bufindex, data, to_fill);
skein512_do_chunk(ctx, (uint64_t *) ctx->buf, 64);
len -= to_fill;

0 comments on commit 15a1ae5

Please sign in to comment.