2 * Written in 2013 by Gregor Pintar <grpintar@gmail.com>
4 * To the extent possible under law, the author(s) have dedicated
5 * all copyright and related and neighboring rights to this software
6 * to the public domain worldwide.
8 * This software is distributed without any warranty.
10 * You should have received a copy of the CC0 Public Domain Dedication.
11 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
18 #include <kripto/cast.h>
19 #include <kripto/memwipe.h>
20 #include <kripto/hash.h>
21 #include <kripto/hash/keccak1600.h>
22 #include <kripto/hash/keccak800.h>
23 #include <kripto/mac.h>
24 #include <kripto/desc/mac.h>
25 #include <kripto/object/mac.h>
27 #include <kripto/mac/keccak1600.h>
28 #include <kripto/mac/keccak800.h>
32 struct kripto_mac_object obj
;
36 static void keccak_input
43 kripto_hash_input(s
->hash
, in
, len
);
46 static void keccak_tag(kripto_mac
*s
, void *tag
, unsigned int len
)
48 kripto_hash_output(s
->hash
, tag
, len
);
51 static kripto_mac
*keccak_recreate
60 (void)kripto_hash_recreate(s
->hash
, r
, tag_len
);
62 kripto_hash_input(s
->hash
, key
, key_len
);
67 static kripto_mac
*keccak1600_create
69 const kripto_mac_desc
*desc
,
80 s
= malloc(sizeof(kripto_mac
));
83 s
->obj
.desc
= kripto_mac_keccak1600
;
85 s
->hash
= kripto_hash_create(kripto_hash_keccak1600
, r
, tag_len
);
92 kripto_hash_input(s
->hash
, key
, key_len
);
97 static kripto_mac
*keccak800_create
99 const kripto_mac_desc
*desc
,
102 unsigned int key_len
,
110 s
= malloc(sizeof(kripto_mac
));
113 s
->obj
.desc
= kripto_mac_keccak800
;
115 s
->hash
= kripto_hash_create(kripto_hash_keccak800
, r
, tag_len
);
122 kripto_hash_input(s
->hash
, key
, key_len
);
127 static void keccak_destroy(kripto_mac
*s
)
129 kripto_hash_destroy(s
->hash
);
133 static const kripto_mac_desc keccak1600
=
141 UINT_MAX
/* max key */
144 const kripto_mac_desc
*const kripto_mac_keccak1600
= &keccak1600
;
146 static const kripto_mac_desc keccak800
=
154 UINT_MAX
/* max key */
157 const kripto_mac_desc
*const kripto_mac_keccak800
= &keccak800
;