summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2020-04-13 16:08:29 +0300
committerDmitry Baryshkov <dbaryshkov@gmail.com>2020-04-13 17:18:24 +0300
commit98a5ec41157e945a782c5b471e6efcc9a95cbbb0 (patch)
treed2405dfd92d9648f0c3f40e80c760d0bb26cde90
parente02c17ee702e4c14663daa01c36d7e7e298a2160 (diff)
downloadgnutls-98a5ec41157e945a782c5b471e6efcc9a95cbbb0.tar.gz
devel: modify curve448 script to import gost sources
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>
-rwxr-xr-xdevel/import-curve448-from-nettle.sh67
1 files changed, 54 insertions, 13 deletions
diff --git a/devel/import-curve448-from-nettle.sh b/devel/import-curve448-from-nettle.sh
index 214e8d0c15..8b04f13653 100755
--- a/devel/import-curve448-from-nettle.sh
+++ b/devel/import-curve448-from-nettle.sh
@@ -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