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 fix a bug in verifying m...



details:   https://anonhg.NetBSD.org/src/rev/9c0e14d8d70a
branches:  trunk
changeset: 752321:9c0e14d8d70a
user:      agc <agc%NetBSD.org@localhost>
date:      Tue Feb 23 01:24:44 2010 +0000

description:
fix a bug in verifying memory.

add two examples to the netpgp(1) manual page outlining how to sign
and encrypt via a pipeline, and how to decrypt and verify/cat using a
pipeline.

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c    |   5 +-
 crypto/external/bsd/netpgp/dist/src/lib/validate.c  |   4 +-
 crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.1 |  43 ++++++++++++++++++++-
 3 files changed, 48 insertions(+), 4 deletions(-)

diffs (107 lines):

diff -r cc25a7da8415 -r 9c0e14d8d70a crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Tue Feb 23 00:23:36 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Tue Feb 23 01:24:44 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.39 2010/02/12 03:38:48 agc Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.40 2010/02/23 01:24:44 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1014,6 +1014,9 @@
        }
        signedmem = __ops_memory_new();
        __ops_memory_add(signedmem, in, size);
+       if (out) {
+               cat = __ops_memory_new();
+       }
        ret = __ops_validate_mem(io, &result, signedmem,
                                (out) ? &cat : NULL,
                                armored, netpgp->pubring);
diff -r cc25a7da8415 -r 9c0e14d8d70a crypto/external/bsd/netpgp/dist/src/lib/validate.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/validate.c        Tue Feb 23 00:23:36 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/validate.c        Tue Feb 23 01:24:44 2010 +0000
@@ -54,7 +54,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: validate.c,v 1.29 2010/02/12 03:38:48 agc Exp $");
+__RCSID("$NetBSD: validate.c,v 1.30 2010/02/23 01:24:44 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -949,7 +949,7 @@
        __ops_teardown_memory_read(stream, mem);
 
        /* this is triggered only for --cat output */
-       if (*cat) {
+       if (cat) {
                /* need to send validated output somewhere */
                *cat = validation.mem;
        } else {
diff -r cc25a7da8415 -r 9c0e14d8d70a crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.1
--- a/crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.1       Tue Feb 23 00:23:36 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.1       Tue Feb 23 01:24:44 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: netpgp.1,v 1.7 2010/02/06 02:24:34 agc Exp $
+.\" $NetBSD: netpgp.1,v 1.8 2010/02/23 01:24:45 agc Exp $
 .\"
 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -406,6 +406,10 @@
 netpgp passphrase:
 %
 .Ed
+.Pp
+This simple (and contrived) example shows that
+.Nm
+commands can be used together in a pipeline to produce the desired effect.
 .Bd -literal
 % netpgp --sign \*[Lt] a | netpgp --cat \*[Gt] b 
 netpgp: default key set to "C0596823"
@@ -428,6 +432,43 @@
 uid              Alistair Crooks (Yahoo!) \*[Lt]agcrooks%yahoo-inc.com@localhost\*[Gt]
 %
 .Ed
+.Pp
+For operations like signing and encrypting a file at the same time,
+the best way is to make use of pipelines:
+.Bd -literal
+% netpgp --sign \*[Lt] example | netpgp --encrypt --userid=c0596823 \*[Gt] example.gpg
+netpgp: default key set to "C0596823"
+pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12
+Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823
+uid              Alistair Crooks \*[Lt]alistair%hockley-crooks.com@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%pkgsrc.org@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%netbsd.org@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%alistaircrooks.com@localhost\*[Gt]
+uid              Alistair Crooks (Yahoo!) \*[Lt]agcrooks%yahoo-inc.com@localhost\*[Gt]
+netpgp passphrase:
+% netpgp --decrypt \*[Lt] example.gpg | netpgp --cat
+netpgp: default key set to "C0596823"
+netpgp: default key set to "C0596823"
+pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12
+Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823
+uid              Alistair Crooks \*[Lt]alistair%hockley-crooks.com@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%pkgsrc.org@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%netbsd.org@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%alistaircrooks.com@localhost\*[Gt]
+uid              Alistair Crooks (Yahoo!) \*[Lt]agcrooks%yahoo-inc.com@localhost\*[Gt]
+netpgp passphrase:
+Good signature for \*[Lt]stdin\*[Gt] made Mon Feb 22 07:21:19 2010
+using RSA (Encrypt or Sign) key 1b68dcfcc0596823
+pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12
+Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823
+uid              Alistair Crooks \*[Lt]alistair%hockley-crooks.com@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%pkgsrc.org@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%netbsd.org@localhost\*[Gt]
+uid              Alistair Crooks \*[Lt]agc%alistaircrooks.com@localhost\*[Gt]
+uid              Alistair Crooks (Yahoo!) \*[Lt]agcrooks%yahoo-inc.com@localhost\*[Gt]
+...contents of original file...
+%
+.Ed
 .Sh RETURN VALUES
 The
 .Nm



Home | Main Index | Thread Index | Old Index