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 The experiment in keeping a separ...



details:   https://anonhg.NetBSD.org/src/rev/2cc0530d4a18
branches:  trunk
changeset: 755016:2cc0530d4a18
user:      agc <agc%NetBSD.org@localhost>
date:      Thu May 20 00:33:01 2010 +0000

description:
The experiment in keeping a separate, trimmed-down codebase for just the
verify functionality was useful, but the time has come to learn lessons
and move on.

Replace the trimmed down code with a call to the verification code from
libnetpgp(3).

diffstat:

 crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.am |      4 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c    |  10357 +---------
 crypto/external/bsd/netpgp/netpgpverify/Makefile             |      8 +-
 3 files changed, 171 insertions(+), 10198 deletions(-)

diffs (truncated from 10562 to 300 lines):

diff -r af02a9d97580 -r 2cc0530d4a18 crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.am
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.am      Thu May 20 00:13:02 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.am      Thu May 20 00:33:01 2010 +0000
@@ -1,4 +1,4 @@
-## $NetBSD: Makefile.am,v 1.1 2009/06/09 00:51:03 agc Exp $
+## $NetBSD: Makefile.am,v 1.2 2010/05/20 00:33:01 agc Exp $
 
 AM_CFLAGS              = $(WARNCFLAGS)
 
@@ -8,6 +8,8 @@
 
 netpgpverify_CPPFLAGS  = -I$(top_srcdir)/include
 
+netpgpverify_LDADD     = ../lib/libnetpgp.la
+
 man1_MANS              = netpgpverify.1
 
 dist_man_MANS          = netpgpverify.1
diff -r af02a9d97580 -r 2cc0530d4a18 crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c Thu May 20 00:13:02 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c Thu May 20 00:33:01 2010 +0000
@@ -1,5 +1,7 @@
+/* $NetBSD: verify.c,v 1.11 2010/05/20 00:33:01 agc Exp $ */
+
 /*-
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -26,10209 +28,89 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-/*
- * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
- * All rights reserved.
- * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
- * their moral rights under the UK Copyright Design and Patents Act 1988 to
- * be recorded as the authors of this copyright work.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- *
- * You may obtain a copy of the License at
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "config.h"
-
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#if defined(__NetBSD__)
-__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: verify.c,v 1.10 2010/05/04 00:02:46 agc Exp $");
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-
-#include <sys/mman.h>
-
-#ifdef HAVE_OPENSSL_AES_H
-#include <openssl/aes.h>
-#endif
-
-#ifdef HAVE_OPENSSL_CAST_H
-#include <openssl/cast.h>
-#endif
 
-#ifdef HAVE_OPENSSL_DES_H
-#include <openssl/des.h>
-#endif
-
-#ifdef HAVE_OPENSSL_DSA_H
-#include <openssl/dsa.h>
-#endif
-
-#ifdef HAVE_OPENSSL_ERR_H
-#include <openssl/err.h>
-#endif
-
-#ifdef HAVE_OPENSSL_IDEA_H
-#include <openssl/idea.h>
-#endif
-
-#ifdef HAVE_OPENSSL_MD5_H
-#include <openssl/md5.h>
-#endif
-
-#ifdef HAVE_OPENSSL_SHA_H
-#include <openssl/sha.h>
-#endif
+/* Command line program to perform netpgp operations */
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/stat.h>
 
