]> git.cryptolib.org Git - avr-crypto-lib.git/blob - sha256.h
new, derived from old avr/crypto + cast5
[avr-crypto-lib.git] / sha256.h
1 /**
2  * File:                sha256.h
3  * Author:      Daniel Otte 
4  * Date:                16.05.2006
5  * License:     GPL
6  * 
7  */
8
9 #ifndef SHA256_H_
10 #define SHA256_H_
11
12 #define __LITTLE_ENDIAN__
13
14
15 #include <stdint.h>
16
17
18 #define SHA256_HASH_BITS  256
19 #define SHA256_BLOCK_BITS 512
20
21 typedef struct {
22         uint32_t h[8];
23         uint64_t length;
24 } sha256_ctx_t;
25
26 typedef uint8_t sha256_hash_t[SHA256_HASH_BITS/8];
27
28 void sha256_init(sha256_ctx_t *state);
29 void sha256_nextBlock (sha256_ctx_t *state, void* block);
30 void sha256_lastBlock(sha256_ctx_t *state, void* block, uint16_t length);
31
32 void sha256_ctx2hash(sha256_hash_t *dest, sha256_ctx_t *state);
33 void sha256(sha256_hash_t *dest, void* msg, uint32_t length);
34 uint32_t change_endian32(uint32_t x);
35
36
37 #endif /*SHA256_H_*/