(dst: Uint32Array, state: Uint32Array)
| 27 | x[d] = vd; |
| 28 | } |
| 29 | function generateChaCha20(dst: Uint32Array, state: Uint32Array) : void { |
| 30 | if (dst.length < 16 || state.length < 16) return; |
| 31 | dst.set(state); |
| 32 | for (let i = 0; i < CHACHA_ROUNDS; i += 2) { |
| 33 | quarterRound(dst, 0, 4, 8, 12); |
| 34 | quarterRound(dst, 1, 5, 9, 13); |
| 35 | quarterRound(dst, 2, 6, 10, 14); |
| 36 | quarterRound(dst, 3, 7, 11, 15); |
| 37 | quarterRound(dst, 0, 5, 10, 15); |
| 38 | quarterRound(dst, 1, 6, 11, 12); |
| 39 | quarterRound(dst, 2, 7, 8, 13); |
| 40 | quarterRound(dst, 3, 4, 9, 14); |
| 41 | } |
| 42 | for (let i = 0; i < 16; i++) { |
| 43 | let d = dst[i]; |
| 44 | const s = state[i]; |
| 45 | if (d === undefined || s === undefined) throw new Error('generateChaCha20: Something went wrong!'); |
| 46 | d = (d + s) | 0; |
| 47 | dst[i] = d; |
| 48 | } |
| 49 | } |
| 50 | export class ChaCha20 extends RandomBase { |
| 51 | private keynonce: Uint32Array; |
| 52 | private state: Uint32Array; |
no test coverage detected