echo.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* echo.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 ECHO_H_
  17. #define ECHO_H_
  18. #include <stdint.h>
  19. #define ECHO_SMALL_BLOCKSIZE 1536
  20. #define ECHO_SMALL_BLOCKSIZE_B ((ECHO_SMALL_BLOCKSIZE+7)/8)
  21. #define ECHO_LARGE_BLOCKSIZE 1024
  22. #define ECHO_LARGE_BLOCKSIZE_B ((ECHO_LARGE_BLOCKSIZE+7)/8)
  23. #define ECHO224_BLOCKSIZE ECHO_SMALL_BLOCKSIZE
  24. #define ECHO224_BLOCKSIZE_B ((ECHO224_BLOCKSIZE+7)/8)
  25. #define ECHO256_BLOCKSIZE ECHO_SMALL_BLOCKSIZE
  26. #define ECHO256_BLOCKSIZE_B ((ECHO256_BLOCKSIZE+7)/8)
  27. #define ECHO384_BLOCKSIZE ECHO_LARGE_BLOCKSIZE
  28. #define ECHO384_BLOCKSIZE_B ((ECHO384_BLOCKSIZE+7)/8)
  29. #define ECHO512_BLOCKSIZE ECHO_LARGE_BLOCKSIZE
  30. #define ECHO512_BLOCKSIZE_B ((ECHO512_BLOCKSIZE+7)/8)
  31. typedef struct{
  32. uint8_t v[4*16];
  33. uint8_t salt[16];
  34. uint64_t counter;
  35. uint16_t id;
  36. }echo_small_ctx_t;
  37. typedef struct{
  38. uint8_t v[8*16];
  39. uint8_t salt[16];
  40. uint64_t counter;
  41. uint16_t id;
  42. }echo_large_ctx_t;
  43. void echo_small_nextBlock(echo_small_ctx_t* ctx, void* block);
  44. void echo_small_lastBlock(echo_small_ctx_t* ctx, void* block, uint16_t length_b);
  45. void echo_small_ctx2hash(void* dest, uint16_t length_b, echo_small_ctx_t* ctx);
  46. void echo224_ctx2hash(void* dest, echo_small_ctx_t* ctx);
  47. void echo256_ctx2hash(void* dest, echo_small_ctx_t* ctx);
  48. void echo224_init(echo_small_ctx_t* ctx);
  49. void echo256_init(echo_small_ctx_t* ctx);
  50. void echo_large_nextBlock(echo_large_ctx_t* ctx, void* block);
  51. void echo_large_lastBlock(echo_large_ctx_t* ctx, void* block, uint16_t length_b);
  52. void echo_large_ctx2hash(void* dest, uint16_t length_b, echo_large_ctx_t* ctx);
  53. void echo384_ctx2hash(void* dest, echo_large_ctx_t* ctx);
  54. void echo512_ctx2hash(void* dest, echo_large_ctx_t* ctx);
  55. void echo384_init(echo_large_ctx_t* ctx);
  56. void echo512_init(echo_large_ctx_t* ctx);
  57. #endif /* ECHO_H_ */