blake_small.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* blake_small.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2009 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 blake_small.h
  18. * \author Daniel Otte
  19. * \email daniel.otte@rub.de
  20. * \date 2009-04-27
  21. * \license GPLv3 or later
  22. *
  23. */
  24. #ifndef BLAKE_SMALL_H_
  25. #define BLAKE_SMALL_H_
  26. #include <stdint.h>
  27. #define BLAKE_SMALL_BLOCKSIZE 512
  28. #define BLAKE_SMALL_BLOCKSIZE_B ((BLAKE_SMALL_BLOCKSIZE+7)/8)
  29. #define BLAKE224_BLOCKSIZE BLAKE_SMALL_BLOCKSIZE
  30. #define BLAKE224_BLOCKSIZE_B BLAKE_SMALL_BLOCKSIZE_B
  31. #define BLAKE256_BLOCKSIZE BLAKE_SMALL_BLOCKSIZE
  32. #define BLAKE256_BLOCKSIZE_B BLAKE_SMALL_BLOCKSIZE_B
  33. typedef struct {
  34. uint32_t h[8];
  35. uint32_t s[4];
  36. uint32_t counter;
  37. uint8_t appendone;
  38. } blake_small_ctx_t;
  39. typedef blake_small_ctx_t blake224_ctx_t;
  40. typedef blake_small_ctx_t blake256_ctx_t;
  41. void blake224_init(blake224_ctx_t* ctx);
  42. void blake256_init(blake256_ctx_t* ctx);
  43. void blake_small_nextBlock(blake_small_ctx_t* ctx, const void* block);
  44. void blake_small_lastBlock(blake_small_ctx_t* ctx, const void* block, uint16_t length_b);
  45. void blake224_nextBlock(blake224_ctx_t* ctx, const void* block);
  46. void blake224_lastBlock(blake224_ctx_t* ctx, const void* block, uint16_t length_b);
  47. void blake256_nextBlock(blake256_ctx_t* ctx, const void* block);
  48. void blake256_lastBlock(blake256_ctx_t* ctx, const void* block, uint16_t length_b);
  49. void blake224_ctx2hash(void* dest, const blake224_ctx_t* ctx);
  50. void blake256_ctx2hash(void* dest, const blake256_ctx_t* ctx);
  51. void blake224(void* dest, const void* msg, uint32_t length_b);
  52. void blake256(void* dest, const void* msg, uint32_t length_b);
  53. #endif /* BLAKE_SMALL_H_ */