void testdecrypt(uint8_t *block, uint8_t *key){
	cli_putstr("\r\n==testy-decrypt==\r\n key: ");
	cli_hexdump(key,10);
	cli_putstr("\r\n crypt: ");
	cli_hexdump(block,8);
	skipjack_dec(block,key);
	cli_putstr("\r\n plain: ");
	cli_hexdump(block,8);
}
int test_enc(const void *buffer, void *key){
	uint8_t data[8];
	int r;
	memcpy(data, buffer, 8);
	skipjack_enc(data, key);
	cli_putstr_P(PSTR("  key = "));
	cli_hexdump(key, 10);
	cli_putstr_P(PSTR(" plaintext = "));
	cli_hexdump(buffer, 8);
	cli_putstr_P(PSTR(" ciphertext = "));
	cli_hexdump(data, 8);
	skipjack_dec(data, key);
	r = memcmp(data, buffer, 8);
	cli_putstr_P(PSTR(" decrypt: "));
	if(r){
		cli_putstr_P(PSTR("fail"));
	}else{
		cli_putstr_P(PSTR("ok"));
	}
	return r;
}
Example #3
0
int main() {
	iu8 inp[8]	= { 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa };
	iu8 key[10]	= { 0x00, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11 };
	iu8 enc[8], dec[8];
	iu8 chk[8]	= { 0x25, 0x87, 0xca, 0xe2, 0x7a, 0x12, 0xd3, 0x00 };
	iu8 tab[10][256];
	long i;
	clock_t elapsed;

	memcpy( enc, inp, 8 );
	skipjack_enc( enc, key );
	printf((memcmp(enc, chk, 8) == 0) ? "encryption OK!\n" : "encryption failure!\n");
	memcpy( dec, enc, 8 );
	skipjack_dec( dec, key );
	printf((memcmp(dec, inp, 8) == 0) ? "decryption OK!\n" : "decryption failure!\n");

	elapsed = -clock();
	for (i = 0; i < 1000000L; i++) {
		skipjack_enc( enc, key );
	}
	elapsed += clock();
	printf ("elapsed time: %.1f s.\n", (float)elapsed/CLOCKS_PER_SEC);
	return 0;
}