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 Changes to 3.99.9/20100809
details: https://anonhg.NetBSD.org/src/rev/6aef681014bc
branches: trunk
changeset: 757072:6aef681014bc
user: agc <agc%NetBSD.org@localhost>
date: Fri Aug 13 18:29:40 2010 +0000
description:
Changes to 3.99.9/20100809
+ add single character options to netpgp(1) and netpgpkeys(1)
+ add -o long-option(=value)? options to netpgp(1) and netpgpkeys(1)
+ add some small preparations for using the first subkey for encryption
(much more to follow)
diffstat:
crypto/external/bsd/netpgp/dist/src/lib/config.h.in | 4 -
crypto/external/bsd/netpgp/dist/src/lib/create.c | 20 +-
crypto/external/bsd/netpgp/dist/src/lib/crypto.c | 6 +-
crypto/external/bsd/netpgp/dist/src/lib/keyring.c | 60 +-
crypto/external/bsd/netpgp/dist/src/lib/keyring.h | 2 +-
crypto/external/bsd/netpgp/dist/src/lib/misc.c | 5 +-
crypto/external/bsd/netpgp/dist/src/lib/netpgp.c | 17 +-
crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c | 6 +-
crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c | 6 +-
crypto/external/bsd/netpgp/dist/src/lib/packet-print.c | 38 +-
crypto/external/bsd/netpgp/dist/src/lib/packet.h | 12 +-
crypto/external/bsd/netpgp/dist/src/lib/reader.c | 8 +-
crypto/external/bsd/netpgp/dist/src/lib/ssh2pgp.c | 8 +-
crypto/external/bsd/netpgp/dist/src/lib/version.h | 2 +-
crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.1 | 10 +-
crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.c | 314 +++++++----
crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.1 | 10 +-
crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c | 273 ++++++---
18 files changed, 490 insertions(+), 311 deletions(-)
diffs (truncated from 1305 to 300 lines):
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/config.h.in
--- a/crypto/external/bsd/netpgp/dist/src/lib/config.h.in Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/config.h.in Fri Aug 13 18:29:40 2010 +0000
@@ -114,10 +114,6 @@
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#undef LT_OBJDIR
-
/* Name of package */
#undef PACKAGE
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/create.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/create.c Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/create.c Fri Aug 13 18:29:40 2010 +0000
@@ -57,7 +57,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: create.c,v 1.31 2010/07/09 05:35:34 agc Exp $");
+__RCSID("$NetBSD: create.c,v 1.32 2010/08/13 18:29:40 agc Exp $");
#endif
#include <sys/types.h>
@@ -961,11 +961,18 @@
const __ops_pubkey_t *pubkey;
__ops_pk_sesskey_t *sesskey;
+ const uint8_t *id;
uint8_t unencoded_m_buf[SZ_UNENCODED_M_BUF];
uint8_t *encoded_m_buf;
size_t sz_encoded_m_buf;
- pubkey = __ops_get_pubkey(key);
+ if (memcmp(key->encid, "\0\0\0\0\0\0\0\0", 8) == 0) {
+ pubkey = __ops_get_pubkey(key);
+ id = key->sigid;
+ } else {
+ pubkey = &key->enckey;
+ id = key->encid;
+ }
sz_encoded_m_buf = BN_num_bytes(pubkey->key.rsa.n);
if ((encoded_m_buf = calloc(1, sz_encoded_m_buf)) == NULL) {
(void) fprintf(stderr,
@@ -986,13 +993,12 @@
return NULL;
}
sesskey->version = OPS_PKSK_V3;
- (void) memcpy(sesskey->key_id, key->key_id,
- sizeof(sesskey->key_id));
+ (void) memcpy(sesskey->key_id, id, sizeof(sesskey->key_id));
if (__ops_get_debug_level(__FILE__)) {
- hexdump(stderr, "Encrypting for RSA keyid", key->key_id, sizeof(sesskey->key_id));
+ hexdump(stderr, "Encrypting for RSA keyid", id, sizeof(sesskey->key_id));
}
- switch (key->key.pubkey.alg) {
+ switch (pubkey->alg) {
case OPS_PKA_RSA:
case OPS_PKA_DSA:
case OPS_PKA_ELGAMAL:
@@ -1004,7 +1010,7 @@
free(sesskey);
return NULL;
}
- sesskey->alg = key->key.pubkey.alg;
+ sesskey->alg = pubkey->alg;
/* \todo allow user to specify other algorithm */
sesskey->symm_alg = OPS_SA_CAST5;
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/crypto.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/crypto.c Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/crypto.c Fri Aug 13 18:29:40 2010 +0000
@@ -54,7 +54,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: crypto.c,v 1.25 2010/07/09 05:35:34 agc Exp $");
+__RCSID("$NetBSD: crypto.c,v 1.26 2010/08/13 18:29:40 agc Exp $");
#endif
#include <sys/types.h>
@@ -264,7 +264,7 @@
__ops_encrypt_file(__ops_io_t *io,
const char *infile,
const char *outfile,
- const __ops_key_t *pubkey,
+ const __ops_key_t *key,
const unsigned use_armour,
const unsigned allow_overwrite)
{
@@ -289,7 +289,7 @@
}
/* Push the encrypted writer */
- if (!__ops_push_enc_se_ip(output, pubkey)) {
+ if (!__ops_push_enc_se_ip(output, key)) {
__ops_memory_free(inmem);
return 0;
}
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/keyring.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Fri Aug 13 18:29:40 2010 +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.40 2010/08/07 04:16:40 agc Exp $");
+__RCSID("$NetBSD: keyring.c,v 1.41 2010/08/13 18:29:40 agc Exp $");
#endif
#ifdef HAVE_FCNTL_H
@@ -338,7 +338,7 @@
const uint8_t *
__ops_get_key_id(const __ops_key_t *key)
{
- return key->key_id;
+ return key->sigid;
}
/**
@@ -509,7 +509,7 @@
sig = __ops_create_sig_new();
__ops_sig_start_key_sig(sig, &key->key.seckey.pubkey, userid, OPS_CERT_POSITIVE);
__ops_add_birthtime(sig, time(NULL));
- __ops_add_issuer_keyid(sig, key->key_id);
+ __ops_add_issuer_keyid(sig, key->sigid);
__ops_add_primary_userid(sig, 1);
__ops_end_hashed_subpkts(sig);
@@ -823,15 +823,16 @@
{
for ( ; keyring && *from < keyring->keyc; *from += 1) {
if (__ops_get_debug_level(__FILE__)) {
- hexdump(io->errs, "keyring keyid", keyring->keys[*from].key_id, OPS_KEY_ID_SIZE);
+ hexdump(io->errs, "keyring keyid", keyring->keys[*from].sigid, OPS_KEY_ID_SIZE);
hexdump(io->errs, "keyid", keyid, OPS_KEY_ID_SIZE);
}
- if (memcmp(keyring->keys[*from].key_id, keyid,
- OPS_KEY_ID_SIZE) == 0) {
+ if (memcmp(keyring->keys[*from].sigid, keyid, OPS_KEY_ID_SIZE) == 0 ||
+ memcmp(&keyring->keys[*from].sigid[OPS_KEY_ID_SIZE / 2],
+ keyid, OPS_KEY_ID_SIZE / 2) == 0) {
return &keyring->keys[*from];
}
- if (memcmp(&keyring->keys[*from].key_id[OPS_KEY_ID_SIZE / 2],
- keyid, OPS_KEY_ID_SIZE / 2) == 0) {
+ if (memcmp(&keyring->keys[*from].encid, keyid, OPS_KEY_ID_SIZE) == 0 ||
+ memcmp(&keyring->keys[*from].encid[OPS_KEY_ID_SIZE / 2], keyid, OPS_KEY_ID_SIZE / 2) == 0) {
return &keyring->keys[*from];
}
}
@@ -1017,7 +1018,7 @@
"sec", &key->key.seckey.pubkey, psigs);
} else {
__ops_sprint_mj(io, keyring, key, &obj->value.v[obj->c],
- "pub", &key->key.pubkey, psigs);
+ "signature ", &key->key.pubkey, psigs);
}
if (obj->value.v[obj->c].type != 0) {
obj->c += 1;
@@ -1057,24 +1058,37 @@
/* add a key to a public keyring */
int
-__ops_add_to_pubring(__ops_keyring_t *keyring, const __ops_pubkey_t *pubkey)
+__ops_add_to_pubring(__ops_keyring_t *keyring, const __ops_pubkey_t *pubkey, __ops_content_enum tag)
{
__ops_key_t *key;
time_t duration;
if (__ops_get_debug_level(__FILE__)) {
- fprintf(stderr, "__ops_add_to_pubring\n");
+ fprintf(stderr, "__ops_add_to_pubring (type %u)\n", tag);
}
- EXPAND_ARRAY(keyring, key);
- key = &keyring->keys[keyring->keyc++];
- duration = key->key.pubkey.duration;
- (void) memset(key, 0x0, sizeof(*key));
- __ops_keyid(key->key_id, OPS_KEY_ID_SIZE, pubkey, keyring->hashtype);
- __ops_fingerprint(&key->fingerprint, pubkey, keyring->hashtype);
- key->type = OPS_PTAG_CT_PUBLIC_KEY;
- key->key.pubkey = *pubkey;
- key->key.pubkey.duration = duration;
- return 1;
+ switch(tag) {
+ case OPS_PTAG_CT_PUBLIC_KEY:
+ EXPAND_ARRAY(keyring, key);
+ key = &keyring->keys[keyring->keyc++];
+ duration = key->key.pubkey.duration;
+ (void) memset(key, 0x0, sizeof(*key));
+ key->type = tag;
+ __ops_keyid(key->sigid, OPS_KEY_ID_SIZE, pubkey, keyring->hashtype);
+ __ops_fingerprint(&key->sigfingerprint, pubkey, keyring->hashtype);
+ key->key.pubkey = *pubkey;
+ key->key.pubkey.duration = duration;
+ return 1;
+ case OPS_PTAG_CT_PUBLIC_SUBKEY:
+ /* subkey is not the first */
+ key = &keyring->keys[keyring->keyc - 1];
+ __ops_keyid(key->encid, OPS_KEY_ID_SIZE, pubkey, keyring->hashtype);
+ duration = key->key.pubkey.duration;
+ (void) memcpy(&key->enckey, pubkey, sizeof(key->enckey));
+ key->enckey.duration = duration;
+ return 1;
+ default:
+ return 0;
+ }
}
/* add a key to a secret keyring */
@@ -1099,8 +1113,8 @@
key = &keyring->keys[keyring->keyc++];
(void) memset(key, 0x0, sizeof(*key));
pubkey = &seckey->pubkey;
- __ops_keyid(key->key_id, OPS_KEY_ID_SIZE, pubkey, keyring->hashtype);
- __ops_fingerprint(&key->fingerprint, pubkey, keyring->hashtype);
+ __ops_keyid(key->sigid, OPS_KEY_ID_SIZE, pubkey, keyring->hashtype);
+ __ops_fingerprint(&key->sigfingerprint, pubkey, keyring->hashtype);
key->type = OPS_PTAG_CT_SECRET_KEY;
key->key.seckey = *seckey;
if (__ops_get_debug_level(__FILE__)) {
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/keyring.h
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.h Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.h Fri Aug 13 18:29:40 2010 +0000
@@ -143,7 +143,7 @@
char *__ops_export_key(__ops_io_t *, const __ops_key_t *, uint8_t *);
-int __ops_add_to_pubring(__ops_keyring_t *, const __ops_pubkey_t *);
+int __ops_add_to_pubring(__ops_keyring_t *, const __ops_pubkey_t *, __ops_content_enum tag);
int __ops_add_to_secring(__ops_keyring_t *, const __ops_seckey_t *);
int __ops_append_keyring(__ops_keyring_t *, __ops_keyring_t *);
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/misc.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/misc.c Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/misc.c Fri Aug 13 18:29:40 2010 +0000
@@ -57,7 +57,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: misc.c,v 1.33 2010/07/09 05:35:34 agc Exp $");
+__RCSID("$NetBSD: misc.c,v 1.34 2010/08/13 18:29:40 agc Exp $");
#endif
#include <sys/types.h>
@@ -118,7 +118,8 @@
keyring = accumulate->keyring;
switch (pkt->tag) {
case OPS_PTAG_CT_PUBLIC_KEY:
- __ops_add_to_pubring(keyring, &content->pubkey);
+ case OPS_PTAG_CT_PUBLIC_SUBKEY:
+ __ops_add_to_pubring(keyring, &content->pubkey, pkt->tag);
return OPS_KEEP_MEMORY;
case OPS_PTAG_CT_SECRET_KEY:
case OPS_PTAG_CT_ENCRYPTED_SECRET_KEY:
diff -r a90e56626bd9 -r 6aef681014bc crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c Fri Aug 13 16:21:50 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c Fri Aug 13 18:29:40 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.66 2010/08/07 04:16:40 agc Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.67 2010/08/13 18:29:40 agc Exp $");
#endif
#include <sys/types.h>
@@ -319,7 +319,7 @@
int n;
(void) memset(id, 0x0, len);
- src = pubring->keys[(last) ? pubring->keyc - 1 : 0].key_id;
+ src = pubring->keys[(last) ? pubring->keyc - 1 : 0].sigid;
for (i = 0, n = 0 ; i < OPS_KEY_ID_SIZE ; i += 2) {
n += snprintf(&id[n], len - n, "%02x%02x", src[i], src[i + 1]);
}
@@ -739,7 +739,7 @@
id_array.c, 10, 10, "netpgp_match_keys_json", return 0);
__ops_sprint_mj(netpgp->io, netpgp->pubring,
key, &id_array.value.v[id_array.c++],
- "pub",
+ "signature ",
&key->key.pubkey, psigs);
}
k += 1;
@@ -930,7 +930,7 @@
char *out,
int armored)
{
- const __ops_key_t *keypair;
+ const __ops_key_t *key;
const unsigned overwrite = 1;
const char *suffix;
__ops_io_t *io;
@@ -944,14 +944,14 @@
}
suffix = (armored) ? ".asc" : ".gpg";
Home |
Main Index |
Thread Index |
Old Index