Lines Matching refs:ctx

16 void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const uint8_t *blkPtr,
18 void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const uint8_t *blkPtr,
20 void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx, const uint8_t *blkPtr,
26 Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen)
34 ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
39 bcopy(SKEIN_256_IV_256, ctx->X, sizeof (ctx->X));
42 bcopy(SKEIN_256_IV_224, ctx->X, sizeof (ctx->X));
45 bcopy(SKEIN_256_IV_160, ctx->X, sizeof (ctx->X));
48 bcopy(SKEIN_256_IV_128, ctx->X, sizeof (ctx->X));
58 Skein_Start_New_Type(ctx, CFG_FINAL);
70 bzero(ctx->X, sizeof (ctx->X));
71 Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
75 * The chaining vars ctx->X are now initialized for the given
79 Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */
90 Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, uint64_t treeInfo,
101 /* compute the initial chaining values ctx->X[], based on key */
104 bzero(ctx->X, sizeof (ctx->X));
107 Skein_assert(sizeof (cfg.b) >= sizeof (ctx->X));
110 ctx->h.hashBitLen = 8 * sizeof (ctx->X);
112 Skein_Start_New_Type(ctx, KEY);
114 bzero(ctx->X, sizeof (ctx->X));
116 (void) Skein_256_Update(ctx, key, keyBytes);
118 (void) Skein_256_Final_Pad(ctx, cfg.b);
119 /* copy over into ctx->X[] */
120 bcopy(cfg.b, ctx->X, sizeof (cfg.b));
126 ctx->X[i] = Skein_Swap64(ctx->X[i]);
134 ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
135 Skein_Start_New_Type(ctx, CFG_FINAL);
143 Skein_Show_Key(256, &ctx->h, key, keyBytes);
146 Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
148 /* The chaining vars ctx->X are now initialized */
150 ctx->h.bCnt = 0; /* buffer b[] starts out empty */
151 Skein_Start_New_Type(ctx, MSG);
158 Skein_256_Update(Skein_256_Ctxt_t *ctx, const uint8_t *msg, size_t msgByteCnt)
163 Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
166 if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) {
168 if (ctx->h.bCnt) {
170 n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt;
174 bcopy(msg, &ctx->b[ctx->h.bCnt], n);
177 ctx->h.bCnt += n;
179 Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES);
180 Skein_256_Process_Block(ctx, ctx->b, 1,
182 ctx->h.bCnt = 0;
191 Skein_256_Process_Block(ctx, msg, n,
196 Skein_assert(ctx->h.bCnt == 0);
201 Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES);
202 bcopy(msg, &ctx->b[ctx->h.bCnt], msgByteCnt);
203 ctx->h.bCnt += msgByteCnt;
211 Skein_256_Final(Skein_256_Ctxt_t *ctx, uint8_t *hashVal)
217 Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
219 ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */
221 if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES)
222 bzero(&ctx->b[ctx->h.bCnt],
223 SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
226 Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
230 byteCnt = (ctx->h.hashBitLen + 7) >> 3;
234 bzero(ctx->b, sizeof (ctx->b));
236 bcopy(ctx->X, X, sizeof (X));
240 bcopy(&tmp, ctx->b, sizeof (tmp));
241 Skein_Start_New_Type(ctx, OUT_FINAL);
243 Skein_256_Process_Block(ctx, ctx->b, 1, sizeof (uint64_t));
249 ctx->X, n); /* "output" the ctr mode bytes */
250 Skein_Show_Final(256, &ctx->h, n,
253 bcopy(X, ctx->X, sizeof (X));
262 Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen)
270 ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
275 bcopy(SKEIN_512_IV_512, ctx->X, sizeof (ctx->X));
278 bcopy(SKEIN_512_IV_384, ctx->X, sizeof (ctx->X));
281 bcopy(SKEIN_512_IV_256, ctx->X, sizeof (ctx->X));
284 bcopy(SKEIN_512_IV_224, ctx->X, sizeof (ctx->X));
294 Skein_Start_New_Type(ctx, CFG_FINAL);
306 bzero(ctx->X, sizeof (ctx->X));
307 Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
312 * The chaining vars ctx->X are now initialized for the given
316 Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */
327 Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, uint64_t treeInfo,
338 /* compute the initial chaining values ctx->X[], based on key */
341 bzero(ctx->X, sizeof (ctx->X));
344 Skein_assert(sizeof (cfg.b) >= sizeof (ctx->X));
347 ctx->h.hashBitLen = 8 * sizeof (ctx->X);
349 Skein_Start_New_Type(ctx, KEY);
351 bzero(ctx->X, sizeof (ctx->X));
352 (void) Skein_512_Update(ctx, key, keyBytes); /* hash the key */
354 (void) Skein_512_Final_Pad(ctx, cfg.b);
355 /* copy over into ctx->X[] */
356 bcopy(cfg.b, ctx->X, sizeof (cfg.b));
362 ctx->X[i] = Skein_Swap64(ctx->X[i]);
370 ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
371 Skein_Start_New_Type(ctx, CFG_FINAL);
379 Skein_Show_Key(512, &ctx->h, key, keyBytes);
382 Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
384 /* The chaining vars ctx->X are now initialized */
386 ctx->h.bCnt = 0; /* buffer b[] starts out empty */
387 Skein_Start_New_Type(ctx, MSG);
394 Skein_512_Update(Skein_512_Ctxt_t *ctx, const uint8_t *msg, size_t msgByteCnt)
399 Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
402 if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) {
404 if (ctx->h.bCnt) {
406 n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt;
410 bcopy(msg, &ctx->b[ctx->h.bCnt], n);
413 ctx->h.bCnt += n;
415 Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES);
416 Skein_512_Process_Block(ctx, ctx->b, 1,
418 ctx->h.bCnt = 0;
427 Skein_512_Process_Block(ctx, msg, n,
432 Skein_assert(ctx->h.bCnt == 0);
437 Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES);
438 bcopy(msg, &ctx->b[ctx->h.bCnt], msgByteCnt);
439 ctx->h.bCnt += msgByteCnt;
447 Skein_512_Final(Skein_512_Ctxt_t *ctx, uint8_t *hashVal)
453 Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
455 ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */
457 if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
458 bzero(&ctx->b[ctx->h.bCnt],
459 SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
462 Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
466 byteCnt = (ctx->h.hashBitLen + 7) >> 3;
470 bzero(ctx->b, sizeof (ctx->b));
472 bcopy(ctx->X, X, sizeof (X));
476 bcopy(&tmp, ctx->b, sizeof (tmp));
477 Skein_Start_New_Type(ctx, OUT_FINAL);
479 Skein_512_Process_Block(ctx, ctx->b, 1, sizeof (uint64_t));
485 ctx->X, n); /* "output" the ctr mode bytes */
486 Skein_Show_Final(512, &ctx->h, n,
489 bcopy(X, ctx->X, sizeof (X));
498 Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen)
506 ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
511 bcopy(SKEIN1024_IV_512, ctx->X, sizeof (ctx->X));
514 bcopy(SKEIN1024_IV_384, ctx->X, sizeof (ctx->X));
517 bcopy(SKEIN1024_IV_1024, ctx->X, sizeof (ctx->X));
527 Skein_Start_New_Type(ctx, CFG_FINAL);
539 bzero(ctx->X, sizeof (ctx->X));
540 Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
545 * The chaining vars ctx->X are now initialized for the given
549 Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */
560 Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen, uint64_t treeInfo,
571 /* compute the initial chaining values ctx->X[], based on key */
574 bzero(ctx->X, sizeof (ctx->X));
576 Skein_assert(sizeof (cfg.b) >= sizeof (ctx->X));
579 ctx->h.hashBitLen = 8 * sizeof (ctx->X);
581 Skein_Start_New_Type(ctx, KEY);
583 bzero(ctx->X, sizeof (ctx->X));
584 (void) Skein1024_Update(ctx, key, keyBytes); /* hash the key */
586 (void) Skein1024_Final_Pad(ctx, cfg.b);
587 /* copy over into ctx->X[] */
588 bcopy(cfg.b, ctx->X, sizeof (cfg.b));
594 ctx->X[i] = Skein_Swap64(ctx->X[i]);
602 ctx->h.hashBitLen = hashBitLen; /* output hash bit count */
603 Skein_Start_New_Type(ctx, CFG_FINAL);
612 Skein_Show_Key(1024, &ctx->h, key, keyBytes);
615 Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN);
617 /* The chaining vars ctx->X are now initialized */
619 ctx->h.bCnt = 0; /* buffer b[] starts out empty */
620 Skein_Start_New_Type(ctx, MSG);
627 Skein1024_Update(Skein1024_Ctxt_t *ctx, const uint8_t *msg, size_t msgByteCnt)
632 Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
635 if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) {
637 if (ctx->h.bCnt) {
639 n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt;
643 bcopy(msg, &ctx->b[ctx->h.bCnt], n);
646 ctx->h.bCnt += n;
648 Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES);
649 Skein1024_Process_Block(ctx, ctx->b, 1,
651 ctx->h.bCnt = 0;
660 Skein1024_Process_Block(ctx, msg, n,
665 Skein_assert(ctx->h.bCnt == 0);
670 Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES);
671 bcopy(msg, &ctx->b[ctx->h.bCnt], msgByteCnt);
672 ctx->h.bCnt += msgByteCnt;
680 Skein1024_Final(Skein1024_Ctxt_t *ctx, uint8_t *hashVal)
686 Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
688 ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */
690 if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES)
691 bzero(&ctx->b[ctx->h.bCnt],
692 SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
695 Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
699 byteCnt = (ctx->h.hashBitLen + 7) >> 3;
703 bzero(ctx->b, sizeof (ctx->b));
705 bcopy(ctx->X, X, sizeof (X));
709 bcopy(&tmp, ctx->b, sizeof (tmp));
710 Skein_Start_New_Type(ctx, OUT_FINAL);
712 Skein1024_Process_Block(ctx, ctx->b, 1, sizeof (uint64_t));
718 ctx->X, n); /* "output" the ctr mode bytes */
719 Skein_Show_Final(1024, &ctx->h, n,
722 bcopy(X, ctx->X, sizeof (X));
732 Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, uint8_t *hashVal)
735 Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
737 ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */
739 if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES)
740 bzero(&ctx->b[ctx->h.bCnt],
741 SKEIN_256_BLOCK_BYTES - ctx->h.bCnt);
743 Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
746 Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES);
753 Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, uint8_t *hashVal)
756 Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
758 ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */
760 if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES)
761 bzero(&ctx->b[ctx->h.bCnt],
762 SKEIN_512_BLOCK_BYTES - ctx->h.bCnt);
764 Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
767 Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES);
774 Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, uint8_t *hashVal)
777 Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
780 ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL;
782 if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES)
783 bzero(&ctx->b[ctx->h.bCnt],
784 SKEIN1024_BLOCK_BYTES - ctx->h.bCnt);
786 Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt);
789 Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES);
797 Skein_256_Output(Skein_256_Ctxt_t *ctx, uint8_t *hashVal)
803 Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL);
807 byteCnt = (ctx->h.hashBitLen + 7) >> 3;
811 bzero(ctx->b, sizeof (ctx->b));
813 bcopy(ctx->X, X, sizeof (X));
817 bcopy(&tmp, ctx->b, sizeof (tmp));
818 Skein_Start_New_Type(ctx, OUT_FINAL);
820 Skein_256_Process_Block(ctx, ctx->b, 1, sizeof (uint64_t));
826 ctx->X, n); /* "output" the ctr mode bytes */
827 Skein_Show_Final(256, &ctx->h, n,
830 bcopy(X, ctx->X, sizeof (X));
837 Skein_512_Output(Skein_512_Ctxt_t *ctx, uint8_t *hashVal)
843 Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL);
847 byteCnt = (ctx->h.hashBitLen + 7) >> 3;
851 bzero(ctx->b, sizeof (ctx->b));
853 bcopy(ctx->X, X, sizeof (X));
857 bcopy(&tmp, ctx->b, sizeof (tmp));
858 Skein_Start_New_Type(ctx, OUT_FINAL);
860 Skein_512_Process_Block(ctx, ctx->b, 1, sizeof (uint64_t));
866 ctx->X, n); /* "output" the ctr mode bytes */
867 Skein_Show_Final(256, &ctx->h, n,
870 bcopy(X, ctx->X, sizeof (X));
877 Skein1024_Output(Skein1024_Ctxt_t *ctx, uint8_t *hashVal)
883 Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL);
887 byteCnt = (ctx->h.hashBitLen + 7) >> 3;
891 bzero(ctx->b, sizeof (ctx->b));
893 bcopy(ctx->X, X, sizeof (X));
897 bcopy(&tmp, ctx->b, sizeof (tmp));
898 Skein_Start_New_Type(ctx, OUT_FINAL);
900 Skein1024_Process_Block(ctx, ctx->b, 1, sizeof (uint64_t));
906 ctx->X, n); /* "output" the ctr mode bytes */
907 Skein_Show_Final(256, &ctx->h, n,
910 bcopy(X, ctx->X, sizeof (X));