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 get rid of a hardcod...



details:   https://anonhg.NetBSD.org/src/rev/ce722a74752f
branches:  trunk
changeset: 753919:ce722a74752f
user:      agc <agc%NetBSD.org@localhost>
date:      Wed Apr 14 00:25:10 2010 +0000

description:
get rid of a hardcoded test for the hash agorithm being SHA1, which was just
plain wrong these days.

don't duplicate functionality needlessly.

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/create.c |  20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)

diffs (56 lines):

diff -r f10879df2cc5 -r ce722a74752f crypto/external/bsd/netpgp/dist/src/lib/create.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/create.c  Wed Apr 14 00:24:00 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/create.c  Wed Apr 14 00:25:10 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.24 2010/03/13 23:30:41 agc Exp $");
+__RCSID("$NetBSD: create.c,v 1.25 2010/04/14 00:25:10 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -313,11 +313,6 @@
        if (!__ops_write_scalar(output, (unsigned)key->s2k_specifier, 1)) {
                return 0;
        }
-
-       if (key->hash_alg != OPS_HASH_SHA1) {
-               (void) fprintf(stderr, "write_seckey_body: hash alg\n");
-               return 0;
-       }
        if (!__ops_write_scalar(output, (unsigned)key->hash_alg, 1)) {
                return 0;
        }
@@ -1087,7 +1082,6 @@
                        "__ops_write_pk_sesskey: bad algorithm\n");
                return 0;
        }
-
        return __ops_write_ptag(output, OPS_PTAG_CT_PK_SESSION_KEY) &&
                __ops_write_length(output, (unsigned)(1 + 8 + 1 +
                        BN_num_bytes(pksk->params.rsa.encrypted_m) + 2)) &&
@@ -1161,19 +1155,15 @@
 {
        __ops_memory_t  *mem;
        unsigned         ret;
-       size_t           len;
+       int              len;
 
        mem = __ops_memory_new();
        if (!__ops_mem_readfile(mem, filename)) {
+               (void) fprintf(stderr, "__ops_mem_readfile of '%s' failed\n", filename);
                return 0;
        }
-       len = __ops_mem_len(mem);
-       ret = __ops_write_ptag(output, OPS_PTAG_CT_LITDATA) &&
-               __ops_write_length(output, 1 + 1 + 4 + len) &&
-               __ops_write_scalar(output, (unsigned)type, 1) &&
-               __ops_write_scalar(output, 0, 1) /* filename */ &&
-               __ops_write_scalar(output, 0, 4) /* date */ &&
-               __ops_write(output, __ops_mem_data(mem), len);
+       len = (size_t)__ops_mem_len(mem);
+       ret = __ops_write_litdata(output, __ops_mem_data(mem), len, type);
        __ops_memory_free(mem);
        return ret;
 }



Home | Main Index | Thread Index | Old Index