From e34de52833507224f5f0522fd205ee4fae81176e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 8 Mar 2013 10:34:04 +0100 Subject: logsig: update implementation to new concatenation rules from paper - when concatenting hashes, the hash ID must be included (actually the imprint, not just the hash is concatenated) - when concatenting integers, the smallest number of octets must be used (actually, we have just level currently, which always is one octet) --- runtime/librsgt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'runtime/librsgt.c') diff --git a/runtime/librsgt.c b/runtime/librsgt.c index 16dc3995..aa37dc84 100644 --- a/runtime/librsgt.c +++ b/runtime/librsgt.c @@ -456,16 +456,21 @@ static inline void bufAddHash(gtctx ctx, uchar *buf, size_t *len, GTDataHash *hash) { if(hash == NULL) { + // TODO: how to get the REAL HASH ID? --> add field! + buf[*len] = hashIdentifier(ctx->hashAlg); + ++(*len); memcpy(buf+*len, ctx->blkStrtHash, ctx->lenBlkStrtHash); *len += ctx->lenBlkStrtHash; } else { + buf[*len] = hashIdentifier(ctx->hashAlg); + ++(*len); memcpy(buf+*len, hash->digest, hash->digest_length); *len += hash->digest_length; } } /* concat: add tree level to buffer */ static inline void -bufAddLevel(uchar *buf, size_t *len, int level) +bufAddLevel(uchar *buf, size_t *len, uint8_t level) { memcpy(buf+*len, &level, sizeof(level)); *len += sizeof(level); @@ -494,7 +499,8 @@ hash_r(gtctx ctx, GTDataHash **r, const uchar *rec, const size_t len) static void -hash_node(gtctx ctx, GTDataHash **node, GTDataHash *m, GTDataHash *r, int level) +hash_node(gtctx ctx, GTDataHash **node, GTDataHash *m, GTDataHash *r, + uint8_t level) { // x = hash(concat(m, r, 0)); /* hash leaf */ uchar concatBuf[16*1024]; @@ -511,7 +517,7 @@ sigblkAddRecord(gtctx ctx, const uchar *rec, const size_t len) { GTDataHash *x; /* current hash */ GTDataHash *m, *r, *t; - int8_t j; + uint8_t j; hash_m(ctx, &m); hash_r(ctx, &r, rec, len); -- cgit v1.2.3