void testrun_trivium(void){ uint8_t key[10]; uint8_t iv[4]; uint8_t buffer[64]; scgen_ctx_t ctx; memset(key, 0, 10); memset(iv, 0, 4); key[0] = 0x80; scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx); scal_cipher_gen_fillblock(buffer, 64, &ctx); cli_putstr_P(PSTR("\r\nTest:\r\n Key = ")); cli_hexdump(key, 10); cli_putstr_P(PSTR("\r\n IV = ")); cli_hexdump(iv, 4); cli_putstr_P(PSTR("\r\n Cipher = ")); cli_hexdump_block(buffer, 64, 4, 16); scal_cipher_free(&ctx); key[0] = 0x40; scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx); scal_cipher_gen_fillblock(buffer, 64, &ctx); cli_putstr_P(PSTR("\r\nTest:\r\n Key = ")); cli_hexdump(key, 10); cli_putstr_P(PSTR("\r\n IV = ")); cli_hexdump(iv, 4); cli_putstr_P(PSTR("\r\n Cipher = ")); cli_hexdump_block(buffer, 64, 4, 16); scal_cipher_free(&ctx); key[0] = 0x20; scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx); scal_cipher_gen_fillblock(buffer, 64, &ctx); cli_putstr_P(PSTR("\r\nTest:\r\n Key = ")); cli_hexdump(key, 10); cli_putstr_P(PSTR("\r\n IV = ")); cli_hexdump(iv, 4); cli_putstr_P(PSTR("\r\n Cipher = ")); cli_hexdump_block(buffer, 64, 4, 16); scal_cipher_free(&ctx); key[0] = 0x10; scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx); scal_cipher_gen_fillblock(buffer, 64, &ctx); cli_putstr_P(PSTR("\r\nTest:\r\n Key = ")); cli_hexdump(key, 10); cli_putstr_P(PSTR("\r\n IV = ")); cli_hexdump(iv, 4); cli_putstr_P(PSTR("\r\n Cipher = ")); cli_hexdump_block(buffer, 64, 4, 16); scal_cipher_free(&ctx); }
static void normal_block(scgen_ctx_t *ctx){ uint8_t xor_block[64]; uint8_t block[64]; const uint8_t* hook_ptr = normal_hooks; const char* *hook_str_ptr = stream_n_str; uint8_t i; memset(xor_block, 0, 64); for(i=0; i<=448/64; ++i){ scal_cipher_gen_fillblock(block, 64, ctx); memxor(xor_block, block, 64); if(i==*hook_ptr){ ++hook_ptr; nessie_print_item(*(hook_str_ptr++), block, 64); } } nessie_print_item(*(hook_str_ptr), xor_block, 64); }
static void long_block(scgen_ctx_t *ctx){ uint8_t xor_block[64]; uint8_t block[64]; const uint16_t* hook_ptr = long_hooks; const char* *hook_str_ptr = stream_l_str; uint16_t i; memset(xor_block, 0, 64); for(i=0; i<=131008/64; ++i){ scal_cipher_gen_fillblock(block, 64, ctx); memxor(xor_block, block, 64); if(i==*hook_ptr){ ++hook_ptr; nessie_print_item(*(hook_str_ptr++), block, 64); } if(i%64==0){ NESSIE_SEND_ALIVE; } } nessie_print_item(*(hook_str_ptr), xor_block, 64); }