Lines Matching defs:state
55 * \param state ChaCha20 state to modify.
56 * \param a The index of 'a' in the state.
57 * \param b The index of 'b' in the state.
58 * \param c The index of 'c' in the state.
59 * \param d The index of 'd' in the state.
61 static inline void chacha20_quarter_round(uint32_t state[16],
68 state[a] += state[b];
69 state[d] ^= state[a];
70 state[d] = ROTL32(state[d], 16);
73 state[c] += state[d];
74 state[b] ^= state[c];
75 state[b] = ROTL32(state[b], 12);
78 state[a] += state[b];
79 state[d] ^= state[a];
80 state[d] = ROTL32(state[d], 8);
83 state[c] += state[d];
84 state[b] ^= state[c];
85 state[b] = ROTL32(state[b], 7);
94 * \param state The ChaCha20 state to update.
96 static void chacha20_inner_block(uint32_t state[16])
98 chacha20_quarter_round(state, 0, 4, 8, 12);
99 chacha20_quarter_round(state, 1, 5, 9, 13);
100 chacha20_quarter_round(state, 2, 6, 10, 14);
101 chacha20_quarter_round(state, 3, 7, 11, 15);
103 chacha20_quarter_round(state, 0, 5, 10, 15);
104 chacha20_quarter_round(state, 1, 6, 11, 12);
105 chacha20_quarter_round(state, 2, 7, 8, 13);
106 chacha20_quarter_round(state, 3, 4, 9, 14);
112 * \param initial_state The initial ChaCha20 state (key, nonce, counter).
157 mbedtls_platform_zeroize(ctx->state, sizeof(ctx->state));
175 ctx->state[0] = 0x61707865;
176 ctx->state[1] = 0x3320646e;
177 ctx->state[2] = 0x79622d32;
178 ctx->state[3] = 0x6b206574;
181 ctx->state[4] = MBEDTLS_GET_UINT32_LE(key, 0);
182 ctx->state[5] = MBEDTLS_GET_UINT32_LE(key, 4);
183 ctx->state[6] = MBEDTLS_GET_UINT32_LE(key, 8);
184 ctx->state[7] = MBEDTLS_GET_UINT32_LE(key, 12);
185 ctx->state[8] = MBEDTLS_GET_UINT32_LE(key, 16);
186 ctx->state[9] = MBEDTLS_GET_UINT32_LE(key, 20);
187 ctx->state[10] = MBEDTLS_GET_UINT32_LE(key, 24);
188 ctx->state[11] = MBEDTLS_GET_UINT32_LE(key, 28);
198 ctx->state[12] = counter;
201 ctx->state[13] = MBEDTLS_GET_UINT32_LE(nonce, 0);
202 ctx->state[14] = MBEDTLS_GET_UINT32_LE(nonce, 4);
203 ctx->state[15] = MBEDTLS_GET_UINT32_LE(nonce, 8);
233 chacha20_block(ctx->state, ctx->keystream8);
234 ctx->state[CHACHA20_CTR_INDEX]++;
245 chacha20_block(ctx->state, ctx->keystream8);
246 ctx->state[CHACHA20_CTR_INDEX]++;