]> git.cryptolib.org Git - avr-crypto-lib.git/blob - shabal/shabal.h
fixing some decryption bugs in GCM128
[avr-crypto-lib.git] / shabal / shabal.h
1 /* shabal.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    shabal.h
21  * \author  Daniel Otte
22  * \email   daniel.otte@rub.de
23  * \date    2009-04-17
24  * \license GPLv3 or later
25  * 
26  */
27
28 #ifndef SHABAL_H_
29 #define SHABAL_H_
30
31 #include <stdint.h>
32
33 #define SHABAL_BLOCKSIZE 512
34 #define SHABAL_BLOCKSIZE_B ((SHABAL_BLOCKSIZE+7)/8)
35
36 #define SHABAL_R 12
37 #define SHABAL_P  3
38
39 typedef struct{
40         union{
41                 uint64_t w64;
42                 uint32_t w32[2];
43         } w; /* the counter */
44         uint32_t *b;
45         uint32_t *c;
46         uint32_t a[SHABAL_R];
47         uint32_t b_buffer[16];
48         uint32_t c_buffer[16];
49 }shabal_ctx_t;
50
51
52 void shabal192_init(shabal_ctx_t *ctx);
53 void shabal224_init(shabal_ctx_t *ctx);
54 void shabal256_init(shabal_ctx_t *ctx);
55 void shabal384_init(shabal_ctx_t *ctx);
56 void shabal512_init(shabal_ctx_t *ctx);
57
58 void shabal_nextBlock(shabal_ctx_t *ctx, const void *block);
59 void shabal_lastBlock(shabal_ctx_t *ctx, const void *block, uint16_t length_b);
60
61 void shabal192_ctx2hash(void *dest, const shabal_ctx_t *ctx);
62 void shabal224_ctx2hash(void *dest, const shabal_ctx_t *ctx);
63 void shabal256_ctx2hash(void *dest, const shabal_ctx_t *ctx);
64 void shabal384_ctx2hash(void *dest, const shabal_ctx_t *ctx);
65 void shabal512_ctx2hash(void *dest, const shabal_ctx_t *ctx);
66
67 void shabal192(void *dest, void *msg, uint32_t length_b);
68 void shabal224(void *dest, void *msg, uint32_t length_b);
69 void shabal256(void *dest, void *msg, uint32_t length_b);
70 void shabal384(void *dest, void *msg, uint32_t length_b);
71 void shabal512(void *dest, void *msg, uint32_t length_b);
72
73 void shabal_ctx2hash(void *dest, const shabal_ctx_t *ctx, uint16_t outlength_b);
74
75 #endif /* SHABAL_H_ */