3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * email: daniel.otte@rub.de
25 * common function for nessie-tests
31 #include <stdlib.h> /* utoa() */
32 #include "nessie_common.h"
33 #include "hexdigit_tab.h"
35 #include "string-extras.h"
39 void nessie_send_alive(void){
40 cli_putc(NESSIE_ALIVE_CHAR);
43 void nessie_send_alive_a(uint16_t i){
45 cli_putc(NESSIE_ALIVE_CHAR);
49 void nessie_print_block(uint8_t* block, uint16_t blocksize_bit){
50 cli_hexdump(block, (blocksize_bit+7)/8);
54 #define BYTESPERLINE 16
56 void nessie_print_item(const char* name, uint8_t* buffer, uint16_t size_B){
59 name_len=strlen(name);
60 if(name_len>SPACES-1){
61 cli_putstr("\r\n!!! formatting error !!!\r\n");
65 for(i=0; i<SPACES-name_len-1; ++i){
70 /* now the data printing begins */
71 if(size_B<=BYTESPERLINE){
72 /* one line seems sufficient */
73 nessie_print_block(buffer, size_B*8);
75 /* we need more lines */
76 nessie_print_block(buffer, BYTESPERLINE*8); /* first line */
77 int16_t toprint = size_B - BYTESPERLINE;
78 buffer += BYTESPERLINE;
81 for(i=0; i<SPACES; ++i){
84 nessie_print_block(buffer, ((toprint>BYTESPERLINE)?BYTESPERLINE:toprint)*8);
85 buffer += BYTESPERLINE;
86 toprint -= BYTESPERLINE;
92 void nessie_print_set_vector(uint8_t set, uint16_t vector){
93 cli_putstr("\r\n\r\nSet ");
95 cli_putstr(", vector#");
96 cli_putc((vector<1000)?' ':'0'+vector/1000);
97 cli_putc((vector<100)?' ':'0'+(vector/100)%10);
98 cli_putc((vector<10 )?' ':'0'+(vector/10)%10);
99 cli_putc('0'+vector%10);
104 Test vectors -- set 3
105 =====================
107 void nessie_print_setheader(uint8_t set){
108 cli_putstr("\r\n\r\nTest vectors -- set ");
109 cli_putc('0'+set%10);
110 cli_putstr("\r\n=====================");
114 ********************************************************************************
115 *Project NESSIE - New European Schemes for Signature, Integrity, and Encryption*
116 ********************************************************************************
118 Primitive Name: Serpent
119 =======================
124 void nessie_print_header(const char* name,
126 uint16_t blocksize_b,
131 cli_putstr("\r\n\r\n"
132 "********************************************************************************\r\n"
133 "* ARM-Crypto-Lib - crypto primitives for ARM microcontrollers by Daniel Otte *\r\n"
134 "********************************************************************************\r\n"
137 cli_putstr("Primitive Name: ");
141 for(i=0; i<16+strlen(name); ++i){
144 char str[6]; /* must catch numbers up to 65535 + terminating \0 */
146 cli_putstr("\r\nKey size: ");
147 ustoa(keysize_b, str, 10);
152 cli_putstr("\r\nBlock size: ");
153 ustoa(blocksize_b, str, 10);
158 cli_putstr("\r\nHash size: ");
159 ustoa(hashsize_b, str, 10);
165 cli_putstr("\r\nMac size: ");
166 ustoa(macsize_b, str, 10);
171 if(ivsize_b==(uint16_t)-1){
172 cli_putstr("\r\nNo initial value (IV) mode");
174 cli_putstr("\r\nIV size: ");
175 ustoa(ivsize_b, str, 10);
183 void nessie_print_footer(void){
184 cli_putstr("\r\n\r\n\r\n\r\nEnd of test vectors\r\n\r\n");