Module Name: src
Committed By: agc
Date: Wed May 19 02:50:16 UTC 2010
Modified Files:
src/crypto/external/bsd/netpgp/dist/src/lib: netpgp.c
Log Message:
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) <[email protected]>
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) <[email protected]>
sub 1024/DSA 8222c3ecd4a643c5 2010-05-19 [EXPIRES 2013-05-18]
%
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 \
src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.50 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.51
--- src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.50 Sun May 16 06:48:52 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c Wed May 19 02:50:16 2010
@@ -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")),