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/netpgpverify Update netp...
details: https://anonhg.NetBSD.org/src/rev/f6848be64d6b
branches: trunk
changeset: 334659:f6848be64d6b
user: agc <agc%NetBSD.org@localhost>
date: Sat Nov 29 20:18:44 2014 +0000
description:
Update netpgpverify to version 20141129
+ get rid of old libnetpgp-based source from /usr/src/crypto/external
tree, it's not been used in a while
+ enhancement to tiger.c (from apb, IIRC) to use the union rather than
dubious and probably unportable casts.
+ bump version number
diffstat:
crypto/external/bsd/netpgp/dist/src/netpgpverify/tiger.c | 2 +-
crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c | 361 --------------
crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h | 2 +-
3 files changed, 2 insertions(+), 363 deletions(-)
diffs (truncated from 389 to 300 lines):
diff -r cf74d93610b0 -r f6848be64d6b crypto/external/bsd/netpgp/dist/src/netpgpverify/tiger.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/tiger.c Sat Nov 29 14:48:42 2014 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/tiger.c Sat Nov 29 20:18:44 2014 +0000
@@ -819,7 +819,7 @@
for (; j < 56; j++) {
u.temp8[j] = 0;
}
- ((uint64_t *)(void *)(&(u.temp8[56])))[0] = ((uint64_t)length) << 3;
+ u.temp64[7] = ((uint64_t)length) << 3;
tiger_compress(u.temp64, ctx->ctx);
}
diff -r cf74d93610b0 -r f6848be64d6b crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c Sat Nov 29 14:48:42 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,361 +0,0 @@
-/* $NetBSD: verify.c,v 1.15 2010/09/01 17:25:57 agc Exp $ */
-
-/*-
- * Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Alistair Crooks (agc%NetBSD.org@localhost)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Command line program to perform netpgp operations */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <getopt.h>
-#include <netpgp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/*
- * SHA1 is now looking as though it should not be used. Let's
- * pre-empt this by specifying SHA256 - gpg interoperates just fine
- * with SHA256 - agc, 20090522
- */
-#define DEFAULT_HASH_ALG "SHA256"
-
-static const char *usage =
- "\t--verify [options] files... OR\n"
- "\t--cat [--output=file] [options] files...\n"
- "where options are:\n"
- "\t[--coredumps] AND/OR\n"
- "\t[--homedir=<homedir>] AND/OR\n"
- "\t[--keyring=<keyring>] AND/OR\n"
- "\t[--userid=<userid>] AND/OR\n"
- "\t[--maxmemalloc=<number of bytes>] AND/OR\n"
- "\t[--verbose]\n";
-
-enum optdefs {
- /* commands */
- VERIFY,
- VERIFY_CAT,
- VERSION_CMD,
- HELP_CMD,
-
- /* options */
- SSHKEYS,
- KEYRING,
- USERID,
- ARMOUR,
- HOMEDIR,
- OUTPUT,
- RESULTS,
- VERBOSE,
- COREDUMPS,
- SSHKEYFILE,
- MAX_MEM_ALLOC,
-
- /* debug */
- OPS_DEBUG
-};
-
-#define EXIT_ERROR 2
-
-static struct option options[] = {
- /* file manipulation commands */
- {"verify", no_argument, NULL, VERIFY},
- {"cat", no_argument, NULL, VERIFY_CAT},
- {"vericat", no_argument, NULL, VERIFY_CAT},
- {"verify-cat", no_argument, NULL, VERIFY_CAT},
- {"verify-show", no_argument, NULL, VERIFY_CAT},
- {"verifyshow", no_argument, NULL, VERIFY_CAT},
- {"help", no_argument, NULL, HELP_CMD},
- {"version", no_argument, NULL, VERSION_CMD},
- /* options */
- {"ssh", no_argument, NULL, SSHKEYS},
- {"ssh-keys", no_argument, NULL, SSHKEYS},
- {"sshkeyfile", required_argument, NULL, SSHKEYFILE},
- {"coredumps", no_argument, NULL, COREDUMPS},
- {"keyring", required_argument, NULL, KEYRING},
- {"userid", required_argument, NULL, USERID},
- {"home", required_argument, NULL, HOMEDIR},
- {"homedir", required_argument, NULL, HOMEDIR},
- {"armor", no_argument, NULL, ARMOUR},
- {"armour", no_argument, NULL, ARMOUR},
- {"verbose", no_argument, NULL, VERBOSE},
- {"output", required_argument, NULL, OUTPUT},
- {"results", required_argument, NULL, RESULTS},
- {"maxmemalloc", required_argument, NULL, MAX_MEM_ALLOC},
- {"max-mem", required_argument, NULL, MAX_MEM_ALLOC},
- {"max-alloc", required_argument, NULL, MAX_MEM_ALLOC},
- { NULL, 0, NULL, 0},
-};
-
-/* gather up program variables into one struct */
-typedef struct prog_t {
- char keyring[MAXPATHLEN + 1]; /* name of keyring */
- char *progname; /* program name */
- char *output; /* output file name */
- int overwrite; /* overwrite files? */
- int armour; /* ASCII armor */
- int detached; /* use separate file */
- int cmd; /* netpgp command */
-} prog_t;
-
-
-/* print a usage message */
-static void
-print_usage(const char *usagemsg, char *progname)
-{
- (void) fprintf(stderr,
- "%s\nAll bug reports, praise and chocolate, please, to:\n%s\n",
- netpgp_get_info("version"),
- netpgp_get_info("maintainer"));
- (void) fprintf(stderr, "Usage: %s COMMAND OPTIONS:\n%s %s",
- progname, progname, usagemsg);
-}
-
-/* read all of stdin into memory */
-static int
-stdin_to_mem(netpgp_t *netpgp, char **temp, char **out, unsigned *maxsize)
-{
- unsigned newsize;
- unsigned size;
- char buf[BUFSIZ * 8];
- char *loc;
- int n;
-
- *maxsize = (unsigned)atoi(netpgp_getvar(netpgp, "max mem alloc"));
- size = 0;
- *out = *temp = NULL;
- while ((n = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
- /* round up the allocation */
- newsize = size + ((n / BUFSIZ) + 1) * BUFSIZ;
- if (newsize > *maxsize) {
- (void) fprintf(stderr, "bounds check\n");
- return size;
- }
- loc = realloc(*temp, newsize);
- if (loc == NULL) {
- (void) fprintf(stderr, "short read\n");
- return size;
- }
- *temp = loc;
- (void) memcpy(&(*temp)[size], buf, n);
- size += n;
- }
- if ((*out = calloc(1, *maxsize)) == NULL) {
- (void) fprintf(stderr, "Bad alloc\n");
- return 0;
- }
- return (int)size;
-}
-
-/* output the text to stdout */
-static int
-show_output(char *out, int size, const char *header)
-{
- int cc;
- int n;
-
- if (size <= 0) {
- (void) fprintf(stderr, "%s\n", header);
- return 0;
- }
- for (cc = 0 ; cc < size ; cc += n) {
- if ((n = write(STDOUT_FILENO, &out[cc], size - cc)) <= 0) {
- break;
- }
- }
- if (cc < size) {
- (void) fprintf(stderr, "Short write\n");
- return 0;
- }
- return cc == size;
-}
-
-/* do a command once for a specified file 'f' */
-static int
-netpgp_cmd(netpgp_t *netpgp, prog_t *p, char *f)
-{
- unsigned maxsize;
- char *out;
- char *in;
- int ret;
- int cc;
-
- if (f == NULL) {
- cc = stdin_to_mem(netpgp, &in, &out, &maxsize);
- ret = netpgp_verify_memory(netpgp, in, cc,
- (p->cmd == VERIFY_CAT) ? out : NULL,
- (p->cmd == VERIFY_CAT) ? maxsize : 0,
- p->armour);
- ret = show_output(out, ret, "Bad memory verification");
- free(in);
- free(out);
- return ret;
- }
- return netpgp_verify_file(netpgp, f,
- (p->cmd == VERIFY) ? NULL :
- (p->output) ? p->output : "-",
- p->armour);
-}
-
-
-int
-main(int argc, char **argv)
-{
- netpgp_t netpgp;
- prog_t p;
- int optindex;
- int homeset;
- int ret;
- int ch;
- int i;
-
- (void) memset(&p, 0x0, sizeof(p));
- (void) memset(&netpgp, 0x0, sizeof(netpgp));
- homeset = 0;
- p.progname = argv[0];
- p.overwrite = 1;
- p.output = NULL;
- if (argc < 2) {
- print_usage(usage, p.progname);
- exit(EXIT_ERROR);
- }
- /* set some defaults */
- netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
- /* 4 MiB for a memory file */
- netpgp_setvar(&netpgp, "max mem alloc", "4194304");
- optindex = 0;
- while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
- switch (options[optindex].val) {
- case COREDUMPS:
- netpgp_setvar(&netpgp, "coredumps", "allowed");
- p.cmd = options[optindex].val;
- break;
- case VERIFY:
- case VERIFY_CAT:
- p.cmd = options[optindex].val;
- break;
- case VERSION_CMD:
- printf(
-"%s\nAll bug reports, praise and chocolate, please, to:\n%s\n",
- netpgp_get_info("version"),
- netpgp_get_info("maintainer"));
- exit(EXIT_SUCCESS);
- /* options */
- case SSHKEYS:
- netpgp_setvar(&netpgp, "ssh keys", "1");
- break;
- case KEYRING:
- if (optarg == NULL) {
- (void) fprintf(stderr,
- "No keyring argument provided\n");
- exit(EXIT_ERROR);
- }
- snprintf(p.keyring, sizeof(p.keyring), "%s", optarg);
- break;
- case USERID:
- if (optarg == NULL) {
Home |
Main Index |
Thread Index |
Old Index