]> git.cryptolib.org Git - avr-crypto-lib.git/blob - sha2/sha224.h
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / sha2 / sha224.h
1 /* sha224.h */
2 /*
3     This file is part of the ARM-Crypto-Lib.
4     Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
5
6     This program is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 /**
20  * \file        sha224.h
21  * \author  Daniel Otte 
22  * \date    2011-10-11
23  * \license     GPLv3 or later
24  * 
25  */
26
27 #ifndef SHA224_H_
28 #define SHA224_H_
29
30 #include <stdint.h>
31 #include "sha2_small_common.h"
32 /** \def SHA224_HASH_BITS
33  * defines the size of a SHA-224 hash value in bits
34  */
35
36 /** \def SHA224_HASH_BYTES
37  * defines the size of a SHA-224 hash value in bytes
38  */
39
40 /** \def SHA224_BLOCK_BITS
41  * defines the size of a SHA-224 input block in bits
42  */
43
44 /** \def SHA224_BLOCK_BYTES
45  * defines the size of a SHA-224 input block in bytes
46  */
47
48 #define SHA224_HASH_BITS  224
49 #define SHA224_HASH_BYTES (SHA224_HASH_BITS/8)
50 #define SHA224_BLOCK_BITS 512
51 #define SHA224_BLOCK_BYTES (SHA224_BLOCK_BITS/8)
52
53 /** \typedef sha224_ctx_t
54  * \brief SHA-224 context type
55  * 
56  * A variable of this type may hold the state of a SHA-224 hashing process
57  */
58 typedef sha2_small_common_ctx_t sha224_ctx_t;
59
60 /** \fn void sha224_init(sha224_ctx_t *state)
61  * \brief initialize a SHA-224 context
62  * 
63  * This function sets a ::sha224_ctx_t to the initial values for hashing.
64  * \param state pointer to the SHA-224 hashing context
65  */
66 void sha224_init(sha224_ctx_t *state);
67
68 /** \fn void sha224_nextBlock (sha224_ctx_t *state, const void *block)
69  * \brief update the context with a given block
70  * 
71  * This function updates the SHA-224 hash context by processing the given block
72  * of fixed length.
73  * \param state pointer to the SHA-224 hash context
74  * \param block pointer to the block of fixed length (512 bit = 64 byte)
75  */
76 void sha224_nextBlock (sha224_ctx_t *state, const void *block);
77
78 /** \fn void sha224_lastBlock(sha224_ctx_t *state, const void *block, uint16_t length_b)
79  * \brief finalize the context with the given block 
80  * 
81  * This function finalizes the SHA-224 hash context by processing the given block
82  * of variable length.
83  * \param state pointer to the SHA-224 hash context
84  * \param block pointer to the block of fixed length (512 bit = 64 byte)
85  * \param length_b the length of the block in bits
86  */
87 void sha224_lastBlock(sha224_ctx_t *state, const void *block, uint16_t length_b);
88
89 /** \fn void sha224_ctx2hash(sha224_hash_t *dest, const sha224_ctx_t *state)
90  * \brief convert the hash state into the hash value
91  * This function reads the context and writes the hash value to the destination
92  * \param dest pointer to the location where the hash value should be written
93  * \param state pointer to the SHA-224 hash context
94  */
95 void sha224_ctx2hash(void *dest, const sha224_ctx_t *state);
96
97 /** \fn void sha224(sha224_hash_t *dest, const void *msg, uint32_t length_b)
98  * \brief simple SHA-224 hashing function for direct hashing
99  * 
100  * This function automatically hashes a given message of arbitary length with
101  * the SHA-224 hashing algorithm.
102  * \param dest pointer to the location where the hash value is going to be written to
103  * \param msg pointer to the message thats going to be hashed
104  * \param length_b length of the message in bits
105  */
106 void sha224(void *dest, const void *msg, uint32_t length_b);
107
108 #endif /*SHA224_H_*/