pkgsrc-Changes archive

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

CVS commit: pkgsrc/security/netpgpverify/files



Module Name:    pkgsrc
Committed By:   agc
Date:           Wed Jan 16 00:33:12 UTC 2019

Modified Files:
        pkgsrc/security/netpgpverify/files: bignum.c bn.h verify.h

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 pkgsrc/security/netpgpverify/files/bignum.c
cvs rdiff -u -r1.5 -r1.6 pkgsrc/security/netpgpverify/files/bn.h
cvs rdiff -u -r1.38 -r1.39 pkgsrc/security/netpgpverify/files/verify.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/security/netpgpverify/files/bignum.c
diff -u pkgsrc/security/netpgpverify/files/bignum.c:1.9 pkgsrc/security/netpgpverify/files/bignum.c:1.10
--- pkgsrc/security/netpgpverify/files/bignum.c:1.9     Sat Jul  9 17:18:24 2016
+++ pkgsrc/security/netpgpverify/files/bignum.c Wed Jan 16 00:33:12 2019
@@ -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 @@ multiply_modulo(mp_int *d, mp_int * a, m
        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 @@ mp_getradix_num(mp_int *a, int radix, ch
 
        /* clear a */
        mp_zero(a);
-
        /* if first digit is - then set negative */
        if ((ch = *s++) == '-') {
                neg = MP_NEG;
@@ -5056,9 +5074,12 @@ mp_getradix_num(mp_int *a, int radix, ch
        } 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 @@ mp_getradix_num(mp_int *a, int radix, ch
                if (y == radix) {
                        break;
                }
-
                /* shift up and add */
                if ((err = multiply_digit(a, radix, a)) != MP_OKAY) {
                        return err;
@@ -5075,13 +5095,11 @@ mp_getradix_num(mp_int *a, int radix, ch
                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 @@ PGPV_BN_cmp(PGPV_BIGNUM *a, PGPV_BIGNUM 
 }
 
 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 @@ PGPV_BN_mod_mul(PGPV_BIGNUM *ret, PGPV_B
        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 @@ PGPV_BN_gcd(PGPV_BIGNUM *r, PGPV_BIGNUM 
 {
        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;
+}

Index: pkgsrc/security/netpgpverify/files/bn.h
diff -u pkgsrc/security/netpgpverify/files/bn.h:1.5 pkgsrc/security/netpgpverify/files/bn.h:1.6
--- pkgsrc/security/netpgpverify/files/bn.h:1.5 Fri Jun  3 00:11:10 2016
+++ pkgsrc/security/netpgpverify/files/bn.h     Wed Jan 16 00:33:12 2019
@@ -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 @@ __BEGIN_DECLS
 #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 @@ __BEGIN_DECLS
 #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 @@ __BEGIN_DECLS
 #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 @@ __BEGIN_DECLS
 #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 @@ typedef struct bn_ctx_t {
 
 #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 @@ void PGPV_BN_set_negative(PGPV_BIGNUM */
 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_is_bit_set(const PGPV_BIGNUM
 
 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

Index: pkgsrc/security/netpgpverify/files/verify.h
diff -u pkgsrc/security/netpgpverify/files/verify.h:1.38 pkgsrc/security/netpgpverify/files/verify.h:1.39
--- pkgsrc/security/netpgpverify/files/verify.h:1.38    Thu Oct 19 08:23:21 2017
+++ pkgsrc/security/netpgpverify/files/verify.h Wed Jan 16 00:33:12 2019
@@ -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