pub/dsa-misc.c: Include a magic prefix in the hashing.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 31 Mar 2014 15:01:46 +0000 (16:01 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 13 Apr 2015 16:32:41 +0000 (17:32 +0100)
To prevent protocol interference.  In practice, I think including the
private key should be enough, because nobody would use that in any other
kind of hash, right...?

pub/dsa-misc.c

index 4f68c7b..8b03271 100644 (file)
@@ -84,6 +84,7 @@ mp *dsa_nonce(mp *d, mp *q, mp *x, const octet *m,
   size_t bsz = 2*n + 2*ch->hashsz;
   octet *b = XS_ALLOC(bsz);
   octet *kb = b, *rb = kb + n, *hb = rb + ch->hashsz;
+  static const char prefix[] = "catacomb-dsa-nonce";
   ghash *h;
 
   mp_storeb(x, kb, n);
@@ -92,6 +93,7 @@ mp *dsa_nonce(mp *d, mp *q, mp *x, const octet *m,
   do {
     for (j = 0; j < n; j += ch->hashsz) {
       h = GH_INIT(ch);
+      GH_HASH(h, prefix, sizeof(prefix));
       GH_HASHBUF32(h, kb, n);
       GH_HASHBUF32(h, m, ch->hashsz);
       if (r) GH_HASHBUF32(h, rb, ch->hashsz);