-/* Apple */
-#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
-#undef MD5_DIGEST_LENGTH
-#undef SHA_DIGEST_LENGTH
-#define COMMON_DIGEST_FOR_OPENSSL      1
-#include <CommonCrypto/CommonDigest.h>
-#endif
-
-#ifdef HAVE_OPENSSL_RAND_H
-#include <openssl/rand.h>
-#endif
-
-#ifdef HAVE_OPENSSL_RSA_H
-#include <openssl/rsa.h>
-#endif
-
-#ifdef HAVE_BZLIB_H
-#include <bzlib.h>
-#endif
-
-#include <errno.h>
-
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#include <stdarg.h>
+#include <getopt.h>
+#include <netpgp.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#include <time.h>
-
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
-
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
-
-/* external interface */
-#include <netpgp.h>
-
-#ifndef NETPGP_AUTOCONF_VERSION
-#define NETPGP_AUTOCONF_VERSION        PACKAGE_VERSION
-#endif
-
-#ifndef NETPGP_MAINTAINER
-#define NETPGP_MAINTAINER      PACKAGE_BUGREPORT
-#endif
-
-/* don't use some digest algorithms */
-#undef USE_SHA224
-#undef USE_SHA384
-
-/* development versions have .99 suffix */
-#define NETPGP_BASE_VERSION    "3.99.1"
-
-#define NETPGP_VERSION_CAT(a, b)       "NetPGP portable " a "/[" b "]"
-#define NETPGP_VERSION_STRING \
-       NETPGP_VERSION_CAT(NETPGP_BASE_VERSION, NETPGP_AUTOCONF_VERSION)
-
-/* SHA1 Hash Size */
-#define OPS_SHA1_HASH_SIZE     SHA_DIGEST_LENGTH
-#define OPS_SHA256_HASH_SIZE   SHA256_DIGEST_LENGTH
-#define OPS_CHECKHASH_SIZE     OPS_SHA1_HASH_SIZE
-
-enum {
-       MAX_ID_LENGTH           = 128,
-       MAX_PASSPHRASE_LENGTH   = 256
-};
-
-#define PRItime                "ll"
-
-#ifdef WIN32
-#define PRIsize                "I"
-#else
-#define PRIsize                "z"
-#endif
-
-/* if this is defined, we'll use mmap in preference to file ops */
-#define USE_MMAP_FOR_FILES      1
-
-/* for silencing unused parameter warnings */
-#define __OPS_USED(x)  /*LINTED*/(void)&(x)
-
-#ifndef __UNCONST
-#define __UNCONST(a)   ((void *)(unsigned long)(const void *)(a))
-#endif
-
-/* number of elements in an array */
-#define NETPGP_BUFSIZ  8192
-
-/* this struct describes an area of memory allocated/mmapped */
-typedef struct __ops_memory_t {
-       uint8_t         *buf;           /* pointer to memory */
-       size_t           length;        /* length of memory */
-       size_t           allocated;     /* size, if allocated */
-       unsigned         mmapped;       /* whether buf is mmap-ed */
-} __ops_memory_t;
-
-/* Remember to add names to map in errors.c */
-typedef enum {
-       OPS_E_OK = 0x0000,      /* no error */
-       OPS_E_FAIL = 0x0001,    /* general error */
-       OPS_E_SYSTEM_ERROR = 0x0002,    /* system error, look at errno for
-                                        * details */
-       OPS_E_UNIMPLEMENTED = 0x0003,   /* feature not yet implemented */
-
-       /* reader errors */
-       OPS_E_R = 0x1000,       /* general reader error */
-       OPS_E_R_READ_FAILED = OPS_E_R + 1,
-       OPS_E_R_EARLY_EOF = OPS_E_R + 2,
-       OPS_E_R_BAD_FORMAT = OPS_E_R + 3,       /* For example, malformed
-                                                * armour */
-       OPS_E_R_UNSUPPORTED = OPS_E_R + 4,
-       OPS_E_R_UNCONSUMED_DATA = OPS_E_R + 5,
-
-       /* writer errors */
-       OPS_E_W = 0x2000,       /* general writer error */
-       OPS_E_W_WRITE_FAILED = OPS_E_W + 1,
-       OPS_E_W_WRITE_TOO_SHORT = OPS_E_W + 2,
-
-       /* parser errors */
-       OPS_E_P = 0x3000,       /* general parser error */
-       OPS_E_P_NOT_ENOUGH_DATA = OPS_E_P + 1,
-       OPS_E_P_UNKNOWN_TAG = OPS_E_P + 2,
-       OPS_E_P_PACKET_CONSUMED = OPS_E_P + 3,
-       OPS_E_P_MPI_FORMAT_ERROR = OPS_E_P + 4,
-       OPS_E_P_PACKET_NOT_CONSUMED = OPS_E_P + 5,
-       OPS_E_P_DECOMPRESSION_ERROR = OPS_E_P + 6,
-       OPS_E_P_NO_USERID = OPS_E_P + 7,
-
-       /* creator errors */
-       OPS_E_C = 0x4000,       /* general creator error */
-
-       /* validation errors */
-       OPS_E_V = 0x5000,       /* general validation error */
-       OPS_E_V_BAD_SIGNATURE = OPS_E_V + 1,
-       OPS_E_V_NO_SIGNATURE = OPS_E_V + 2,
-       OPS_E_V_UNKNOWN_SIGNER = OPS_E_V + 3,
-       OPS_E_V_BAD_HASH = OPS_E_V + 4,
-
-       /* Algorithm support errors */
-       OPS_E_ALG = 0x6000,     /* general algorithm error */
-       OPS_E_ALG_UNSUPPORTED_SYMMETRIC_ALG = OPS_E_ALG + 1,
-       OPS_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG = OPS_E_ALG + 2,
-       OPS_E_ALG_UNSUPPORTED_SIGNATURE_ALG = OPS_E_ALG + 3,
-       OPS_E_ALG_UNSUPPORTED_HASH_ALG = OPS_E_ALG + 4,
-       OPS_E_ALG_UNSUPPORTED_COMPRESS_ALG = OPS_E_ALG + 5,
-
-       /* Protocol errors */
-       OPS_E_PROTO = 0x7000,   /* general protocol error */
-       OPS_E_PROTO_BAD_SYMMETRIC_DECRYPT = OPS_E_PROTO + 2,
-       OPS_E_PROTO_UNKNOWN_SS = OPS_E_PROTO + 3,
-       OPS_E_PROTO_CRITICAL_SS_IGNORED = OPS_E_PROTO + 4,
-       OPS_E_PROTO_BAD_PUBLIC_KEY_VRSN = OPS_E_PROTO + 5,
-       OPS_E_PROTO_BAD_SIGNATURE_VRSN = OPS_E_PROTO + 6,
-       OPS_E_PROTO_BAD_ONE_PASS_SIG_VRSN = OPS_E_PROTO + 7,
-       OPS_E_PROTO_BAD_PKSK_VRSN = OPS_E_PROTO + 8,
-       OPS_E_PROTO_DECRYPTED_MSG_WRONG_LEN = OPS_E_PROTO + 9,
-       OPS_E_PROTO_BAD_SK_CHECKSUM = OPS_E_PROTO + 10
-} __ops_errcode_t;
-
-/** one entry in a linked list of errors */
-typedef struct __ops_error_t {
-       __ops_errcode_t errcode;
-       int             sys_errno; /* if errcode is OPS_E_SYSTEM_ERROR */
-       char            *comment;
-       const char      *file;
-       int              line;
-       struct __ops_error_t    *next;
-} __ops_error_t;
-
-#define OPS_SYSTEM_ERROR_1(err,code,sys,fmt,arg)       do {            \
-       __ops_push_error(err,OPS_E_SYSTEM_ERROR,errno,__FILE__,__LINE__,sys);\
-       __ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg);         \
-} while(/*CONSTCOND*/0)
-
-#define OPS_MEMORY_ERROR(err) {                                                \
-       loggit("Memory error");                         \



Home | Main Index | Thread Index | Old Index