]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
devel: modify curve448 script to import gost sources
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Mon, 13 Apr 2020 13:08:29 +0000 (16:08 +0300)
committerDmitry Baryshkov <dbaryshkov@gmail.com>
Mon, 13 Apr 2020 14:18:24 +0000 (17:18 +0300)
Curve448 script already imports several ecc sources into GnuTLS tree.
Modify it to also vendor in GOST-related ecc files.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
devel/import-curve448-from-nettle.sh

index 214e8d0c153871d64f669d138bb274b0dc6bab06..8b04f13653ffc877a91f752f3b612a8c3224d578 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# This script copies the Curve448 and Ed448 implementation from the
+# This script copies the Curve448 and Ed448, GOST 34.10 implementation from the
 # nettle upstream, with necessary adjustments for bundling in GnuTLS.
 
 set +e
@@ -19,16 +19,27 @@ eccdata.c
 ecc-curve448.c
 ecc-add-eh.c
 ecc-add-ehh.c
+ecc-add-jja.c
+ecc-add-jjj.c
 ecc-a-to-j.c
 ecc-dup-eh.c
+ecc-dup-jj.c
 ecc-eh-to-a.c
+ecc-gost-gc256b.c
+ecc-gost-gc512a.c
+ecc-gostdsa-sign.c
+ecc-gostdsa-verify.c
 ecc-internal.h
+ecc-j-to-a.c
 ecc-mod-arith.c
 ecc-mod.c
 ecc-mod-inv.c
+ecc-mul-a.c
 ecc-mul-a-eh.c
+ecc-mul-g.c
 ecc-mul-g-eh.c
 ecc-mul-m.c
+ecc-random.c
 ed448-shake256.c
 ed448-shake256-pubkey.c
 ed448-shake256-sign.c
@@ -42,6 +53,9 @@ eddsa-internal.h
 eddsa-pubkey.c
 eddsa-sign.c
 eddsa-verify.c
+gostdsa.h
+gostdsa-sign.c
+gostdsa-verify.c
 gmp-glue.h
 gmp-glue.c
 nettle-write.h
@@ -58,8 +72,10 @@ write-le64.c
 
 PUBLIC="
 bignum.h
+dsa.h
 ecc-curve.h
 ecc.h
+ecdsa.h
 macros.h
 memxor.h
 nettle-meta.h
@@ -101,10 +117,6 @@ for f in $IMPORTS; do
          sed 's/\(NETTLE_'$g'\)/GNUTLS_LIB_NETTLE_CURVE448_\1/' $dst > $dst-t && \
            mv $dst-t $dst
        fi
-       ;;
-    esac
-    case $dst in
-      *.h)
        # Add prefix to function symbols avoid clashing with the public ones.
        sed -e 's/^#define \(.*\) nettle_\1/#define \1 gnutls_nettle_curve448_\1/' \
            -e 's/^#define \(.*\) _nettle_\1/#define \1 _gnutls_nettle_curve448_\1/' \
@@ -115,14 +127,10 @@ for f in $IMPORTS; do
            $dst > $dst-t && \
          mv $dst-t $dst
       ;;
-    esac
-    case $dst in
       */eccdata.c)
        sed 's/^#include "mini-gmp.c"/#include <gmp.h>/' $dst > $dst-t && \
          mv $dst-t $dst
        ;;
-    esac
-    case $dst in
       */ecc-curve448.c)
        # The generated file is arch dependent, conditionalize the
        # inclusion.
@@ -140,18 +148,51 @@ for f in $IMPORTS; do
 ; d
 }' $dst > $dst-t && mv $dst-t $dst
        ;;
-    esac
-    case $dst in
+      */ecc-gost-gc256b.c)
+       # The generated file is arch dependent, conditionalize the
+       # inclusion.
+       sed '/^#include "ecc-gost-gc256b\.h"/ { i\
+#if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)\
+# pragma GCC diagnostic ignored "-Wunused-const-variable"\
+#endif\
+#if GMP_NUMB_BITS == 32\
+#include "curve448/ecc-gost-gc256b-32.h"\
+#elif GMP_NUMB_BITS == 64\
+#include "curve448/ecc-gost-gc256b-64.h"\
+#else\
+#error unsupported configuration\
+#endif
+; d
+}' $dst | sed -e 's/#include "ecc-internal.h"/\0\n#include "ecc-gost-curve.h"/' > $dst-t && mv $dst-t $dst
+       ;;
+      */ecc-gost-gc512a.c)
+       # The generated file is arch dependent, conditionalize the
+       # inclusion.
+       sed '/^#include "ecc-gost-gc512a\.h"/ { i\
+#if defined __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)\
+# pragma GCC diagnostic ignored "-Wunused-const-variable"\
+#endif\
+#if GMP_NUMB_BITS == 32\
+#include "curve448/ecc-gost-gc512a-32.h"\
+#elif GMP_NUMB_BITS == 64\
+#include "curve448/ecc-gost-gc512a-64.h"\
+#else\
+#error unsupported configuration\
+#endif
+; d
+}' $dst | sed -e 's/#include "ecc-internal.h"/\0\n#include "ecc-gost-curve.h"/' > $dst-t && mv $dst-t $dst
+       ;;
       */eddsa-hash.c)
        # Known to be unnecessary.
        sed '/^#include "nettle-internal\.h"/d' $dst > $dst-t && mv $dst-t $dst
        ;;
-    esac
-    case $dst in
       */ecc-add-eh*.c)
        # Suppress whitespace errors in 'make syntax-check'.
        sed 's/ *       /               /g' $dst > $dst-t && mv $dst-t $dst
        ;;
+      */ecc-random.c|*/gostdsa-sign.c)
+       sed 's/"nettle-internal\.h"/"nettle-alloca.h"/' $dst > $dst-t && mv $dst-t $dst
+       ;;
     esac
   else
     echo "Error: $src not found" 1>&2