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 Bring over ...



details:   https://anonhg.NetBSD.org/src/rev/d11dda4b3ebf
branches:  trunk
changeset: 971771:d11dda4b3ebf
user:      agc <agc%NetBSD.org@localhost>
date:      Mon May 04 00:18:34 2020 +0000

description:
Bring over changes from source of truth in pkgsrc - bump version to 20200503

        Update netpgpverify and libnetpgpverify to version 20200503

        ensure all exported functions use a unique prfix, so that they don't
        conflict with symbols (both data and text) in libcrypto. this works for
        statically linked binaries and libraries, rather then the version map which
        only works for dynalically-linked.

diffstat:

 crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd    |    7 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.c           |    6 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.h           |    6 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c        |   70 +++++-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/bn.h            |   16 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/bzlib.c         |   86 +++---
 crypto/external/bsd/netpgp/dist/src/netpgpverify/bzlib.h         |   32 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/bzlib_private.h |   26 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c     |   41 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/rsa.c           |   78 +++---
 crypto/external/bsd/netpgp/dist/src/netpgpverify/rsa.h           |   87 ++++---
 crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h        |    6 +-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/zlib.c          |   62 ++--
 crypto/external/bsd/netpgp/dist/src/netpgpverify/zlib.h          |  109 +++++----
 14 files changed, 357 insertions(+), 275 deletions(-)

diffs (truncated from 1765 to 300 lines):

diff -r 2c277bdc4a89 -r d11dda4b3ebf crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd     Sun May 03 21:46:37 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd     Mon May 04 00:18:34 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.bsd,v 1.7 2017/04/17 19:50:28 agc Exp $
+# $NetBSD: Makefile.bsd,v 1.8 2020/05/04 00:18:34 agc Exp $
 
 PROG=netpgpverify
 
@@ -12,6 +12,11 @@
 
 CPPFLAGS+=-I.
 
+CPPFLAGS.bzlib.c+=     -Wno-error=implicit-fallthrough
+CPPFLAGS.zlib.c+=      -Wno-error=implicit-fallthrough
+
+LDFLAGS+=-Wl,--version-script=${.CURDIR}/verify.map
+
 .ifndef PRODUCTION
 CPPFLAGS+=-g -O0
 LDFLAGS+=-g -O0
diff -r 2c277bdc4a89 -r d11dda4b3ebf crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.c    Sun May 03 21:46:37 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.c    Mon May 04 00:18:34 2020 +0000
@@ -235,7 +235,7 @@
 ** base64 encode a stream adding padding and line breaks as per spec.
 */
 int 
