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 When writing an asci...



details:   https://anonhg.NetBSD.org/src/rev/bda45cf3b475
branches:  trunk
changeset: 749176:bda45cf3b475
user:      agc <agc%NetBSD.org@localhost>
date:      Fri Nov 20 15:21:18 2009 +0000

description:
When writing an ascii-armoured message, push the linebreak writer onto
the write function stack for the body of the message as well as the
headers.

This means that an ascii-armoured signed file created by netpgp conforms
to RFC 4880 (and 2440, thanks, moof[1]), and can be verified by gpg now, as
well as netpgp.

[1] Are there any other RFCs which are superceded by their double?

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/writer.c |  26 ++++++++++++++++-------
 1 files changed, 18 insertions(+), 8 deletions(-)

diffs (60 lines):

diff -r 4207aa7fd116 -r bda45cf3b475 crypto/external/bsd/netpgp/dist/src/lib/writer.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/writer.c  Fri Nov 20 14:24:58 2009 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/writer.c  Fri Nov 20 15:21:18 2009 +0000
@@ -58,7 +58,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: writer.c,v 1.16 2009/11/20 07:17:07 agc Exp $");
+__RCSID("$NetBSD: writer.c,v 1.17 2009/11/20 15:21:18 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -650,11 +650,11 @@
        linebreak_t *linebreak = __ops_writer_get_arg(writer);
        unsigned        n;
 
+printf("in linebreak writer, len %d\n", len);
        for (n = 0; n < len; ++n, ++linebreak->pos) {
                if (src[n] == '\r' || src[n] == '\n') {
                        linebreak->pos = 0;
                }
-
                if (linebreak->pos == BREAKPOS) {
                        if (!__ops_stacked_write("\r\n", 2, errors, writer)) {
                                return 0;
@@ -759,18 +759,28 @@
 __ops_writer_push_armor_msg(__ops_output_t *output)
 {
        static const char        header[] = "-----BEGIN PGP MESSAGE-----\r\n";
+       linebreak_t             *linebreak;
        base64_t                *base64;
 
        __ops_write(output, header, sizeof(header) - 1);
        __ops_write(output, "\r\n", 2);
+       if ((linebreak = calloc(1, sizeof(*linebreak))) == NULL) {
+               (void) fprintf(stderr,
+                       "__ops_writer_push_armor_msg: bad lb alloc\n");
+               return;
+       }
+       __ops_writer_push(output, linebreak_writer, NULL,
+               generic_destroyer,
+               linebreak);
        if ((base64 = calloc(1, sizeof(*base64))) == NULL) {
-               (void) fprintf(stderr, "__ops_writer_push_armor_msg: bad alloc\n");
-       } else {
-               base64->checksum = CRC24_INIT;
-               __ops_writer_push(output, base64_writer,
-                       armoured_message_finaliser, generic_destroyer,
-                       base64);
+               (void) fprintf(stderr,
+                       "__ops_writer_push_armor_msg: bad alloc\n");
+               return;
        }
+       base64->checksum = CRC24_INIT;
+       __ops_writer_push(output, base64_writer,
+               armoured_message_finaliser, generic_destroyer,
+               base64);
 }
 
 static unsigned 



Home | Main Index | Thread Index | Old Index