| 205 | } |
| 206 | |
| 207 | void crypto_hchacha20(u8 out[32], const u8 key[32], const u8 in [16]) |
| 208 | { |
| 209 | u32 block[16]; |
| 210 | chacha20_init_key(block, key); |
| 211 | // input |
| 212 | load32_le_buf(block + 12, in, 4); |
| 213 | chacha20_rounds(block, block); |
| 214 | // prevent reversal of the rounds by revealing only half of the buffer. |
| 215 | store32_le_buf(out , block , 4); // constant |
| 216 | store32_le_buf(out+16, block+12, 4); // counter and nonce |
| 217 | WIPE_BUFFER(block); |
| 218 | } |
| 219 | |
| 220 | u64 crypto_chacha20_ctr(u8 *cipher_text, const u8 *plain_text, |
| 221 | size_t text_size, const u8 key[32], const u8 nonce[8], |
no test coverage detected