Lines Matching defs:ctx
55 SipHash_Init(SIPHASH_CTX *ctx, const SIPHASH_KEY *key)
62 ctx->v[0] = 0x736f6d6570736575ULL ^ k0;
63 ctx->v[1] = 0x646f72616e646f6dULL ^ k1;
64 ctx->v[2] = 0x6c7967656e657261ULL ^ k0;
65 ctx->v[3] = 0x7465646279746573ULL ^ k1;
67 memset(ctx->buf, 0, sizeof(ctx->buf));
68 ctx->bytes = 0;
73 SipHash_Update(SIPHASH_CTX *ctx, int rc, int rf, const void *src, size_t len)
81 used = ctx->bytes % sizeof(ctx->buf);
82 ctx->bytes += len;
85 left = sizeof(ctx->buf) - used;
88 memcpy(&ctx->buf[used], ptr, left);
89 SipHash_CRounds(ctx, rc);
93 memcpy(&ctx->buf[used], ptr, len);
98 while (len >= sizeof(ctx->buf)) {
99 memcpy(ctx->buf, ptr, sizeof(ctx->buf));
100 SipHash_CRounds(ctx, rc);
101 len -= sizeof(ctx->buf);
102 ptr += sizeof(ctx->buf);
106 memcpy(ctx->buf, ptr, len);
111 SipHash_Final(void *dst, SIPHASH_CTX *ctx, int rc, int rf)
115 r = htole64(SipHash_End(ctx, rc, rf));
121 SipHash_End(SIPHASH_CTX *ctx, int rc, int rf)
126 used = ctx->bytes % sizeof(ctx->buf);
127 left = sizeof(ctx->buf) - used;
128 memset(&ctx->buf[used], 0, left - 1);
129 ctx->buf[7] = ctx->bytes;
131 SipHash_CRounds(ctx, rc);
132 ctx->v[2] ^= 0xff;
133 SipHash_Rounds(ctx, rf);
135 r = (ctx->v[0] ^ ctx->v[1]) ^ (ctx->v[2] ^ ctx->v[3]);
136 explicit_bzero(ctx, sizeof(*ctx));
144 SIPHASH_CTX ctx;
146 SipHash_Init(&ctx, key);
147 SipHash_Update(&ctx, rc, rf, src, len);
148 return (SipHash_End(&ctx, rc, rf));
155 SipHash_Rounds(SIPHASH_CTX *ctx, int rounds)
158 ctx->v[0] += ctx->v[1];
159 ctx->v[2] += ctx->v[3];
160 ctx->v[1] = SIP_ROTL(ctx->v[1], 13);
161 ctx->v[3] = SIP_ROTL(ctx->v[3], 16);
163 ctx->v[1] ^= ctx->v[0];
164 ctx->v[3] ^= ctx->v[2];
165 ctx->v[0] = SIP_ROTL(ctx->v[0], 32);
167 ctx->v[2] += ctx->v[1];
168 ctx->v[0] += ctx->v[3];
169 ctx->v[1] = SIP_ROTL(ctx->v[1], 17);
170 ctx->v[3] = SIP_ROTL(ctx->v[3], 21);
172 ctx->v[1] ^= ctx->v[2];
173 ctx->v[3] ^= ctx->v[0];
174 ctx->v[2] = SIP_ROTL(ctx->v[2], 32);
179 SipHash_CRounds(SIPHASH_CTX *ctx, int rounds)
181 uint64_t m = le64toh(*(uint64_t *)ctx->buf);
183 ctx->v[3] ^= m;
184 SipHash_Rounds(ctx, rounds);
185 ctx->v[0] ^= m;