3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 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/>.
23 * \license GPLv3 or later
27 #include <avr/pgmspace.h>
30 #include "hashfunction_descriptor.h"
32 #include "string-extras.h"
36 hfdesc_t** algolist=NULL;
38 void shavs_listalgos(void){
41 cli_putstr_P(PSTR("\r\nDBG: &algolist: "));
42 cli_hexdump(&algolist, 2);
43 cli_putstr_P(PSTR("\r\nDBG: algolist[0]: "));
44 cli_hexdump(algolist, 8);
48 cli_putstr_P(PSTR("\r\nthe following algorithms are available:\r\n"));
49 while(option<='z' && (t=(hfdesc_t*)pgm_read_word(&(algolist[i])))){
51 cli_putc((t==algo)?'*':' ');
53 cli_putstr_P(PSTR(":\t"));
54 cli_putstr_P((void*)(pgm_read_word(&(t->name))));
55 cli_putstr_P(PSTR("\r\n"));
60 void shavs_setalgo(char* param){
61 param = strstrip(param);
62 if(param[1]=='\0'){ /* single letter specified */
63 uint8_t i,option = param[0]-'a';
66 cli_putstr_P(PSTR("\r\nERROR: algolist not set!"));
69 for(i=0; i<=option; ++i){
70 if((void*)pgm_read_word(&(algolist[i]))==NULL){
71 cli_putstr_P(PSTR("\r\nERROR: invalid selection!"));
75 algo=(hfdesc_t*)pgm_read_word(&(algolist[option]));
76 } else { /* name specifyed */
79 while((t=(hfdesc_t*)pgm_read_word(&(algolist[i]))) &&
80 strcasecmp_P(param, (void*)pgm_read_word(&(t->name))))
85 cli_putstr_P(PSTR("\r\nERROR: could not find \""));
87 cli_putstr_P(PSTR("\"!"));