Home | History | Annotate | Download | only in libmincrypt

Lines Matching refs:ctx

38 static void SHA1_Transform(SHA_CTX* ctx) {
41 uint8_t* p = ctx->buf;
56 A = ctx->state[0];
57 B = ctx->state[1];
58 C = ctx->state[2];
59 D = ctx->state[3];
60 E = ctx->state[4];
81 ctx->state[0] += A;
82 ctx->state[1] += B;
83 ctx->state[2] += C;
84 ctx->state[3] += D;
85 ctx->state[4] += E;
96 void SHA_init(SHA_CTX* ctx) {
97 ctx->f = &SHA_VTAB;
98 ctx->state[0] = 0x67452301;
99 ctx->state[1] = 0xEFCDAB89;
100 ctx->state[2] = 0x98BADCFE;
101 ctx->state[3] = 0x10325476;
102 ctx->state[4] = 0xC3D2E1F0;
103 ctx->count = 0;
107 void SHA_update(SHA_CTX* ctx, const void* data, int len) {
108 int i = (int) (ctx->count & 63);
111 ctx->count += len;
114 ctx->buf[i++] = *p++;
116 SHA1_Transform(ctx);
123 const uint8_t* SHA_final(SHA_CTX* ctx) {
124 uint8_t *p = ctx->buf;
125 uint64_t cnt = ctx->count * 8;
128 SHA_update(ctx, (uint8_t*)"\x80", 1);
129 while ((ctx->count & 63) != 56) {
130 SHA_update(ctx, (uint8_t*)"\0", 1);
134 SHA_update(ctx, &tmp, 1);
138 uint32_t tmp = ctx->state[i];
145 return ctx->buf;
150 SHA_CTX ctx;
151 SHA_init(&ctx);
152 SHA_update(&ctx, data, len);
153 memcpy(digest, SHA_final(&ctx), SHA_DIGEST_SIZE);