versadac  1
versadac - Scalable Recorder Firmware
sha256.h
Go to the documentation of this file.
1 /* sha256.h */
2 /*
3  This file is part of the AVR-Crypto-Lib.
4  Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
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 */
27 #ifndef SHA256_H_
28 #define SHA256_H_
29 
30 //#ifndef __LITTLE_ENDIAN__
31 //#define __LITTLE_ENDIAN__
32 //#endif
33 
34 #include <stdint.h>
35 
52 #define SHA256_HASH_BITS 256
53 #define SHA256_HASH_BYTES (SHA256_HASH_BITS/8)
54 #define SHA256_BLOCK_BITS 512
55 #define SHA256_BLOCK_BYTES (SHA256_BLOCK_BITS/8)
56 
62 typedef struct {
63  uint32_t h[8];
64  uint64_t length;
65 } sha256_ctx_t;
66 
74 
81 void sha256_init(sha256_ctx_t *state);
82 
91 void sha256_nextBlock (sha256_ctx_t* state, const void* block);
92 
102 void sha256_lastBlock(sha256_ctx_t* state, const void* block, uint16_t length_b);
103 
110 void sha256_ctx2hash(sha256_hash_t* dest, const sha256_ctx_t* state);
111 
121 void sha256(sha256_hash_t* dest, const void* msg, uint32_t length_b);
122 
123 
124 
125 bool TempRegressionTest_SHA256(void);
126 
127 #endif /*SHA256_H_*/
void sha256_nextBlock(sha256_ctx_t *state, const void *block)
update the context with a given block
Definition: sha256.cpp:122
void sha256(sha256_hash_t *dest, const void *msg, uint32_t length_b)
simple SHA-256 hashing function for direct hashing
Definition: sha256.cpp:213
void sha256_lastBlock(sha256_ctx_t *state, const void *block, uint16_t length_b)
finalize the context with the given block
Definition: sha256.cpp:169
Definition: sha256.h:62
uint8_t sha256_hash_t[SHA256_HASH_BYTES]
SHA-256 hash value type.
Definition: sha256.h:73
#define SHA256_HASH_BYTES
Definition: sha256.h:53
void sha256_init(sha256_ctx_t *state)
initialise a SHA-256 context
Definition: sha256.cpp:68
void sha256_ctx2hash(sha256_hash_t *dest, const sha256_ctx_t *state)
convert the hash state into the hash value This function reads the context and writes the hash value ...
Definition: sha256.cpp:229