Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/lib One more reason not ...



details:   https://anonhg.NetBSD.org/src/rev/be56af31b842
branches:  trunk
changeset: 754991:be56af31b842
user:      agc <agc%NetBSD.org@localhost>
date:      Wed May 19 02:50:16 2010 +0000

description:
One more reason not to use DSA keys:

The DSA algorithm seems to require a digest value which is 20 bytes
long, which kind of implies SHA-1.

If we have a DSA signature, use SHA-1 as a hash algorithm, for backwards
compatibility. RSA signatures continue to use SHA256 by default, although
this can be given as an argument, if desired.

This fixes DSA signatures with netpgp:

% netpgp --sign --userid d4a643c5 a
pub 1024/DSA 8222c3ecd4a643c5 2010-05-19 [EXPIRES 2013-05-18]
Key fingerprint: 3e4a 5df4 033b 2333 219b 1afd 8222 c3ec d4a6 43c5
uid              Alistair Crooks (DSA TEST KEY - DO NOT USE) <agc%netbsd.org@localhost>
sub 1024/DSA 8222c3ecd4a643c5 2010-05-19 [EXPIRES 2013-05-18]
netpgp passphrase:
% netpgp --verify a.gpg
Good signature for a.gpg made Tue May 18 05:41:25 2010
using DSA key 8222c3ecd4a643c5
pub 1024/DSA 8222c3ecd4a643c5 2010-05-19 [EXPIRES 2013-05-18]
Key fingerprint: 3e4a 5df4 033b 2333 219b 1afd 8222 c3ec d4a6 43c5
uid              Alistair Crooks (DSA TEST KEY - DO NOT USE) <agc%netbsd.org@localhost>
sub 1024/DSA 8222c3ecd4a643c5 2010-05-19 [EXPIRES 2013-05-18]
%

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (50 lines):

diff -r b16fafb9a957 -r be56af31b842 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Tue May 18 23:34:40 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Wed May 19 02:50:16 2010 +0000
@@ -34,7 +34,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: netpgp.c,v 1.50 2010/05/16 06:48:52 agc Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.51 2010/05/19 02:50:16 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -886,7 +886,7 @@
        __ops_seckey_t          *seckey;
        const unsigned           overwrite = 1;
        __ops_io_t              *io;
-       char                    *hashalg;
+       const char              *hashalg;
        int                      ret;
 
        io = netpgp->io;
@@ -934,6 +934,9 @@
        } while (seckey == NULL);
        /* sign file */
        hashalg = netpgp_getvar(netpgp, "hash");
+       if (seckey->pubkey.alg == OPS_PKA_DSA) {
+               hashalg = "sha1";
+       }
        if (detached) {
                ret = __ops_sign_detached(io, f, out, seckey, hashalg,
                                get_birthtime(netpgp_getvar(netpgp, "birthtime")),
@@ -1017,7 +1020,7 @@
        __ops_seckey_t          *seckey;
        __ops_memory_t          *signedmem;
        __ops_io_t              *io;
-       char                    *hashalg;
+       const char              *hashalg;
        int                      ret;
 
        io = netpgp->io;
@@ -1059,6 +1062,9 @@
        /* sign file */
        (void) memset(out, 0x0, outsize);
        hashalg = netpgp_getvar(netpgp, "hash");
+       if (seckey->pubkey.alg == OPS_PKA_DSA) {
+               hashalg = "sha1";
+       }
        signedmem = __ops_sign_buf(io, mem, size, seckey,
                                get_birthtime(netpgp_getvar(netpgp, "birthtime")),
                                get_duration(netpgp_getvar(netpgp, "duration")),



Home | Main Index | Thread Index | Old Index