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 + rationalise birthtime/expi...



details:   https://anonhg.NetBSD.org/src/rev/90eb8ba1a0e6
branches:  trunk
changeset: 757112:90eb8ba1a0e6
user:      agc <agc%NetBSD.org@localhost>
date:      Sun Aug 15 07:52:26 2010 +0000

description:
+ rationalise birthtime/expiration timestamps into a single function

+ clean up some 64-bit (amd64) lint

diffstat:

 crypto/external/bsd/netpgp/dist/TODO                     |    2 +-
 crypto/external/bsd/netpgp/dist/src/lib/compress.c       |   16 +-
 crypto/external/bsd/netpgp/dist/src/lib/create.c         |   18 +-
 crypto/external/bsd/netpgp/dist/src/lib/crypto.c         |    8 +-
 crypto/external/bsd/netpgp/dist/src/lib/keyring.c        |   16 +-
 crypto/external/bsd/netpgp/dist/src/lib/keyring.h        |    3 +-
 crypto/external/bsd/netpgp/dist/src/lib/misc.c           |   34 ++--
 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c         |   22 +-
 crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c |  115 +-------------
 crypto/external/bsd/netpgp/dist/src/lib/packet-print.c   |   38 ++--
 crypto/external/bsd/netpgp/dist/src/lib/reader.c         |   42 ++--
 crypto/external/bsd/netpgp/dist/src/lib/signature.c      |   96 +++++-------
 crypto/external/bsd/netpgp/dist/src/lib/signature.h      |    3 +-
 crypto/external/bsd/netpgp/dist/src/lib/ssh2pgp.c        |    4 +-
 crypto/external/bsd/netpgp/dist/src/lib/symmetric.c      |   10 +-
 crypto/external/bsd/netpgp/dist/src/lib/validate.c       |   32 ++-
 crypto/external/bsd/netpgp/dist/src/lib/writer.c         |   80 +++++-----
 17 files changed, 227 insertions(+), 312 deletions(-)

diffs (truncated from 1734 to 300 lines):

diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/TODO
--- a/crypto/external/bsd/netpgp/dist/TODO      Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/TODO      Sun Aug 15 07:52:26 2010 +0000
@@ -13,7 +13,6 @@
 64-bit offsets
 thresholds
 default compression when signing?
-json/yaml output
 
 Done
 ====
@@ -97,3 +96,4 @@
 hkp to include sigs too
 make netpgpkeys work - add, import, commit, update, sign, passphrase
 fix ssh fingerprints not matching netpgp
+json/yaml output
diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/src/lib/compress.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/compress.c        Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/compress.c        Sun Aug 15 07:52:26 2010 +0000
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: compress.c,v 1.15 2010/03/05 16:01:09 agc Exp $");
+__RCSID("$NetBSD: compress.c,v 1.16 2010/08/15 07:52:26 agc Exp $");
 #endif
 
 #ifdef HAVE_ZLIB_H
@@ -199,7 +199,7 @@
                z->offset += len;
        }
 
-       return length;
+       return (int)length;
 }
 
 /* \todo remove code duplication between this and zlib_compressed_data_reader */
@@ -283,7 +283,7 @@
                bz->offset += len;
        }
 
-       return length;
+       return (int)length;
 }
 
 /**
@@ -346,11 +346,11 @@
 
        switch (type) {
        case OPS_C_ZIP:
-               ret = inflateInit2(&z.zstream, -15);
+               ret = (int)inflateInit2(&z.zstream, -15);
                break;
 
        case OPS_C_ZLIB:
-               ret = inflateInit(&z.zstream);
+               ret = (int)inflateInit(&z.zstream);
                break;
 
        case OPS_C_BZIP2:
@@ -434,7 +434,7 @@
 
        /* all other fields set to zero by use of calloc */
 
