]> git.cryptolib.org Git - arm-crypto-lib.git/blob - blake/blake_small.h
AES makestub added
[arm-crypto-lib.git] / blake / blake_small.h
1 /* blake_small.h */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2009  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 */
19 /*
20  * \file    blake_small.h
21  * \author  Daniel Otte
22  * \email   daniel.otte@rub.de
23  * \date    2009-04-27
24  * \license GPLv3 or later
25  * 
26  */
27 #ifndef BLAKE_SMALL_H_
28 #define BLAKE_SMALL_H_
29
30 #include <stdint.h>
31
32 #define BLAKE_SMALL_BLOCKSIZE   512
33 #define BLAKE_SMALL_BLOCKSIZE_B ((BLAKE_SMALL_BLOCKSIZE+7)/8)
34 #define BLAKE28_BLOCKSIZE      BLAKE_SMALL_BLOCKSIZE
35 #define BLAKE28_BLOCKSIZE_B    BLAKE_SMALL_BLOCKSIZE_B
36 #define BLAKE32_BLOCKSIZE      BLAKE_SMALL_BLOCKSIZE
37 #define BLAKE32_BLOCKSIZE_B    BLAKE_SMALL_BLOCKSIZE_B
38
39 typedef struct {
40         uint32_t h[8];
41         uint32_t s[4];
42         uint32_t counter;
43         uint8_t  appendone;
44 } blake_small_ctx_t;
45
46 typedef blake_small_ctx_t blake28_ctx_t;
47 typedef blake_small_ctx_t blake32_ctx_t;
48
49 void blake28_init(blake28_ctx_t* ctx);
50 void blake32_init(blake32_ctx_t* ctx);
51
52 void blake_small_nextBlock(blake_small_ctx_t* ctx, const void* block);
53 void blake_small_lastBlock(blake_small_ctx_t* ctx, const void* block, uint16_t length_b);
54
55 void blake28_nextBlock(blake28_ctx_t* ctx, const void* block);
56 void blake28_lastBlock(blake28_ctx_t* ctx, const void* block, uint16_t length_b);
57
58 void blake32_nextBlock(blake32_ctx_t* ctx, const void* block);
59 void blake32_lastBlock(blake32_ctx_t* ctx, const void* block, uint16_t length_b);
60
61 void blake28_ctx2hash(void* dest, const blake28_ctx_t* ctx);
62 void blake32_ctx2hash(void* dest, const blake32_ctx_t* ctx);
63
64 void blake28(void* dest, const void* msg, uint32_t length_b);
65 void blake32(void* dest, const void* msg, uint32_t length_b);
66
67 #endif /* BLAKE_SMALL_H_ */