X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=keysize_descriptor.c;h=b9a8d71f207a0b5d1cf26792cf442e17a694868f;hp=8ffb06f7eb55928d763b92725605d83b8b504036;hb=61b5214b9a948a74fe9c22586b84d19d24537fdb;hpb=3f2f2071c47e2e424af71cc85697f3eb26c24277 diff --git a/keysize_descriptor.c b/keysize_descriptor.c index 8ffb06f..b9a8d71 100644 --- a/keysize_descriptor.c +++ b/keysize_descriptor.c @@ -1,7 +1,7 @@ /* keysize_descriptor.c */ /* - This file is part of the ARM-Crypto-Lib. - Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de) + This file is part of the AVR-Crypto-Lib. + Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ */ #include +#include #include "keysize_descriptor.h" uint8_t is_valid_keysize_P(const void* ks_desc, uint16_t keysize){ @@ -77,11 +78,84 @@ uint16_t get_keysize(const void* ks_desc){ uint8_t type; uint16_t keysize; type = *((uint8_t*)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 = *((uint16_t*)ks_desc); + keysize = *((uint8_t*)ks_desc); return keysize; } - +uint16_t get_keysizes(const void* ks_desc, uint16_t** list){ + uint8_t type; + uint16_t items; + uint8_t i; + type = *((uint8_t*)ks_desc); + ks_desc = (uint8_t*)ks_desc + 1; + if(type==KS_TYPE_LIST){ + items = *((uint8_t*)ks_desc); + ks_desc = (uint8_t*)ks_desc + 1; + if(!*list){ + *list = malloc(items*2); + if(!*list){ + return 0; + } + } + for(i=0; i