sha224.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* sha224.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2011 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 sha224.h
  18. * \author Daniel Otte
  19. * \date 2011-10-11
  20. * \license GPLv3 or later
  21. *
  22. */
  23. #ifndef SHA224_H_
  24. #define SHA224_H_
  25. #include <stdint.h>
  26. #include <crypto/sha2_small_common.h>
  27. /** \def SHA224_HASH_BITS
  28. * defines the size of a SHA-224 hash value in bits
  29. */
  30. /** \def SHA224_HASH_BYTES
  31. * defines the size of a SHA-224 hash value in bytes
  32. */
  33. /** \def SHA224_BLOCK_BITS
  34. * defines the size of a SHA-224 input block in bits
  35. */
  36. /** \def SHA224_BLOCK_BYTES
  37. * defines the size of a SHA-224 input block in bytes
  38. */
  39. #define SHA224_HASH_BITS 224
  40. #define SHA224_HASH_BYTES (SHA224_HASH_BITS/8)
  41. #define SHA224_BLOCK_BITS 512
  42. #define SHA224_BLOCK_BYTES (SHA224_BLOCK_BITS/8)
  43. /** \typedef sha224_ctx_t
  44. * \brief SHA-224 context type
  45. *
  46. * A variable of this type may hold the state of a SHA-224 hashing process
  47. */
  48. typedef sha2_small_common_ctx_t sha224_ctx_t;
  49. /** \fn void sha224_init(sha224_ctx_t *state)
  50. * \brief initialize a SHA-224 context
  51. *
  52. * This function sets a ::sha224_ctx_t to the initial values for hashing.
  53. * \param state pointer to the SHA-224 hashing context
  54. */
  55. void sha224_init(sha224_ctx_t *state);
  56. /** \fn void sha224_nextBlock (sha224_ctx_t* state, const void* block)
  57. * \brief update the context with a given block
  58. *
  59. * This function updates the SHA-224 hash context by processing the given block
  60. * of fixed length.
  61. * \param state pointer to the SHA-224 hash context
  62. * \param block pointer to the block of fixed length (512 bit = 64 byte)
  63. */
  64. void sha224_nextBlock (sha224_ctx_t* state, const void* block);
  65. /** \fn void sha224_lastBlock(sha224_ctx_t* state, const void* block, uint16_t length_b)
  66. * \brief finalize the context with the given block
  67. *
  68. * This function finalizes the SHA-224 hash context by processing the given block
  69. * of variable length.
  70. * \param state pointer to the SHA-224 hash context
  71. * \param block pointer to the block of fixed length (512 bit = 64 byte)
  72. * \param length_b the length of the block in bits
  73. */
  74. void sha224_lastBlock(sha224_ctx_t* state, const void* block, uint16_t length_b);
  75. /** \fn void sha224_ctx2hash(sha224_hash_t* dest, const sha224_ctx_t* state)
  76. * \brief convert the hash state into the hash value
  77. * This function reads the context and writes the hash value to the destination
  78. * \param dest pointer to the location where the hash value should be written
  79. * \param state pointer to the SHA-224 hash context
  80. */
  81. void sha224_ctx2hash(void* dest, const sha224_ctx_t* state);
  82. /** \fn void sha224(sha224_hash_t* dest, const void* msg, uint32_t length_b)
  83. * \brief simple SHA-224 hashing function for direct hashing
  84. *
  85. * This function automatically hashes a given message of arbitary length with
  86. * the SHA-224 hashing algorithm.
  87. * \param dest pointer to the location where the hash value is going to be written to
  88. * \param msg pointer to the message thats going to be hashed
  89. * \param length_b length of the message in bits
  90. */
  91. void sha224(void* dest, const void* msg, uint32_t length_b);
  92. #endif /*SHA224_H_*/