#include #include #include "ecrypt-sync.h" void generate_testvector(void); int main(void) { ECRYPT_ctx state; u8 text[64]; u32 i, j; printf( "\n" "Below is a short keystream generated from the all-zero state.\n" "This should be a lot more helpful then the testvectors when\n" "implementing TSC-3 for the first time.\n\n" "All printed numbers are in hexadecimal notation, with MSB to\n" "the left and LSB to the right.\n\n" " state\n" " output x_3 x_2 x_1 x_0\n" ); for (i = 0; i < 4; i++) state.r[i] = 0; printf ("-1 "); for (i = 0; i < 4; i++) { printf ("%.2x" , (u8) (state.r[3-i] >> 32)); printf ("%.8x ", (u32) (state.r[3-i] )); } printf ("\n"); for (i = 0; i < 20; i++) { ECRYPT_keystream_blocks (&state, text, 1); printf ("%2i ", i); for (j = 0; j < 4; j++) printf ("%.2x", text[3-j]); printf (" <= "); for (j = 0; j < 4; j++) { printf ("%.2x" , (u8) (state.r[3-j] >> 32)); printf ("%.8x ", (u32) (state.r[3-j] )); } printf ("\n"); } printf ("\n"); generate_testvector (); exit (0); }