1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

Honor --cert-digest-algo when recreating a cert.

* g10/sign.c (update_keysig_packet): Honor --cert-digest-algo when
  recreating a cert.

This is used by various things in --edit-key like setpref, primary,
etc.  Suggested by Christian Aistleitner.
This commit is contained in:
David Shaw 2012-01-31 21:30:05 -05:00
parent 75b347a2a1
commit 509fe4ce5d

View File

@ -1,6 +1,6 @@
/* sign.c - sign data /* sign.c - sign data
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
* 2007, 2010 Free Software Foundation, Inc. * 2007, 2010, 2012 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -1489,7 +1489,7 @@ update_keysig_packet( PKT_signature **ret_sig,
void *opaque ) void *opaque )
{ {
PKT_signature *sig; PKT_signature *sig;
int rc=0; int rc=0, digest_algo;
MD_HANDLE md; MD_HANDLE md;
if ((!orig_sig || !pk || !sk) if ((!orig_sig || !pk || !sk)
@ -1497,7 +1497,12 @@ update_keysig_packet( PKT_signature **ret_sig,
|| (orig_sig->sig_class == 0x18 && !subpk)) || (orig_sig->sig_class == 0x18 && !subpk))
return G10ERR_GENERAL; return G10ERR_GENERAL;
md = md_open( orig_sig->digest_algo, 0 ); if ( opt.cert_digest_algo )
digest_algo = opt.cert_digest_algo;
else
digest_algo = orig_sig->digest_algo;
md = md_open( digest_algo, 0 );
/* hash the public key certificate and the user id */ /* hash the public key certificate and the user id */
hash_public_key( md, pk ); hash_public_key( md, pk );