pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/security/netpgpverify/files Update netpgpverify and li...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/43ac0df72a63
branches:  trunk
changeset: 328055:43ac0df72a63
user:      agc <agc%pkgsrc.org@localhost>
date:      Wed Jan 16 00:33:12 2019 +0000

description:
Update netpgpverify and libnetpgpverify to 20190111

Changes since previous version:

+ fuller emulation of openssl API, including

        BN_is_one()
        BN_mod_add()
        BN_mod_sub()
        BN_sub_word()
        BN_add_word()

+ provide all functions and macros with compatibility definitions

diffstat:

 security/netpgpverify/files/bignum.c |  70 +++++++++++++++++++++++++++++++----
 security/netpgpverify/files/bn.h     |  53 +++++++++++++++++++++++---
 security/netpgpverify/files/verify.h |   4 +-
 3 files changed, 109 insertions(+), 18 deletions(-)

diffs (279 lines):

diff -r e35a7d0163d4 -r 43ac0df72a63 security/netpgpverify/files/bignum.c
--- a/security/netpgpverify/files/bignum.c      Wed Jan 16 00:19:31 2019 +0000
+++ b/security/netpgpverify/files/bignum.c      Wed Jan 16 00:33:12 2019 +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 e35a7d0163d4 -r 43ac0df72a63 security/netpgpverify/files/bn.h
--- a/security/netpgpverify/files/bn.h  Wed Jan 16 00:19:31 2019 +0000
+++ b/security/netpgpverify/files/bn.h  Wed Jan 16 00:33:12 2019 +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,14 +32,43 @@
 # include <stdio.h>
 #endif
 
-#ifndef __BEGIN_DECLS
+#if !defined(__BEGIN_DECLS)
 #  if defined(__cplusplus)
-#  define __BEGIN_DECLS           extern "C" {
-#  define __END_DECLS             }
+#    define    __BEGIN_EXTERN_C        extern "C" {
+#    define    __END_EXTERN_C          }
+#    define    __static_cast(x,y)      static_cast<x>(y)
 #  else
-#  define __BEGIN_DECLS
-#  define __END_DECLS
+#    define    __BEGIN_EXTERN_C
+#    define    __END_EXTERN_C
+#    define    __static_cast(x,y)      (x)y
 #  endif
+
+#  if __GNUC_PREREQ__(4, 0)
+#    define __dso_public       __attribute__((__visibility__("default")))
+#    define __dso_hidden       __attribute__((__visibility__("hidden")))
+#    define __BEGIN_PUBLIC_DECLS       \
+       _Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C
+#    define __END_PUBLIC_DECLS __END_EXTERN_C _Pragma("GCC visibility pop")
+#    define __BEGIN_HIDDEN_DECLS       \
+       _Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C
+#    define __END_HIDDEN_DECLS __END_EXTERN_C _Pragma("GCC visibility pop")
+#  else
+#    define __dso_public
+#    define __dso_hidden
+#    define __BEGIN_PUBLIC_DECLS       __BEGIN_EXTERN_C
+#    define __END_PUBLIC_DECLS __END_EXTERN_C
+#    define __BEGIN_HIDDEN_DECLS       __BEGIN_EXTERN_C
+#    define __END_HIDDEN_DECLS __END_EXTERN_C
+#  endif
+#  if __GNUC_PREREQ__(4, 2)
+#    define __dso_protected    __attribute__((__visibility__("protected")))
+#  else
+#    define __dso_protected
+#  endif
+
+#  define      __BEGIN_DECLS           __BEGIN_PUBLIC_DECLS
+#  define      __END_DECLS             __END_PUBLIC_DECLS
+
 #endif
 
 __BEGIN_DECLS
@@ -50,6 +79,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 +91,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 +118,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 +134,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 +176,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 +219,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 +245,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 e35a7d0163d4 -r 43ac0df72a63 security/netpgpverify/files/verify.h
--- a/security/netpgpverify/files/verify.h      Wed Jan 16 00:19:31 2019 +0000
+++ b/security/netpgpverify/files/verify.h      Wed Jan 16 00:33:12 2019 +0000
@@ -23,9 +23,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #ifndef NETPGP_VERIFY_H_
-#define NETPGP_VERIFY_H_       20171019
+#define NETPGP_VERIFY_H_       20190111
 
-#define NETPGPVERIFY_VERSION   "netpgpverify portable 20171019"
+#define NETPGPVERIFY_VERSION   "netpgpverify portable 20190111"
 
 #include <sys/types.h>
 



Home | Main Index | Thread Index | Old Index