X-Git-Url: https://git.cryptolib.org/?p=arm-crypto-lib.git;a=blobdiff_plain;f=bcal%2Fkeysize_descriptor.c;fp=bcal%2Fkeysize_descriptor.c;h=0000000000000000000000000000000000000000;hp=8ffb06f7eb55928d763b92725605d83b8b504036;hb=61b5214b9a948a74fe9c22586b84d19d24537fdb;hpb=6131049b56c13e49ea9546f18febf31c572917f4 diff --git a/bcal/keysize_descriptor.c b/bcal/keysize_descriptor.c deleted file mode 100644 index 8ffb06f..0000000 --- a/bcal/keysize_descriptor.c +++ /dev/null @@ -1,87 +0,0 @@ -/* keysize_descriptor.c */ -/* - This file is part of the ARM-Crypto-Lib. - Copyright (C) 2006-2010 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 - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * \file keysize_descriptor.c - * \author Daniel Otte - * \email daniel.otte@rub.de - * \date 2009-01-07 - * \license GPLv3 or later - */ - -#include -#include "keysize_descriptor.h" - -uint8_t is_valid_keysize_P(const void* ks_desc, uint16_t keysize){ - uint8_t type; - type = *((uint8_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 1; - if(type==KS_TYPE_TERMINATOR) - return 0; - if(type==KS_TYPE_LIST){ - uint8_t items; - uint16_t item; - items = *((uint8_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 1; - while(items--){ - item = *((uint16_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 2; - if(item==keysize) - return 1; - } - ks_desc = (uint8_t*)ks_desc - 2; - } - if(type==KS_TYPE_RANGE){ - uint16_t max, min; - min = *((uint16_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 2; - max = *((uint16_t*)ks_desc); - if(min<=keysize && keysize<=max) - return 1; - } - if(type==KS_TYPE_ARG_RANGE){ - uint16_t max, min, dist, offset; - min = *((uint16_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 2; - max = *((uint16_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 2; - dist = *((uint16_t*)ks_desc); - ks_desc = (uint8_t*)ks_desc + 2; - offset = *((uint16_t*)ks_desc); - if(min<=keysize && keysize<=max && (keysize%dist==offset)) - return 1; - } - if(type>KS_TYPE_ARG_RANGE){ - /* bad error, you may insert a big warning message here */ - return 0; - } - return is_valid_keysize_P((uint8_t*)ks_desc+1, keysize); /* search the next record */ -} - -uint16_t get_keysize(const void* ks_desc){ - uint8_t type; - uint16_t keysize; - type = *((uint8_t*)ks_desc); - if(type==KS_TYPE_LIST) - ks_desc = (uint8_t*)ks_desc + 1; - ks_desc = (uint8_t*)ks_desc + 1; - keysize = *((uint16_t*)ks_desc); - return keysize; -} - -