Lines Matching refs:ctx

77 #define	SHA512Transform(ctx, in) SHA512TransformBlocks((ctx), (in), 1)
78 #define SHA256Transform(ctx, in) SHA256TransformBlocks((ctx), (in), 1)
80 void SHA512TransformBlocks(SHA2_CTX *ctx, const void *in, size_t num);
81 void SHA256TransformBlocks(SHA2_CTX *ctx, const void *in, size_t num);
157 SHA256Transform(SHA2_CTX *ctx, const uint8_t *blk)
159 uint32_t a = ctx->state.s32[0];
160 uint32_t b = ctx->state.s32[1];
161 uint32_t c = ctx->state.s32[2];
162 uint32_t d = ctx->state.s32[3];
163 uint32_t e = ctx->state.s32[4];
164 uint32_t f = ctx->state.s32[5];
165 uint32_t g = ctx->state.s32[6];
166 uint32_t h = ctx->state.s32[7];
200 bcopy(blk, ctx->buf_un.buf32, sizeof (ctx->buf_un.buf32));
201 blk = (uint8_t *)ctx->buf_un.buf32;
352 ctx->state.s32[0] += a;
353 ctx->state.s32[1] += b;
354 ctx->state.s32[2] += c;
355 ctx->state.s32[3] += d;
356 ctx->state.s32[4] += e;
357 ctx->state.s32[5] += f;
358 ctx->state.s32[6] += g;
359 ctx->state.s32[7] += h;
366 SHA512Transform(SHA2_CTX *ctx, const uint8_t *blk)
369 uint64_t a = ctx->state.s64[0];
370 uint64_t b = ctx->state.s64[1];
371 uint64_t c = ctx->state.s64[2];
372 uint64_t d = ctx->state.s64[3];
373 uint64_t e = ctx->state.s64[4];
374 uint64_t f = ctx->state.s64[5];
375 uint64_t g = ctx->state.s64[6];
376 uint64_t h = ctx->state.s64[7];
416 bcopy(blk, ctx->buf_un.buf64, sizeof (ctx->buf_un.buf64));
417 blk = (uint8_t *)ctx->buf_un.buf64;
601 ctx->state.s64[0] += a;
602 ctx->state.s64[1] += b;
603 ctx->state.s64[2] += c;
604 ctx->state.s64[3] += d;
605 ctx->state.s64[4] += e;
606 ctx->state.s64[5] += f;
607 ctx->state.s64[6] += g;
608 ctx->state.s64[7] += h;
681 SHA2Init(uint64_t mech, SHA2_CTX *ctx)
688 ctx->state.s32[0] = 0x6a09e667U;
689 ctx->state.s32[1] = 0xbb67ae85U;
690 ctx->state.s32[2] = 0x3c6ef372U;
691 ctx->state.s32[3] = 0xa54ff53aU;
692 ctx->state.s32[4] = 0x510e527fU;
693 ctx->state.s32[5] = 0x9b05688cU;
694 ctx->state.s32[6] = 0x1f83d9abU;
695 ctx->state.s32[7] = 0x5be0cd19U;
700 ctx->state.s64[0] = 0xcbbb9d5dc1059ed8ULL;
701 ctx->state.s64[1] = 0x629a292a367cd507ULL;
702 ctx->state.s64[2] = 0x9159015a3070dd17ULL;
703 ctx->state.s64[3] = 0x152fecd8f70e5939ULL;
704 ctx->state.s64[4] = 0x67332667ffc00b31ULL;
705 ctx->state.s64[5] = 0x8eb44a8768581511ULL;
706 ctx->state.s64[6] = 0xdb0c2e0d64f98fa7ULL;
707 ctx->state.s64[7] = 0x47b5481dbefa4fa4ULL;
712 ctx->state.s64[0] = 0x6a09e667f3bcc908ULL;
713 ctx->state.s64[1] = 0xbb67ae8584caa73bULL;
714 ctx->state.s64[2] = 0x3c6ef372fe94f82bULL;
715 ctx->state.s64[3] = 0xa54ff53a5f1d36f1ULL;
716 ctx->state.s64[4] = 0x510e527fade682d1ULL;
717 ctx->state.s64[5] = 0x9b05688c2b3e6c1fULL;
718 ctx->state.s64[6] = 0x1f83d9abfb41bd6bULL;
719 ctx->state.s64[7] = 0x5be0cd19137e2179ULL;
722 ctx->state.s64[0] = 0x8C3D37C819544DA2ULL;
723 ctx->state.s64[1] = 0x73E1996689DCD4D6ULL;
724 ctx->state.s64[2] = 0x1DFAB7AE32FF9C82ULL;
725 ctx->state.s64[3] = 0x679DD514582F9FCFULL;
726 ctx->state.s64[4] = 0x0F6D2B697BD44DA8ULL;
727 ctx->state.s64[5] = 0x77E36F7304C48942ULL;
728 ctx->state.s64[6] = 0x3F9D85A86A1D36C8ULL;
729 ctx->state.s64[7] = 0x1112E6AD91D692A1ULL;
732 ctx->state.s64[0] = 0x22312194FC2BF72CULL;
733 ctx->state.s64[1] = 0x9F555FA3C84C64C2ULL;
734 ctx->state.s64[2] = 0x2393B86B6F53B151ULL;
735 ctx->state.s64[3] = 0x963877195940EABDULL;
736 ctx->state.s64[4] = 0x96283EE2A88EFFE3ULL;
737 ctx->state.s64[5] = 0xBE5E1E2553863992ULL;
738 ctx->state.s64[6] = 0x2B0199FC2C85B8AAULL;
739 ctx->state.s64[7] = 0x0EB72DDC81C52CA2ULL;
750 ctx->algotype = (uint32_t)mech;
751 ctx->count.c64[0] = ctx->count.c64[1] = 0;
758 SHA256Init(SHA256_CTX *ctx)
760 SHA2Init(SHA256, ctx);
764 SHA384Init(SHA384_CTX *ctx)
766 SHA2Init(SHA384, ctx);
770 SHA512Init(SHA512_CTX *ctx)
772 SHA2Init(SHA512, ctx);
789 SHA2Update(SHA2_CTX *ctx, const void *inptr, size_t input_len)
793 uint32_t algotype = ctx->algotype;
807 buf_index = (ctx->count.c32[1] >> 3) & 0x3F;
810 if ((ctx->count.c32[1] += (input_len << 3)) < (input_len << 3))
811 ctx->count.c32[0]++;
813 ctx->count.c32[0] += (input_len >> 29);
819 buf_index = (ctx->count.c64[1] >> 3) & 0x7F;
822 if ((ctx->count.c64[1] += (input_len << 3)) < (input_len << 3))
823 ctx->count.c64[0]++;
825 ctx->count.c64[0] += (input_len >> 29);
844 bcopy(input, &ctx->buf_un.buf8[buf_index], buf_len);
846 SHA256Transform(ctx, ctx->buf_un.buf8);
848 SHA512Transform(ctx, ctx->buf_un.buf8);
856 SHA256Transform(ctx, &input[i]);
860 SHA512Transform(ctx, &input[i]);
868 SHA256TransformBlocks(ctx, &input[i],
875 SHA512TransformBlocks(ctx, &input[i],
897 bcopy(&input[i], &ctx->buf_un.buf8[buf_index], input_len - i);
914 SHA2Final(void *digest, SHA2_CTX *ctx)
916 uint8_t bitcount_be[sizeof (ctx->count.c32)];
917 uint8_t bitcount_be64[sizeof (ctx->count.c64)];
919 uint32_t algotype = ctx->algotype;
922 index = (ctx->count.c32[1] >> 3) & 0x3f;
923 Encode(bitcount_be, ctx->count.c32, sizeof (bitcount_be));
924 SHA2Update(ctx, PADDING, ((index < 56) ? 56 : 120) - index);
925 SHA2Update(ctx, bitcount_be, sizeof (bitcount_be));
926 Encode(digest, ctx->state.s32, sizeof (ctx->state.s32));
928 index = (ctx->count.c64[1] >> 3) & 0x7f;
929 Encode64(bitcount_be64, ctx->count.c64,
931 SHA2Update(ctx, PADDING, ((index < 112) ? 112 : 240) - index);
932 SHA2Update(ctx, bitcount_be64, sizeof (bitcount_be64));
934 ctx->state.s64[6] = ctx->state.s64[7] = 0;
935 Encode64(digest, ctx->state.s64,
947 Encode64(digest, ctx->state.s64, sizeof (uint64_t) * 3);
948 Encode64(last, &ctx->state.s64[3], sizeof (uint64_t));
951 Encode64(digest, ctx->state.s64, sizeof (uint64_t) * 4);
953 Encode64(digest, ctx->state.s64,
954 sizeof (ctx->state.s64));
959 bzero(ctx, sizeof (*ctx));