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.
This commit is contained in:
agc 2010-02-23 01:24:44 +00:00
parent 6db342e072
commit 156f140565
3 changed files with 48 additions and 4 deletions

View File

@ -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 @@ netpgp_verify_memory(netpgp_t *netpgp, const void *in, const size_t size,
}
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);

View File

@ -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_validate_mem(__ops_io_t *io,
__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 {

View File

@ -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 @@ uid Alistair Crooks \*[Lt]alistair@hockley-crooks.com\*[Gt]
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 \*[Lt]agc@alistaircrooks.com\*[Gt]
uid Alistair Crooks (Yahoo!) \*[Lt]agcrooks@yahoo-inc.com\*[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\*[Gt]
uid Alistair Crooks \*[Lt]agc@pkgsrc.org\*[Gt]
uid Alistair Crooks \*[Lt]agc@netbsd.org\*[Gt]
uid Alistair Crooks \*[Lt]agc@alistaircrooks.com\*[Gt]
uid Alistair Crooks (Yahoo!) \*[Lt]agcrooks@yahoo-inc.com\*[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\*[Gt]
uid Alistair Crooks \*[Lt]agc@pkgsrc.org\*[Gt]
uid Alistair Crooks \*[Lt]agc@netbsd.org\*[Gt]
uid Alistair Crooks \*[Lt]agc@alistaircrooks.com\*[Gt]
uid Alistair Crooks (Yahoo!) \*[Lt]agcrooks@yahoo-inc.com\*[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\*[Gt]
uid Alistair Crooks \*[Lt]agc@pkgsrc.org\*[Gt]
uid Alistair Crooks \*[Lt]agc@netbsd.org\*[Gt]
uid Alistair Crooks \*[Lt]agc@alistaircrooks.com\*[Gt]
uid Alistair Crooks (Yahoo!) \*[Lt]agcrooks@yahoo-inc.com\*[Gt]
...contents of original file...
%
.Ed
.Sh RETURN VALUES
The
.Nm