/*
Count = 0
Klen = 24
Mlen = 0
Tlen = 2
Key = 2b2aaa666be161ed16648e862ac9bd1e317f71bc69e268b5
Msg = 00
*/
void testrun_aes192_cmac0(void){
	uint8_t key[24]= {
			0x2b, 0x2a, 0xaa, 0x66, 0x6b, 0xe1, 0x61, 0xed,
			0x16, 0x64, 0x8e, 0x86, 0x2a, 0xc9, 0xbd, 0x1e,
			0x31, 0x7f, 0x71, 0xbc, 0x69, 0xe2, 0x68, 0xb5
	};
	uint8_t tag[2];
	uint8_t plain[1] = {
			0x00
	};
	bcal_cmac_ctx_t ctx;
	uint8_t r;


	cli_putstr_P(PSTR("\r\n** AES192-CMAC-0-TEST **"));

	cli_putstr_P(PSTR("\r\n  key:   "));
	cli_hexdump(key, 192/8);
	r = bcal_cmac_init(&aes192_desc, key, 192, &ctx);
	cli_putstr_P(PSTR("\r\n  init = 0x"));
	cli_hexdump(&r, 1);
	if(r)
		return;
	bcal_cmac(tag, 16, plain, 0*8, &ctx);
	cli_putstr_P(PSTR("\r\n  tag:     "));
	cli_hexdump_block(tag, 2, 4, 16);
	bcal_cmac_free(&ctx);
}
Exemplo n.º 2
0
// -3d1d 6db7 8251 f371 * -7a18 3791 d18b b7c5 = 1d25ce4fdf93390f8d6c709f4d711cf5
// -20538248dece6d29068d * 400b1411b874f81394c6 = -81646b193d95136a6fedb73cee6d30c39fb950e
// -BC8B 7D53 4921 853D * 0DDA 6044 00CE DDE6   =  -a33eb0c5847db8837589c22db395dce
void test_mul_simple(void){
	bigint_t a, b, c;

//	uint8_t a_b[10] = {0x8d, 0x06, 0x29, 0x6d, 0xce, 0xde, 0x48, 0x82, 0x53, 0x20};
//	uint8_t b_b[10] = {0xc6, 0x94, 0x13, 0xf8, 0x74, 0xb8, 0x11, 0x14, 0x0b, 0x40};
	uint8_t a_b[8] = {0x3d, 0x85, 0x21, 0x49, 0x53, 0x7d, 0x8b, 0xbc};
	uint8_t b_b[8] = {0xe6, 0xdd, 0xce, 0x00, 0x44, 0x60, 0xda, 0x0d};

	uint8_t c_b[16];
	a.wordv=a_b;
	b.wordv=b_b;
	c.wordv=c_b;
	a.length_B = 8;
	b.length_B = 8;
	a.info=0x80;
	bigint_adjust(&a);
	bigint_adjust(&b);
	bigint_mul_s(&c, &a, &b);
	cli_putstr_P(PSTR("\r\n test: "));
	bigint_print_hex(&a);
	cli_putstr_P(PSTR(" * "));
	bigint_print_hex(&b);
	cli_putstr_P(PSTR(" = "));
	bigint_print_hex(&c);
}
Exemplo n.º 3
0
void testrun_performance_shabea(void){
	uint64_t t;
	char str[16];
	uint8_t key[32], data[32];
	
	calibrateTimer();
	print_overhead();
	
	memset(key,  0, 32);
	memset(data, 0, 32);
	
	startTimer(1);
	shabea256(data, key, 256, 1, 16);
	t = stopTimer();
	cli_putstr_P(PSTR("\r\n\tencrypt time: "));
	ultoa((unsigned long)t, str, 10);
	cli_putstr(str);
	
	
	startTimer(1);
	shabea256(data, key, 256, 0, 16);
	t = stopTimer();
	cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
	ultoa((unsigned long)t, str, 10);
	cli_putstr(str);
	
	cli_putstr_P(PSTR("\r\n"));
}
Exemplo n.º 4
0
void quick_test(void){
	dsa_signature_t dsa_sig;
	uint8_t i, t=0, message[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
	load_fix_dsa();
	uint8_t dsa_sig_s_b[dsa_ctx.domain.q.length_W],
	        dsa_sig_r_b[dsa_ctx.domain.q.length_W];
	dsa_print_ctx(&dsa_ctx);
	dsa_sig.r.wordv = dsa_sig_r_b;
	dsa_sig.s.wordv = dsa_sig_s_b;
	cli_putstr_P(PSTR("\r\n\r\n=== DSA QUICK TEST ==="));
	for(i=0; i<8; ++i){
		cli_putstr_P(PSTR("\r\n"));
		cli_putc('1'+i);
		cli_putstr_P(PSTR(": message: "));
		if (i){
			cli_hexdump(message, i);
		}else{
			cli_putstr_P(PSTR("<empty>"));
		}
		cli_putstr_P(PSTR("\r\n computing signature ... "));
		dsa_sign_message(&dsa_sig, message, i*8, &sha1_desc, &dsa_ctx, random8);
		dsa_print_signature(&dsa_sig);
		cli_putstr_P(PSTR("\r\n base64:\r\n--- SIGNATURE ---\r\n "));
		dsa_print_signature_b64(&dsa_sig);
		cli_putstr_P(PSTR("\r\n verifying signature ... "));
		t = dsa_verify_message(&dsa_sig, message, i*8, &sha1_desc, &dsa_ctx);
		cli_putstr_P(PSTR("\r\n verification: "));
		if(t==DSA_SIGNATURE_OK){
			cli_putstr_P(PSTR("[PASS]"));
		}else{
			cli_putstr_P(PSTR("[FAIL]"));
		}
	}
}
Exemplo n.º 5
0
void shavs_setalgo(char *param){
	param = strstrip(param);
	if(param[1]=='\0'){ /* single letter specified */
		uint8_t i, option = param[0] - 'a';

		if(!shavs_algolist){
			fputs_P(PSTR("\nERROR: shavs_algolist not set!"), shavs_out_file);
			return;
		}
		for(i=0; i<=option; ++i){
			if((void*)pgm_read_word(&(shavs_algolist[i]))==NULL){
				fputs_P(PSTR("\r\nERROR: invalid selection!"), shavs_out_file);
				return;
			}
		}
		shavs_algo=(hfdesc_t*)pgm_read_word(&(shavs_algolist[option]));
	} else { /* name specifyed */
		hfdesc_t *t=NULL;
		uint8_t i=0;
		while((t=(hfdesc_t*)pgm_read_word(&(shavs_algolist[i]))) &&
		       strcasecmp_P(param, (void*)pgm_read_word(&(t->name))))
			++i;
		if(t){
			shavs_algo=t;
		}else{
		    fprintf_P(shavs_out_file, PSTR("\nERROR: could not find \"%s\"!"), param);
			cli_putstr_P(PSTR("\r\nERROR: could not find \""));
			cli_putstr(param);
			cli_putstr_P(PSTR("\"!"));
		}
	}
}
void testrun_performance_entropium(void){
	uint64_t t;
	char str[16];
	uint8_t data[32];
	
	calibrateTimer();
	print_overhead();
	
	startTimer(1);
	entropium_addEntropy(128, data);
	t = stopTimer();
	cli_putstr_P(PSTR("\r\n\tadd entropy time: "));
	ultoa((unsigned long)t, str, 10);
	cli_putstr(str);
	
	
	startTimer(1);
	entropium_getRandomBlock(data);
	t = stopTimer();
	cli_putstr_P(PSTR("\r\n\tget random time:  "));
	ultoa((unsigned long)t, str, 10);
	cli_putstr(str);
	
	cli_putstr_P(PSTR("\r\n"));
}
Exemplo n.º 7
0
void testrun_nist_vectors(void){
	uint8_t key[10];
	uint8_t data[8];
	uint8_t i;

	cli_putstr_P(PSTR("\r\n\r\n=== NIST vectors run 1 ==="));
	memset(key, 0, 10);
	for(i=0; i<64; ++i){
		memset(data, 0, 8);
		data[i>>3] |= 0x80 >> (i & 7);
		cli_putstr_P(PSTR("\r\n round: 0x"));
		cli_hexdump_byte(i);
		test_enc(data, key);
	}

	cli_putstr_P(PSTR("\r\n\r\n=== NIST vectors run 2 ==="));
	memset(data, 0, 8);
	for(i=0; i<80; ++i){
                memset(key, 0, 10);
                key[i>>3] |= 0x80 >> (i & 7);
                cli_putstr_P(PSTR("\r\n round: 0x"));
                cli_hexdump_byte(i);
                test_enc(data, key);
        }
}
uint8_t read_bigint(bigint_t *a, char *prompt){
	uint16_t read_length, actual_length;
	uint8_t off;
	uint8_t *buffer;
	char read_int_str[18];
	cli_putstr(prompt);
	cli_putstr_P(PSTR("\r\n  length: "));
	cli_getsn(read_int_str, 16);
	read_length = own_atou(read_int_str);
	off = (sizeof(bigint_word_t) - (read_length % sizeof(bigint_word_t))) % sizeof(bigint_word_t);
	buffer = malloc(((read_length + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t)) * sizeof(bigint_word_t));
	if(!buffer){
		cli_putstr_P(PSTR("\r\nERROR: OOM!"));
		return 2;
	}
	cli_putstr_P(PSTR("\r\n  data: "));
	memset(buffer, 0, sizeof(bigint_word_t));
	actual_length = read_os(buffer + off, read_length, NULL);
	if(actual_length != read_length){
		cli_putstr_P(PSTR("\r\nERROR: unexpected end of data!"));
		free(buffer);
		return 1;
	}
	a->wordv = (bigint_word_t*)buffer;
	a->length_W = (read_length + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t);
	a->info = 0;
	bigint_changeendianess(a);
	bigint_adjust(a);
	return 0;
}
/*
128-bit key
key         01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10
plaintext   01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10
ciphertext  67 67 31 38 54 96 69 73 08 57 06 56 48 ea be 43
*/
void testrun_camellia(void){

  uint8_t data[16] = { 0x01, 0x23, 0x45, 0x67, 
                       0x89, 0xab, 0xcd, 0xef, 
                       0xfe, 0xdc, 0xba, 0x98, 
                       0x76, 0x54, 0x32, 0x10 };

  uint8_t key[16] = { 0x01, 0x23, 0x45, 0x67, 
                       0x89, 0xab, 0xcd, 0xef, 
                       0xfe, 0xdc, 0xba, 0x98, 
                       0x76, 0x54, 0x32, 0x10 };


  camellia128_ctx_t ctx;
  camellia128_init(key, &ctx);
  cli_putstr_P(PSTR("\r\n key:        "));
  cli_hexdump(data, 16);
  cli_putstr_P(PSTR("\r\n plaintext:  "));
  cli_hexdump(data, 16);
  camellia128_enc(data, &ctx);
  cli_putstr_P(PSTR("\r\n ciphertext: "));
  cli_hexdump(data, 16);
  camellia128_dec(data, &ctx);
  cli_putstr_P(PSTR("\r\n decrypted:  "));
  cli_hexdump(data, 16);

}
void testrun_md5(void){
	md5_hash_t hash;
	char* testv[]={
		"", 
		"a", 
		"abc", 
		"message digest", 
		"abcdefghijklmnopqrstuvwxyz", 
		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 
		"12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
	uint16_t i;
	
	cli_putstr("\r\n=== MD5 test suit ===");
	for(i=0; i<7; ++i){
		cli_putstr("\r\n MD5 (\"");
		cli_putstr(testv[i]);
		cli_putstr("\") = \r\n\t");
		md5(&hash, testv[i], strlen(testv[i])*8);
		cli_hexdump(hash, 16);
	}
	uint8_t buffer[512/8];
	char str[5];
	for(i=505; i<512; ++i){
		memset(buffer, 0, 512/8);
		cli_putstr_P(PSTR("\r\nMD5("));
		utoa(i, str, 10);
		cli_putstr(str);
		cli_putstr_P(PSTR(" zero bits) = "));
		md5(&hash, buffer, i);
		cli_hexdump(hash, 16);
	}
}
Exemplo n.º 11
0
void testrun_nessie_des(const char* param){
	if(!param){
		bcal_nessie_multiple(algolist);
	}else{
		uint8_t i=0;
		bcdesc_t* ptr;
		for(;;){
			ptr = (bcdesc_t*)pgm_read_word(&algolist[i++]);
			if(ptr == NULL){
				cli_putstr_P(PSTR("\r\nunknown algorithm: "));
				cli_putstr(param);
				cli_putstr_P(PSTR("\r\navailable algorithms are:"));
				i = 0;
				while((ptr = (bcdesc_t*)pgm_read_word(&algolist[i++]))){
					cli_putstr_P(PSTR("\r\n\t"));
					cli_putstr_P((const char*)pgm_read_word(&ptr->name));
				}
				return;
			}
			if(!strcmp_P(param, (const char*)pgm_read_word(&ptr->name))){
				bcal_nessie(ptr);
				return;
			}
		}
	}
}
Exemplo n.º 12
0
void testrun_performance_rabbit(void){
	uint64_t t;
	char str[16];
	uint8_t key[16];
	rabbit_ctx_t ctx;

	calibrateTimer();
	print_overhead();

	memset(key,  0, 16);

	startTimer(1);
	rabbit_init(key, 128, NULL, &ctx);
	t = stopTimer();
	cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
	ultoa((unsigned long)t, str, 10);
	cli_putstr(str);

	startTimer(1);
	rabbit_gen(&ctx);
	t = stopTimer();
	cli_putstr_P(PSTR("\r\n\tencrypt time: "));
	ultoa((unsigned long)t, str, 10);
	cli_putstr(str);

	cli_putstr_P(PSTR("\r\n"));
}
Exemplo n.º 13
0
void test_gcdext_simple(void){
	bigint_t a, b, c, d, e;

	uint8_t a_b[5] = {0x71, 0x07, 0x00, 0x09, 0x16};
	uint8_t b_b[5] = {0x72, 0x7D, 0x57, 0xAC, 0X6F};
	uint8_t c_b[6], d_b[6], e_b[6];
	a.wordv=a_b;
	a.length_B = 5;
	a.info=0x00;
	bigint_adjust(&a);
	b.wordv=b_b;
	b.length_B = 5;
	b.info=0x00;
	bigint_adjust(&b);
	c.wordv = c_b;
	d.wordv = d_b;
	e.wordv = e_b;
	bigint_gcdext(&c, &d, &e, &a, &b);
	cli_putstr_P(PSTR("\r\n test: gcd( "));
	bigint_print_hex(&a);
	cli_putstr_P(PSTR(", "));
	bigint_print_hex(&b);
	cli_putstr_P(PSTR(") => a =  "));
	bigint_print_hex(&d);
	cli_putstr_P(PSTR("; b =  "));
	bigint_print_hex(&e);
	cli_putstr_P(PSTR("; gcd =  "));
	bigint_print_hex(&c);
}
void testrun_aes128_cmac(void){
	uint8_t key[16];
	uint8_t tag[16];
	uint8_t plain[64];
	uint16_t length[] = { 0, 128, 320, 512 };
	bcal_cmac_ctx_t ctx;
	uint8_t r,i;

	memcpy_P(key,   modes_key,   16);
	memcpy_P(plain, modes_plain, 64);

	cli_putstr_P(PSTR("\r\n** AES128-CMAC-TEST **"));

	cli_putstr_P(PSTR("\r\n  key:   "));
	cli_hexdump(key, 128/8);
	for(i=0; i<4; ++i){
		r = bcal_cmac_init(&aes128_desc, key, 128, &ctx);
		cli_putstr_P(PSTR("\r\n  init = 0x"));
		cli_hexdump(&r, 1);
		cli_putstr_P(PSTR("\r\n  message: "));
		cli_hexdump_block(plain, length[i]/8, 4, 16);
		if(r)
			return;
		bcal_cmac(tag, 128, plain, length[i], &ctx);
		cli_putstr_P(PSTR("\r\n  tag:     "));
		cli_hexdump_block(tag, 128/8, 4, 16);
		bcal_cmac_free(&ctx);
	}
}
/*
Klen = 16
Mlen = 18
Tlen = 2
Key = 3250974e306b4b678f914b514d1e90f6
Msg = cf132fd4ebc25fd3866f1a95a6193a1a9cdf
*/
void testrun_aes128_cmac72(void){
	uint8_t key[16]= {
			0x32, 0x50, 0x97, 0x4e, 0x30, 0x6b, 0x4b, 0x67,
			0x8f, 0x91, 0x4b, 0x51, 0x4d, 0x1e, 0x90, 0xf6
	};
	uint8_t tag[2];
	uint8_t plain[18] = {
			0xcf, 0x13, 0x2f, 0xd4, 0xeb, 0xc2, 0x5f, 0xd3,
			0x86, 0x6f, 0x1a, 0x95, 0xa6, 0x19, 0x3a, 0x1a,
			0x9c, 0xdf,
	};
	bcal_cmac_ctx_t ctx;
	uint8_t r;


	cli_putstr_P(PSTR("\r\n** AES128-CMAC-72-TEST **"));

	cli_putstr_P(PSTR("\r\n  key:   "));
	cli_hexdump(key, 128/8);
	r = bcal_cmac_init(&aes128_desc, key, 128, &ctx);
	cli_putstr_P(PSTR("\r\n  init = 0x"));
	cli_hexdump(&r, 1);
	cli_putstr_P(PSTR("\r\n  message: "));
	cli_hexdump_block(plain, 18, 4, 16);
	if(r)
		return;
	bcal_cmac(tag, 16, plain, 18*8, &ctx);
	cli_putstr_P(PSTR("\r\n  tag:     "));
	cli_hexdump_block(tag, 2, 4, 16);
	bcal_cmac_free(&ctx);
}
Exemplo n.º 16
0
void testrun_performance_grain(void) {
    uint64_t t;
    char str[16];
    uint8_t key[10], iv[8];
    grain_ctx_t ctx;

    calibrateTimer();
    print_overhead();

    memset(key,  0, 10);
    memset(iv,  0, 8);

    startTimer(1);
    grain_init(key, iv, &ctx);
    t = stopTimer();
    cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
    ultoa((unsigned long)t, str, 10);
    cli_putstr(str);

    startTimer(1);
    grain_enc(&ctx);
    t = stopTimer();
    cli_putstr_P(PSTR("\r\n\tencrypt time: "));
    ultoa((unsigned long)t, str, 10);
    cli_putstr(str);

    cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
 *  additional validation-functions											 *
 *****************************************************************************/
void testrun_stdtest_ubi256(uint16_t outsize){
	ubi256_ctx_t ctx;
	skein_config_t conf;
	uint64_t iv[4];
	
	cli_putstr_P(PSTR("\r\n\r\nTest vectors for UBI (256 bits):"));
	memset(&conf, 0, sizeof(skein_config_t));

	ubi256_init(&ctx, &conf, UBI_TYPE_CFG);
	conf.schema[0] = 'S';
	conf.schema[1] = 'H';
	conf.schema[2] = 'A';
	conf.schema[3] = '3';
	conf.version = 1;
	conf.out_length = outsize;
	ubi256_lastBlock(&ctx, &conf, 256);
	ubi256_ctx2hash(iv, &ctx);
		
	cli_putstr_P(PSTR("\r\nIV: "));
	cli_hexdump_rev(&(iv[0]), 8);
	cli_putstr_P(PSTR("    "));
	cli_hexdump_rev(&(iv[1]), 8);
	cli_putstr_P(PSTR("    "));
	cli_hexdump_rev(&(iv[2]), 8);
	cli_putstr_P(PSTR("    "));
	cli_hexdump_rev(&(iv[3]), 8);
}
Exemplo n.º 18
0
void test_reduce_bigint(void){
	bigint_t a, b;
	cli_putstr_P(PSTR("\r\nreduce test\r\n"));
	for(;;){
		cli_putstr_P(PSTR("\r\nenter a:"));
		if(bigint_read_hex_echo(&a)){
			cli_putstr_P(PSTR("\r\n end reduce test"));
			return;
		}
		cli_putstr_P(PSTR("\r\nenter b:"));
		if(bigint_read_hex_echo(&b)){
			free(a.wordv);
			cli_putstr_P(PSTR("\r\n end reduce test"));
			return;
		}
		cli_putstr_P(PSTR("\r\n "));
		bigint_print_hex(&a);
		cli_putstr_P(PSTR(" % "));
		bigint_print_hex(&b);
		cli_putstr_P(PSTR(" = "));
		bigint_reduce(&a, &b);
		bigint_print_hex(&a);
		cli_putstr_P(PSTR("\r\n"));
		free(a.wordv);
		free(b.wordv);
	}
}
Exemplo n.º 19
0
void test_reduce_bigint(void){
	bigint_t a, b, c;
	cli_putstr_P(PSTR("\r\nreduce test\r\n"));
	for (;;) {
		cli_putstr_P(PSTR("\r\nenter a:"));
		if (bigint_read_hex_echo(&a, 0)) {
			cli_putstr_P(PSTR("\r\n end reduce test"));
			return;
		}
		cli_putstr_P(PSTR("\r\nenter b:"));
		if (bigint_read_hex_echo(&b, 0)) {
			free(a.wordv);
			cli_putstr_P(PSTR("\r\n end reduce test"));
			return;
		}
		cli_putstr_P(PSTR("\r\n "));
		bigint_print_hex(&a);
		cli_putstr_P(PSTR(" % "));
		bigint_print_hex(&b);
		cli_putstr_P(PSTR(" = "));
		memset(&c, 0, sizeof(c));
		bigint_divide(NULL, &c, &a, &b);
		bigint_print_hex(&c);
		cli_putstr_P(PSTR("\r\n"));
        bigint_free(&c);
        bigint_free(&b);
		bigint_free(&a);
	}
}
void cubehash256_test0(void){
	cubehash_ctx_t ctx;
	uint8_t hash[32];
	cubehash256_init(&ctx);
	cli_putstr_P(PSTR("\r\ninit done "));
	cubehash_lastBlock(&ctx, NULL, 0);
	cli_putstr_P(PSTR("\r\nlastblock done "));
	cubehash256_ctx2hash(hash, &ctx);
	cli_putstr_P(PSTR("\r\nhash = "));
	cli_hexdump(hash, 32);
}
Exemplo n.º 21
0
void echo256_test0(void){
	echo_small_ctx_t ctx;
	uint8_t hash[32];
	echo256_init(&ctx);
	cli_putstr_P(PSTR("\r\ninit done "));
	echo_small_lastBlock(&ctx, NULL, 0);
	cli_putstr_P(PSTR("\r\nlastblock done "));
	echo256_ctx2hash(hash, &ctx);
	cli_putstr_P(PSTR("\r\nhash = "));
	cli_hexdump(hash, 32);
}
void test_dump(void){
	char lstr[16];
	int len;
	cli_putstr_P(PSTR("\r\nenter dump length: "));
	cli_getsn_cecho(lstr, 15);
	len = own_atou(lstr);
	cli_putstr_P(PSTR("\r\ndumping 0x"));
	cli_hexdump_rev(&len, 2);
	cli_putstr_P(PSTR(" byte:"));
	cli_hexdump_block(pub_key.modulus.wordv, len, 4, 8);
}
Exemplo n.º 23
0
int main (void){
	DEBUG_INIT();
	cli_rx = (cli_rx_fpt)uart0_getc;
	cli_tx = (cli_tx_fpt)uart0_putc;	 	
	for(;;){
		cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
		cli_putstr(algo_name);
		cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
		cmd_interface(cmdlist);
	}
}
Exemplo n.º 24
0
void md5_interactive(void){
	char msg[101];
	uint8_t hash[MD5_HASH_BYTES];
	uint8_t msg_len;
	cli_putstr_P(PSTR("\r\nmsg: "));
	cli_getsn(msg, 100);
	msg_len = strlen(msg);
	md5((void*)hash, msg, msg_len*8);
	cli_putstr_P(PSTR("\r\nmd5: "));
	cli_hexdump(hash, MD5_HASH_BYTES);
}
void load_key(void){
	uint8_t r;
	if(keys_allocated){
		cli_putstr_P(PSTR("\r\nDBG: freeing old keys"));
		free_key();
	}
	keys_allocated = 1;
	r = read_key_crt();
	if(r){
		cli_putstr_P(PSTR("\r\nERROR: read_key_crt returned 0x"));
		cli_hexdump_byte(r);
	}
}
Exemplo n.º 26
0
void echo512_interm(void){
	echo_large_ctx_t ctx;
	uint8_t data[872/8];
	uint8_t hash[64];
	echo512_init(&ctx);
	memcpy_P(data, intermediate_data2, 872/8);
	cli_putstr_P(PSTR("\r\ninit done "));
	echo_large_lastBlock(&ctx, data, 872);
	cli_putstr_P(PSTR("\r\nlastblock done "));
	echo512_ctx2hash(hash, &ctx);
	cli_putstr_P(PSTR("\r\nhash = "));
	cli_hexdump(hash, 64);
}
Exemplo n.º 27
0
void echo256_interm(void){
	echo_small_ctx_t ctx;
	uint8_t data[1384/8];
	uint8_t hash[32];
	echo256_init(&ctx);
	memcpy_P(data, intermediate_data, 173);
	cli_putstr_P(PSTR("\r\ninit done "));
	echo_small_lastBlock(&ctx, data, 1384);
	cli_putstr_P(PSTR("\r\nlastblock done "));
	echo256_ctx2hash(hash, &ctx);
	cli_putstr_P(PSTR("\r\nhash = "));
	cli_hexdump(hash, 32);
}
Exemplo n.º 28
0
void testrun_test_serpent(void){
	uint8_t key[32];
	serpent_ctx_t ctx;
	uint8_t i;
	memset(key, 0, 16);
	serpent_init(key, 128, &ctx);
	for(i=0; i<33; ++i){
		cli_putstr_P(PSTR("\r\n subkekey "));	
		cli_hexdump(&i, 1);
		cli_putstr_P(PSTR(" : "));	
		cli_hexdump(ctx.k[i], 16);
	}
}
void test_sbox(void){
	uint8_t i=0,x;
	cli_putstr_P(PSTR("\r\nKhazad Sbox:\r\n\t"));
	do{
		x = khazad_sbox(i);
		cli_hexdump_byte(x);
		cli_putc(' ');
		if(i%16==15){
			cli_putstr_P(PSTR("\r\n\t"));
		}
		++i;
	}while(i);
}
int main (void){
	DEBUG_INIT();

	cli_rx = (cli_rx_fpt)uart0_getc;
	cli_tx = (cli_tx_fpt)uart0_putc;
	cmacvs_algolist=(bcdesc_t**)algolist;
	cmacvs_algo=(bcdesc_t*)&aes128_desc;
	for(;;){
		cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
		cli_putstr(algo_name);
		cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
		cmd_interface(cmdlist);
	}
}