blockcipher_descriptor.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* blockcipher_descriptor.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 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 blockcipher_descriptor.h
  18. * \author Daniel Otte
  19. * \date 2009-02-04
  20. *
  21. * \license GPLv3 or later
  22. *
  23. */
  24. #ifndef BLOCKCIPHER_DESCRIPTOR_H_
  25. #define BLOCKCIPHER_DESCRIPTOR_H_
  26. #include <stdint.h>
  27. #ifndef VOID_FPT
  28. #define VOID_FPT
  29. typedef void(*void_fpt)(void);
  30. #endif
  31. typedef void(*bc_init1_fpt)(void*, void*);
  32. typedef void(*bc_init2_fpt)(void*, uint16_t,void*);
  33. typedef void(*bc_enc1_fpt)(void*, void*);
  34. typedef void(*bc_enc2_fpt)(void*, void*, void*);
  35. typedef void(*bc_dec1_fpt)(void*, void*);
  36. typedef void(*bc_dec2_fpt)(void*, void*, void*);
  37. typedef void(*bc_free_fpt)(void*);
  38. typedef union{
  39. void_fpt initvoid;
  40. bc_init1_fpt init1;
  41. bc_init2_fpt init2;
  42. } bc_init_fpt;
  43. typedef union{
  44. void_fpt encvoid;
  45. bc_enc1_fpt enc1;
  46. bc_enc2_fpt enc2;
  47. } bc_enc_fpt;
  48. typedef union{
  49. void_fpt decvoid;
  50. bc_dec1_fpt dec1;
  51. bc_dec2_fpt dec2;
  52. } bc_dec_fpt;
  53. #define BC_INIT_TYPE 0x01
  54. #define BC_INIT_TYPE_1 0x00
  55. #define BC_INIT_TYPE_2 0x01
  56. #define BC_ENC_TYPE 0x02
  57. #define BC_ENC_TYPE_1 0x00
  58. #define BC_ENC_TYPE_2 0x02
  59. #
  60. #define BC_DEC_TYPE 0x04
  61. #define BC_DEC_TYPE_1 0x00
  62. #define BC_DEC_TYPE_2 0x04
  63. #define BCDESC_TYPE_BLOCKCIPHER 0x01
  64. typedef struct {
  65. uint8_t type; /* 1==blockcipher */
  66. uint8_t flags;
  67. const char* name;
  68. uint16_t ctxsize_B;
  69. uint16_t blocksize_b;
  70. bc_init_fpt init;
  71. bc_enc_fpt enc;
  72. bc_dec_fpt dec;
  73. bc_free_fpt free;
  74. const void* valid_keysize_desc;
  75. } bcdesc_t; /* blockcipher descriptor type */
  76. typedef struct{
  77. bcdesc_t* desc_ptr;
  78. void* ctx;
  79. uint16_t keysize;
  80. } bcgen_ctx_t;
  81. #endif /* BLOCKCIPHER_DESCRIPTOR_H_ */