]> git.cryptolib.org Git - avr-crypto-lib.git/blob - skein/ubi.h
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / skein / ubi.h
1 /* ubi.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  * \author  Daniel Otte
21  * \email   bg@nerilex.org
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         union {
53                 uint8_t v8[16];
54                 uint16_t v16[8];
55                 uint32_t v32[4];
56                 uint64_t v64[2];
57         } tweak;
58         uint8_t g[32];
59 }ubi256_ctx_t;
60
61 typedef struct{
62         union {
63                 uint8_t v8[16];
64                 uint16_t v16[8];
65                 uint32_t v32[4];
66                 uint64_t v64[2];
67         } tweak;
68         uint8_t g[64];
69 }ubi512_ctx_t;
70
71 typedef struct{
72         union {
73                 uint8_t v8[16];
74                 uint16_t v16[8];
75                 uint32_t v32[4];
76                 uint64_t v64[2];
77         } tweak;
78         uint8_t g[128];
79 }ubi1024_ctx_t;
80
81 void ubi256_init(ubi256_ctx_t *ctx, const void *g, uint8_t type);
82 void ubi256_nextBlock(ubi256_ctx_t *ctx, const void *block);
83 void ubi256_lastBlock(ubi256_ctx_t *ctx, const void *block, uint16_t length_b);
84 void ubi256_ctx2hash(void *dest, const ubi256_ctx_t *ctx);
85
86 void ubi512_init(ubi512_ctx_t *ctx, const void *g, uint8_t type);
87 void ubi512_nextBlock(ubi512_ctx_t *ctx, const void *block);
88 void ubi512_lastBlock(ubi512_ctx_t *ctx, const void *block, uint16_t length_b);
89 void ubi512_ctx2hash(void *dest, const ubi512_ctx_t *ctx);
90
91 void ubi1024_init(ubi1024_ctx_t *ctx, const void *g, uint8_t type);
92 void ubi1024_nextBlock(ubi1024_ctx_t *ctx, const void *block);
93 void ubi1024_lastBlock(ubi1024_ctx_t *ctx, const void *block, uint16_t length_b);
94 void ubi1024_ctx2hash(void *dest, const ubi1024_ctx_t *ctx);
95
96 typedef struct{
97         char     schema[4];
98         uint16_t version;
99         uint16_t reserved1;
100         uint64_t out_length;
101         uint8_t  tree_leaf_size;
102         uint8_t  tree_fan_out;
103         uint8_t  tree_max_height;
104         uint8_t  reserved2[13];
105 }skein_config_t;
106
107
108 #endif /* UBI_H_ */