X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/82fa9679b601bfc08d92b98ef9638572e6fa22cf..d470270aa476e8100eb78b1958ce5dd557983195:/dsig.c diff --git a/dsig.c b/dsig.c index 32b5ea5..e591538 100644 --- a/dsig.c +++ b/dsig.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: dsig.c,v 1.2 2000/07/01 11:27:22 mdw Exp $ + * $Id: dsig.c,v 1.4 2000/08/04 23:23:44 mdw Exp $ * * Verify signatures on distribuitions of files * @@ -30,6 +30,12 @@ /*----- Revision history --------------------------------------------------* * * $Log: dsig.c,v $ + * Revision 1.4 2000/08/04 23:23:44 mdw + * Various fixes. + * + * Revision 1.3 2000/07/15 20:53:23 mdw + * More hash functions. Bug fix in getstring. + * * Revision 1.2 2000/07/01 11:27:22 mdw * Use new PKCS#1 padding functions rather than rolling by hand. * @@ -55,18 +61,25 @@ #include #include -#include "dsa.h" #include "getdate.h" #include "grand.h" #include "ghash.h" #include "key.h" #include "key-data.h" -#include "md5.h" #include "noise.h" + +#include "dsa.h" +#include "rsa.h" #include "pkcs1.h" + +#include "md4.h" +#include "md5.h" +#include "rmd128.h" #include "rmd160.h" -#include "rsa.h" +#include "rmd256.h" +#include "rmd320.h" #include "sha.h" +#include "tiger.h" /*----- Digital signature algorithm ---------------------------------------*/ @@ -85,6 +98,8 @@ static int dsasign(key *k, const void *m, size_t msz, dstr *d) return (e); } sz = mp_octets(dp.dp.q); + if (sz < msz) + die(EXIT_FAILURE, "hash function too wide for this signing key"); DENSURE(d, sz * 2); p = d->buf + d->len; rand_get(RAND_GLOBAL, p, sz); @@ -175,7 +190,8 @@ typedef struct sig { const void */*s*/, size_t /*ssz*/); } sig; -static const gchash *hashtab[] = { &rmd160, &sha, &md5, 0 }; +static const gchash *hashtab[] = { + &rmd160, &tiger, &sha, &rmd128, &rmd256, &rmd320, &md5, &md4, 0 }; static sig sigtab[] = { { "dsa", "dsig-dsa", dsasign, dsaverify }, { "rsa", "dsig-rsa", rsasign, rsaverify }, @@ -333,7 +349,7 @@ static int getstring(FILE *fp, dstr *d, unsigned raw) again: ch = getc(fp); - while (isspace((unsigned char)ch)) + while (isspace(ch)) ch = getc(fp); if (ch == '#') { do ch = getc(fp); while (ch != '\n' && ch != EOF); @@ -365,7 +381,7 @@ again: if (ch == EOF) break; switch (ch) { - case 'a': ch = '\n'; break; + case 'a': ch = '\a'; break; case 'b': ch = '\b'; break; case 'f': ch = '\f'; break; case 'n': ch = '\n'; break; @@ -374,6 +390,7 @@ again: case 'v': ch = '\v'; break; } DPUTC(d, ch); + ch = getc(fp); continue; }