shabal.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* shabal.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 shabal.h
  18. * \author Daniel Otte
  19. * \email daniel.otte@rub.de
  20. * \date 2009-04-17
  21. * \license GPLv3 or later
  22. *
  23. */
  24. #ifndef SHABAL_H_
  25. #define SHABAL_H_
  26. #include <stdint.h>
  27. #define SHABAL_BLOCKSIZE 512
  28. #define SHABAL_BLOCKSIZE_B ((SHABAL_BLOCKSIZE+7)/8)
  29. #define SHABAL_R 12
  30. #define SHABAL_P 3
  31. typedef struct{
  32. union{
  33. uint64_t w64;
  34. uint32_t w32[2];
  35. } w; /* the counter */
  36. uint32_t *b;
  37. uint32_t *c;
  38. uint32_t a[SHABAL_R];
  39. uint32_t b_buffer[16];
  40. uint32_t c_buffer[16];
  41. }shabal_ctx_t;
  42. void shabal192_init(shabal_ctx_t* ctx);
  43. void shabal224_init(shabal_ctx_t* ctx);
  44. void shabal256_init(shabal_ctx_t* ctx);
  45. void shabal384_init(shabal_ctx_t* ctx);
  46. void shabal512_init(shabal_ctx_t* ctx);
  47. void shabal_nextBlock(shabal_ctx_t* ctx, const void* block);
  48. void shabal_lastBlock(shabal_ctx_t* ctx, const void* block, uint16_t length_b);
  49. void shabal192_ctx2hash(void* dest, const shabal_ctx_t* ctx);
  50. void shabal224_ctx2hash(void* dest, const shabal_ctx_t* ctx);
  51. void shabal256_ctx2hash(void* dest, const shabal_ctx_t* ctx);
  52. void shabal384_ctx2hash(void* dest, const shabal_ctx_t* ctx);
  53. void shabal512_ctx2hash(void* dest, const shabal_ctx_t* ctx);
  54. void shabal192(void* dest, void* msg, uint32_t length_b);
  55. void shabal224(void* dest, void* msg, uint32_t length_b);
  56. void shabal256(void* dest, void* msg, uint32_t length_b);
  57. void shabal384(void* dest, void* msg, uint32_t length_b);
  58. void shabal512(void* dest, void* msg, uint32_t length_b);
  59. void shabal_ctx2hash(void* dest, const shabal_ctx_t* ctx, uint16_t outlength_b);
  60. #endif /* SHABAL_H_ */