bcal-eax.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* bcal-eax.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2010 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. #ifndef BCALEAX_H_
  17. #define BCALEAX_H_
  18. #include <stdint.h>
  19. #include <string.h>
  20. #include <crypto/bcal-basic.h>
  21. #include <crypto/blockcipher_descriptor.h>
  22. #include <crypto/bcal-cmac.h>
  23. #include <crypto/bcal-ctr.h>
  24. typedef struct{
  25. uint8_t* nonce;
  26. bcal_cmac_ctx_t ntag;
  27. bcal_cmac_ctx_t ctag;
  28. bcal_cmac_ctx_t htag;
  29. bcal_ctr_ctx_t cipher;
  30. uint8_t blocksize_B;
  31. uint8_t header_set;
  32. } bcal_eax_ctx_t;
  33. uint8_t bcal_eax_init(const bcdesc_t* desc, const void* key, uint16_t keysize_b, bcal_eax_ctx_t* ctx);
  34. void bcal_eax_free(bcal_eax_ctx_t* ctx);
  35. void bcal_eax_loadNonce(const void* nonce, uint16_t length_b, bcal_eax_ctx_t* ctx);
  36. void bcal_eax_addNextHeader(const void* header, bcal_eax_ctx_t* ctx);
  37. void bcal_eax_addLastHeader(const void* header, uint16_t length_b, bcal_eax_ctx_t* ctx);
  38. void bcal_eax_encNextBlock(void* block, bcal_eax_ctx_t* ctx);
  39. void bcal_eax_encLastBlock(void* block, uint16_t length_b, bcal_eax_ctx_t* ctx);
  40. void bcal_eax_decNextBlock(void* block, bcal_eax_ctx_t* ctx);
  41. void bcal_eax_decLastBlock(void* block, uint16_t length_b, bcal_eax_ctx_t* ctx);
  42. void bcal_eax_ctx2tag(void* dest, uint16_t length_b, bcal_eax_ctx_t* ctx);
  43. //void bcal_eax(void* dest, uint16_t out_length_b, const void* block, uint32_t length_b, bcal_eax_ctx_t* ctx);
  44. #endif /* BCALEAX_H_ */