-b64encode(const char *in, const size_t insize, void *vp, size_t outsize, int linesize)
+netpgpv_b64encode(const char *in, const size_t insize, void *vp, size_t outsize, int linesize)
 {
        const char      *inp;
        unsigned         i;
@@ -299,7 +299,7 @@
 ** decode a base64 encoded stream discarding padding, line breaks and noise
 */
 int
-b64decode(const char *in, const size_t insize, void *vp, size_t outsize)
+netpgpv_b64decode(const char *in, const size_t insize, void *vp, size_t outsize)
 {
        const char      *inp;
        unsigned         wordlen;
@@ -349,7 +349,7 @@
 
 /* return the encoded size for n bytes input */
 int
-b64_encsize(unsigned n)
+netpgpv_b64_encsize(unsigned n)
 {
        return ((4 * n) / 3) + 4;
 }
diff -r 2c277bdc4a89 -r d11dda4b3ebf crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.h
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.h    Sun May 03 21:46:37 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/b64.h    Mon May 04 00:18:34 2020 +0000
@@ -25,8 +25,8 @@
 #ifndef B64_H_
 #define B64_H_ 20091223
 
-int b64encode(const char */*in*/, const size_t /*insize*/, void */*vp*/, size_t /*outsize*/, int /*linesize*/);
-int b64decode(const char */*in*/, const size_t /*insize*/, void */*vp*/, size_t /*outsize*/);
-int b64_encsize(unsigned /*n*/);
+int netpgpv_b64encode(const char */*in*/, const size_t /*insize*/, void */*vp*/, size_t /*outsize*/, int /*linesize*/);
+int netpgpv_b64decode(const char */*in*/, const size_t /*insize*/, void */*vp*/, size_t /*outsize*/);
+int netpgpv_b64_encsize(unsigned /*n*/);
 
 #endif
diff -r 2c277bdc4a89 -r d11dda4b3ebf crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c Sun May 03 21:46:37 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c Mon May 04 00:18:34 2020 +0000
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 Alistair Crooks <agc%NetBSD.org@localhost>
+ * Copyright (c) 2012-2019 Alistair Crooks <agc%NetBSD.org@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -3539,6 +3539,25 @@
        return res;
 }
 
+/* d = a + b (mod c) */
+static int
+add_modulo(mp_int *d, mp_int * a, mp_int * b, mp_int * c)
+{
+       mp_int  t;
+       int     res;
+
+       if ((res = mp_init(&t)) != MP_OKAY) {
+               return res;
+       }
+       if ((res = signed_add(a, b, &t)) != MP_OKAY) {
+               mp_clear(&t);
+               return res;
+       }
+       res = modulo(&t, c, d);
+       mp_clear(&t);
+       return res;
+}
+
 /* Source: /usr/cvsroot/libtommath/dist/libtommath/bn_mp_mulmod.c,v $ */
 /* Revision: 1.1.1.1 $ */
 /* Date: 2011/03/12 22:58:18 $ */
@@ -5048,7 +5067,6 @@
 
        /* clear a */
        mp_zero(a);
-
        /* if first digit is - then set negative */
        if ((ch = *s++) == '-') {
                neg = MP_NEG;
@@ -5056,9 +5074,12 @@
        } else {
                neg = MP_ZPOS;
        }
-
        for (;;) {
-               /* find y in the radix map */
+               /* fold lower to upper case */
+               if (ch >= 'a' && ch <= 'z') {
+                       ch = (ch - 'a') + 'A';
+               }
+               /* find index y in the radix map */
                for (y = 0; y < radix; y++) {
                        if (mp_s_rmap[y] == ch) {
                                break;
@@ -5067,7 +5088,6 @@
                if (y == radix) {
                        break;
                }
-
                /* shift up and add */
                if ((err = multiply_digit(a, radix, a)) != MP_OKAY) {
                        return err;
@@ -5075,13 +5095,11 @@
                if ((err = add_single_digit(a, y, a)) != MP_OKAY) {
                        return err;
                }
-
                ch = *s++;
        }
        if (compare_digit(a, 0) != MP_EQ) {
                a->sign = neg;
        }
-
        return MP_OKAY;
 }
 
@@ -5501,13 +5519,13 @@
 }
 
 int
-PGPV_BN_mod_exp(PGPV_BIGNUM *Y, PGPV_BIGNUM *G, PGPV_BIGNUM *X, PGPV_BIGNUM *P, PGPV_BN_CTX *ctx)
+PGPV_BN_mod_exp(PGPV_BIGNUM *Y, PGPV_BIGNUM *G, const PGPV_BIGNUM *X, const PGPV_BIGNUM *P, PGPV_BN_CTX *ctx)
 {
        if (Y == NULL || G == NULL || X == NULL || P == NULL) {
                return MP_VAL;
        }
        USE_ARG(ctx);
-       return exponent_modulo(G, X, P, Y) == MP_OKAY;
+       return exponent_modulo(G, __UNCONST(X), __UNCONST(P), Y) == MP_OKAY;
 }
 
 PGPV_BIGNUM *
@@ -5530,6 +5548,16 @@
        return multiply_modulo(ret, a, b, __UNCONST(m)) == MP_OKAY;
 }
 
+int
+PGPV_BN_mod_add(PGPV_BIGNUM *ret, PGPV_BIGNUM *a, PGPV_BIGNUM *b, const PGPV_BIGNUM *m, PGPV_BN_CTX *ctx)
+{
+       USE_ARG(ctx);
+       if (ret == NULL || a == NULL || b == NULL || m == NULL) {
+               return 0;
+       }
+       return add_modulo(ret, a, b, __UNCONST(m)) == MP_OKAY;
+}
+
 PGPV_BN_CTX *
 PGPV_BN_CTX_new(void)
 {
@@ -5777,3 +5805,27 @@
 {
        return mp_gcd(a, b, r);
 }
+
+int 
+PGPV_BN_sub_word(PGPV_BIGNUM *a, PGPV_BN_ULONG w)
+{
+       PGPV_BIGNUM     *bnw;
+
+       bnw = PGPV_BN_new();
+       PGPV_BN_set_word(bnw, w);
+       PGPV_BN_sub(a, a, bnw);
+       PGPV_BN_free(bnw);
+       return 1;
+}
+
+int 
+PGPV_BN_add_word(PGPV_BIGNUM *a, PGPV_BN_ULONG w)
+{
+       PGPV_BIGNUM     *bnw;
+
+       bnw = PGPV_BN_new();
+       PGPV_BN_set_word(bnw, w);
+       PGPV_BN_add(a, a, bnw);
+       PGPV_BN_free(bnw);
+       return 1;
+}
diff -r 2c277bdc4a89 -r d11dda4b3ebf crypto/external/bsd/netpgp/dist/src/netpgpverify/bn.h
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/bn.h     Sun May 03 21:46:37 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/bn.h     Mon May 04 00:18:34 2020 +0000
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 Alistair Crooks <agc%NetBSD.org@localhost>
+ * Copyright (c) 2012-2019 Alistair Crooks <agc%NetBSD.org@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@
 # include <stdio.h>
 #endif
 
-#ifndef __BEGIN_DECLS
+#if !defined(__BEGIN_DECLS)
 #  if defined(__cplusplus)
 #  define __BEGIN_DECLS           extern "C" {
 #  define __END_DECLS             }
@@ -50,6 +50,7 @@
 #define        BN_CTX          PGPV_BN_CTX
 #define BN_is_negative PGPV_BN_is_negative
 #define BN_is_zero     PGPV_BN_is_zero
+#define BN_is_one      PGPV_BN_is_one
 #define BN_is_odd      PGPV_BN_is_odd
 #define BN_is_even     PGPV_BN_is_even
 #define BN_new         PGPV_BN_new
@@ -61,6 +62,7 @@
 #define BN_clear_free  PGPV_BN_clear_free
 #define BN_cmp         PGPV_BN_cmp
 #define BN_bn2bin      PGPV_BN_bn2bin
+#define BN_bin2bn      PGPV_BN_bin2bn
 #define BN_bn2hex      PGPV_BN_bn2hex
 #define BN_bn2dec      PGPV_BN_bn2dec
 #define BN_bn2radix    PGPV_BN_bn2radix
@@ -87,6 +89,7 @@
 #define BN_mod_exp     PGPV_BN_mod_exp
 #define BN_mod_inverse PGPV_BN_mod_inverse
 #define BN_mod_mul     PGPV_BN_mod_mul
+#define BN_mod_add     PGPV_BN_mod_add
 #define BN_mod_sub     PGPV_BN_mod_sub
 #define BN_raise       PGPV_BN_raise
 #define BN_factorial   PGPV_BN_factorial
@@ -102,6 +105,8 @@
 #define BN_value_one   PGPV_BN_value_one
 #define BN_is_bit_set  PGPV_BN_is_bit_set
 #define BN_gcd         PGPV_BN_gcd
+#define BN_sub_word    PGPV_BN_sub_word
+#define BN_add_word    PGPV_BN_add_word
 #endif /* USE_BN_INTERFACE */
 
 /* should be 32bit on ILP32, 64bit on LP64 */
@@ -142,6 +147,7 @@
 
 #define PGPV_BN_is_negative(x) ((x)->sign == MP_NEG)
 #define PGPV_BN_is_zero(a)             (((a)->used == 0) ? 1 : 0)
+#define PGPV_BN_is_one(a)              (((a)->used == 1 && (a)->dp[0] == 1) ? 1 : 0)
 #define PGPV_BN_is_odd(a)              (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? 1 : 0)
 #define PGPV_BN_is_even(a)             (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? 1 : 0)
 
@@ -184,9 +190,10 @@
 int PGPV_BN_num_bytes(const PGPV_BIGNUM */*a*/);
 int PGPV_BN_num_bits(const PGPV_BIGNUM */*a*/);
 
-int PGPV_BN_mod_exp(PGPV_BIGNUM */*r*/, PGPV_BIGNUM */*a*/, PGPV_BIGNUM */*p*/, PGPV_BIGNUM */*m*/, PGPV_BN_CTX */*ctx*/);
+int PGPV_BN_mod_exp(PGPV_BIGNUM */*r*/, PGPV_BIGNUM */*a*/, const PGPV_BIGNUM */*p*/, const PGPV_BIGNUM */*m*/, PGPV_BN_CTX */*ctx*/);
 PGPV_BIGNUM *PGPV_BN_mod_inverse(PGPV_BIGNUM */*ret*/, PGPV_BIGNUM */*a*/, const PGPV_BIGNUM */*n*/, PGPV_BN_CTX */*ctx*/);
 int PGPV_BN_mod_mul(PGPV_BIGNUM */*ret*/, PGPV_BIGNUM */*a*/, PGPV_BIGNUM */*b*/, const PGPV_BIGNUM */*m*/, PGPV_BN_CTX */*ctx*/);
+int PGPV_BN_mod_add(PGPV_BIGNUM */*ret*/, PGPV_BIGNUM */*a*/, PGPV_BIGNUM */*b*/, const PGPV_BIGNUM */*m*/, PGPV_BN_CTX */*ctx*/);
 int PGPV_BN_mod_sub(PGPV_BIGNUM */*r*/, PGPV_BIGNUM */*a*/, PGPV_BIGNUM */*b*/, const PGPV_BIGNUM */*m*/, PGPV_BN_CTX */*ctx*/);
 
 int PGPV_BN_raise(PGPV_BIGNUM */*res*/, PGPV_BIGNUM */*a*/, PGPV_BIGNUM */*b*/);
@@ -209,6 +216,9 @@
 
 int PGPV_BN_gcd(PGPV_BIGNUM */*r*/, PGPV_BIGNUM */*a*/, PGPV_BIGNUM */*b*/, PGPV_BN_CTX */*ctx*/);
 
+int PGPV_BN_sub_word(PGPV_BIGNUM */*a*/, PGPV_BN_ULONG /*w*/);
+int PGPV_BN_add_word(PGPV_BIGNUM */*a*/, PGPV_BN_ULONG /*w*/);
+
 __END_DECLS
 
 #endif
diff -r 2c277bdc4a89 -r d11dda4b3ebf crypto/external/bsd/netpgp/dist/src/netpgpverify/bzlib.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/bzlib.c  Sun May 03 21:46:37 2020 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/bzlib.c  Mon May 04 00:18:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bzlib.c,v 1.4 2016/06/14 20:47:08 agc Exp $    */
+/*     $NetBSD: bzlib.c,v 1.5 2020/05/04 00:18:34 agc Exp $    */
 
 
 /*-------------------------------------------------------------*/
@@ -39,7 +39,7 @@



Home | Main Index | Thread Index | Old Index