Mon Jun 27 07:05:32 2011 UTC ()
only attempt to load the secret key if we need to (for signing or for
decrypting).


(agc)
diff -r1.90 -r1.91 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c

cvs diff -r1.90 -r1.91 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c (expand / switch to unified diff)

--- src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c 2011/06/25 00:37:44 1.90
+++ src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c 2011/06/27 07:05:31 1.91
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE. 27 * POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29#include "config.h" 29#include "config.h"
30 30
31#ifdef HAVE_SYS_CDEFS_H 31#ifdef HAVE_SYS_CDEFS_H
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#endif 33#endif
34 34
35#if defined(__NetBSD__) 35#if defined(__NetBSD__)
36__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); 36__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
37__RCSID("$NetBSD: netpgp.c,v 1.90 2011/06/25 00:37:44 agc Exp $"); 37__RCSID("$NetBSD: netpgp.c,v 1.91 2011/06/27 07:05:31 agc Exp $");
38#endif 38#endif
39 39
40#include <sys/types.h> 40#include <sys/types.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/mman.h> 43#include <sys/mman.h>
44 44
45#ifdef HAVE_SYS_RESOURCE_H 45#ifdef HAVE_SYS_RESOURCE_H
46#include <sys/resource.h> 46#include <sys/resource.h>
47#endif 47#endif
48 48
49#ifdef HAVE_FCNTL_H 49#ifdef HAVE_FCNTL_H
50#include <fcntl.h> 50#include <fcntl.h>
@@ -842,30 +842,32 @@ netpgp_init(netpgp_t *netpgp) @@ -842,30 +842,32 @@ netpgp_init(netpgp_t *netpgp)
842 if (netpgp_getvar(netpgp, "need userid") != NULL) { 842 if (netpgp_getvar(netpgp, "need userid") != NULL) {
843 (void) fprintf(io->errs, 843 (void) fprintf(io->errs,
844 "Cannot find user id\n"); 844 "Cannot find user id\n");
845 return 0; 845 return 0;
846 } 846 }
847 } else { 847 } else {
848 (void) netpgp_setvar(netpgp, "userid", userid); 848 (void) netpgp_setvar(netpgp, "userid", userid);
849 } 849 }
850 netpgp->pubring = readkeyring(netpgp, "pubring"); 850 netpgp->pubring = readkeyring(netpgp, "pubring");
851 if (netpgp->pubring == NULL) { 851 if (netpgp->pubring == NULL) {
852 (void) fprintf(io->errs, "Can't read pub keyring\n"); 852 (void) fprintf(io->errs, "Can't read pub keyring\n");
853 return 0; 853 return 0;
854 } 854 }
855 netpgp->secring = readkeyring(netpgp, "secring"); 855 if (netpgp_getvar(netpgp, "need seckey")) {
856 if (netpgp->secring == NULL) { 856 netpgp->secring = readkeyring(netpgp, "secring");
857 (void) fprintf(io->errs, "Can't read sec keyring\n"); 857 if (netpgp->secring == NULL) {
858 return 0; 858 (void) fprintf(io->errs, "Can't read sec keyring\n");
 859 return 0;
 860 }
859 } 861 }
860 } else { 862 } else {
861 last = (netpgp->pubring != NULL); 863 last = (netpgp->pubring != NULL);
862 if (!readsshkeys(netpgp, homedir, netpgp_getvar(netpgp, "need seckey"))) { 864 if (!readsshkeys(netpgp, homedir, netpgp_getvar(netpgp, "need seckey"))) {
863 (void) fprintf(io->errs, "Can't read ssh keys\n"); 865 (void) fprintf(io->errs, "Can't read ssh keys\n");
864 return 0; 866 return 0;
865 } 867 }
866 if ((userid = netpgp_getvar(netpgp, "userid")) == NULL) { 868 if ((userid = netpgp_getvar(netpgp, "userid")) == NULL) {
867 set_first_pubring(netpgp->pubring, id, sizeof(id), last); 869 set_first_pubring(netpgp->pubring, id, sizeof(id), last);
868 netpgp_setvar(netpgp, "userid", userid = id); 870 netpgp_setvar(netpgp, "userid", userid = id);
869 } 871 }
870 if (userid == NULL) { 872 if (userid == NULL) {
871 if (netpgp_getvar(netpgp, "need userid") != NULL) { 873 if (netpgp_getvar(netpgp, "need userid") != NULL) {