X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=keysize_descriptor.c;h=d78ed031c925921b6574eaa0eca6065e76f5c147;hp=045ff65f4c24c2c5188fad812ebbf24886f94095;hb=66c915087d1f7b8eb7280be43c16e9588faf2e55;hpb=3f759a542ce8ba4ffbeb6d336a3557a8abbd3ad4 diff --git a/keysize_descriptor.c b/keysize_descriptor.c index 045ff65..d78ed03 100644 --- a/keysize_descriptor.c +++ b/keysize_descriptor.c @@ -25,6 +25,7 @@ */ #include +#include #include #include "keysize_descriptor.h" @@ -76,11 +77,85 @@ uint16_t get_keysize(PGM_VOID_P ks_desc){ uint8_t type; uint16_t keysize; type = pgm_read_byte(ks_desc); - if(type==KS_TYPE_LIST) + if(type==KS_TYPE_LIST){ ks_desc = (uint8_t*)ks_desc + 1; + } ks_desc = (uint8_t*)ks_desc + 1; keysize = pgm_read_word(ks_desc); return keysize; } - +uint16_t get_keysizes(PGM_VOID_P ks_desc, uint16_t** list){ + uint8_t type; + uint16_t items; + uint8_t i; + type = pgm_read_byte(ks_desc); + ks_desc = (uint8_t*)ks_desc + 1; + if(type==KS_TYPE_LIST){ + items = pgm_read_byte(ks_desc); + ks_desc = (uint8_t*)ks_desc + 1; + if(!*list){ + *list = malloc(items*2); + if(!*list){ + return 0; + } + } + for(i=0; i