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"
38 void nessie_send_alive(void){
39 cli_putc(NESSIE_ALIVE_CHAR);
42 void nessie_send_alive_a(uint16_t i){
44 cli_putc(NESSIE_ALIVE_CHAR);
48 void nessie_print_block(uint8_t* block, uint16_t blocksize_bit){
49 cli_hexdump(block, (blocksize_bit+7)/8);
53 #define BYTESPERLINE 16
55 void nessie_print_item(const char* name, uint8_t* buffer, uint16_t size_B){
58 name_len=strlen(name);
59 if(name_len>SPACES-1){
60 cli_putstr("\r\n!!! formatting error !!!\r\n");
64 for(i=0; i<SPACES-name_len-1; ++i){
69 /* now the data printing begins */
70 if(size_B<=BYTESPERLINE){
71 /* one line seems sufficient */
72 nessie_print_block(buffer, size_B*8);
74 /* we need more lines */
75 nessie_print_block(buffer, BYTESPERLINE*8); /* first line */
76 int16_t toprint = size_B - BYTESPERLINE;
77 buffer += BYTESPERLINE;
80 for(i=0; i<SPACES; ++i){
83 nessie_print_block(buffer, ((toprint>BYTESPERLINE)?BYTESPERLINE:toprint)*8);
84 buffer += BYTESPERLINE;
85 toprint -= BYTESPERLINE;
91 void nessie_print_set_vector(uint8_t set, uint16_t vector){
92 cli_putstr("\r\n\r\nSet ");
94 cli_putstr(", vector#");
95 cli_putc((vector<1000)?' ':'0'+vector/1000);
96 cli_putc((vector<100)?' ':'0'+(vector/100)%10);
97 cli_putc((vector<10 )?' ':'0'+(vector/10)%10);
98 cli_putc('0'+vector%10);
103 Test vectors -- set 3
104 =====================
106 void nessie_print_setheader(uint8_t set){
107 cli_putstr("\r\n\r\nTest vectors -- set ");
108 cli_putc('0'+set%10);
109 cli_putstr("\r\n=====================");
113 ********************************************************************************
114 *Project NESSIE - New European Schemes for Signature, Integrity, and Encryption*
115 ********************************************************************************
117 Primitive Name: Serpent
118 =======================
123 void nessie_print_header(const char* name,
125 uint16_t blocksize_b,
130 cli_putstr("\r\n\r\n"
131 "********************************************************************************\r\n"
132 "* ARM-Crypto-Lib - crypto primitives for ARM microcontrolles by Daniel Otte *\r\n"
133 "********************************************************************************\r\n"
135 cli_putstr("Primitive Name: ");
139 for(i=0; i<16+strlen(name); ++i){
142 char str[6]; /* must catch numbers up to 65535 + terminatin \0 */
144 cli_putstr("\r\nKey size: ");
145 ustoa(keysize_b, str, 10);
150 cli_putstr("\r\nBlock size: ");
151 ustoa(blocksize_b, str, 10);
156 cli_putstr("\r\nHash size: ");
157 ustoa(hashsize_b, str, 10);
162 cli_putstr("\r\nMac size: ");
163 ustoa(macsize_b, str, 10);
168 if(ivsize_b==(uint16_t)-1){
169 cli_putstr("\r\nNo initial value (IV) mode");
171 cli_putstr("\r\nIV size: ");
172 ustoa(ivsize_b, str, 10);
180 void nessie_print_footer(void){
181 cli_putstr("\r\n\r\n\r\n\r\nEnd of test vectors\r\n\r\n");