keysize_descriptor.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* keysize_descriptor.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /**
  17. * \file keysize_descriptor.h
  18. * \author Daniel Otte
  19. * \email daniel.otte@rub.de
  20. * \date 2009-01-07
  21. * \license GPLv3 or later
  22. */
  23. #ifndef KEYSIZE_DESCRIPTOR_H_
  24. #define KEYSIZE_DESCRIPTOR_H_
  25. #include <stdint.h>
  26. #define KS_TYPE_TERMINATOR 0x00
  27. #define KS_TYPE_LIST 0x01
  28. #define KS_TYPE_RANGE 0x02
  29. #define KS_TYPE_ARG_RANGE 0x03
  30. #define KS_INT(a) ((a)&0xFF), ((a)>>8)
  31. typedef struct{ /* keysize is valid if listed in items */
  32. uint8_t n_items; /* number of items (value 0 is reserved) */
  33. uint16_t items[]; /* list of valid lengths */
  34. }keysize_desc_list_t;
  35. typedef struct{ /* keysize is valid if min<=keysize<=max */
  36. uint16_t min;
  37. uint16_t max;
  38. }keysize_desc_range_t;
  39. typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod distance == offset */
  40. uint16_t min;
  41. uint16_t max;
  42. uint16_t distance;
  43. uint16_t offset;
  44. }keysize_desc_arg_range_t;
  45. uint8_t is_valid_keysize_P(const void* ks_desc, uint16_t keysize);
  46. uint16_t get_keysize(const void* ks_desc);
  47. uint16_t get_keysizes(const void* ks_desc, uint16_t** list);
  48. #endif /* KEYSIZE_DESCRIPTOR_H_ */