-
-/*****************************************************************************
- * self tests *
- *****************************************************************************/
-void camellia128_ctx_dump(camellia128_ctx_t *s);
-
-void test_encrypt(uint8_t *block, uint8_t *key, uint16_t keylength, bool print){
- camellia128_ctx_t s;
- if (print){
- uart_putstr("\r\nCamellia (enc):\r\n key:\t\t");
- uart_hexdump(key, keylength/8);
- uart_putstr("\r\n plaintext:\t");
- uart_hexdump(block, 16);
- }
-
- camellia128_init(&s, key);;
- camellia128_enc(&s, block);
- if (print){
- uart_putstr("\r\n ciphertext:\t");
- uart_hexdump(block, 16);
- }
-}
-
-void test_decrypt(uint8_t *block, uint8_t *key, uint16_t keylength, bool print){
- camellia128_ctx_t s;
- if (print){
- uart_putstr("\r\nCamellia (dec):\r\n key:\t\t");
- uart_hexdump(key, keylength/8);
- uart_putstr("\r\n ciphertext:\t");
- uart_hexdump(block, 16);
- }
- camellia128_init(&s, key);
- camellia128_dec(&s, block);
- if (print){
- uart_putstr("\r\n plaintext:\t");
- uart_hexdump(block, 16);
- }
-}
-
-void nessie_test_iterate(uint8_t *block, uint8_t *key){
- uint16_t i;
- test_encrypt(block, key, 128, true);
- test_decrypt(block, key, 128, true);
- uart_putstr("\r\n100 times:");
- for(i=0; i<99; ++i){
- test_encrypt(block, key, 128, false);
- }
- test_encrypt(block, key, 128, true);
- uart_putstr("\r\n1000 times:");
- for(i=0; i<(999-100); ++i){
- test_encrypt(block, key, 128, false);
- }
- test_encrypt(block, key, 128, true);