diff --git a/builds/msvc/vs2010/libsodium/libsodium.vcxproj b/builds/msvc/vs2010/libsodium/libsodium.vcxproj index d5e2dccc..f0394e7a 100644 --- a/builds/msvc/vs2010/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2010/libsodium/libsodium.vcxproj @@ -95,6 +95,7 @@ + @@ -298,6 +299,7 @@ + diff --git a/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2012/libsodium/libsodium.vcxproj b/builds/msvc/vs2012/libsodium/libsodium.vcxproj index ec920874..8d4a6d10 100644 --- a/builds/msvc/vs2012/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2012/libsodium/libsodium.vcxproj @@ -95,6 +95,7 @@ + @@ -298,6 +299,7 @@ + diff --git a/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2013/libsodium/libsodium.vcxproj b/builds/msvc/vs2013/libsodium/libsodium.vcxproj index a0c65ff0..e16bf966 100644 --- a/builds/msvc/vs2013/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2013/libsodium/libsodium.vcxproj @@ -95,6 +95,7 @@ + @@ -298,6 +299,7 @@ + diff --git a/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2015/libsodium/libsodium.vcxproj b/builds/msvc/vs2015/libsodium/libsodium.vcxproj index b2162b55..41316ebf 100644 --- a/builds/msvc/vs2015/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2015/libsodium/libsodium.vcxproj @@ -95,6 +95,7 @@ + @@ -298,6 +299,7 @@ + diff --git a/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2017/libsodium/libsodium.vcxproj b/builds/msvc/vs2017/libsodium/libsodium.vcxproj index eb722c73..3d6ae6a2 100644 --- a/builds/msvc/vs2017/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2017/libsodium/libsodium.vcxproj @@ -95,6 +95,7 @@ + @@ -298,6 +299,7 @@ + diff --git a/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2019/libsodium/libsodium.vcxproj b/builds/msvc/vs2019/libsodium/libsodium.vcxproj index 0f784304..68e3d6fd 100644 --- a/builds/msvc/vs2019/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2019/libsodium/libsodium.vcxproj @@ -119,6 +119,7 @@ + @@ -322,6 +323,7 @@ + diff --git a/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2022/libsodium/libsodium.vcxproj b/builds/msvc/vs2022/libsodium/libsodium.vcxproj index 5713e10e..1a59d595 100644 --- a/builds/msvc/vs2022/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2022/libsodium/libsodium.vcxproj @@ -119,6 +119,7 @@ + @@ -322,6 +323,7 @@ + diff --git a/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/builds/msvc/vs2026/libsodium/libsodium.vcxproj b/builds/msvc/vs2026/libsodium/libsodium.vcxproj index af1061a1..b354130b 100644 --- a/builds/msvc/vs2026/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2026/libsodium/libsodium.vcxproj @@ -119,6 +119,7 @@ + @@ -322,6 +323,7 @@ + diff --git a/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters index cf1114a5..94cd5dac 100644 --- a/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters @@ -105,6 +105,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 @@ -710,6 +713,9 @@ crypto_pwhash\argon2 + + crypto_pwhash\argon2 + crypto_pwhash\argon2 diff --git a/ci/appveyor/libsodium.vcxproj b/ci/appveyor/libsodium.vcxproj index 101709d6..2f270810 100644 --- a/ci/appveyor/libsodium.vcxproj +++ b/ci/appveyor/libsodium.vcxproj @@ -343,6 +343,7 @@ + @@ -546,6 +547,7 @@ + diff --git a/ci/appveyor/libsodium.vcxproj.filters b/ci/appveyor/libsodium.vcxproj.filters index 351b6da4..194649cc 100644 --- a/ci/appveyor/libsodium.vcxproj.filters +++ b/ci/appveyor/libsodium.vcxproj.filters @@ -96,6 +96,9 @@ Source Files + + Source Files + Source Files @@ -701,6 +704,9 @@ Header Files + + Header Files + Header Files diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 2746a94e..410ee8ed 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -261,7 +261,9 @@ libarmcrypto_la_SOURCES = \ crypto_aead/aegis256/aegis256_armcrypto.h \ crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c \ crypto_ipcrypt/ipcrypt_armcrypto.c \ - crypto_ipcrypt/ipcrypt_armcrypto.h + crypto_ipcrypt/ipcrypt_armcrypto.h \ + crypto_pwhash/argon2/argon2-fill-block-neon.c \ + crypto_pwhash/argon2/blamka-round-neon.h libaesni_la_LDFLAGS = $(libsodium_la_LDFLAGS) libaesni_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ diff --git a/src/libsodium/Makefile.in b/src/libsodium/Makefile.in index 47f70946..78690f03 100644 --- a/src/libsodium/Makefile.in +++ b/src/libsodium/Makefile.in @@ -238,7 +238,8 @@ am_libarmcrypto_la_OBJECTS = \ crypto_aead/aegis128l/libarmcrypto_la-aegis128l_armcrypto.lo \ crypto_aead/aegis256/libarmcrypto_la-aegis256_armcrypto.lo \ crypto_aead/aes256gcm/armcrypto/libarmcrypto_la-aead_aes256gcm_armcrypto.lo \ - crypto_ipcrypt/libarmcrypto_la-ipcrypt_armcrypto.lo + crypto_ipcrypt/libarmcrypto_la-ipcrypt_armcrypto.lo \ + crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo libarmcrypto_la_OBJECTS = $(am_libarmcrypto_la_OBJECTS) libarmcrypto_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ @@ -667,6 +668,7 @@ am__depfiles_remade = crypto_aead/aegis128l/$(DEPDIR)/libaesni_la-aegis128l_aesn crypto_onetimeauth/poly1305/donna/$(DEPDIR)/libsodium_la-poly1305_donna.Plo \ crypto_onetimeauth/poly1305/sse2/$(DEPDIR)/libsse2_la-poly1305_sse2.Plo \ crypto_pwhash/$(DEPDIR)/libsodium_la-crypto_pwhash.Plo \ + crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Plo \ crypto_pwhash/argon2/$(DEPDIR)/libavx2_la-argon2-fill-block-avx2.Plo \ crypto_pwhash/argon2/$(DEPDIR)/libavx512f_la-argon2-fill-block-avx512f.Plo \ crypto_pwhash/argon2/$(DEPDIR)/libsodium_la-argon2-core.Plo \ @@ -1190,7 +1192,9 @@ libarmcrypto_la_SOURCES = \ crypto_aead/aegis256/aegis256_armcrypto.h \ crypto_aead/aes256gcm/armcrypto/aead_aes256gcm_armcrypto.c \ crypto_ipcrypt/ipcrypt_armcrypto.c \ - crypto_ipcrypt/ipcrypt_armcrypto.h + crypto_ipcrypt/ipcrypt_armcrypto.h \ + crypto_pwhash/argon2/argon2-fill-block-neon.c \ + crypto_pwhash/argon2/blamka-round-neon.h libaesni_la_LDFLAGS = $(libsodium_la_LDFLAGS) libaesni_la_CPPFLAGS = $(libsodium_la_CPPFLAGS) \ @@ -1394,6 +1398,15 @@ crypto_aead/aes256gcm/armcrypto/libarmcrypto_la-aead_aes256gcm_armcrypto.lo: \ crypto_ipcrypt/libarmcrypto_la-ipcrypt_armcrypto.lo: \ crypto_ipcrypt/$(am__dirstamp) \ crypto_ipcrypt/$(DEPDIR)/$(am__dirstamp) +crypto_pwhash/argon2/$(am__dirstamp): + @$(MKDIR_P) crypto_pwhash/argon2 + @: >>crypto_pwhash/argon2/$(am__dirstamp) +crypto_pwhash/argon2/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) crypto_pwhash/argon2/$(DEPDIR) + @: >>crypto_pwhash/argon2/$(DEPDIR)/$(am__dirstamp) +crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo: \ + crypto_pwhash/argon2/$(am__dirstamp) \ + crypto_pwhash/argon2/$(DEPDIR)/$(am__dirstamp) libarmcrypto.la: $(libarmcrypto_la_OBJECTS) $(libarmcrypto_la_DEPENDENCIES) $(EXTRA_libarmcrypto_la_DEPENDENCIES) $(AM_V_CCLD)$(libarmcrypto_la_LINK) $(libarmcrypto_la_OBJECTS) $(libarmcrypto_la_LIBADD) $(LIBS) @@ -1406,12 +1419,6 @@ crypto_generichash/blake2b/ref/$(DEPDIR)/$(am__dirstamp): crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.lo: \ crypto_generichash/blake2b/ref/$(am__dirstamp) \ crypto_generichash/blake2b/ref/$(DEPDIR)/$(am__dirstamp) -crypto_pwhash/argon2/$(am__dirstamp): - @$(MKDIR_P) crypto_pwhash/argon2 - @: >>crypto_pwhash/argon2/$(am__dirstamp) -crypto_pwhash/argon2/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) crypto_pwhash/argon2/$(DEPDIR) - @: >>crypto_pwhash/argon2/$(DEPDIR)/$(am__dirstamp) crypto_pwhash/argon2/libavx2_la-argon2-fill-block-avx2.lo: \ crypto_pwhash/argon2/$(am__dirstamp) \ crypto_pwhash/argon2/$(DEPDIR)/$(am__dirstamp) @@ -2542,6 +2549,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@crypto_onetimeauth/poly1305/donna/$(DEPDIR)/libsodium_la-poly1305_donna.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@crypto_onetimeauth/poly1305/sse2/$(DEPDIR)/libsse2_la-poly1305_sse2.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@crypto_pwhash/$(DEPDIR)/libsodium_la-crypto_pwhash.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@crypto_pwhash/argon2/$(DEPDIR)/libavx2_la-argon2-fill-block-avx2.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@crypto_pwhash/argon2/$(DEPDIR)/libavx512f_la-argon2-fill-block-avx512f.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@crypto_pwhash/argon2/$(DEPDIR)/libsodium_la-argon2-core.Plo@am__quote@ # am--include-marker @@ -2743,6 +2751,13 @@ crypto_ipcrypt/libarmcrypto_la-ipcrypt_armcrypto.lo: crypto_ipcrypt/ipcrypt_armc @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarmcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o crypto_ipcrypt/libarmcrypto_la-ipcrypt_armcrypto.lo `test -f 'crypto_ipcrypt/ipcrypt_armcrypto.c' || echo '$(srcdir)/'`crypto_ipcrypt/ipcrypt_armcrypto.c +crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo: crypto_pwhash/argon2/argon2-fill-block-neon.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarmcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo -MD -MP -MF crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Tpo -c -o crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo `test -f 'crypto_pwhash/argon2/argon2-fill-block-neon.c' || echo '$(srcdir)/'`crypto_pwhash/argon2/argon2-fill-block-neon.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Tpo crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='crypto_pwhash/argon2/argon2-fill-block-neon.c' object='crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarmcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o crypto_pwhash/argon2/libarmcrypto_la-argon2-fill-block-neon.lo `test -f 'crypto_pwhash/argon2/argon2-fill-block-neon.c' || echo '$(srcdir)/'`crypto_pwhash/argon2/argon2-fill-block-neon.c + crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.lo: crypto_generichash/blake2b/ref/blake2b-compress-avx2.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libavx2_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.lo -MD -MP -MF crypto_generichash/blake2b/ref/$(DEPDIR)/libavx2_la-blake2b-compress-avx2.Tpo -c -o crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.lo `test -f 'crypto_generichash/blake2b/ref/blake2b-compress-avx2.c' || echo '$(srcdir)/'`crypto_generichash/blake2b/ref/blake2b-compress-avx2.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) crypto_generichash/blake2b/ref/$(DEPDIR)/libavx2_la-blake2b-compress-avx2.Tpo crypto_generichash/blake2b/ref/$(DEPDIR)/libavx2_la-blake2b-compress-avx2.Plo @@ -4189,6 +4204,7 @@ distclean: distclean-recursive -rm -f crypto_onetimeauth/poly1305/donna/$(DEPDIR)/libsodium_la-poly1305_donna.Plo -rm -f crypto_onetimeauth/poly1305/sse2/$(DEPDIR)/libsse2_la-poly1305_sse2.Plo -rm -f crypto_pwhash/$(DEPDIR)/libsodium_la-crypto_pwhash.Plo + -rm -f crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Plo -rm -f crypto_pwhash/argon2/$(DEPDIR)/libavx2_la-argon2-fill-block-avx2.Plo -rm -f crypto_pwhash/argon2/$(DEPDIR)/libavx512f_la-argon2-fill-block-avx512f.Plo -rm -f crypto_pwhash/argon2/$(DEPDIR)/libsodium_la-argon2-core.Plo @@ -4371,6 +4387,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f crypto_onetimeauth/poly1305/donna/$(DEPDIR)/libsodium_la-poly1305_donna.Plo -rm -f crypto_onetimeauth/poly1305/sse2/$(DEPDIR)/libsse2_la-poly1305_sse2.Plo -rm -f crypto_pwhash/$(DEPDIR)/libsodium_la-crypto_pwhash.Plo + -rm -f crypto_pwhash/argon2/$(DEPDIR)/libarmcrypto_la-argon2-fill-block-neon.Plo -rm -f crypto_pwhash/argon2/$(DEPDIR)/libavx2_la-argon2-fill-block-avx2.Plo -rm -f crypto_pwhash/argon2/$(DEPDIR)/libavx512f_la-argon2-fill-block-avx512f.Plo -rm -f crypto_pwhash/argon2/$(DEPDIR)/libsodium_la-argon2-core.Plo diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index 0017da52..6878ddf6 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -45,7 +45,12 @@ # define MAP_POPULATE 0 #endif +#if (defined(__aarch64__) || defined(_M_ARM64)) && \ + (defined(__ARM_NEON) || defined(__ARM_NEON__)) +static fill_segment_fn fill_segment = argon2_fill_segment_neon; +#else static fill_segment_fn fill_segment = argon2_fill_segment_ref; +#endif static void load_block(block *dst, const void *input) @@ -547,7 +552,12 @@ argon2_pick_best_implementation(void) return 0; } #endif +#if (defined(__aarch64__) || defined(_M_ARM64)) && \ + (defined(__ARM_NEON) || defined(__ARM_NEON__)) + fill_segment = argon2_fill_segment_neon; +#else fill_segment = argon2_fill_segment_ref; +#endif return 0; /* LCOV_EXCL_STOP */ diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.h b/src/libsodium/crypto_pwhash/argon2/argon2-core.h index b7e77630..d544f3eb 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.h +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.h @@ -259,6 +259,8 @@ void argon2_fill_segment_ssse3(const argon2_instance_t *instance, argon2_position_t position); void argon2_fill_segment_wasm32(const argon2_instance_t *instance, argon2_position_t position); +void argon2_fill_segment_neon(const argon2_instance_t *instance, + argon2_position_t position); void argon2_fill_segment_ref(const argon2_instance_t *instance, argon2_position_t position); diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-neon.c b/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-neon.c new file mode 100644 index 00000000..3e3fec7a --- /dev/null +++ b/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-neon.c @@ -0,0 +1,216 @@ +/* + * Argon2 source code package + * + * Written by Daniel Dinu and Dmitry Khovratovich, 2015 + * + * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with + * this software. If not, see + * . + * + * AARCH64 NEON implementation ported from SSSE3 version. + */ + +#include +#include +#include + +#include "argon2-core.h" +#include "argon2.h" +#include "private/common.h" + +#if (defined(__aarch64__) || defined(_M_ARM64)) && \ + (defined(__ARM_NEON) || defined(__ARM_NEON__)) + +# include +# include "blamka-round-neon.h" + +static void +fill_block(uint64x2_t *state, const uint8_t *ref_block, uint8_t *next_block) +{ + uint64x2_t block_XY[ARGON2_OWORDS_IN_BLOCK]; + uint32_t i; + + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + block_XY[i] = state[i] = veorq_u64( + state[i], vld1q_u64((const uint64_t *) (&ref_block[16 * i]))); + } + + for (i = 0; i < 8; ++i) { + BLAKE2_ROUND_NEON(state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], + state[8 * i + 3], state[8 * i + 4], state[8 * i + 5], + state[8 * i + 6], state[8 * i + 7]); + } + + for (i = 0; i < 8; ++i) { + BLAKE2_ROUND_NEON(state[8 * 0 + i], state[8 * 1 + i], state[8 * 2 + i], + state[8 * 3 + i], state[8 * 4 + i], state[8 * 5 + i], + state[8 * 6 + i], state[8 * 7 + i]); + } + + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + state[i] = veorq_u64(state[i], block_XY[i]); + vst1q_u64((uint64_t *) (&next_block[16 * i]), state[i]); + } +} + +static void +fill_block_with_xor(uint64x2_t *state, const uint8_t *ref_block, + uint8_t *next_block) +{ + uint64x2_t block_XY[ARGON2_OWORDS_IN_BLOCK]; + uint32_t i; + + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + state[i] = veorq_u64( + state[i], vld1q_u64((const uint64_t *) (&ref_block[16 * i]))); + block_XY[i] = veorq_u64( + state[i], vld1q_u64((const uint64_t *) (&next_block[16 * i]))); + } + + for (i = 0; i < 8; ++i) { + BLAKE2_ROUND_NEON(state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], + state[8 * i + 3], state[8 * i + 4], state[8 * i + 5], + state[8 * i + 6], state[8 * i + 7]); + } + + for (i = 0; i < 8; ++i) { + BLAKE2_ROUND_NEON(state[8 * 0 + i], state[8 * 1 + i], state[8 * 2 + i], + state[8 * 3 + i], state[8 * 4 + i], state[8 * 5 + i], + state[8 * 6 + i], state[8 * 7 + i]); + } + + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + state[i] = veorq_u64(state[i], block_XY[i]); + vst1q_u64((uint64_t *) (&next_block[16 * i]), state[i]); + } +} + +static void +generate_addresses(const argon2_instance_t *instance, + const argon2_position_t *position, uint64_t *pseudo_rands) +{ + block address_block, input_block, tmp_block; + uint32_t i; + + init_block_value(&address_block, 0); + init_block_value(&input_block, 0); + + if (instance != NULL && position != NULL) { + input_block.v[0] = position->pass; + input_block.v[1] = position->lane; + input_block.v[2] = position->slice; + input_block.v[3] = instance->memory_blocks; + input_block.v[4] = instance->passes; + input_block.v[5] = instance->type; + + for (i = 0; i < instance->segment_length; ++i) { + if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) { + uint64x2_t zero_block[ARGON2_OWORDS_IN_BLOCK]; + uint64x2_t zero2_block[ARGON2_OWORDS_IN_BLOCK]; + + memset(zero_block, 0, sizeof(zero_block)); + memset(zero2_block, 0, sizeof(zero2_block)); + init_block_value(&address_block, 0); + init_block_value(&tmp_block, 0); + + input_block.v[6]++; + + fill_block_with_xor(zero_block, (uint8_t *) &input_block.v, + (uint8_t *) &tmp_block.v); + fill_block_with_xor(zero2_block, (uint8_t *) &tmp_block.v, + (uint8_t *) &address_block.v); + } + + pseudo_rands[i] = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK]; + } + } +} + +void +argon2_fill_segment_neon(const argon2_instance_t *instance, + argon2_position_t position) +{ + block *ref_block = NULL, *curr_block = NULL; + uint64_t pseudo_rand, ref_index, ref_lane; + uint32_t prev_offset, curr_offset; + uint32_t starting_index, i; + uint64x2_t state[ARGON2_OWORDS_IN_BLOCK]; + int data_independent_addressing = 1; + + uint64_t *pseudo_rands = NULL; + + if (instance == NULL) { + return; + } + + if (instance->type == Argon2_id && + (position.pass != 0 || position.slice >= ARGON2_SYNC_POINTS / 2)) { + data_independent_addressing = 0; + } + + pseudo_rands = instance->pseudo_rands; + + if (data_independent_addressing) { + generate_addresses(instance, &position, pseudo_rands); + } + + starting_index = 0; + + if ((0 == position.pass) && (0 == position.slice)) { + starting_index = 2; + } + + curr_offset = position.lane * instance->lane_length + + position.slice * instance->segment_length + starting_index; + + if (0 == curr_offset % instance->lane_length) { + prev_offset = curr_offset + instance->lane_length - 1; + } else { + prev_offset = curr_offset - 1; + } + + memcpy(state, ((instance->region->memory + prev_offset)->v), + ARGON2_BLOCK_SIZE); + + for (i = starting_index; i < instance->segment_length; + ++i, ++curr_offset, ++prev_offset) { + if (curr_offset % instance->lane_length == 1) { + prev_offset = curr_offset - 1; + } + + if (data_independent_addressing) { +#pragma warning(push) +#pragma warning(disable : 6385) + pseudo_rand = pseudo_rands[i]; +#pragma warning(pop) + } else { + pseudo_rand = instance->region->memory[prev_offset].v[0]; + } + + ref_lane = ((pseudo_rand >> 32)) % instance->lanes; + + if ((position.pass == 0) && (position.slice == 0)) { + ref_lane = position.lane; + } + + position.index = i; + ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF, + ref_lane == position.lane); + + ref_block = instance->region->memory + + instance->lane_length * ref_lane + ref_index; + curr_block = instance->region->memory + curr_offset; + if (position.pass != 0) { + fill_block_with_xor(state, (uint8_t *) ref_block->v, + (uint8_t *) curr_block->v); + } else { + fill_block(state, (uint8_t *) ref_block->v, + (uint8_t *) curr_block->v); + } + } +} + +#endif diff --git a/src/libsodium/crypto_pwhash/argon2/blamka-round-neon.h b/src/libsodium/crypto_pwhash/argon2/blamka-round-neon.h new file mode 100644 index 00000000..3362fe72 --- /dev/null +++ b/src/libsodium/crypto_pwhash/argon2/blamka-round-neon.h @@ -0,0 +1,161 @@ +#ifndef blamka_round_neon_H +#define blamka_round_neon_H + +#include + +#include "private/common.h" + +static inline uint64x2_t +fBlaMka_neon(uint64x2_t x, uint64x2_t y) +{ + const uint32x2_t x_lo = vmovn_u64(x); + const uint32x2_t y_lo = vmovn_u64(y); + const uint64x2_t z = vmull_u32(x_lo, y_lo); + + return vaddq_u64(vaddq_u64(x, y), vaddq_u64(z, z)); +} + +static inline uint64x2_t +rotr64_32_neon(uint64x2_t x) +{ + return vreinterpretq_u64_u32(vrev64q_u32(vreinterpretq_u32_u64(x))); +} + +static inline uint64x2_t +rotr64_24_neon(uint64x2_t x) +{ + static const uint8_t rot24_tbl[16] = { + 3, 4, 5, 6, 7, 0, 1, 2, + 11, 12, 13, 14, 15, 8, 9, 10 + }; + const uint8x16_t tbl = vld1q_u8(rot24_tbl); + return vreinterpretq_u64_u8(vqtbl1q_u8(vreinterpretq_u8_u64(x), tbl)); +} + +static inline uint64x2_t +rotr64_16_neon(uint64x2_t x) +{ + static const uint8_t rot16_tbl[16] = { + 2, 3, 4, 5, 6, 7, 0, 1, + 10, 11, 12, 13, 14, 15, 8, 9 + }; + const uint8x16_t tbl = vld1q_u8(rot16_tbl); + return vreinterpretq_u64_u8(vqtbl1q_u8(vreinterpretq_u8_u64(x), tbl)); +} + +static inline uint64x2_t +rotr64_63_neon(uint64x2_t x) +{ + return veorq_u64(vshrq_n_u64(x, 63), vaddq_u64(x, x)); +} + +#define G1_NEON(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + A0 = fBlaMka_neon(A0, B0); \ + A1 = fBlaMka_neon(A1, B1); \ + \ + D0 = veorq_u64(D0, A0); \ + D1 = veorq_u64(D1, A1); \ + \ + D0 = rotr64_32_neon(D0); \ + D1 = rotr64_32_neon(D1); \ + \ + C0 = fBlaMka_neon(C0, D0); \ + C1 = fBlaMka_neon(C1, D1); \ + \ + B0 = veorq_u64(B0, C0); \ + B1 = veorq_u64(B1, C1); \ + \ + B0 = rotr64_24_neon(B0); \ + B1 = rotr64_24_neon(B1); \ + } while ((void) 0, 0) + +#define G2_NEON(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + A0 = fBlaMka_neon(A0, B0); \ + A1 = fBlaMka_neon(A1, B1); \ + \ + D0 = veorq_u64(D0, A0); \ + D1 = veorq_u64(D1, A1); \ + \ + D0 = rotr64_16_neon(D0); \ + D1 = rotr64_16_neon(D1); \ + \ + C0 = fBlaMka_neon(C0, D0); \ + C1 = fBlaMka_neon(C1, D1); \ + \ + B0 = veorq_u64(B0, C0); \ + B1 = veorq_u64(B1, C1); \ + \ + B0 = rotr64_63_neon(B0); \ + B1 = rotr64_63_neon(B1); \ + } while ((void) 0, 0) + +#define DIAGONALIZE_NEON(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + uint64x2_t t0, t1; \ + \ + t0 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(B0), \ + vreinterpretq_u8_u64(B1), 8)); \ + t1 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(B1), \ + vreinterpretq_u8_u64(B0), 8)); \ + B0 = t0; \ + B1 = t1; \ + \ + t0 = C0; \ + C0 = C1; \ + C1 = t0; \ + \ + t0 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(D0), \ + vreinterpretq_u8_u64(D1), 8)); \ + t1 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(D1), \ + vreinterpretq_u8_u64(D0), 8)); \ + D0 = t1; \ + D1 = t0; \ + } while ((void) 0, 0) + +#define UNDIAGONALIZE_NEON(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + uint64x2_t t0, t1; \ + \ + t0 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(B1), \ + vreinterpretq_u8_u64(B0), 8)); \ + t1 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(B0), \ + vreinterpretq_u8_u64(B1), 8)); \ + B0 = t0; \ + B1 = t1; \ + \ + t0 = C0; \ + C0 = C1; \ + C1 = t0; \ + \ + t0 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(D1), \ + vreinterpretq_u8_u64(D0), 8)); \ + t1 = vreinterpretq_u64_u8( \ + vextq_u8(vreinterpretq_u8_u64(D0), \ + vreinterpretq_u8_u64(D1), 8)); \ + D0 = t1; \ + D1 = t0; \ + } while ((void) 0, 0) + +#define BLAKE2_ROUND_NEON(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + G1_NEON(A0, B0, C0, D0, A1, B1, C1, D1); \ + G2_NEON(A0, B0, C0, D0, A1, B1, C1, D1); \ + \ + DIAGONALIZE_NEON(A0, B0, C0, D0, A1, B1, C1, D1); \ + \ + G1_NEON(A0, B0, C0, D0, A1, B1, C1, D1); \ + G2_NEON(A0, B0, C0, D0, A1, B1, C1, D1); \ + \ + UNDIAGONALIZE_NEON(A0, B0, C0, D0, A1, B1, C1, D1); \ + } while ((void) 0, 0) + +#endif