]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
nettle: vendor in SIV-CMAC implementation
authorDaiki Ueno <ueno@gnu.org>
Sun, 26 Apr 2020 17:27:05 +0000 (19:27 +0200)
committerDaiki Ueno <ueno@gnu.org>
Mon, 4 May 2020 12:26:39 +0000 (14:26 +0200)
Signed-off-by: Daiki Ueno <ueno@gnu.org>
configure.ac
devel/import-from-nettle.sh
lib/nettle/Makefile.am

index 600a83819f12316a15664565f3211bef7909a425..7bac929ce0b0f31b4b1e71e86d8acb9290e47456 100644 (file)
@@ -670,6 +670,13 @@ AC_CHECK_FUNCS([nettle_chacha_set_counter],
 LIBS=$save_LIBS
 AM_CONDITIONAL(NEED_CHACHA, [test "$have_chacha_set_counter" != "yes"])
 
+# Check for SIV-CMAC
+save_LIBS=$LIBS
+LIBS="$LIBS $NETTLE_LIBS"
+AC_CHECK_FUNCS(nettle_siv_cmac_aes128_set_key)
+LIBS=$save_LIBS
+AM_CONDITIONAL(NEED_SIV, [test "$ac_cv_func_nettle_siv_cmac_aes128_set_key" != "yes"])
+
 # Check sonames of the linked libraries needed for FIPS selftests.
 save_LIBS=$LIBS
 LIBS="$LIBS $GMP_LIBS"
index c0de610fd6da992f57d6c912fac32e5a5fc3d9be..3867f9e2a7a3da6b4ead1b9d1b56de5b6feb264f 100755 (executable)
@@ -32,6 +32,10 @@ xts.c
 xts.h
 xts-aes128.c
 xts-aes256.c
+siv-cmac.c
+siv-cmac.h
+siv-cmac-aes128.c
+siv-cmac-aes256.c
 "
 
 PUBLIC="
@@ -96,7 +100,7 @@ for f in $IMPORTS; do
       ;;
     esac
     case $dst in
-      */cfb.c | */cmac.c | */xts.c)
+      */cfb.c | */cmac.c | */xts.c | */siv-cmac.c)
        sed \
          -e 's/"nettle-internal\.h"/"nettle-alloca.h"/' \
          $dst > $dst-t && mv $dst-t $dst
@@ -111,6 +115,20 @@ for f in $IMPORTS; do
          $dst > $dst-t && mv $dst-t $dst
        ;;
     esac
+    case $dst in
+      */siv-cmac*.[ch])
+       sed \
+         -e '/^#include "cmac\.h"/ { i\
+#ifdef HAVE_NETTLE_CMAC128_UPDATE\
+#include <nettle/cmac.h>\
+#else\
+#include "cmac.h"\
+#endif
+; d
+}' \
+       $dst > $dst-t && mv $dst-t $dst
+      ;;
+    esac
   else
     echo "Error: $src not found" 1>&2
     exit 1
index 078e634eb661fda91539bb6c247b306432f71eac..936f20c6adbcbcb3f2ba78544b2a64da83fc2167 100644 (file)
@@ -190,3 +190,9 @@ libcrypto_la_SOURCES += \
        backport/poly1305.h backport/poly1305-internal.c \
        backport/poly1305-internal.h
 endif
+
+if NEED_SIV
+libcrypto_la_SOURCES += \
+       backport/siv-cmac-aes128.c backport/siv-cmac-aes256.c \
+       backport/siv-cmac.c backport/siv-cmac.h
+endif