hfal_keccak.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* hfal_keccak.c */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 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 hfal_keccak.c
  18. * \email daniel.otte@rub.de
  19. * \author Daniel Otte
  20. * \date 2010-02-09
  21. * \license GPLv3 or later
  22. *
  23. */
  24. #include <stdlib.h>
  25. #include <crypto/hashfunction_descriptor.h>
  26. #include <crypto/keccak.h>
  27. static const char keccak224_str[] = "Keccak-224";
  28. static const char keccak256_str[] = "Keccak-256";
  29. static const char keccak384_str[] = "Keccak-384";
  30. static const char keccak512_str[] = "Keccak-512";
  31. const hfdesc_t keccak224_desc = {
  32. HFDESC_TYPE_HASHFUNCTION,
  33. 0,
  34. keccak224_str,
  35. sizeof(keccak_ctx_t),
  36. KECCAK224_BLOCKSIZE,
  37. 224,
  38. (hf_init_fpt)keccak224_init,
  39. (hf_nextBlock_fpt)keccak_nextBlock,
  40. (hf_lastBlock_fpt)keccak_lastBlock,
  41. (hf_ctx2hash_fpt)keccak224_ctx2hash,
  42. (hf_free_fpt)NULL,
  43. (hf_mem_fpt)NULL
  44. };
  45. const hfdesc_t keccak256_desc = {
  46. HFDESC_TYPE_HASHFUNCTION,
  47. 0,
  48. keccak256_str,
  49. sizeof(keccak_ctx_t),
  50. KECCAK256_BLOCKSIZE,
  51. 256,
  52. (hf_init_fpt)keccak256_init,
  53. (hf_nextBlock_fpt)keccak_nextBlock,
  54. (hf_lastBlock_fpt)keccak_lastBlock,
  55. (hf_ctx2hash_fpt)keccak256_ctx2hash,
  56. (hf_free_fpt)NULL,
  57. (hf_mem_fpt)NULL
  58. };
  59. const hfdesc_t keccak384_desc = {
  60. HFDESC_TYPE_HASHFUNCTION,
  61. 0,
  62. keccak384_str,
  63. sizeof(keccak_ctx_t),
  64. KECCAK384_BLOCKSIZE,
  65. 384,
  66. (hf_init_fpt)keccak384_init,
  67. (hf_nextBlock_fpt)keccak_nextBlock,
  68. (hf_lastBlock_fpt)keccak_lastBlock,
  69. (hf_ctx2hash_fpt)keccak384_ctx2hash,
  70. (hf_free_fpt)NULL,
  71. (hf_mem_fpt)NULL
  72. };
  73. const hfdesc_t keccak512_desc = {
  74. HFDESC_TYPE_HASHFUNCTION,
  75. 0,
  76. keccak512_str,
  77. sizeof(keccak_ctx_t),
  78. KECCAK512_BLOCKSIZE,
  79. 512,
  80. (hf_init_fpt)keccak512_init,
  81. (hf_nextBlock_fpt)keccak_nextBlock,
  82. (hf_lastBlock_fpt)keccak_lastBlock,
  83. (hf_ctx2hash_fpt)keccak512_ctx2hash,
  84. (hf_free_fpt)NULL,
  85. (hf_mem_fpt)NULL
  86. };