keccak.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* keccak.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 KECCAK_H_
  17. #define KECCAK_H_
  18. #include <stdint.h>
  19. #define KECCAK224_BLOCKSIZE 1152
  20. #define KECCAK224_BLOCKSIZE_B (KECCAK224_BLOCKSIZE/8)
  21. #define KECCAK256_BLOCKSIZE 1088
  22. #define KECCAK256_BLOCKSIZE_B (KECCAK256_BLOCKSIZE/8)
  23. #define KECCAK384_BLOCKSIZE 832
  24. #define KECCAK384_BLOCKSIZE_B (KECCAK384_BLOCKSIZE/8)
  25. #define KECCAK512_BLOCKSIZE 576
  26. #define KECCAK512_BLOCKSIZE_B (KECCAK512_BLOCKSIZE/8)
  27. typedef struct{
  28. uint64_t a[5][5];
  29. uint16_t r, c;
  30. uint8_t d, bs;
  31. } keccak_ctx_t;
  32. void keccak_init(uint16_t r, uint16_t c, uint8_t d, keccak_ctx_t* ctx);
  33. void keccak224_init(keccak_ctx_t* ctx);
  34. void keccak256_init(keccak_ctx_t* ctx);
  35. void keccak384_init(keccak_ctx_t* ctx);
  36. void keccak512_init(keccak_ctx_t* ctx);
  37. void keccak_nextBlock(keccak_ctx_t* ctx, const void* block);
  38. void keccak_lastBlock(keccak_ctx_t* ctx, const void* block, uint16_t length_b);
  39. void keccak_ctx2hash(void* dest, uint16_t length_b, keccak_ctx_t* ctx);
  40. void keccak224_ctx2hash(void* dest, keccak_ctx_t* ctx);
  41. void keccak256_ctx2hash(void* dest, keccak_ctx_t* ctx);
  42. void keccak384_ctx2hash(void* dest, keccak_ctx_t* ctx);
  43. void keccak512_ctx2hash(void* dest, keccak_ctx_t* ctx);
  44. #endif /* KECCAK_H_ */