added support for authenticated hashes

This commit is contained in:
TLINDEN
2015-07-21 14:18:03 +02:00
parent 95ab61b3cb
commit 362f7dff6b
14 changed files with 906 additions and 930 deletions

View File

@@ -812,13 +812,18 @@ http://mrob.com/pub/math/int128.c.txt
http://locklessinc.com/articles/256bit_arithmetic/
*/
int pcp_checksum(PCPCTX *ptx, Pcpstream *in, byte *checksum) {
int pcp_checksum(PCPCTX *ptx, Pcpstream *in, byte *checksum, byte *key, size_t keylen) {
crypto_generichash_state *st = ucmalloc(sizeof(crypto_generichash_state));
byte *buf = ucmalloc(PCP_BLOCK_SIZE);
size_t bufsize = 0;
int ret = 1;
crypto_generichash_init(st, NULL, 0, 0);
if(key != NULL && keylen <= crypto_generichash_KEYBYTES_MAX) {
crypto_generichash_init(st, key, keylen, crypto_generichash_KEYBYTES_MAX);
}
else
crypto_generichash_init(st, NULL, 0, 0);
while(!ps_end(in)) {
bufsize = ps_read(in, buf, PCP_BLOCK_SIZE);