-       if (deflateInit(&zip->stream, level) != Z_OK) {
+       if ((int)deflateInit(&zip->stream, level) != Z_OK) {
                (void) fprintf(stderr, "__ops_writez: can't initialise\n");
                return 0;
        }
@@ -462,11 +462,11 @@
 
        /* setup stream */
        zip->stream.next_in = zip->src;
-       zip->stream.avail_in = sz_in;
+       zip->stream.avail_in = (unsigned)sz_in;
        zip->stream.total_in = 0;
 
        zip->stream.next_out = zip->dst;
-       zip->stream.avail_out = sz_out;
+       zip->stream.avail_out = (unsigned)sz_out;
        zip->stream.total_out = 0;
 
        do {
diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/src/lib/create.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/create.c  Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/create.c  Sun Aug 15 07:52:26 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.32 2010/08/13 18:29:40 agc Exp $");
+__RCSID("$NetBSD: create.c,v 1.33 2010/08/15 07:52:26 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -138,8 +138,8 @@
 __ops_write_struct_userid(__ops_output_t *output, const uint8_t *id)
 {
        return __ops_write_ptag(output, OPS_PTAG_CT_USER_ID) &&
-               __ops_write_length(output, strlen((const char *) id)) &&
-               __ops_write(output, id, strlen((const char *) id));
+               __ops_write_length(output, (unsigned)strlen((const char *) id)) &&
+               __ops_write(output, id, (unsigned)strlen((const char *) id));
 }
 
 /**
@@ -389,7 +389,7 @@
                        if (key->s2k_specifier == OPS_S2KS_SALTED) {
                                hash.add(&hash, key->salt, OPS_SALT_SIZE);
                        }
-                       hash.add(&hash, passphrase, pplen);
+                       hash.add(&hash, passphrase, (unsigned)pplen);
                        hash.finish(&hash, hashed);
 
                        /*
@@ -525,7 +525,7 @@
                        return 0;
                }
                for (j = 0; j < key->packetc; j++) {
-                       if (!__ops_write(output, key->packets[j].raw, key->packets[j].length)) {
+                       if (!__ops_write(output, key->packets[j].raw, (unsigned)key->packets[j].length)) {
                                return 0;
                        }
                }
@@ -584,7 +584,7 @@
                        return 0;
                }
                for (j = 0; j < key->packetc; j++) {
-                       if (!__ops_write(output, key->packets[j].raw, key->packets[j].length)) {
+                       if (!__ops_write(output, key->packets[j].raw, (unsigned)key->packets[j].length)) {
                                return 0;
                        }
                }
@@ -1160,7 +1160,7 @@
                (void) fprintf(stderr, "__ops_mem_readfile of '%s' failed\n", filename);
                return 0;
        }
-       len = (size_t)__ops_mem_len(mem);
+       len = (int)__ops_mem_len(mem);
        ret = __ops_write_litdata(output, __ops_mem_data(mem), len, type);
        __ops_memory_free(mem);
        return ret;
@@ -1237,7 +1237,7 @@
                return 0;
        }
 
-       done = __ops_encrypt_se(&crypt_info, encrypted, data, (unsigned)len);
+       done = (int)__ops_encrypt_se(&crypt_info, encrypted, data, (unsigned)len);
        if (done != len) {
                (void) fprintf(stderr,
                        "__ops_write_symm_enc_data: done != len\n");
@@ -1245,7 +1245,7 @@
        }
 
        return __ops_write_ptag(output, OPS_PTAG_CT_SE_DATA) &&
-               __ops_write_length(output, 1 + encrypted_sz) &&
+               __ops_write_length(output, (unsigned)(1 + encrypted_sz)) &&
                __ops_write(output, data, (unsigned)len);
 }
 
diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/src/lib/crypto.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/crypto.c  Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/crypto.c  Sun Aug 15 07:52:26 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.26 2010/08/13 18:29:40 agc Exp $");
+__RCSID("$NetBSD: crypto.c,v 1.27 2010/08/15 07:52:26 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -295,7 +295,7 @@
        }
 
        /* This does the writing */
-       __ops_write(output, __ops_mem_data(inmem), __ops_mem_len(inmem));
+       __ops_write(output, __ops_mem_data(inmem), (unsigned)__ops_mem_len(inmem));
 
        /* tidy up */
        __ops_memory_free(inmem);
@@ -333,7 +333,7 @@
        __ops_push_enc_se_ip(output, pubkey);
 
        /* This does the writing */
-       __ops_write(output, input, insize);
+       __ops_write(output, input, (unsigned)insize);
 
        /* tidy up */
        __ops_writer_close(output);
@@ -395,7 +395,7 @@
 
                if (strcmp(suffix, ".gpg") == 0 ||
                    strcmp(suffix, ".asc") == 0) {
-                       filenamelen = strlen(infile) - strlen(suffix);
+                       filenamelen = (unsigned)(strlen(infile) - strlen(suffix));
                        if ((filename = calloc(1, filenamelen + 1)) == NULL) {
                                (void) fprintf(stderr, "can't allocate %" PRIsize "d bytes\n",
                                        (size_t)(filenamelen + 1));
diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/src/lib/keyring.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Sun Aug 15 07:52:26 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.41 2010/08/13 18:29:40 agc Exp $");
+__RCSID("$NetBSD: keyring.c,v 1.42 2010/08/15 07:52:26 agc Exp $");
 #endif
 
 #ifdef HAVE_FCNTL_H
@@ -246,7 +246,7 @@
        case OPS_GET_PASSPHRASE:
                (void) __ops_getpassphrase(decrypt->passfp, pass, sizeof(pass));
                *content->skey_passphrase.passphrase = netpgp_strdup(pass);
-               __ops_forget(pass, sizeof(pass));
+               __ops_forget(pass, (unsigned)sizeof(pass));
                return OPS_KEEP_MEMORY;
 
        case OPS_PARSER_ERRCODE:
@@ -508,7 +508,7 @@
        /* create sig for this pkt */
        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_time(sig, (int64_t)time(NULL), "birth");
        __ops_add_issuer_keyid(sig, key->sigid);
        __ops_add_primary_userid(sig, 1);
        __ops_end_hashed_subpkts(sig);
@@ -819,7 +819,7 @@
 */
 const __ops_key_t *
 __ops_getkeybyid(__ops_io_t *io, const __ops_keyring_t *keyring,
-                          const uint8_t *keyid, unsigned *from)
+                          const uint8_t *keyid, unsigned *from, __ops_pubkey_t **pubkey)
 {
        for ( ; keyring && *from < keyring->keyc; *from += 1) {
                if (__ops_get_debug_level(__FILE__)) {
@@ -829,10 +829,16 @@
                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) {
+                       if (pubkey) {
+                               *pubkey = &keyring->keys[*from].key.pubkey;
+                       }
                        return &keyring->keys[*from];
                }
                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) {
+                       if (pubkey) {
+                               *pubkey = &keyring->keys[*from].enckey;
+                       }
                        return &keyring->keys[*from];
                }
        }
@@ -905,7 +911,7 @@
                hexdump(io->outs, "keyid", keyid, 4);
        }
        savedstart = *from;
-       if ((kp = __ops_getkeybyid(io, keyring, keyid, from)) != NULL) {
+       if ((kp = __ops_getkeybyid(io, keyring, keyid, from, NULL)) != NULL) {
                return kp;
        }
        *from = savedstart;
diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/src/lib/keyring.h
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.h Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.h Sun Aug 15 07:52:26 2010 +0000
@@ -75,7 +75,8 @@
 const __ops_key_t *__ops_getkeybyid(__ops_io_t *,
                                        const __ops_keyring_t *,
                                        const uint8_t *,
-                                       unsigned *);
+                                       unsigned *,
+                                       __ops_pubkey_t **);
 const __ops_key_t *__ops_getkeybyname(__ops_io_t *,
                                        const __ops_keyring_t *,
                                        const char *);
diff -r 241128a23023 -r 90eb8ba1a0e6 crypto/external/bsd/netpgp/dist/src/lib/misc.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/misc.c    Sun Aug 15 07:27:33 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/misc.c    Sun Aug 15 07:52:26 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.34 2010/08/13 18:29:40 agc Exp $");
+__RCSID("$NetBSD: misc.c,v 1.35 2010/08/15 07:52:27 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -404,7 +404,7 @@
        ibuf[1] = (uint8_t)(n >> 16) & 0xff;
        ibuf[2] = (uint8_t)(n >> 8) & 0xff;
        ibuf[3] = (uint8_t)n & 0xff;
-       (*hash->add)(hash, (const uint8_t *)(void *)ibuf, sizeof(ibuf));
+       (*hash->add)(hash, (const uint8_t *)(void *)ibuf, (unsigned)sizeof(ibuf));
        return sizeof(ibuf);
 }
 
@@ -417,7 +417,7 @@
        }



Home | Main Index | Thread Index | Old Index