2 * Copyright (C) 2013 Gregor Pintar <grpintar@gmail.com>
4 * Permission is granted to deal in this work without any restriction,
5 * including unlimited rights to use, publicly perform, publish,
6 * reproduce, relicence, modify, merge, and/or distribute in any form,
7 * for any purpose, with or without fee, and by any means.
9 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind,
10 * to the utmost extent permitted by applicable law. In no event
11 * shall a licensor, author or contributor be held liable for any
12 * issues arising in any way out of dealing in the work.
19 #include <kripto/cast.h>
20 #include <kripto/memwipe.h>
21 #include <kripto/hash.h>
22 #include <kripto/hash/keccak1600.h>
23 #include <kripto/hash/keccak800.h>
24 #include <kripto/mac.h>
25 #include <kripto/desc/mac.h>
26 #include <kripto/object/mac.h>
28 #include <kripto/mac/keccak1600.h>
29 #include <kripto/mac/keccak800.h>
33 struct kripto_mac_object obj
;
37 static void keccak_input
44 kripto_hash_input(s
->hash
, in
, len
);
47 static void keccak_tag(kripto_mac
*s
, void *tag
, unsigned int len
)
49 kripto_hash_output(s
->hash
, tag
, len
);
52 static kripto_mac
*keccak_recreate
61 (void)kripto_hash_recreate(s
->hash
, r
, tag_len
);
63 kripto_hash_input(s
->hash
, key
, key_len
);
68 static kripto_mac
*keccak1600_create
70 const kripto_mac_desc
*desc
,
81 s
= malloc(sizeof(kripto_mac
));
84 s
->obj
.desc
= kripto_mac_keccak1600
;
86 s
->hash
= kripto_hash_create(kripto_hash_keccak1600
, r
, tag_len
);
93 kripto_hash_input(s
->hash
, key
, key_len
);
98 static kripto_mac
*keccak800_create
100 const kripto_mac_desc
*desc
,
103 unsigned int key_len
,
111 s
= malloc(sizeof(kripto_mac
));
114 s
->obj
.desc
= kripto_mac_keccak800
;
116 s
->hash
= kripto_hash_create(kripto_hash_keccak800
, r
, tag_len
);
123 kripto_hash_input(s
->hash
, key
, key_len
);
128 static void keccak_destroy(kripto_mac
*s
)
130 kripto_hash_destroy(s
->hash
);
134 static const kripto_mac_desc keccak1600
=
144 const kripto_mac_desc
*const kripto_mac_keccak1600
= &keccak1600
;
146 static const kripto_mac_desc keccak800
=
156 const kripto_mac_desc
*const kripto_mac_keccak800
= &keccak800
;