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/>.
16 #include <kripto/desc/hash.h>
18 #include <kripto/hash.h>
22 const kripto_hash_desc
*desc
;
25 kripto_hash
*kripto_hash_create
27 const kripto_hash_desc
*desc
,
34 assert(len
<= kripto_hash_maxout(desc
));
36 return desc
->create(rounds
, len
);
39 kripto_hash
*kripto_hash_recreate
48 assert(s
->desc
->recreate
);
49 assert(len
<= kripto_hash_maxout(s
->desc
));
51 return s
->desc
->recreate(s
, rounds
, len
);
54 void kripto_hash_input(kripto_hash
*s
, const void *in
, size_t len
)
58 assert(s
->desc
->input
);
60 s
->desc
->input(s
, in
, len
);
63 void kripto_hash_output(kripto_hash
*s
, void *out
, size_t len
)
67 assert(s
->desc
->output
);
68 assert(len
<= kripto_hash_maxout(s
->desc
));
70 s
->desc
->output(s
, out
, len
);
73 void kripto_hash_destroy(kripto_hash
*s
)
77 assert(s
->desc
->destroy
);
84 const kripto_hash_desc
*desc
,
93 assert(desc
->hash_all
);
94 assert(out_len
<= kripto_hash_maxout(desc
));
96 return desc
->hash_all(rounds
, in
, in_len
, out
, out_len
);
99 const kripto_hash_desc
*kripto_hash_getdesc(const kripto_hash
*s
)
107 size_t kripto_hash_maxout(const kripto_hash_desc
*desc
)
110 assert(desc
->maxout
);
115 unsigned int kripto_hash_blocksize(const kripto_hash_desc
*desc
)
118 assert(desc
->blocksize
);
120 return desc
->blocksize
;