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.
17 #include <kripto/desc/hash.h>
19 #include <kripto/hash.h>
23 const kripto_hash_desc
*desc
;
26 kripto_hash
*kripto_hash_create
28 const kripto_hash_desc
*desc
,
35 assert(len
<= kripto_hash_maxout(desc
));
37 return desc
->create(rounds
, len
);
40 kripto_hash
*kripto_hash_recreate
49 assert(s
->desc
->recreate
);
50 assert(len
<= kripto_hash_maxout(s
->desc
));
52 return s
->desc
->recreate(s
, rounds
, len
);
55 void kripto_hash_input(kripto_hash
*s
, const void *in
, size_t len
)
59 assert(s
->desc
->input
);
61 s
->desc
->input(s
, in
, len
);
64 void kripto_hash_output(kripto_hash
*s
, void *out
, size_t len
)
68 assert(s
->desc
->output
);
69 assert(len
<= kripto_hash_maxout(s
->desc
));
71 s
->desc
->output(s
, out
, len
);
74 void kripto_hash_destroy(kripto_hash
*s
)
78 assert(s
->desc
->destroy
);
85 const kripto_hash_desc
*desc
,
94 assert(desc
->hash_all
);
95 assert(out_len
<= kripto_hash_maxout(desc
));
97 return desc
->hash_all(rounds
, in
, in_len
, out
, out_len
);
100 const kripto_hash_desc
*kripto_hash_getdesc(const kripto_hash
*s
)
108 size_t kripto_hash_maxout(const kripto_hash_desc
*desc
)
111 assert(desc
->maxout
);
116 unsigned int kripto_hash_blocksize(const kripto_hash_desc
*desc
)
119 assert(desc
->blocksize
);
121 return desc
->blocksize
;