hfal_skein256.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* hfal_skein256.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_skein256.c
  18. * \email daniel.otte@rub.de
  19. * \author Daniel Otte
  20. * \date 2009-03-13
  21. * \license GPLv3 or later
  22. *
  23. */
  24. #include <stdlib.h>
  25. #include <crypto/hashfunction_descriptor.h>
  26. #include <crypto/skein.h>
  27. static const char skein256_128_str[] = "Skein-256-128";
  28. static const char skein256_160_str[] = "Skein-256-160";
  29. static const char skein256_224_str[] = "Skein-256-224";
  30. static const char skein256_256_str[] = "Skein-256-256";
  31. static const char skein256_384_str[] = "Skein-256-384";
  32. static const char skein256_512_str[] = "Skein-256-512";
  33. void skein256_128_init(skein256_ctx_t* ctx){
  34. skein256_init(ctx, 128);
  35. }
  36. void skein256_160_init(skein256_ctx_t* ctx){
  37. skein256_init(ctx, 160);
  38. }
  39. void skein256_224_init(skein256_ctx_t* ctx){
  40. skein256_init(ctx, 224);
  41. }
  42. void skein256_256_init(skein256_ctx_t* ctx){
  43. skein256_init(ctx, 256);
  44. }
  45. void skein256_384_init(skein256_ctx_t* ctx){
  46. skein256_init(ctx, 384);
  47. }
  48. void skein256_512_init(skein256_ctx_t* ctx){
  49. skein256_init(ctx, 512);
  50. }
  51. const hfdesc_t skein256_128_desc = {
  52. HFDESC_TYPE_HASHFUNCTION,
  53. 0,
  54. skein256_128_str,
  55. sizeof(skein256_ctx_t),
  56. SKEIN256_BLOCKSIZE,
  57. 128,
  58. (hf_init_fpt)skein256_128_init,
  59. (hf_nextBlock_fpt)skein256_nextBlock,
  60. (hf_lastBlock_fpt)skein256_lastBlock,
  61. (hf_ctx2hash_fpt)skein256_ctx2hash,
  62. (hf_free_fpt)NULL,
  63. (hf_mem_fpt)NULL
  64. };
  65. const hfdesc_t skein256_160_desc = {
  66. HFDESC_TYPE_HASHFUNCTION,
  67. 0,
  68. skein256_160_str,
  69. sizeof(skein256_ctx_t),
  70. SKEIN256_BLOCKSIZE,
  71. 160,
  72. (hf_init_fpt)skein256_160_init,
  73. (hf_nextBlock_fpt)skein256_nextBlock,
  74. (hf_lastBlock_fpt)skein256_lastBlock,
  75. (hf_ctx2hash_fpt)skein256_ctx2hash,
  76. (hf_free_fpt)NULL,
  77. (hf_mem_fpt)NULL
  78. };
  79. const hfdesc_t skein256_224_desc = {
  80. HFDESC_TYPE_HASHFUNCTION,
  81. 0,
  82. skein256_224_str,
  83. sizeof(skein256_ctx_t),
  84. SKEIN256_BLOCKSIZE,
  85. 224,
  86. (hf_init_fpt)skein256_224_init,
  87. (hf_nextBlock_fpt)skein256_nextBlock,
  88. (hf_lastBlock_fpt)skein256_lastBlock,
  89. (hf_ctx2hash_fpt)skein256_ctx2hash,
  90. (hf_free_fpt)NULL,
  91. (hf_mem_fpt)NULL
  92. };
  93. const hfdesc_t skein256_256_desc = {
  94. HFDESC_TYPE_HASHFUNCTION,
  95. 0,
  96. skein256_256_str,
  97. sizeof(skein256_ctx_t),
  98. SKEIN256_BLOCKSIZE,
  99. 256,
  100. (hf_init_fpt)skein256_256_init,
  101. (hf_nextBlock_fpt)skein256_nextBlock,
  102. (hf_lastBlock_fpt)skein256_lastBlock,
  103. (hf_ctx2hash_fpt)skein256_ctx2hash,
  104. (hf_free_fpt)NULL,
  105. (hf_mem_fpt)NULL
  106. };
  107. const hfdesc_t skein256_384_desc = {
  108. HFDESC_TYPE_HASHFUNCTION,
  109. 0,
  110. skein256_384_str,
  111. sizeof(skein256_ctx_t),
  112. SKEIN256_BLOCKSIZE,
  113. 384,
  114. (hf_init_fpt)skein256_384_init,
  115. (hf_nextBlock_fpt)skein256_nextBlock,
  116. (hf_lastBlock_fpt)skein256_lastBlock,
  117. (hf_ctx2hash_fpt)skein256_ctx2hash,
  118. (hf_free_fpt)NULL,
  119. (hf_mem_fpt)NULL
  120. };
  121. const hfdesc_t skein256_512_desc = {
  122. HFDESC_TYPE_HASHFUNCTION,
  123. 0,
  124. skein256_512_str,
  125. sizeof(skein256_ctx_t),
  126. SKEIN256_BLOCKSIZE,
  127. 512,
  128. (hf_init_fpt)skein256_512_init,
  129. (hf_nextBlock_fpt)skein256_nextBlock,
  130. (hf_lastBlock_fpt)skein256_lastBlock,
  131. (hf_ctx2hash_fpt)skein256_ctx2hash,
  132. (hf_free_fpt)NULL,
  133. (hf_mem_fpt)NULL
  134. };