Home | History | Annotate | Download | only in libc

Lines Matching refs:ctx

33 static void SHA1_transform(SHA_CTX *ctx) {
36 uint8_t *p = ctx->buf;
51 A = ctx->state[0];
52 B = ctx->state[1];
53 C = ctx->state[2];
54 D = ctx->state[3];
55 E = ctx->state[4];
76 ctx->state[0] += A;
77 ctx->state[1] += B;
78 ctx->state[2] += C;
79 ctx->state[3] += D;
80 ctx->state[4] += E;
83 void SHA_init(SHA_CTX *ctx) {
84 ctx->state[0] = 0x67452301;
85 ctx->state[1] = 0xEFCDAB89;
86 ctx->state[2] = 0x98BADCFE;
87 ctx->state[3] = 0x10325476;
88 ctx->state[4] = 0xC3D2E1F0;
89 ctx->count = 0;
92 void SHA_update(SHA_CTX *ctx, const void *data, int len) {
93 int i = ctx->count % sizeof(ctx->buf);
96 ctx->count += len;
99 ctx->buf[i++] = *p++;
100 if (i == sizeof(ctx->buf)) {
101 SHA1_transform(ctx);
106 const uint8_t *SHA_final(SHA_CTX *ctx) {
107 uint8_t *p = ctx->buf;
108 uint64_t cnt = ctx->count * 8;
111 SHA_update(ctx, (uint8_t*)"\x80", 1);
112 while ((ctx->count % sizeof(ctx->buf)) != (sizeof(ctx->buf) - 8)) {
113 SHA_update(ctx, (uint8_t*)"\0", 1);
117 SHA_update(ctx, &tmp, 1);
121 uint32_t tmp = ctx->state[i];
128 return ctx->buf;
135 SHA_CTX ctx;
136 SHA_init(&ctx);
137 SHA_update(&ctx, data, len);
138 p = SHA_final(&ctx);