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 Do not ask for a pas...
details: https://anonhg.NetBSD.org/src/rev/79b59d25041d
branches: trunk
changeset: 352352:79b59d25041d
user: khorben <khorben%NetBSD.org@localhost>
date: Mon Mar 27 21:19:12 2017 +0000
description:
Do not ask for a passphrase when empty
Submitted on tech-pkg@ as:
[PATCH 06/11] Do not ask for a passphrase when empty
Only modified for consistency with the coding style.
diffstat:
crypto/external/bsd/netpgp/dist/src/lib/keyring.c | 28 +++++++++++++++++++++-
1 files changed, 26 insertions(+), 2 deletions(-)
diffs (61 lines):
diff -r 3a6b886f4b20 -r 79b59d25041d crypto/external/bsd/netpgp/dist/src/lib/keyring.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Mon Mar 27 21:06:50 2017 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Mon Mar 27 21:19:12 2017 +0000
@@ -57,7 +57,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: keyring.c,v 1.54 2017/03/27 21:06:50 khorben Exp $");
+__RCSID("$NetBSD: keyring.c,v 1.55 2017/03/27 21:19:12 khorben Exp $");
#endif
#ifdef HAVE_FCNTL_H
@@ -226,7 +226,7 @@
pgp_seckey_t *seckey;
} decrypt_t;
-static pgp_cb_ret_t
+static pgp_cb_ret_t
decrypt_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
{
const pgp_contents_t *content = &pkt->u;
@@ -294,6 +294,20 @@
return PGP_RELEASE_MEMORY;
}
+static pgp_cb_ret_t
+decrypt_cb_empty(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
+{
+ const pgp_contents_t *content = &pkt->u;
+
+ switch (pkt->tag) {
+ case PGP_GET_PASSPHRASE:
+ *content->skey_passphrase.passphrase = netpgp_strdup("");
+ return PGP_KEEP_MEMORY;
+ default:
+ return decrypt_cb(pkt, cbinfo);
+ }
+}
+
/**
\ingroup Core_Keys
\brief Decrypts secret key from given keydata with given passphrase
@@ -308,8 +322,18 @@
const int printerrors = 1;
decrypt_t decrypt;
+ /* XXX first try with an empty passphrase */
(void) memset(&decrypt, 0x0, sizeof(decrypt));
decrypt.key = key;
+ stream = pgp_new(sizeof(*stream));
+ pgp_keydata_reader_set(stream, key);
+ pgp_set_callback(stream, decrypt_cb_empty, &decrypt);
+ stream->readinfo.accumulate = 1;
+ pgp_parse(stream, !printerrors);
+ if (decrypt.seckey != NULL) {
+ return decrypt.seckey;
+ }
+ /* ask for a passphrase */
decrypt.passfp = passfp;
stream = pgp_new(sizeof(*stream));
pgp_keydata_reader_set(stream, key);
Home |
Main Index |
Thread Index |
Old Index