This implementation of the ChaCha20 encryption algorithm has been heavily optimized, drawing inspiration from the excellent analysis provided in:
ChaCha20 Performance on PDP-11.
- Due to interrupts being disabled during encryption/decryption, throughput measurements must be conducted using an external timer device.
- Benchmarks indicate a throughput of approximately 950 bytes per second, which is roughly 6 times slower than on a PDP-11/40. Despite this, the performance is quite respectable, given the hardware constraints of the 6502.
To verify the correctness of the implementation:
- Compare the encrypted output of block #1 against the expected byte sequence specified in RFC 7539, titled "ChaCha20 and Poly1305 for IETF Protocols", published by the Internet Engineering Task Force (IETF) in May 2015.
- The RFC includes test vectors that can be used for validation. The serialized block output for comparison is provided at line 47 in the header of
test.c.
With this approach, you can ensure the implementation adheres to the expected behavior defined in the RFC, making it a fast and reliable implementation of ChaCha20 for the 6502.