Lines Matching refs:ctx

67 # define readLane(x, y)     load64(ctx->state+sizeof(uint64_t)*idx(x, y))
68 # define writeLane(x, y, v) store64(ctx->state+sizeof(uint64_t)*idx(x, y), v)
69 # define XORLane(x, y, v) xor64(ctx->state+sizeof(uint64_t)*idx(x, y), v)
71 # define readLane(x, y) (((uint64_t*)ctx->state)[idx(x,y)])
72 # define writeLane(x, y, v) (((uint64_t*)ctx->state)[idx(x,y)] = v)
73 # define XORLane(x, y, v) (((uint64_t*)ctx->state)[idx(x,y)] ^= v)
90 static void permute(PHP_SHA3_CTX* ctx) { in permute() argument
152 static void PHP_SHA3_Init(PHP_SHA3_CTX* ctx, in PHP_SHA3_Init() argument
154 memset(ctx, 0, sizeof(PHP_SHA3_CTX)); in PHP_SHA3_Init()
157 static void PHP_SHA3_Update(PHP_SHA3_CTX* ctx, in PHP_SHA3_Update() argument
162 unsigned int len = block_size - ctx->pos; in PHP_SHA3_Update()
166 ctx->state[ctx->pos++] ^= *(buf++); in PHP_SHA3_Update()
168 if (ctx->pos >= block_size) { in PHP_SHA3_Update()
169 permute(ctx); in PHP_SHA3_Update()
170 ctx->pos = 0; in PHP_SHA3_Update()
176 PHP_SHA3_CTX* ctx, in PHP_SHA3_Final() argument
182 ctx->state[ctx->pos++] ^= 0x06; in PHP_SHA3_Final()
183 ctx->state[block_size-1] ^= 0x80; in PHP_SHA3_Final()
184 permute(ctx); in PHP_SHA3_Final()
189 memcpy(digest, ctx->state, bs); in PHP_SHA3_Final()
193 permute(ctx); in PHP_SHA3_Final()
197 ZEND_SECURE_ZERO(ctx, sizeof(PHP_SHA3_CTX)); in PHP_SHA3_Final()
203 void PHP_SHA3##bits##Init(PHP_SHA3_##bits##_CTX* ctx) { \
204 PHP_SHA3_Init(ctx, bits); \
206 void PHP_SHA3##bits##Update(PHP_SHA3_##bits##_CTX* ctx, \
209 PHP_SHA3_Update(ctx, input, inputLen, \
213 PHP_SHA3_##bits##_CTX* ctx) { \
214 PHP_SHA3_Final(digest, ctx, \
248 void PHP_SHA3##bits##Init(PHP_SHA3_##bits##_CTX* ctx) { \
249 ctx->hashinstance = emalloc(sizeof(Keccak_HashInstance)); \
250 Keccak_HashInitialize_SHA3_##bits((Keccak_HashInstance *)ctx->hashinstance); \
252 void PHP_SHA3##bits##Update(PHP_SHA3_##bits##_CTX* ctx, \
255 Keccak_HashUpdate((Keccak_HashInstance *)ctx->hashinstance, input, inputLen * 8); \
258 PHP_SHA3_##bits##_CTX* ctx) { \
259 Keccak_HashFinal((Keccak_HashInstance *)ctx->hashinstance, digest); \
260 efree(ctx->hashinstance); \
261 ctx->hashinstance = NULL; \