diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-03-08 10:34:04 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-03-08 10:34:04 +0100 |
commit | e34de52833507224f5f0522fd205ee4fae81176e (patch) | |
tree | dc5c76107a9c3d0ff5edd13c4d0f8a544271d07f | |
parent | e01e72695022ae50af68a47c4aef2c338eff8c8e (diff) | |
download | rsyslog-e34de52833507224f5f0522fd205ee4fae81176e.tar.gz rsyslog-e34de52833507224f5f0522fd205ee4fae81176e.tar.bz2 rsyslog-e34de52833507224f5f0522fd205ee4fae81176e.zip |
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)
-rw-r--r-- | runtime/librsgt.c | 12 |
1 files changed, 9 insertions, 3 deletions
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); |