]> git.cryptolib.org Git - avr-crypto-lib.git/blob - skein/ubi.h
new makefile and modified build process
[avr-crypto-lib.git] / skein / ubi.h
1 /* ubi.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  * \author  Daniel Otte
21  * \email   daniel.otte@rub.de
22  * \date    2009-03-12
23  * \license GPLv3 or later
24  * 
25  */
26
27 #ifndef UBI_H_
28 #define UBI_H_
29
30 #include <stdint.h>
31
32 #define UBI_TYPE_KEY  0
33 #define UBI_TYPE_CFG  4
34 #define UBI_TYPE_PRS  8
35 #define UBI_TYPE_PK  12
36 #define UBI_TYPE_KDF 16
37 #define UBI_TYPE_NON 20
38 #define UBI_TYPE_MSG 48
39 #define UBI_TYPE_OUT 63
40
41 #define UBI256_BLOCKSIZE 256
42 #define UBI256_BLOCKSIZE_B ((UBI256_BLOCKSIZE+7)/8)
43
44 #define UBI512_BLOCKSIZE 512
45 #define UBI512_BLOCKSIZE_B ((UBI512_BLOCKSIZE+7)/8)
46
47 #define UBI1024_BLOCKSIZE 1024
48 #define UBI1024_BLOCKSIZE_B ((UBI1024_BLOCKSIZE+7)/8)
49
50
51 typedef struct{
52         uint8_t tweak[16];
53         uint8_t g[32];
54 }ubi256_ctx_t;
55
56 typedef struct{
57         uint8_t tweak[16];
58         uint8_t g[64];
59 }ubi512_ctx_t;
60
61 typedef struct{
62         uint8_t tweak[16];
63         uint8_t g[128];
64 }ubi1024_ctx_t;
65
66 void ubi256_init(ubi256_ctx_t* ctx, const void* g, uint8_t type);
67 void ubi256_nextBlock(ubi256_ctx_t* ctx, const void* block);
68 void ubi256_lastBlock(ubi256_ctx_t* ctx, const void* block, uint16_t length_b);
69 void ubi256_ctx2hash(void* dest, const ubi256_ctx_t* ctx);
70
71 void ubi512_init(ubi512_ctx_t* ctx, const void* g, uint8_t type);
72 void ubi512_nextBlock(ubi512_ctx_t* ctx, const void* block);
73 void ubi512_lastBlock(ubi512_ctx_t* ctx, const void* block, uint16_t length_b);
74 void ubi512_ctx2hash(void* dest, const ubi512_ctx_t* ctx);
75
76 void ubi1024_init(ubi1024_ctx_t* ctx, const void* g, uint8_t type);
77 void ubi1024_nextBlock(ubi1024_ctx_t* ctx, const void* block);
78 void ubi1024_lastBlock(ubi1024_ctx_t* ctx, const void* block, uint16_t length_b);
79 void ubi1024_ctx2hash(void* dest, const ubi1024_ctx_t* ctx);
80
81 typedef struct{
82         char     schema[4];
83         uint16_t version;
84         uint16_t reserved1;
85         uint64_t out_length;
86         uint8_t  tree_leaf_size;
87         uint8_t  tree_fan_out;
88         uint8_t  tree_max_height;
89         uint8_t  reserved2[13];
90 }skein_config_t;
91
92
93 #endif /* UBI_H_ */