/* This program is used to generate the first 256 keystream bytes of stream cipher HC-256 for a 256-bit key and a 256-bit IV The docuement of HC-256 are available at: 1) Hongjun Wu. ``A New Stream Cipher HC-256.'' Fast Software Encryption -- FSE 2004, LNCS 3017, pp. 226-244, Springer-Verlag 2004. 2) eSTREAM website: http://www.ecrypt.eu.org/stream/hcp3.html ----------------------------------- Written by: Hongjun Wu Last Modified: December 15, 2009 */ #include #include "hc256_ref.h" //#include "hc256_opt32.h" int main() { unsigned char key[32],iv[32]; unsigned char message[1024],ciphertext[1024]; unsigned long long msglength; unsigned long i; /*set the value of the key and iv*/ for (i = 0; i < 32; i++) { key[i] = 0; iv[i] = 0; } /*key[0] = 0x55;*/ /*iv[0] = 1;*/ /*set the value of message to 0 so that the ciphertext contains the keystream*/ for (i = 0; i < 1024; i++) message[i] = 0; /*generate the first 256 keystream bytes*/ msglength = 256; HC256(key,iv,message,ciphertext,msglength); /*print out the first 256 keystream bytes*/ printf("The first %d keystream bytes are: \n\n",msglength); for (i = 0; i < msglength; i++) { printf("%x%x",ciphertext[i] >> 4, ciphertext[i] & 0xf); if ( ((i+1)%16) == 0 ) printf("\n"); } printf("\n"); return (0); }