cmac.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**************************************************************************
  2. Copyright (C) 2009 Lander Casado, Philippas Tsigas
  3. All rights reserved.
  4. Permission is hereby granted, free of charge, to any person obtaining
  5. a copy of this software and associated documentation files
  6. (the "Software"), to deal with the Software without restriction, including
  7. without limitation the rights to use, copy, modify, merge, publish,
  8. distribute, sublicense, and/or sell copies of the Software, and to
  9. permit persons to whom the Software is furnished to do so, subject to
  10. the following conditions:
  11. Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimers. Redistributions in
  13. binary form must reproduce the above copyright notice, this list of
  14. conditions and the following disclaimers in the documentation and/or
  15. other materials provided with the distribution.
  16. In no event shall the authors or copyright holders be liable for any special,
  17. incidental, indirect or consequential damages of any kind, or any damages
  18. whatsoever resulting from loss of use, data or profits, whether or not
  19. advised of the possibility of damage, and on any theory of liability,
  20. arising out of or in connection with the use or performance of this software.
  21. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  27. DEALINGS WITH THE SOFTWARE
  28. *****************************************************************************/
  29. #ifndef _CMAC_H_
  30. #define _CMAC_H_
  31. #include "aes.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #define AES_CMAC_KEY_LENGTH 16
  36. #define AES_CMAC_DIGEST_LENGTH 16
  37. typedef unsigned char u_int8_t;
  38. typedef unsigned int u_int;
  39. typedef struct _AES_CMAC_CTX {
  40. aes_context rijndael;
  41. u_int8_t X[16];
  42. u_int8_t M_last[16];
  43. u_int M_n;
  44. } AES_CMAC_CTX;
  45. //#include <sys/cdefs.h>
  46. //__BEGIN_DECLS
  47. void AES_CMAC_Init(AES_CMAC_CTX * ctx);
  48. void AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const u_int8_t key[AES_CMAC_KEY_LENGTH]);
  49. void AES_CMAC_Update(AES_CMAC_CTX * ctx, const u_int8_t * data, u_int len);
  50. // __attribute__((__bounded__(__string__,2,3)));
  51. void AES_CMAC_Final(u_int8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX * ctx);
  52. // __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
  53. //__END_DECLS
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* _CMAC_H_ */