HC32 File Crypter documentation by EddyHawk
---
What
---
HC32 is a file encrypter coded by EddyHawk (me).
It is part of PROTAGON File Crypter (PFC) series done by me.
HC32 uses HC-256 cipher.
It also uses MD4 & SHA-512 hash functions, and HMAC & PbKDF2 constructions,
 all taken from WE Pascal sources.

---
What is HC-256
---
HC-256 is a stream cipher designed by Hongjun Wu [2004]. It is a synchronous
stream cipher having 256bit key, 256bit IV, & claiming 256bit security. It's
a submission to ECRYPT/eSTREAM and its variant having 128bit key (HC-128) has
been included in eSTREAM portfolio along with RABBIT, SALSA20/12, SOSEMANUK,
GRAIN v1, MICKEY v2, & TRIVIUM.
Crypt best performance of HC-256 is 4.2 cycles/byte on Pentium 4, claimed by
the designer.
HC-256 is relatively easy to be implemented.
HC-256 outputs 4 byte (32bit) at a time. But its optimized code from Wu,
the one having 4.2 cycles/byte on Pentium 4, is actually coded to output
64 byte (512bit) at a time.

HC-256 requirement: 8kb memory for P & Q tables.
HC-256 restriction: 2^128 bit keystream per pair of key/passphrase & nonce

HC-256 has very slow key schedule (~72k cycles), partly due to its 'mega'
dropping (4,096 iterations of next_state).
Unbroken status: as 2015, 11 years
Yet there are reports that HC-256 is vulnerable to cache-timing attacks.

---
What is WE Pascal source
---
Wolfgang Ehrhardt (WE) creates an excellent collection of crypt Pascal sources
 which is freely available in Internet, supporting Borland Pascal 7,
 all flavors of Borland Delphi, Free Pascal Compiler, & Virtual Pascal,
 in single source.

MD4 & SHA-512 hash functions and HMAC & PbKDF2 constructions for HC-32
 are taken from that collection [CRC_Hash 25 Aug 2014], then compiled under
 Virtual Pascal v2.1b279.

---
HC32 specific features
---
Very simple self-test is included in HC32 & activated during HC32 run.

Besides implementing optimized HC-256 key schedule, I did further size & speed
optimization to the key schedule. Optimized encryption isn't implemented since
it causes another overhead to key schedule & since the output must be at least
512bit.

HC32 also xors keystream with plaintext using my 'xorbuf'.
Due to the way HC-256 is implemented, 'xorbuf' doesn't require another
file buffer to hold the keystream.

Current (key & IV setup & dropping) time: ~360k cycles (!) on my 5th cpu

End.