diff --git a/.gitignore b/.gitignore index 3315e98d..2cc8cdfd 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,7 @@ test/default/core4 test/default/core5 test/default/core6 test/default/core_ed25519 +test/default/core_ed25519_h2c test/default/core_ristretto255 test/default/ed25519_convert test/default/generichash @@ -122,6 +123,7 @@ test/default/generichash3 test/default/hash test/default/hash3 test/default/kdf +test/default/kdf_hkdf test/default/keygen test/default/kx test/default/metamorphic diff --git a/.travis.yml b/.travis.yml index 5982d09a..6a61ba5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: false +dist: xenial language: c diff --git a/README.markdown b/README.markdown index 4f14321e..2794fbc5 100644 --- a/README.markdown +++ b/README.markdown @@ -22,12 +22,10 @@ as well as Javascript and Webassembly. ## Documentation -The documentation is available on Gitbook and built from the [libsodium-doc](https://github.com/jedisct1/libsodium-doc) repository: +The documentation is available on Gitbook and built from the +[libsodium-doc](https://github.com/jedisct1/libsodium-doc) repository: -* [libsodium documentation](https://download.libsodium.org/doc/) - -online, requires Javascript. -* [offline documentation](https://www.gitbook.com/book/jedisct1/libsodium/details) -in PDF format. +* [libsodium documentation](https://doc.libsodium.org) - online, requires Javascript. ## Integrity Checking @@ -54,9 +52,7 @@ This project exists thanks to all the people who contribute. [[Contribute](CONTR Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/libsodium/contribute)] -#### Individuals - - +#### Individuals Href="https://opencollective.com/libsodium"> #### Organizations @@ -64,8 +60,6 @@ Support this project with your organization. Your logo will show up here with a - - ## License [ISC license](https://en.wikipedia.org/wiki/ISC_license). diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fe1ac8c4..693569fe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,7 +7,7 @@ pr: none jobs: - job: "wasi" pool: - vmImage: "ubuntu-16.04" + vmImage: "ubuntu-18.04" steps: - script: | sudo apt-get install build-essential curl cmake @@ -16,8 +16,8 @@ jobs: curl https://get.wasmer.io -sSfL | sh displayName: Install wasmer - script: | - curl -sL -o wasi-sdk.deb https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk_8.0_amd64.deb - sudo dpkg -i wasi-sdk.deb && rm -f wasi-sdk.deb + curl -sL -o - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/wasi-sdk-10.0-linux.tar.gz | tar xz -f - -C /opt/ + sudo mv /opt/wasi-sdk-* /opt/wasi-sdk sudo ln -s /opt/wasi-sdk/share/*sysroot* /opt/wasi-sysroot displayName: Install the WASI SDK - script: | @@ -62,23 +62,6 @@ jobs: pathToPublish: bin artifactName: libsodium - - job: "windows_reallyold" - pool: - vmImage: "vs2015-win2012r2" - steps: - - powershell: | - cd builds\msvc\build - & .\buildbase.bat ..\vs2015\libsodium.sln 14 - & .\buildbase.bat ..\vs2013\libsodium.sln 12 - & .\buildbase.bat ..\vs2012\libsodium.sln 11 - & .\buildbase.bat ..\vs2010\libsodium.sln 10 - displayName: Compile it all - - task: PublishBuildArtifacts@1 - condition: not(canceled()) - inputs: - pathToPublish: bin - artifactName: libsodium - - job: mingw64 pool: vmImage: "windows-2019" diff --git a/builds/msvc/version.h b/builds/msvc/version.h index 174d9921..b5e27007 100644 --- a/builds/msvc/version.h +++ b/builds/msvc/version.h @@ -6,8 +6,8 @@ #define SODIUM_VERSION_STRING "1.0.18" -#define SODIUM_LIBRARY_VERSION_MAJOR 10 -#define SODIUM_LIBRARY_VERSION_MINOR 3 +#define SODIUM_LIBRARY_VERSION_MAJOR 11 +#define SODIUM_LIBRARY_VERSION_MINOR 0 #ifdef __cplusplus extern "C" { diff --git a/builds/msvc/vs2010/libsodium/libsodium.vcxproj b/builds/msvc/vs2010/libsodium/libsodium.vcxproj index c615ed34..117e28d8 100644 --- a/builds/msvc/vs2010/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2010/libsodium/libsodium.vcxproj @@ -88,7 +88,6 @@ - @@ -120,6 +119,8 @@ + + @@ -243,6 +244,7 @@ + @@ -251,6 +253,7 @@ + @@ -259,7 +262,6 @@ - diff --git a/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters index d20a341f..dc96b0a7 100644 --- a/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters @@ -57,9 +57,6 @@ crypto_sign\ed25519 - - crypto_sign\ed25519\ref10 - crypto_sign\ed25519\ref10 @@ -153,6 +150,12 @@ crypto_kdf\blake2b + + crypto_kdf\hkdf + + + crypto_kdf\hkdf + crypto_shorthash @@ -518,6 +521,9 @@ include\sodium + + include\sodium + include\sodium @@ -542,6 +548,9 @@ include\sodium + + include\sodium + include\sodium @@ -566,9 +575,6 @@ include\sodium - - include\sodium - include\sodium\private @@ -862,6 +868,9 @@ {3d42d2a2-b192-33dd-9162-508916414707} + + {baf7d894-9298-391d-8dc2-e4c3010f5ddc} + {898b6bd5-1360-3a34-adcd-0fade7561685} diff --git a/builds/msvc/vs2012/libsodium/libsodium.vcxproj b/builds/msvc/vs2012/libsodium/libsodium.vcxproj index 05a9b0ae..2cdc40eb 100644 --- a/builds/msvc/vs2012/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2012/libsodium/libsodium.vcxproj @@ -88,7 +88,6 @@ - @@ -120,6 +119,8 @@ + + @@ -243,6 +244,7 @@ + @@ -251,6 +253,7 @@ + @@ -259,7 +262,6 @@ - diff --git a/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters index d20a341f..dc96b0a7 100644 --- a/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters @@ -57,9 +57,6 @@ crypto_sign\ed25519 - - crypto_sign\ed25519\ref10 - crypto_sign\ed25519\ref10 @@ -153,6 +150,12 @@ crypto_kdf\blake2b + + crypto_kdf\hkdf + + + crypto_kdf\hkdf + crypto_shorthash @@ -518,6 +521,9 @@ include\sodium + + include\sodium + include\sodium @@ -542,6 +548,9 @@ include\sodium + + include\sodium + include\sodium @@ -566,9 +575,6 @@ include\sodium - - include\sodium - include\sodium\private @@ -862,6 +868,9 @@ {3d42d2a2-b192-33dd-9162-508916414707} + + {baf7d894-9298-391d-8dc2-e4c3010f5ddc} + {898b6bd5-1360-3a34-adcd-0fade7561685} diff --git a/builds/msvc/vs2013/libsodium/libsodium.vcxproj b/builds/msvc/vs2013/libsodium/libsodium.vcxproj index f5c6ac2e..b5c9f6e0 100644 --- a/builds/msvc/vs2013/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2013/libsodium/libsodium.vcxproj @@ -88,7 +88,6 @@ - @@ -120,6 +119,8 @@ + + @@ -243,6 +244,7 @@ + @@ -251,6 +253,7 @@ + @@ -259,7 +262,6 @@ - diff --git a/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters index d20a341f..dc96b0a7 100644 --- a/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters @@ -57,9 +57,6 @@ crypto_sign\ed25519 - - crypto_sign\ed25519\ref10 - crypto_sign\ed25519\ref10 @@ -153,6 +150,12 @@ crypto_kdf\blake2b + + crypto_kdf\hkdf + + + crypto_kdf\hkdf + crypto_shorthash @@ -518,6 +521,9 @@ include\sodium + + include\sodium + include\sodium @@ -542,6 +548,9 @@ include\sodium + + include\sodium + include\sodium @@ -566,9 +575,6 @@ include\sodium - - include\sodium - include\sodium\private @@ -862,6 +868,9 @@ {3d42d2a2-b192-33dd-9162-508916414707} + + {baf7d894-9298-391d-8dc2-e4c3010f5ddc} + {898b6bd5-1360-3a34-adcd-0fade7561685} diff --git a/builds/msvc/vs2015/libsodium/libsodium.vcxproj b/builds/msvc/vs2015/libsodium/libsodium.vcxproj index c6a2b3bc..c43fa443 100644 --- a/builds/msvc/vs2015/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2015/libsodium/libsodium.vcxproj @@ -88,7 +88,6 @@ - @@ -120,6 +119,8 @@ + + @@ -243,6 +244,7 @@ + @@ -251,6 +253,7 @@ + @@ -259,7 +262,6 @@ - diff --git a/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters index d20a341f..dc96b0a7 100644 --- a/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters @@ -57,9 +57,6 @@ crypto_sign\ed25519 - - crypto_sign\ed25519\ref10 - crypto_sign\ed25519\ref10 @@ -153,6 +150,12 @@ crypto_kdf\blake2b + + crypto_kdf\hkdf + + + crypto_kdf\hkdf + crypto_shorthash @@ -518,6 +521,9 @@ include\sodium + + include\sodium + include\sodium @@ -542,6 +548,9 @@ include\sodium + + include\sodium + include\sodium @@ -566,9 +575,6 @@ include\sodium - - include\sodium - include\sodium\private @@ -862,6 +868,9 @@ {3d42d2a2-b192-33dd-9162-508916414707} + + {baf7d894-9298-391d-8dc2-e4c3010f5ddc} + {898b6bd5-1360-3a34-adcd-0fade7561685} diff --git a/builds/msvc/vs2017/libsodium/libsodium.vcxproj b/builds/msvc/vs2017/libsodium/libsodium.vcxproj index 3470fae9..b1887a3c 100644 --- a/builds/msvc/vs2017/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2017/libsodium/libsodium.vcxproj @@ -88,7 +88,6 @@ - @@ -120,6 +119,8 @@ + + @@ -243,6 +244,7 @@ + @@ -251,6 +253,7 @@ + @@ -259,7 +262,6 @@ - diff --git a/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters index d20a341f..dc96b0a7 100644 --- a/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters @@ -57,9 +57,6 @@ crypto_sign\ed25519 - - crypto_sign\ed25519\ref10 - crypto_sign\ed25519\ref10 @@ -153,6 +150,12 @@ crypto_kdf\blake2b + + crypto_kdf\hkdf + + + crypto_kdf\hkdf + crypto_shorthash @@ -518,6 +521,9 @@ include\sodium + + include\sodium + include\sodium @@ -542,6 +548,9 @@ include\sodium + + include\sodium + include\sodium @@ -566,9 +575,6 @@ include\sodium - - include\sodium - include\sodium\private @@ -862,6 +868,9 @@ {3d42d2a2-b192-33dd-9162-508916414707} + + {baf7d894-9298-391d-8dc2-e4c3010f5ddc} + {898b6bd5-1360-3a34-adcd-0fade7561685} diff --git a/builds/msvc/vs2019/libsodium/libsodium.vcxproj b/builds/msvc/vs2019/libsodium/libsodium.vcxproj index 6254de5f..8d43cd5e 100644 --- a/builds/msvc/vs2019/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2019/libsodium/libsodium.vcxproj @@ -88,7 +88,6 @@ - @@ -120,6 +119,8 @@ + + @@ -243,6 +244,7 @@ + @@ -251,6 +253,7 @@ + @@ -259,7 +262,6 @@ - diff --git a/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters index d20a341f..dc96b0a7 100644 --- a/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters @@ -57,9 +57,6 @@ crypto_sign\ed25519 - - crypto_sign\ed25519\ref10 - crypto_sign\ed25519\ref10 @@ -153,6 +150,12 @@ crypto_kdf\blake2b + + crypto_kdf\hkdf + + + crypto_kdf\hkdf + crypto_shorthash @@ -518,6 +521,9 @@ include\sodium + + include\sodium + include\sodium @@ -542,6 +548,9 @@ include\sodium + + include\sodium + include\sodium @@ -566,9 +575,6 @@ include\sodium - - include\sodium - include\sodium\private @@ -862,6 +868,9 @@ {3d42d2a2-b192-33dd-9162-508916414707} + + {baf7d894-9298-391d-8dc2-e4c3010f5ddc} + {898b6bd5-1360-3a34-adcd-0fade7561685} diff --git a/configure.ac b/configure.ac index 199e67b7..bbfdc60e 100644 --- a/configure.ac +++ b/configure.ac @@ -14,10 +14,10 @@ AM_DEP_TRACK AC_SUBST(VERSION) -SODIUM_LIBRARY_VERSION_MAJOR=10 -SODIUM_LIBRARY_VERSION_MINOR=3 -DLL_VERSION=24 -SODIUM_LIBRARY_VERSION=26:0:3 +SODIUM_LIBRARY_VERSION_MAJOR=11 +SODIUM_LIBRARY_VERSION_MINOR=0 +DLL_VERSION=27 +SODIUM_LIBRARY_VERSION=27:0:0 # | | | # +------+ | +---+ # | | | diff --git a/dist-build/emscripten-symbols.def b/dist-build/emscripten-symbols.def index 8b5a3cbd..ec4ac66e 100644 --- a/dist-build/emscripten-symbols.def +++ b/dist-build/emscripten-symbols.def @@ -1,3 +1,14 @@ +_crypto_aead_aegis256_abytes 0 0 +_crypto_aead_aegis256_decrypt 0 0 +_crypto_aead_aegis256_decrypt_detached 0 0 +_crypto_aead_aegis256_encrypt 0 0 +_crypto_aead_aegis256_encrypt_detached 0 0 +_crypto_aead_aegis256_is_available 0 0 +_crypto_aead_aegis256_keybytes 0 0 +_crypto_aead_aegis256_keygen 0 0 +_crypto_aead_aegis256_messagebytes_max 0 0 +_crypto_aead_aegis256_npubbytes 0 0 +_crypto_aead_aegis256_nsecbytes 0 0 _crypto_aead_aes256gcm_abytes 0 0 _crypto_aead_aes256gcm_beforenm 0 0 _crypto_aead_aes256gcm_decrypt 0 0 @@ -15,17 +26,6 @@ _crypto_aead_aes256gcm_messagebytes_max 0 0 _crypto_aead_aes256gcm_npubbytes 0 0 _crypto_aead_aes256gcm_nsecbytes 0 0 _crypto_aead_aes256gcm_statebytes 0 0 -_crypto_aead_aegis256_abytes 0 0 -_crypto_aead_aegis256_decrypt 0 0 -_crypto_aead_aegis256_decrypt_detached 0 0 -_crypto_aead_aegis256_encrypt 0 0 -_crypto_aead_aegis256_encrypt_detached 0 0 -_crypto_aead_aegis256_is_available 0 0 -_crypto_aead_aegis256_keybytes 0 0 -_crypto_aead_aegis256_keygen 0 0 -_crypto_aead_aegis256_messagebytes_max 0 0 -_crypto_aead_aegis256_npubbytes 0 0 -_crypto_aead_aegis256_nsecbytes 0 0 _crypto_aead_chacha20poly1305_abytes 1 1 _crypto_aead_chacha20poly1305_decrypt 1 1 _crypto_aead_chacha20poly1305_decrypt_detached 1 1 @@ -156,7 +156,8 @@ _crypto_box_seedbytes 1 1 _crypto_box_zerobytes 0 1 _crypto_core_ed25519_add 0 1 _crypto_core_ed25519_bytes 0 1 -_crypto_core_ed25519_from_hash 0 1 +_crypto_core_ed25519_from_string 0 1 +_crypto_core_ed25519_from_string_ro 0 1 _crypto_core_ed25519_from_uniform 0 1 _crypto_core_ed25519_hashbytes 0 1 _crypto_core_ed25519_is_valid_point 0 1 @@ -269,6 +270,18 @@ _crypto_kdf_bytes_max 1 1 _crypto_kdf_bytes_min 1 1 _crypto_kdf_contextbytes 1 1 _crypto_kdf_derive_from_key 1 1 +_crypto_kdf_hkdf_sha256_bytes_max 0 1 +_crypto_kdf_hkdf_sha256_bytes_min 0 1 +_crypto_kdf_hkdf_sha256_expand 0 1 +_crypto_kdf_hkdf_sha256_extract 0 1 +_crypto_kdf_hkdf_sha256_keybytes 0 1 +_crypto_kdf_hkdf_sha256_keygen 0 1 +_crypto_kdf_hkdf_sha512_bytes_max 0 1 +_crypto_kdf_hkdf_sha512_bytes_min 0 1 +_crypto_kdf_hkdf_sha512_expand 0 1 +_crypto_kdf_hkdf_sha512_extract 0 1 +_crypto_kdf_hkdf_sha512_keybytes 0 1 +_crypto_kdf_hkdf_sha512_keygen 0 1 _crypto_kdf_keybytes 1 1 _crypto_kdf_keygen 1 1 _crypto_kdf_primitive 0 1 @@ -489,9 +502,6 @@ _crypto_sign_ed25519ph_final_verify 0 1 _crypto_sign_ed25519ph_init 0 1 _crypto_sign_ed25519ph_statebytes 0 1 _crypto_sign_ed25519ph_update 0 1 -_crypto_sign_edwards25519sha512batch 0 0 -_crypto_sign_edwards25519sha512batch_keypair 0 0 -_crypto_sign_edwards25519sha512batch_open 0 0 _crypto_sign_final_create 1 1 _crypto_sign_final_verify 1 1 _crypto_sign_init 1 1 @@ -602,11 +612,11 @@ _sodium_mprotect_readwrite 0 0 _sodium_munlock 0 0 _sodium_pad 1 1 _sodium_runtime_has_aesni 0 0 +_sodium_runtime_has_armcrypto 0 0 _sodium_runtime_has_avx 0 0 _sodium_runtime_has_avx2 0 0 _sodium_runtime_has_avx512f 0 0 _sodium_runtime_has_neon 0 0 -_sodium_runtime_has_armcrypto 0 0 _sodium_runtime_has_pclmul 0 0 _sodium_runtime_has_rdrand 0 0 _sodium_runtime_has_sse2 0 0 @@ -614,8 +624,6 @@ _sodium_runtime_has_sse3 0 0 _sodium_runtime_has_sse41 0 0 _sodium_runtime_has_ssse3 0 0 _sodium_set_misuse_handler 0 0 -_sodium_mshield 1 1 -_sodium_munshield 1 1 _sodium_stackzero 0 0 _sodium_sub 0 0 _sodium_unpad 1 1 diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index 442004a0..6f6cfbe2 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -1,8 +1,8 @@ #! /bin/sh export MAKE_FLAGS='-j4' -export EXPORTED_FUNCTIONS_STANDARD='["_malloc","_free","_crypto_aead_chacha20poly1305_abytes","_crypto_aead_chacha20poly1305_decrypt","_crypto_aead_chacha20poly1305_decrypt_detached","_crypto_aead_chacha20poly1305_encrypt","_crypto_aead_chacha20poly1305_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_abytes","_crypto_aead_chacha20poly1305_ietf_decrypt","_crypto_aead_chacha20poly1305_ietf_decrypt_detached","_crypto_aead_chacha20poly1305_ietf_encrypt","_crypto_aead_chacha20poly1305_ietf_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_keybytes","_crypto_aead_chacha20poly1305_ietf_keygen","_crypto_aead_chacha20poly1305_ietf_messagebytes_max","_crypto_aead_chacha20poly1305_ietf_npubbytes","_crypto_aead_chacha20poly1305_ietf_nsecbytes","_crypto_aead_chacha20poly1305_keybytes","_crypto_aead_chacha20poly1305_keygen","_crypto_aead_chacha20poly1305_messagebytes_max","_crypto_aead_chacha20poly1305_npubbytes","_crypto_aead_chacha20poly1305_nsecbytes","_crypto_aead_xchacha20poly1305_ietf_abytes","_crypto_aead_xchacha20poly1305_ietf_decrypt","_crypto_aead_xchacha20poly1305_ietf_decrypt_detached","_crypto_aead_xchacha20poly1305_ietf_encrypt","_crypto_aead_xchacha20poly1305_ietf_encrypt_detached","_crypto_aead_xchacha20poly1305_ietf_keybytes","_crypto_aead_xchacha20poly1305_ietf_keygen","_crypto_aead_xchacha20poly1305_ietf_messagebytes_max","_crypto_aead_xchacha20poly1305_ietf_npubbytes","_crypto_aead_xchacha20poly1305_ietf_nsecbytes","_crypto_auth","_crypto_auth_bytes","_crypto_auth_keybytes","_crypto_auth_keygen","_crypto_auth_verify","_crypto_box_beforenm","_crypto_box_beforenmbytes","_crypto_box_detached","_crypto_box_detached_afternm","_crypto_box_easy","_crypto_box_easy_afternm","_crypto_box_keypair","_crypto_box_macbytes","_crypto_box_messagebytes_max","_crypto_box_noncebytes","_crypto_box_open_detached","_crypto_box_open_detached_afternm","_crypto_box_open_easy","_crypto_box_open_easy_afternm","_crypto_box_publickeybytes","_crypto_box_seal","_crypto_box_seal_open","_crypto_box_sealbytes","_crypto_box_secretkeybytes","_crypto_box_seed_keypair","_crypto_box_seedbytes","_crypto_generichash","_crypto_generichash_bytes","_crypto_generichash_bytes_max","_crypto_generichash_bytes_min","_crypto_generichash_final","_crypto_generichash_init","_crypto_generichash_keybytes","_crypto_generichash_keybytes_max","_crypto_generichash_keybytes_min","_crypto_generichash_keygen","_crypto_generichash_statebytes","_crypto_generichash_update","_crypto_hash","_crypto_hash_bytes","_crypto_kdf_bytes_max","_crypto_kdf_bytes_min","_crypto_kdf_contextbytes","_crypto_kdf_derive_from_key","_crypto_kdf_keybytes","_crypto_kdf_keygen","_crypto_kx_client_session_keys","_crypto_kx_keypair","_crypto_kx_publickeybytes","_crypto_kx_secretkeybytes","_crypto_kx_seed_keypair","_crypto_kx_seedbytes","_crypto_kx_server_session_keys","_crypto_kx_sessionkeybytes","_crypto_pwhash","_crypto_pwhash_alg_argon2i13","_crypto_pwhash_alg_argon2id13","_crypto_pwhash_alg_default","_crypto_pwhash_bytes_max","_crypto_pwhash_bytes_min","_crypto_pwhash_memlimit_interactive","_crypto_pwhash_memlimit_max","_crypto_pwhash_memlimit_min","_crypto_pwhash_memlimit_moderate","_crypto_pwhash_memlimit_sensitive","_crypto_pwhash_opslimit_interactive","_crypto_pwhash_opslimit_max","_crypto_pwhash_opslimit_min","_crypto_pwhash_opslimit_moderate","_crypto_pwhash_opslimit_sensitive","_crypto_pwhash_passwd_max","_crypto_pwhash_passwd_min","_crypto_pwhash_saltbytes","_crypto_pwhash_str","_crypto_pwhash_str_alg","_crypto_pwhash_str_needs_rehash","_crypto_pwhash_str_verify","_crypto_pwhash_strbytes","_crypto_pwhash_strprefix","_crypto_scalarmult","_crypto_scalarmult_base","_crypto_scalarmult_bytes","_crypto_scalarmult_scalarbytes","_crypto_secretbox_detached","_crypto_secretbox_easy","_crypto_secretbox_keybytes","_crypto_secretbox_keygen","_crypto_secretbox_macbytes","_crypto_secretbox_messagebytes_max","_crypto_secretbox_noncebytes","_crypto_secretbox_open_detached","_crypto_secretbox_open_easy","_crypto_secretstream_xchacha20poly1305_abytes","_crypto_secretstream_xchacha20poly1305_headerbytes","_crypto_secretstream_xchacha20poly1305_init_pull","_crypto_secretstream_xchacha20poly1305_init_push","_crypto_secretstream_xchacha20poly1305_keybytes","_crypto_secretstream_xchacha20poly1305_keygen","_crypto_secretstream_xchacha20poly1305_messagebytes_max","_crypto_secretstream_xchacha20poly1305_pull","_crypto_secretstream_xchacha20poly1305_push","_crypto_secretstream_xchacha20poly1305_rekey","_crypto_secretstream_xchacha20poly1305_statebytes","_crypto_secretstream_xchacha20poly1305_tag_final","_crypto_secretstream_xchacha20poly1305_tag_message","_crypto_secretstream_xchacha20poly1305_tag_push","_crypto_secretstream_xchacha20poly1305_tag_rekey","_crypto_shorthash","_crypto_shorthash_bytes","_crypto_shorthash_keybytes","_crypto_shorthash_keygen","_crypto_sign","_crypto_sign_bytes","_crypto_sign_detached","_crypto_sign_ed25519_pk_to_curve25519","_crypto_sign_ed25519_sk_to_curve25519","_crypto_sign_final_create","_crypto_sign_final_verify","_crypto_sign_init","_crypto_sign_keypair","_crypto_sign_messagebytes_max","_crypto_sign_open","_crypto_sign_publickeybytes","_crypto_sign_secretkeybytes","_crypto_sign_seed_keypair","_crypto_sign_seedbytes","_crypto_sign_statebytes","_crypto_sign_update","_crypto_sign_verify_detached","_randombytes","_randombytes_buf","_randombytes_buf_deterministic","_randombytes_close","_randombytes_random","_randombytes_seedbytes","_randombytes_stir","_randombytes_uniform","_sodium_base642bin","_sodium_base64_encoded_len","_sodium_bin2base64","_sodium_bin2hex","_sodium_hex2bin","_sodium_init","_sodium_library_minimal","_sodium_library_version_major","_sodium_library_version_minor","_sodium_mshield","_sodium_munshield","_sodium_pad","_sodium_unpad","_sodium_version_string"]' -export EXPORTED_FUNCTIONS_SUMO='["_malloc","_free","_crypto_aead_chacha20poly1305_abytes","_crypto_aead_chacha20poly1305_decrypt","_crypto_aead_chacha20poly1305_decrypt_detached","_crypto_aead_chacha20poly1305_encrypt","_crypto_aead_chacha20poly1305_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_abytes","_crypto_aead_chacha20poly1305_ietf_decrypt","_crypto_aead_chacha20poly1305_ietf_decrypt_detached","_crypto_aead_chacha20poly1305_ietf_encrypt","_crypto_aead_chacha20poly1305_ietf_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_keybytes","_crypto_aead_chacha20poly1305_ietf_keygen","_crypto_aead_chacha20poly1305_ietf_messagebytes_max","_crypto_aead_chacha20poly1305_ietf_npubbytes","_crypto_aead_chacha20poly1305_ietf_nsecbytes","_crypto_aead_chacha20poly1305_keybytes","_crypto_aead_chacha20poly1305_keygen","_crypto_aead_chacha20poly1305_messagebytes_max","_crypto_aead_chacha20poly1305_npubbytes","_crypto_aead_chacha20poly1305_nsecbytes","_crypto_aead_xchacha20poly1305_ietf_abytes","_crypto_aead_xchacha20poly1305_ietf_decrypt","_crypto_aead_xchacha20poly1305_ietf_decrypt_detached","_crypto_aead_xchacha20poly1305_ietf_encrypt","_crypto_aead_xchacha20poly1305_ietf_encrypt_detached","_crypto_aead_xchacha20poly1305_ietf_keybytes","_crypto_aead_xchacha20poly1305_ietf_keygen","_crypto_aead_xchacha20poly1305_ietf_messagebytes_max","_crypto_aead_xchacha20poly1305_ietf_npubbytes","_crypto_aead_xchacha20poly1305_ietf_nsecbytes","_crypto_auth","_crypto_auth_bytes","_crypto_auth_hmacsha256","_crypto_auth_hmacsha256_bytes","_crypto_auth_hmacsha256_final","_crypto_auth_hmacsha256_init","_crypto_auth_hmacsha256_keybytes","_crypto_auth_hmacsha256_keygen","_crypto_auth_hmacsha256_statebytes","_crypto_auth_hmacsha256_update","_crypto_auth_hmacsha256_verify","_crypto_auth_hmacsha512","_crypto_auth_hmacsha512256","_crypto_auth_hmacsha512256_bytes","_crypto_auth_hmacsha512256_final","_crypto_auth_hmacsha512256_init","_crypto_auth_hmacsha512256_keybytes","_crypto_auth_hmacsha512256_keygen","_crypto_auth_hmacsha512256_statebytes","_crypto_auth_hmacsha512256_update","_crypto_auth_hmacsha512256_verify","_crypto_auth_hmacsha512_bytes","_crypto_auth_hmacsha512_final","_crypto_auth_hmacsha512_init","_crypto_auth_hmacsha512_keybytes","_crypto_auth_hmacsha512_keygen","_crypto_auth_hmacsha512_statebytes","_crypto_auth_hmacsha512_update","_crypto_auth_hmacsha512_verify","_crypto_auth_keybytes","_crypto_auth_keygen","_crypto_auth_primitive","_crypto_auth_verify","_crypto_box","_crypto_box_afternm","_crypto_box_beforenm","_crypto_box_beforenmbytes","_crypto_box_boxzerobytes","_crypto_box_curve25519xchacha20poly1305_beforenm","_crypto_box_curve25519xchacha20poly1305_beforenmbytes","_crypto_box_curve25519xchacha20poly1305_detached","_crypto_box_curve25519xchacha20poly1305_detached_afternm","_crypto_box_curve25519xchacha20poly1305_easy","_crypto_box_curve25519xchacha20poly1305_easy_afternm","_crypto_box_curve25519xchacha20poly1305_keypair","_crypto_box_curve25519xchacha20poly1305_macbytes","_crypto_box_curve25519xchacha20poly1305_messagebytes_max","_crypto_box_curve25519xchacha20poly1305_noncebytes","_crypto_box_curve25519xchacha20poly1305_open_detached","_crypto_box_curve25519xchacha20poly1305_open_detached_afternm","_crypto_box_curve25519xchacha20poly1305_open_easy","_crypto_box_curve25519xchacha20poly1305_open_easy_afternm","_crypto_box_curve25519xchacha20poly1305_publickeybytes","_crypto_box_curve25519xchacha20poly1305_seal","_crypto_box_curve25519xchacha20poly1305_seal_open","_crypto_box_curve25519xchacha20poly1305_sealbytes","_crypto_box_curve25519xchacha20poly1305_secretkeybytes","_crypto_box_curve25519xchacha20poly1305_seed_keypair","_crypto_box_curve25519xchacha20poly1305_seedbytes","_crypto_box_curve25519xsalsa20poly1305","_crypto_box_curve25519xsalsa20poly1305_afternm","_crypto_box_curve25519xsalsa20poly1305_beforenm","_crypto_box_curve25519xsalsa20poly1305_beforenmbytes","_crypto_box_curve25519xsalsa20poly1305_boxzerobytes","_crypto_box_curve25519xsalsa20poly1305_keypair","_crypto_box_curve25519xsalsa20poly1305_macbytes","_crypto_box_curve25519xsalsa20poly1305_messagebytes_max","_crypto_box_curve25519xsalsa20poly1305_noncebytes","_crypto_box_curve25519xsalsa20poly1305_open","_crypto_box_curve25519xsalsa20poly1305_open_afternm","_crypto_box_curve25519xsalsa20poly1305_publickeybytes","_crypto_box_curve25519xsalsa20poly1305_secretkeybytes","_crypto_box_curve25519xsalsa20poly1305_seed_keypair","_crypto_box_curve25519xsalsa20poly1305_seedbytes","_crypto_box_curve25519xsalsa20poly1305_zerobytes","_crypto_box_detached","_crypto_box_detached_afternm","_crypto_box_easy","_crypto_box_easy_afternm","_crypto_box_keypair","_crypto_box_macbytes","_crypto_box_messagebytes_max","_crypto_box_noncebytes","_crypto_box_open","_crypto_box_open_afternm","_crypto_box_open_detached","_crypto_box_open_detached_afternm","_crypto_box_open_easy","_crypto_box_open_easy_afternm","_crypto_box_primitive","_crypto_box_publickeybytes","_crypto_box_seal","_crypto_box_seal_open","_crypto_box_sealbytes","_crypto_box_secretkeybytes","_crypto_box_seed_keypair","_crypto_box_seedbytes","_crypto_box_zerobytes","_crypto_core_ed25519_add","_crypto_core_ed25519_bytes","_crypto_core_ed25519_from_hash","_crypto_core_ed25519_from_uniform","_crypto_core_ed25519_hashbytes","_crypto_core_ed25519_is_valid_point","_crypto_core_ed25519_nonreducedscalarbytes","_crypto_core_ed25519_random","_crypto_core_ed25519_scalar_add","_crypto_core_ed25519_scalar_complement","_crypto_core_ed25519_scalar_invert","_crypto_core_ed25519_scalar_mul","_crypto_core_ed25519_scalar_negate","_crypto_core_ed25519_scalar_random","_crypto_core_ed25519_scalar_reduce","_crypto_core_ed25519_scalar_sub","_crypto_core_ed25519_scalarbytes","_crypto_core_ed25519_sub","_crypto_core_ed25519_uniformbytes","_crypto_core_hchacha20","_crypto_core_hchacha20_constbytes","_crypto_core_hchacha20_inputbytes","_crypto_core_hchacha20_keybytes","_crypto_core_hchacha20_outputbytes","_crypto_core_hsalsa20","_crypto_core_hsalsa20_constbytes","_crypto_core_hsalsa20_inputbytes","_crypto_core_hsalsa20_keybytes","_crypto_core_hsalsa20_outputbytes","_crypto_core_ristretto255_add","_crypto_core_ristretto255_bytes","_crypto_core_ristretto255_from_hash","_crypto_core_ristretto255_hashbytes","_crypto_core_ristretto255_is_valid_point","_crypto_core_ristretto255_nonreducedscalarbytes","_crypto_core_ristretto255_random","_crypto_core_ristretto255_scalar_add","_crypto_core_ristretto255_scalar_complement","_crypto_core_ristretto255_scalar_invert","_crypto_core_ristretto255_scalar_mul","_crypto_core_ristretto255_scalar_negate","_crypto_core_ristretto255_scalar_random","_crypto_core_ristretto255_scalar_reduce","_crypto_core_ristretto255_scalar_sub","_crypto_core_ristretto255_scalarbytes","_crypto_core_ristretto255_sub","_crypto_core_salsa20","_crypto_core_salsa2012","_crypto_core_salsa2012_constbytes","_crypto_core_salsa2012_inputbytes","_crypto_core_salsa2012_keybytes","_crypto_core_salsa2012_outputbytes","_crypto_core_salsa208","_crypto_core_salsa208_constbytes","_crypto_core_salsa208_inputbytes","_crypto_core_salsa208_keybytes","_crypto_core_salsa208_outputbytes","_crypto_core_salsa20_constbytes","_crypto_core_salsa20_inputbytes","_crypto_core_salsa20_keybytes","_crypto_core_salsa20_outputbytes","_crypto_generichash","_crypto_generichash_blake2b","_crypto_generichash_blake2b_bytes","_crypto_generichash_blake2b_bytes_max","_crypto_generichash_blake2b_bytes_min","_crypto_generichash_blake2b_final","_crypto_generichash_blake2b_init","_crypto_generichash_blake2b_init_salt_personal","_crypto_generichash_blake2b_keybytes","_crypto_generichash_blake2b_keybytes_max","_crypto_generichash_blake2b_keybytes_min","_crypto_generichash_blake2b_keygen","_crypto_generichash_blake2b_personalbytes","_crypto_generichash_blake2b_salt_personal","_crypto_generichash_blake2b_saltbytes","_crypto_generichash_blake2b_statebytes","_crypto_generichash_blake2b_update","_crypto_generichash_bytes","_crypto_generichash_bytes_max","_crypto_generichash_bytes_min","_crypto_generichash_final","_crypto_generichash_init","_crypto_generichash_keybytes","_crypto_generichash_keybytes_max","_crypto_generichash_keybytes_min","_crypto_generichash_keygen","_crypto_generichash_primitive","_crypto_generichash_statebytes","_crypto_generichash_update","_crypto_hash","_crypto_hash_bytes","_crypto_hash_primitive","_crypto_hash_sha256","_crypto_hash_sha256_bytes","_crypto_hash_sha256_final","_crypto_hash_sha256_init","_crypto_hash_sha256_statebytes","_crypto_hash_sha256_update","_crypto_hash_sha512","_crypto_hash_sha512_bytes","_crypto_hash_sha512_final","_crypto_hash_sha512_init","_crypto_hash_sha512_statebytes","_crypto_hash_sha512_update","_crypto_kdf_blake2b_bytes_max","_crypto_kdf_blake2b_bytes_min","_crypto_kdf_blake2b_contextbytes","_crypto_kdf_blake2b_derive_from_key","_crypto_kdf_blake2b_keybytes","_crypto_kdf_bytes_max","_crypto_kdf_bytes_min","_crypto_kdf_contextbytes","_crypto_kdf_derive_from_key","_crypto_kdf_keybytes","_crypto_kdf_keygen","_crypto_kdf_primitive","_crypto_kx_client_session_keys","_crypto_kx_keypair","_crypto_kx_primitive","_crypto_kx_publickeybytes","_crypto_kx_secretkeybytes","_crypto_kx_seed_keypair","_crypto_kx_seedbytes","_crypto_kx_server_session_keys","_crypto_kx_sessionkeybytes","_crypto_onetimeauth","_crypto_onetimeauth_bytes","_crypto_onetimeauth_final","_crypto_onetimeauth_init","_crypto_onetimeauth_keybytes","_crypto_onetimeauth_keygen","_crypto_onetimeauth_poly1305","_crypto_onetimeauth_poly1305_bytes","_crypto_onetimeauth_poly1305_final","_crypto_onetimeauth_poly1305_init","_crypto_onetimeauth_poly1305_keybytes","_crypto_onetimeauth_poly1305_keygen","_crypto_onetimeauth_poly1305_statebytes","_crypto_onetimeauth_poly1305_update","_crypto_onetimeauth_poly1305_verify","_crypto_onetimeauth_primitive","_crypto_onetimeauth_statebytes","_crypto_onetimeauth_update","_crypto_onetimeauth_verify","_crypto_pwhash","_crypto_pwhash_alg_argon2i13","_crypto_pwhash_alg_argon2id13","_crypto_pwhash_alg_default","_crypto_pwhash_argon2i","_crypto_pwhash_argon2i_alg_argon2i13","_crypto_pwhash_argon2i_bytes_max","_crypto_pwhash_argon2i_bytes_min","_crypto_pwhash_argon2i_memlimit_interactive","_crypto_pwhash_argon2i_memlimit_max","_crypto_pwhash_argon2i_memlimit_min","_crypto_pwhash_argon2i_memlimit_moderate","_crypto_pwhash_argon2i_memlimit_sensitive","_crypto_pwhash_argon2i_opslimit_interactive","_crypto_pwhash_argon2i_opslimit_max","_crypto_pwhash_argon2i_opslimit_min","_crypto_pwhash_argon2i_opslimit_moderate","_crypto_pwhash_argon2i_opslimit_sensitive","_crypto_pwhash_argon2i_passwd_max","_crypto_pwhash_argon2i_passwd_min","_crypto_pwhash_argon2i_saltbytes","_crypto_pwhash_argon2i_str","_crypto_pwhash_argon2i_str_needs_rehash","_crypto_pwhash_argon2i_str_verify","_crypto_pwhash_argon2i_strbytes","_crypto_pwhash_argon2i_strprefix","_crypto_pwhash_argon2id","_crypto_pwhash_argon2id_alg_argon2id13","_crypto_pwhash_argon2id_bytes_max","_crypto_pwhash_argon2id_bytes_min","_crypto_pwhash_argon2id_memlimit_interactive","_crypto_pwhash_argon2id_memlimit_max","_crypto_pwhash_argon2id_memlimit_min","_crypto_pwhash_argon2id_memlimit_moderate","_crypto_pwhash_argon2id_memlimit_sensitive","_crypto_pwhash_argon2id_opslimit_interactive","_crypto_pwhash_argon2id_opslimit_max","_crypto_pwhash_argon2id_opslimit_min","_crypto_pwhash_argon2id_opslimit_moderate","_crypto_pwhash_argon2id_opslimit_sensitive","_crypto_pwhash_argon2id_passwd_max","_crypto_pwhash_argon2id_passwd_min","_crypto_pwhash_argon2id_saltbytes","_crypto_pwhash_argon2id_str","_crypto_pwhash_argon2id_str_needs_rehash","_crypto_pwhash_argon2id_str_verify","_crypto_pwhash_argon2id_strbytes","_crypto_pwhash_argon2id_strprefix","_crypto_pwhash_bytes_max","_crypto_pwhash_bytes_min","_crypto_pwhash_memlimit_interactive","_crypto_pwhash_memlimit_max","_crypto_pwhash_memlimit_min","_crypto_pwhash_memlimit_moderate","_crypto_pwhash_memlimit_sensitive","_crypto_pwhash_opslimit_interactive","_crypto_pwhash_opslimit_max","_crypto_pwhash_opslimit_min","_crypto_pwhash_opslimit_moderate","_crypto_pwhash_opslimit_sensitive","_crypto_pwhash_passwd_max","_crypto_pwhash_passwd_min","_crypto_pwhash_primitive","_crypto_pwhash_saltbytes","_crypto_pwhash_scryptsalsa208sha256","_crypto_pwhash_scryptsalsa208sha256_bytes_max","_crypto_pwhash_scryptsalsa208sha256_bytes_min","_crypto_pwhash_scryptsalsa208sha256_ll","_crypto_pwhash_scryptsalsa208sha256_memlimit_interactive","_crypto_pwhash_scryptsalsa208sha256_memlimit_max","_crypto_pwhash_scryptsalsa208sha256_memlimit_min","_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive","_crypto_pwhash_scryptsalsa208sha256_opslimit_interactive","_crypto_pwhash_scryptsalsa208sha256_opslimit_max","_crypto_pwhash_scryptsalsa208sha256_opslimit_min","_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive","_crypto_pwhash_scryptsalsa208sha256_passwd_max","_crypto_pwhash_scryptsalsa208sha256_passwd_min","_crypto_pwhash_scryptsalsa208sha256_saltbytes","_crypto_pwhash_scryptsalsa208sha256_str","_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash","_crypto_pwhash_scryptsalsa208sha256_str_verify","_crypto_pwhash_scryptsalsa208sha256_strbytes","_crypto_pwhash_scryptsalsa208sha256_strprefix","_crypto_pwhash_str","_crypto_pwhash_str_alg","_crypto_pwhash_str_needs_rehash","_crypto_pwhash_str_verify","_crypto_pwhash_strbytes","_crypto_pwhash_strprefix","_crypto_scalarmult","_crypto_scalarmult_base","_crypto_scalarmult_bytes","_crypto_scalarmult_curve25519","_crypto_scalarmult_curve25519_base","_crypto_scalarmult_curve25519_bytes","_crypto_scalarmult_curve25519_scalarbytes","_crypto_scalarmult_ed25519","_crypto_scalarmult_ed25519_base","_crypto_scalarmult_ed25519_base_noclamp","_crypto_scalarmult_ed25519_bytes","_crypto_scalarmult_ed25519_noclamp","_crypto_scalarmult_ed25519_scalarbytes","_crypto_scalarmult_primitive","_crypto_scalarmult_ristretto255","_crypto_scalarmult_ristretto255_base","_crypto_scalarmult_ristretto255_bytes","_crypto_scalarmult_ristretto255_scalarbytes","_crypto_scalarmult_scalarbytes","_crypto_secretbox","_crypto_secretbox_boxzerobytes","_crypto_secretbox_detached","_crypto_secretbox_easy","_crypto_secretbox_keybytes","_crypto_secretbox_keygen","_crypto_secretbox_macbytes","_crypto_secretbox_messagebytes_max","_crypto_secretbox_noncebytes","_crypto_secretbox_open","_crypto_secretbox_open_detached","_crypto_secretbox_open_easy","_crypto_secretbox_primitive","_crypto_secretbox_xchacha20poly1305_detached","_crypto_secretbox_xchacha20poly1305_easy","_crypto_secretbox_xchacha20poly1305_keybytes","_crypto_secretbox_xchacha20poly1305_macbytes","_crypto_secretbox_xchacha20poly1305_messagebytes_max","_crypto_secretbox_xchacha20poly1305_noncebytes","_crypto_secretbox_xchacha20poly1305_open_detached","_crypto_secretbox_xchacha20poly1305_open_easy","_crypto_secretbox_xsalsa20poly1305","_crypto_secretbox_xsalsa20poly1305_boxzerobytes","_crypto_secretbox_xsalsa20poly1305_keybytes","_crypto_secretbox_xsalsa20poly1305_keygen","_crypto_secretbox_xsalsa20poly1305_macbytes","_crypto_secretbox_xsalsa20poly1305_messagebytes_max","_crypto_secretbox_xsalsa20poly1305_noncebytes","_crypto_secretbox_xsalsa20poly1305_open","_crypto_secretbox_xsalsa20poly1305_zerobytes","_crypto_secretbox_zerobytes","_crypto_secretstream_xchacha20poly1305_abytes","_crypto_secretstream_xchacha20poly1305_headerbytes","_crypto_secretstream_xchacha20poly1305_init_pull","_crypto_secretstream_xchacha20poly1305_init_push","_crypto_secretstream_xchacha20poly1305_keybytes","_crypto_secretstream_xchacha20poly1305_keygen","_crypto_secretstream_xchacha20poly1305_messagebytes_max","_crypto_secretstream_xchacha20poly1305_pull","_crypto_secretstream_xchacha20poly1305_push","_crypto_secretstream_xchacha20poly1305_rekey","_crypto_secretstream_xchacha20poly1305_statebytes","_crypto_secretstream_xchacha20poly1305_tag_final","_crypto_secretstream_xchacha20poly1305_tag_message","_crypto_secretstream_xchacha20poly1305_tag_push","_crypto_secretstream_xchacha20poly1305_tag_rekey","_crypto_shorthash","_crypto_shorthash_bytes","_crypto_shorthash_keybytes","_crypto_shorthash_keygen","_crypto_shorthash_primitive","_crypto_shorthash_siphash24","_crypto_shorthash_siphash24_bytes","_crypto_shorthash_siphash24_keybytes","_crypto_shorthash_siphashx24","_crypto_shorthash_siphashx24_bytes","_crypto_shorthash_siphashx24_keybytes","_crypto_sign","_crypto_sign_bytes","_crypto_sign_detached","_crypto_sign_ed25519","_crypto_sign_ed25519_bytes","_crypto_sign_ed25519_detached","_crypto_sign_ed25519_keypair","_crypto_sign_ed25519_messagebytes_max","_crypto_sign_ed25519_open","_crypto_sign_ed25519_pk_to_curve25519","_crypto_sign_ed25519_publickeybytes","_crypto_sign_ed25519_secretkeybytes","_crypto_sign_ed25519_seed_keypair","_crypto_sign_ed25519_seedbytes","_crypto_sign_ed25519_sk_to_curve25519","_crypto_sign_ed25519_sk_to_pk","_crypto_sign_ed25519_sk_to_seed","_crypto_sign_ed25519_verify_detached","_crypto_sign_ed25519ph_final_create","_crypto_sign_ed25519ph_final_verify","_crypto_sign_ed25519ph_init","_crypto_sign_ed25519ph_statebytes","_crypto_sign_ed25519ph_update","_crypto_sign_final_create","_crypto_sign_final_verify","_crypto_sign_init","_crypto_sign_keypair","_crypto_sign_messagebytes_max","_crypto_sign_open","_crypto_sign_primitive","_crypto_sign_publickeybytes","_crypto_sign_secretkeybytes","_crypto_sign_seed_keypair","_crypto_sign_seedbytes","_crypto_sign_statebytes","_crypto_sign_update","_crypto_sign_verify_detached","_crypto_stream","_crypto_stream_chacha20","_crypto_stream_chacha20_ietf","_crypto_stream_chacha20_ietf_keybytes","_crypto_stream_chacha20_ietf_keygen","_crypto_stream_chacha20_ietf_messagebytes_max","_crypto_stream_chacha20_ietf_noncebytes","_crypto_stream_chacha20_ietf_xor","_crypto_stream_chacha20_ietf_xor_ic","_crypto_stream_chacha20_keybytes","_crypto_stream_chacha20_keygen","_crypto_stream_chacha20_messagebytes_max","_crypto_stream_chacha20_noncebytes","_crypto_stream_chacha20_xor","_crypto_stream_chacha20_xor_ic","_crypto_stream_keybytes","_crypto_stream_keygen","_crypto_stream_messagebytes_max","_crypto_stream_noncebytes","_crypto_stream_primitive","_crypto_stream_salsa20","_crypto_stream_salsa2012","_crypto_stream_salsa2012_keybytes","_crypto_stream_salsa2012_keygen","_crypto_stream_salsa2012_messagebytes_max","_crypto_stream_salsa2012_noncebytes","_crypto_stream_salsa2012_xor","_crypto_stream_salsa208","_crypto_stream_salsa208_keybytes","_crypto_stream_salsa208_keygen","_crypto_stream_salsa208_messagebytes_max","_crypto_stream_salsa208_noncebytes","_crypto_stream_salsa208_xor","_crypto_stream_salsa20_keybytes","_crypto_stream_salsa20_keygen","_crypto_stream_salsa20_messagebytes_max","_crypto_stream_salsa20_noncebytes","_crypto_stream_salsa20_xor","_crypto_stream_salsa20_xor_ic","_crypto_stream_xchacha20","_crypto_stream_xchacha20_keybytes","_crypto_stream_xchacha20_keygen","_crypto_stream_xchacha20_messagebytes_max","_crypto_stream_xchacha20_noncebytes","_crypto_stream_xchacha20_xor","_crypto_stream_xchacha20_xor_ic","_crypto_stream_xor","_crypto_stream_xsalsa20","_crypto_stream_xsalsa20_keybytes","_crypto_stream_xsalsa20_keygen","_crypto_stream_xsalsa20_messagebytes_max","_crypto_stream_xsalsa20_noncebytes","_crypto_stream_xsalsa20_xor","_crypto_stream_xsalsa20_xor_ic","_crypto_verify_16","_crypto_verify_16_bytes","_crypto_verify_32","_crypto_verify_32_bytes","_crypto_verify_64","_crypto_verify_64_bytes","_randombytes","_randombytes_buf","_randombytes_buf_deterministic","_randombytes_close","_randombytes_implementation_name","_randombytes_random","_randombytes_seedbytes","_randombytes_stir","_randombytes_uniform","_sodium_base642bin","_sodium_base64_encoded_len","_sodium_bin2base64","_sodium_bin2hex","_sodium_hex2bin","_sodium_init","_sodium_library_minimal","_sodium_library_version_major","_sodium_library_version_minor","_sodium_mshield","_sodium_munshield","_sodium_pad","_sodium_unpad","_sodium_version_string"]' +export EXPORTED_FUNCTIONS_STANDARD='["_malloc","_free","_crypto_aead_chacha20poly1305_abytes","_crypto_aead_chacha20poly1305_decrypt","_crypto_aead_chacha20poly1305_decrypt_detached","_crypto_aead_chacha20poly1305_encrypt","_crypto_aead_chacha20poly1305_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_abytes","_crypto_aead_chacha20poly1305_ietf_decrypt","_crypto_aead_chacha20poly1305_ietf_decrypt_detached","_crypto_aead_chacha20poly1305_ietf_encrypt","_crypto_aead_chacha20poly1305_ietf_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_keybytes","_crypto_aead_chacha20poly1305_ietf_keygen","_crypto_aead_chacha20poly1305_ietf_messagebytes_max","_crypto_aead_chacha20poly1305_ietf_npubbytes","_crypto_aead_chacha20poly1305_ietf_nsecbytes","_crypto_aead_chacha20poly1305_keybytes","_crypto_aead_chacha20poly1305_keygen","_crypto_aead_chacha20poly1305_messagebytes_max","_crypto_aead_chacha20poly1305_npubbytes","_crypto_aead_chacha20poly1305_nsecbytes","_crypto_aead_xchacha20poly1305_ietf_abytes","_crypto_aead_xchacha20poly1305_ietf_decrypt","_crypto_aead_xchacha20poly1305_ietf_decrypt_detached","_crypto_aead_xchacha20poly1305_ietf_encrypt","_crypto_aead_xchacha20poly1305_ietf_encrypt_detached","_crypto_aead_xchacha20poly1305_ietf_keybytes","_crypto_aead_xchacha20poly1305_ietf_keygen","_crypto_aead_xchacha20poly1305_ietf_messagebytes_max","_crypto_aead_xchacha20poly1305_ietf_npubbytes","_crypto_aead_xchacha20poly1305_ietf_nsecbytes","_crypto_auth","_crypto_auth_bytes","_crypto_auth_keybytes","_crypto_auth_keygen","_crypto_auth_verify","_crypto_box_beforenm","_crypto_box_beforenmbytes","_crypto_box_detached","_crypto_box_detached_afternm","_crypto_box_easy","_crypto_box_easy_afternm","_crypto_box_keypair","_crypto_box_macbytes","_crypto_box_messagebytes_max","_crypto_box_noncebytes","_crypto_box_open_detached","_crypto_box_open_detached_afternm","_crypto_box_open_easy","_crypto_box_open_easy_afternm","_crypto_box_publickeybytes","_crypto_box_seal","_crypto_box_seal_open","_crypto_box_sealbytes","_crypto_box_secretkeybytes","_crypto_box_seed_keypair","_crypto_box_seedbytes","_crypto_generichash","_crypto_generichash_bytes","_crypto_generichash_bytes_max","_crypto_generichash_bytes_min","_crypto_generichash_final","_crypto_generichash_init","_crypto_generichash_keybytes","_crypto_generichash_keybytes_max","_crypto_generichash_keybytes_min","_crypto_generichash_keygen","_crypto_generichash_statebytes","_crypto_generichash_update","_crypto_hash","_crypto_hash_bytes","_crypto_kdf_bytes_max","_crypto_kdf_bytes_min","_crypto_kdf_contextbytes","_crypto_kdf_derive_from_key","_crypto_kdf_keybytes","_crypto_kdf_keygen","_crypto_kx_client_session_keys","_crypto_kx_keypair","_crypto_kx_publickeybytes","_crypto_kx_secretkeybytes","_crypto_kx_seed_keypair","_crypto_kx_seedbytes","_crypto_kx_server_session_keys","_crypto_kx_sessionkeybytes","_crypto_pwhash","_crypto_pwhash_alg_argon2i13","_crypto_pwhash_alg_argon2id13","_crypto_pwhash_alg_default","_crypto_pwhash_bytes_max","_crypto_pwhash_bytes_min","_crypto_pwhash_memlimit_interactive","_crypto_pwhash_memlimit_max","_crypto_pwhash_memlimit_min","_crypto_pwhash_memlimit_moderate","_crypto_pwhash_memlimit_sensitive","_crypto_pwhash_opslimit_interactive","_crypto_pwhash_opslimit_max","_crypto_pwhash_opslimit_min","_crypto_pwhash_opslimit_moderate","_crypto_pwhash_opslimit_sensitive","_crypto_pwhash_passwd_max","_crypto_pwhash_passwd_min","_crypto_pwhash_saltbytes","_crypto_pwhash_str","_crypto_pwhash_str_alg","_crypto_pwhash_str_needs_rehash","_crypto_pwhash_str_verify","_crypto_pwhash_strbytes","_crypto_pwhash_strprefix","_crypto_scalarmult","_crypto_scalarmult_base","_crypto_scalarmult_bytes","_crypto_scalarmult_scalarbytes","_crypto_secretbox_detached","_crypto_secretbox_easy","_crypto_secretbox_keybytes","_crypto_secretbox_keygen","_crypto_secretbox_macbytes","_crypto_secretbox_messagebytes_max","_crypto_secretbox_noncebytes","_crypto_secretbox_open_detached","_crypto_secretbox_open_easy","_crypto_secretstream_xchacha20poly1305_abytes","_crypto_secretstream_xchacha20poly1305_headerbytes","_crypto_secretstream_xchacha20poly1305_init_pull","_crypto_secretstream_xchacha20poly1305_init_push","_crypto_secretstream_xchacha20poly1305_keybytes","_crypto_secretstream_xchacha20poly1305_keygen","_crypto_secretstream_xchacha20poly1305_messagebytes_max","_crypto_secretstream_xchacha20poly1305_pull","_crypto_secretstream_xchacha20poly1305_push","_crypto_secretstream_xchacha20poly1305_rekey","_crypto_secretstream_xchacha20poly1305_statebytes","_crypto_secretstream_xchacha20poly1305_tag_final","_crypto_secretstream_xchacha20poly1305_tag_message","_crypto_secretstream_xchacha20poly1305_tag_push","_crypto_secretstream_xchacha20poly1305_tag_rekey","_crypto_shorthash","_crypto_shorthash_bytes","_crypto_shorthash_keybytes","_crypto_shorthash_keygen","_crypto_sign","_crypto_sign_bytes","_crypto_sign_detached","_crypto_sign_ed25519_pk_to_curve25519","_crypto_sign_ed25519_sk_to_curve25519","_crypto_sign_final_create","_crypto_sign_final_verify","_crypto_sign_init","_crypto_sign_keypair","_crypto_sign_messagebytes_max","_crypto_sign_open","_crypto_sign_publickeybytes","_crypto_sign_secretkeybytes","_crypto_sign_seed_keypair","_crypto_sign_seedbytes","_crypto_sign_statebytes","_crypto_sign_update","_crypto_sign_verify_detached","_randombytes","_randombytes_buf","_randombytes_buf_deterministic","_randombytes_close","_randombytes_random","_randombytes_seedbytes","_randombytes_stir","_randombytes_uniform","_sodium_base642bin","_sodium_base64_encoded_len","_sodium_bin2base64","_sodium_bin2hex","_sodium_hex2bin","_sodium_init","_sodium_library_minimal","_sodium_library_version_major","_sodium_library_version_minor","_sodium_pad","_sodium_unpad","_sodium_version_string"]' +export EXPORTED_FUNCTIONS_SUMO='["_malloc","_free","_crypto_aead_chacha20poly1305_abytes","_crypto_aead_chacha20poly1305_decrypt","_crypto_aead_chacha20poly1305_decrypt_detached","_crypto_aead_chacha20poly1305_encrypt","_crypto_aead_chacha20poly1305_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_abytes","_crypto_aead_chacha20poly1305_ietf_decrypt","_crypto_aead_chacha20poly1305_ietf_decrypt_detached","_crypto_aead_chacha20poly1305_ietf_encrypt","_crypto_aead_chacha20poly1305_ietf_encrypt_detached","_crypto_aead_chacha20poly1305_ietf_keybytes","_crypto_aead_chacha20poly1305_ietf_keygen","_crypto_aead_chacha20poly1305_ietf_messagebytes_max","_crypto_aead_chacha20poly1305_ietf_npubbytes","_crypto_aead_chacha20poly1305_ietf_nsecbytes","_crypto_aead_chacha20poly1305_keybytes","_crypto_aead_chacha20poly1305_keygen","_crypto_aead_chacha20poly1305_messagebytes_max","_crypto_aead_chacha20poly1305_npubbytes","_crypto_aead_chacha20poly1305_nsecbytes","_crypto_aead_xchacha20poly1305_ietf_abytes","_crypto_aead_xchacha20poly1305_ietf_decrypt","_crypto_aead_xchacha20poly1305_ietf_decrypt_detached","_crypto_aead_xchacha20poly1305_ietf_encrypt","_crypto_aead_xchacha20poly1305_ietf_encrypt_detached","_crypto_aead_xchacha20poly1305_ietf_keybytes","_crypto_aead_xchacha20poly1305_ietf_keygen","_crypto_aead_xchacha20poly1305_ietf_messagebytes_max","_crypto_aead_xchacha20poly1305_ietf_npubbytes","_crypto_aead_xchacha20poly1305_ietf_nsecbytes","_crypto_auth","_crypto_auth_bytes","_crypto_auth_hmacsha256","_crypto_auth_hmacsha256_bytes","_crypto_auth_hmacsha256_final","_crypto_auth_hmacsha256_init","_crypto_auth_hmacsha256_keybytes","_crypto_auth_hmacsha256_keygen","_crypto_auth_hmacsha256_statebytes","_crypto_auth_hmacsha256_update","_crypto_auth_hmacsha256_verify","_crypto_auth_hmacsha512","_crypto_auth_hmacsha512256","_crypto_auth_hmacsha512256_bytes","_crypto_auth_hmacsha512256_final","_crypto_auth_hmacsha512256_init","_crypto_auth_hmacsha512256_keybytes","_crypto_auth_hmacsha512256_keygen","_crypto_auth_hmacsha512256_statebytes","_crypto_auth_hmacsha512256_update","_crypto_auth_hmacsha512256_verify","_crypto_auth_hmacsha512_bytes","_crypto_auth_hmacsha512_final","_crypto_auth_hmacsha512_init","_crypto_auth_hmacsha512_keybytes","_crypto_auth_hmacsha512_keygen","_crypto_auth_hmacsha512_statebytes","_crypto_auth_hmacsha512_update","_crypto_auth_hmacsha512_verify","_crypto_auth_keybytes","_crypto_auth_keygen","_crypto_auth_primitive","_crypto_auth_verify","_crypto_box","_crypto_box_afternm","_crypto_box_beforenm","_crypto_box_beforenmbytes","_crypto_box_boxzerobytes","_crypto_box_curve25519xchacha20poly1305_beforenm","_crypto_box_curve25519xchacha20poly1305_beforenmbytes","_crypto_box_curve25519xchacha20poly1305_detached","_crypto_box_curve25519xchacha20poly1305_detached_afternm","_crypto_box_curve25519xchacha20poly1305_easy","_crypto_box_curve25519xchacha20poly1305_easy_afternm","_crypto_box_curve25519xchacha20poly1305_keypair","_crypto_box_curve25519xchacha20poly1305_macbytes","_crypto_box_curve25519xchacha20poly1305_messagebytes_max","_crypto_box_curve25519xchacha20poly1305_noncebytes","_crypto_box_curve25519xchacha20poly1305_open_detached","_crypto_box_curve25519xchacha20poly1305_open_detached_afternm","_crypto_box_curve25519xchacha20poly1305_open_easy","_crypto_box_curve25519xchacha20poly1305_open_easy_afternm","_crypto_box_curve25519xchacha20poly1305_publickeybytes","_crypto_box_curve25519xchacha20poly1305_seal","_crypto_box_curve25519xchacha20poly1305_seal_open","_crypto_box_curve25519xchacha20poly1305_sealbytes","_crypto_box_curve25519xchacha20poly1305_secretkeybytes","_crypto_box_curve25519xchacha20poly1305_seed_keypair","_crypto_box_curve25519xchacha20poly1305_seedbytes","_crypto_box_curve25519xsalsa20poly1305","_crypto_box_curve25519xsalsa20poly1305_afternm","_crypto_box_curve25519xsalsa20poly1305_beforenm","_crypto_box_curve25519xsalsa20poly1305_beforenmbytes","_crypto_box_curve25519xsalsa20poly1305_boxzerobytes","_crypto_box_curve25519xsalsa20poly1305_keypair","_crypto_box_curve25519xsalsa20poly1305_macbytes","_crypto_box_curve25519xsalsa20poly1305_messagebytes_max","_crypto_box_curve25519xsalsa20poly1305_noncebytes","_crypto_box_curve25519xsalsa20poly1305_open","_crypto_box_curve25519xsalsa20poly1305_open_afternm","_crypto_box_curve25519xsalsa20poly1305_publickeybytes","_crypto_box_curve25519xsalsa20poly1305_secretkeybytes","_crypto_box_curve25519xsalsa20poly1305_seed_keypair","_crypto_box_curve25519xsalsa20poly1305_seedbytes","_crypto_box_curve25519xsalsa20poly1305_zerobytes","_crypto_box_detached","_crypto_box_detached_afternm","_crypto_box_easy","_crypto_box_easy_afternm","_crypto_box_keypair","_crypto_box_macbytes","_crypto_box_messagebytes_max","_crypto_box_noncebytes","_crypto_box_open","_crypto_box_open_afternm","_crypto_box_open_detached","_crypto_box_open_detached_afternm","_crypto_box_open_easy","_crypto_box_open_easy_afternm","_crypto_box_primitive","_crypto_box_publickeybytes","_crypto_box_seal","_crypto_box_seal_open","_crypto_box_sealbytes","_crypto_box_secretkeybytes","_crypto_box_seed_keypair","_crypto_box_seedbytes","_crypto_box_zerobytes","_crypto_core_ed25519_add","_crypto_core_ed25519_bytes","_crypto_core_ed25519_from_string","_crypto_core_ed25519_from_string_ro","_crypto_core_ed25519_from_uniform","_crypto_core_ed25519_hashbytes","_crypto_core_ed25519_is_valid_point","_crypto_core_ed25519_nonreducedscalarbytes","_crypto_core_ed25519_random","_crypto_core_ed25519_scalar_add","_crypto_core_ed25519_scalar_complement","_crypto_core_ed25519_scalar_invert","_crypto_core_ed25519_scalar_mul","_crypto_core_ed25519_scalar_negate","_crypto_core_ed25519_scalar_random","_crypto_core_ed25519_scalar_reduce","_crypto_core_ed25519_scalar_sub","_crypto_core_ed25519_scalarbytes","_crypto_core_ed25519_sub","_crypto_core_ed25519_uniformbytes","_crypto_core_hchacha20","_crypto_core_hchacha20_constbytes","_crypto_core_hchacha20_inputbytes","_crypto_core_hchacha20_keybytes","_crypto_core_hchacha20_outputbytes","_crypto_core_hsalsa20","_crypto_core_hsalsa20_constbytes","_crypto_core_hsalsa20_inputbytes","_crypto_core_hsalsa20_keybytes","_crypto_core_hsalsa20_outputbytes","_crypto_core_ristretto255_add","_crypto_core_ristretto255_bytes","_crypto_core_ristretto255_from_hash","_crypto_core_ristretto255_hashbytes","_crypto_core_ristretto255_is_valid_point","_crypto_core_ristretto255_nonreducedscalarbytes","_crypto_core_ristretto255_random","_crypto_core_ristretto255_scalar_add","_crypto_core_ristretto255_scalar_complement","_crypto_core_ristretto255_scalar_invert","_crypto_core_ristretto255_scalar_mul","_crypto_core_ristretto255_scalar_negate","_crypto_core_ristretto255_scalar_random","_crypto_core_ristretto255_scalar_reduce","_crypto_core_ristretto255_scalar_sub","_crypto_core_ristretto255_scalarbytes","_crypto_core_ristretto255_sub","_crypto_core_salsa20","_crypto_core_salsa2012","_crypto_core_salsa2012_constbytes","_crypto_core_salsa2012_inputbytes","_crypto_core_salsa2012_keybytes","_crypto_core_salsa2012_outputbytes","_crypto_core_salsa208","_crypto_core_salsa208_constbytes","_crypto_core_salsa208_inputbytes","_crypto_core_salsa208_keybytes","_crypto_core_salsa208_outputbytes","_crypto_core_salsa20_constbytes","_crypto_core_salsa20_inputbytes","_crypto_core_salsa20_keybytes","_crypto_core_salsa20_outputbytes","_crypto_generichash","_crypto_generichash_blake2b","_crypto_generichash_blake2b_bytes","_crypto_generichash_blake2b_bytes_max","_crypto_generichash_blake2b_bytes_min","_crypto_generichash_blake2b_final","_crypto_generichash_blake2b_init","_crypto_generichash_blake2b_init_salt_personal","_crypto_generichash_blake2b_keybytes","_crypto_generichash_blake2b_keybytes_max","_crypto_generichash_blake2b_keybytes_min","_crypto_generichash_blake2b_keygen","_crypto_generichash_blake2b_personalbytes","_crypto_generichash_blake2b_salt_personal","_crypto_generichash_blake2b_saltbytes","_crypto_generichash_blake2b_statebytes","_crypto_generichash_blake2b_update","_crypto_generichash_bytes","_crypto_generichash_bytes_max","_crypto_generichash_bytes_min","_crypto_generichash_final","_crypto_generichash_init","_crypto_generichash_keybytes","_crypto_generichash_keybytes_max","_crypto_generichash_keybytes_min","_crypto_generichash_keygen","_crypto_generichash_primitive","_crypto_generichash_statebytes","_crypto_generichash_update","_crypto_hash","_crypto_hash_bytes","_crypto_hash_primitive","_crypto_hash_sha256","_crypto_hash_sha256_bytes","_crypto_hash_sha256_final","_crypto_hash_sha256_init","_crypto_hash_sha256_statebytes","_crypto_hash_sha256_update","_crypto_hash_sha512","_crypto_hash_sha512_bytes","_crypto_hash_sha512_final","_crypto_hash_sha512_init","_crypto_hash_sha512_statebytes","_crypto_hash_sha512_update","_crypto_kdf_blake2b_bytes_max","_crypto_kdf_blake2b_bytes_min","_crypto_kdf_blake2b_contextbytes","_crypto_kdf_blake2b_derive_from_key","_crypto_kdf_blake2b_keybytes","_crypto_kdf_bytes_max","_crypto_kdf_bytes_min","_crypto_kdf_contextbytes","_crypto_kdf_derive_from_key","_crypto_kdf_hkdf_sha256_bytes_min","_crypto_kdf_hkdf_sha256_expand","_crypto_kdf_hkdf_sha256_extract","_crypto_kdf_hkdf_sha256_keybytes","_crypto_kdf_hkdf_sha256_keygen","_crypto_kdf_hkdf_sha512_bytes_min","_crypto_kdf_hkdf_sha512_expand","_crypto_kdf_hkdf_sha512_extract","_crypto_kdf_hkdf_sha512_keybytes","_crypto_kdf_hkdf_sha512_keygen","_crypto_kdf_keybytes","_crypto_kdf_keygen","_crypto_kdf_primitive","_crypto_kx_client_session_keys","_crypto_kx_keypair","_crypto_kx_primitive","_crypto_kx_publickeybytes","_crypto_kx_secretkeybytes","_crypto_kx_seed_keypair","_crypto_kx_seedbytes","_crypto_kx_server_session_keys","_crypto_kx_sessionkeybytes","_crypto_onetimeauth","_crypto_onetimeauth_bytes","_crypto_onetimeauth_final","_crypto_onetimeauth_init","_crypto_onetimeauth_keybytes","_crypto_onetimeauth_keygen","_crypto_onetimeauth_poly1305","_crypto_onetimeauth_poly1305_bytes","_crypto_onetimeauth_poly1305_final","_crypto_onetimeauth_poly1305_init","_crypto_onetimeauth_poly1305_keybytes","_crypto_onetimeauth_poly1305_keygen","_crypto_onetimeauth_poly1305_statebytes","_crypto_onetimeauth_poly1305_update","_crypto_onetimeauth_poly1305_verify","_crypto_onetimeauth_primitive","_crypto_onetimeauth_statebytes","_crypto_onetimeauth_update","_crypto_onetimeauth_verify","_crypto_pwhash","_crypto_pwhash_alg_argon2i13","_crypto_pwhash_alg_argon2id13","_crypto_pwhash_alg_default","_crypto_pwhash_argon2i","_crypto_pwhash_argon2i_alg_argon2i13","_crypto_pwhash_argon2i_bytes_max","_crypto_pwhash_argon2i_bytes_min","_crypto_pwhash_argon2i_memlimit_interactive","_crypto_pwhash_argon2i_memlimit_max","_crypto_pwhash_argon2i_memlimit_min","_crypto_pwhash_argon2i_memlimit_moderate","_crypto_pwhash_argon2i_memlimit_sensitive","_crypto_pwhash_argon2i_opslimit_interactive","_crypto_pwhash_argon2i_opslimit_max","_crypto_pwhash_argon2i_opslimit_min","_crypto_pwhash_argon2i_opslimit_moderate","_crypto_pwhash_argon2i_opslimit_sensitive","_crypto_pwhash_argon2i_passwd_max","_crypto_pwhash_argon2i_passwd_min","_crypto_pwhash_argon2i_saltbytes","_crypto_pwhash_argon2i_str","_crypto_pwhash_argon2i_str_needs_rehash","_crypto_pwhash_argon2i_str_verify","_crypto_pwhash_argon2i_strbytes","_crypto_pwhash_argon2i_strprefix","_crypto_pwhash_argon2id","_crypto_pwhash_argon2id_alg_argon2id13","_crypto_pwhash_argon2id_bytes_max","_crypto_pwhash_argon2id_bytes_min","_crypto_pwhash_argon2id_memlimit_interactive","_crypto_pwhash_argon2id_memlimit_max","_crypto_pwhash_argon2id_memlimit_min","_crypto_pwhash_argon2id_memlimit_moderate","_crypto_pwhash_argon2id_memlimit_sensitive","_crypto_pwhash_argon2id_opslimit_interactive","_crypto_pwhash_argon2id_opslimit_max","_crypto_pwhash_argon2id_opslimit_min","_crypto_pwhash_argon2id_opslimit_moderate","_crypto_pwhash_argon2id_opslimit_sensitive","_crypto_pwhash_argon2id_passwd_max","_crypto_pwhash_argon2id_passwd_min","_crypto_pwhash_argon2id_saltbytes","_crypto_pwhash_argon2id_str","_crypto_pwhash_argon2id_str_needs_rehash","_crypto_pwhash_argon2id_str_verify","_crypto_pwhash_argon2id_strbytes","_crypto_pwhash_argon2id_strprefix","_crypto_pwhash_bytes_max","_crypto_pwhash_bytes_min","_crypto_pwhash_memlimit_interactive","_crypto_pwhash_memlimit_max","_crypto_pwhash_memlimit_min","_crypto_pwhash_memlimit_moderate","_crypto_pwhash_memlimit_sensitive","_crypto_pwhash_opslimit_interactive","_crypto_pwhash_opslimit_max","_crypto_pwhash_opslimit_min","_crypto_pwhash_opslimit_moderate","_crypto_pwhash_opslimit_sensitive","_crypto_pwhash_passwd_max","_crypto_pwhash_passwd_min","_crypto_pwhash_primitive","_crypto_pwhash_saltbytes","_crypto_pwhash_scryptsalsa208sha256","_crypto_pwhash_scryptsalsa208sha256_bytes_max","_crypto_pwhash_scryptsalsa208sha256_bytes_min","_crypto_pwhash_scryptsalsa208sha256_ll","_crypto_pwhash_scryptsalsa208sha256_memlimit_interactive","_crypto_pwhash_scryptsalsa208sha256_memlimit_max","_crypto_pwhash_scryptsalsa208sha256_memlimit_min","_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive","_crypto_pwhash_scryptsalsa208sha256_opslimit_interactive","_crypto_pwhash_scryptsalsa208sha256_opslimit_max","_crypto_pwhash_scryptsalsa208sha256_opslimit_min","_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive","_crypto_pwhash_scryptsalsa208sha256_passwd_max","_crypto_pwhash_scryptsalsa208sha256_passwd_min","_crypto_pwhash_scryptsalsa208sha256_saltbytes","_crypto_pwhash_scryptsalsa208sha256_str","_crypto_pwhash_scryptsalsa208sha256_str_needs_rehash","_crypto_pwhash_scryptsalsa208sha256_str_verify","_crypto_pwhash_scryptsalsa208sha256_strbytes","_crypto_pwhash_scryptsalsa208sha256_strprefix","_crypto_pwhash_str","_crypto_pwhash_str_alg","_crypto_pwhash_str_needs_rehash","_crypto_pwhash_str_verify","_crypto_pwhash_strbytes","_crypto_pwhash_strprefix","_crypto_scalarmult","_crypto_scalarmult_base","_crypto_scalarmult_bytes","_crypto_scalarmult_curve25519","_crypto_scalarmult_curve25519_base","_crypto_scalarmult_curve25519_bytes","_crypto_scalarmult_curve25519_scalarbytes","_crypto_scalarmult_ed25519","_crypto_scalarmult_ed25519_base","_crypto_scalarmult_ed25519_base_noclamp","_crypto_scalarmult_ed25519_bytes","_crypto_scalarmult_ed25519_noclamp","_crypto_scalarmult_ed25519_scalarbytes","_crypto_scalarmult_primitive","_crypto_scalarmult_ristretto255","_crypto_scalarmult_ristretto255_base","_crypto_scalarmult_ristretto255_bytes","_crypto_scalarmult_ristretto255_scalarbytes","_crypto_scalarmult_scalarbytes","_crypto_secretbox","_crypto_secretbox_boxzerobytes","_crypto_secretbox_detached","_crypto_secretbox_easy","_crypto_secretbox_keybytes","_crypto_secretbox_keygen","_crypto_secretbox_macbytes","_crypto_secretbox_messagebytes_max","_crypto_secretbox_noncebytes","_crypto_secretbox_open","_crypto_secretbox_open_detached","_crypto_secretbox_open_easy","_crypto_secretbox_primitive","_crypto_secretbox_xchacha20poly1305_detached","_crypto_secretbox_xchacha20poly1305_easy","_crypto_secretbox_xchacha20poly1305_keybytes","_crypto_secretbox_xchacha20poly1305_macbytes","_crypto_secretbox_xchacha20poly1305_messagebytes_max","_crypto_secretbox_xchacha20poly1305_noncebytes","_crypto_secretbox_xchacha20poly1305_open_detached","_crypto_secretbox_xchacha20poly1305_open_easy","_crypto_secretbox_xsalsa20poly1305","_crypto_secretbox_xsalsa20poly1305_boxzerobytes","_crypto_secretbox_xsalsa20poly1305_keybytes","_crypto_secretbox_xsalsa20poly1305_keygen","_crypto_secretbox_xsalsa20poly1305_macbytes","_crypto_secretbox_xsalsa20poly1305_messagebytes_max","_crypto_secretbox_xsalsa20poly1305_noncebytes","_crypto_secretbox_xsalsa20poly1305_open","_crypto_secretbox_xsalsa20poly1305_zerobytes","_crypto_secretbox_zerobytes","_crypto_secretstream_xchacha20poly1305_abytes","_crypto_secretstream_xchacha20poly1305_headerbytes","_crypto_secretstream_xchacha20poly1305_init_pull","_crypto_secretstream_xchacha20poly1305_init_push","_crypto_secretstream_xchacha20poly1305_keybytes","_crypto_secretstream_xchacha20poly1305_keygen","_crypto_secretstream_xchacha20poly1305_messagebytes_max","_crypto_secretstream_xchacha20poly1305_pull","_crypto_secretstream_xchacha20poly1305_push","_crypto_secretstream_xchacha20poly1305_rekey","_crypto_secretstream_xchacha20poly1305_statebytes","_crypto_secretstream_xchacha20poly1305_tag_final","_crypto_secretstream_xchacha20poly1305_tag_message","_crypto_secretstream_xchacha20poly1305_tag_push","_crypto_secretstream_xchacha20poly1305_tag_rekey","_crypto_shorthash","_crypto_shorthash_bytes","_crypto_shorthash_keybytes","_crypto_shorthash_keygen","_crypto_shorthash_primitive","_crypto_shorthash_siphash24","_crypto_shorthash_siphash24_bytes","_crypto_shorthash_siphash24_keybytes","_crypto_shorthash_siphashx24","_crypto_shorthash_siphashx24_bytes","_crypto_shorthash_siphashx24_keybytes","_crypto_sign","_crypto_sign_bytes","_crypto_sign_detached","_crypto_sign_ed25519","_crypto_sign_ed25519_bytes","_crypto_sign_ed25519_detached","_crypto_sign_ed25519_keypair","_crypto_sign_ed25519_messagebytes_max","_crypto_sign_ed25519_open","_crypto_sign_ed25519_pk_to_curve25519","_crypto_sign_ed25519_publickeybytes","_crypto_sign_ed25519_secretkeybytes","_crypto_sign_ed25519_seed_keypair","_crypto_sign_ed25519_seedbytes","_crypto_sign_ed25519_sk_to_curve25519","_crypto_sign_ed25519_sk_to_pk","_crypto_sign_ed25519_sk_to_seed","_crypto_sign_ed25519_verify_detached","_crypto_sign_ed25519ph_final_create","_crypto_sign_ed25519ph_final_verify","_crypto_sign_ed25519ph_init","_crypto_sign_ed25519ph_statebytes","_crypto_sign_ed25519ph_update","_crypto_sign_final_create","_crypto_sign_final_verify","_crypto_sign_init","_crypto_sign_keypair","_crypto_sign_messagebytes_max","_crypto_sign_open","_crypto_sign_primitive","_crypto_sign_publickeybytes","_crypto_sign_secretkeybytes","_crypto_sign_seed_keypair","_crypto_sign_seedbytes","_crypto_sign_statebytes","_crypto_sign_update","_crypto_sign_verify_detached","_crypto_stream","_crypto_stream_chacha20","_crypto_stream_chacha20_ietf","_crypto_stream_chacha20_ietf_keybytes","_crypto_stream_chacha20_ietf_keygen","_crypto_stream_chacha20_ietf_messagebytes_max","_crypto_stream_chacha20_ietf_noncebytes","_crypto_stream_chacha20_ietf_xor","_crypto_stream_chacha20_ietf_xor_ic","_crypto_stream_chacha20_keybytes","_crypto_stream_chacha20_keygen","_crypto_stream_chacha20_messagebytes_max","_crypto_stream_chacha20_noncebytes","_crypto_stream_chacha20_xor","_crypto_stream_chacha20_xor_ic","_crypto_stream_keybytes","_crypto_stream_keygen","_crypto_stream_messagebytes_max","_crypto_stream_noncebytes","_crypto_stream_primitive","_crypto_stream_salsa20","_crypto_stream_salsa2012","_crypto_stream_salsa2012_keybytes","_crypto_stream_salsa2012_keygen","_crypto_stream_salsa2012_messagebytes_max","_crypto_stream_salsa2012_noncebytes","_crypto_stream_salsa2012_xor","_crypto_stream_salsa208","_crypto_stream_salsa208_keybytes","_crypto_stream_salsa208_keygen","_crypto_stream_salsa208_messagebytes_max","_crypto_stream_salsa208_noncebytes","_crypto_stream_salsa208_xor","_crypto_stream_salsa20_keybytes","_crypto_stream_salsa20_keygen","_crypto_stream_salsa20_messagebytes_max","_crypto_stream_salsa20_noncebytes","_crypto_stream_salsa20_xor","_crypto_stream_salsa20_xor_ic","_crypto_stream_xchacha20","_crypto_stream_xchacha20_keybytes","_crypto_stream_xchacha20_keygen","_crypto_stream_xchacha20_messagebytes_max","_crypto_stream_xchacha20_noncebytes","_crypto_stream_xchacha20_xor","_crypto_stream_xchacha20_xor_ic","_crypto_stream_xor","_crypto_stream_xsalsa20","_crypto_stream_xsalsa20_keybytes","_crypto_stream_xsalsa20_keygen","_crypto_stream_xsalsa20_messagebytes_max","_crypto_stream_xsalsa20_noncebytes","_crypto_stream_xsalsa20_xor","_crypto_stream_xsalsa20_xor_ic","_crypto_verify_16","_crypto_verify_16_bytes","_crypto_verify_32","_crypto_verify_32_bytes","_crypto_verify_64","_crypto_verify_64_bytes","_randombytes","_randombytes_buf","_randombytes_buf_deterministic","_randombytes_close","_randombytes_implementation_name","_randombytes_random","_randombytes_seedbytes","_randombytes_stir","_randombytes_uniform","_sodium_base642bin","_sodium_base64_encoded_len","_sodium_bin2base64","_sodium_bin2hex","_sodium_hex2bin","_sodium_init","_sodium_library_minimal","_sodium_library_version_major","_sodium_library_version_minor","_sodium_pad","_sodium_unpad","_sodium_version_string"]' export EXPORTED_RUNTIME_METHODS='["UTF8ToString","getValue","setValue"]' export MAX_MEMORY=16777216 export MAX_MEMORY_SUMO=16777216 diff --git a/dist-build/generate-emscripten-symbols.sh b/dist-build/generate-emscripten-symbols.sh index 873307d2..a0641faa 100755 --- a/dist-build/generate-emscripten-symbols.sh +++ b/dist-build/generate-emscripten-symbols.sh @@ -17,7 +17,7 @@ symbols() { fi done < emscripten-symbols.def - /usr/bin/nm /usr/local/lib/libsodium.23.dylib | \ + /usr/bin/nm /usr/local/lib/libsodium.27.dylib | \ fgrep ' T _' | \ cut -d' ' -f3 | { while read symbol; do diff --git a/dist-build/osx.sh b/dist-build/osx.sh index d47a0018..1c623743 100755 --- a/dist-build/osx.sh +++ b/dist-build/osx.sh @@ -1,7 +1,7 @@ #! /bin/sh export PREFIX="$(pwd)/libsodium-osx" -export OSX_VERSION_MIN=${OSX_VERSION_MIN-"10.8"} +export OSX_VERSION_MIN=${OSX_VERSION_MIN-"10.10"} export OSX_CPU_ARCH=${OSX_CPU_ARCH-"core2"} mkdir -p $PREFIX || exit 1 diff --git a/libsodium.vcxproj b/libsodium.vcxproj index 6402b7a1..749ada97 100644 --- a/libsodium.vcxproj +++ b/libsodium.vcxproj @@ -326,7 +326,6 @@ - @@ -358,6 +357,8 @@ + + @@ -481,6 +482,7 @@ + @@ -489,6 +491,7 @@ + @@ -497,7 +500,6 @@ - diff --git a/libsodium.vcxproj.filters b/libsodium.vcxproj.filters index 830ca81c..9de5c18a 100644 --- a/libsodium.vcxproj.filters +++ b/libsodium.vcxproj.filters @@ -48,9 +48,6 @@ Source Files - - Source Files - Source Files @@ -144,6 +141,12 @@ Source Files + + Source Files + + + Source Files + Source Files @@ -509,6 +512,9 @@ Header Files + + Header Files + Header Files @@ -533,6 +539,9 @@ Header Files + + Header Files + Header Files @@ -557,9 +566,6 @@ Header Files - - Header Files - Header Files diff --git a/msvc-scripts/process.bat b/msvc-scripts/process.bat index 291679e4..406ec5fb 100755 --- a/msvc-scripts/process.bat +++ b/msvc-scripts/process.bat @@ -1,5 +1,5 @@ cscript msvc-scripts/rep.vbs //Nologo s/@VERSION@/1.0.18/ < src\libsodium\include\sodium\version.h.in > tmp -cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MAJOR@/10/ < tmp > tmp2 -cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MINOR@/3/ < tmp2 > tmp3 +cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MAJOR@/11/ < tmp > tmp2 +cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MINOR@/0/ < tmp2 > tmp3 cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_MINIMAL_DEF@// < tmp3 > src\libsodium\include\sodium\version.h del tmp tmp2 tmp3 diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index cedb8d70..2fd7ebbd 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -153,6 +153,8 @@ libsodium_la_SOURCES += \ crypto_box/curve25519xchacha20poly1305/box_seal_curve25519xchacha20poly1305.c \ crypto_core/ed25519/core_ed25519.c \ crypto_core/ed25519/core_ristretto255.c \ + crypto_kdf/hkdf/kdf_hkdf_sha256.c \ + crypto_kdf/hkdf/kdf_hkdf_sha512.c \ crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c \ crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h \ crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c \ @@ -165,7 +167,6 @@ libsodium_la_SOURCES += \ crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c \ crypto_shorthash/siphash24/shorthash_siphashx24.c \ crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c \ - crypto_sign/ed25519/ref10/obsolete.c \ crypto_stream/salsa2012/ref/stream_salsa2012_ref.c \ crypto_stream/salsa2012/stream_salsa2012.c \ crypto_stream/salsa208/ref/stream_salsa208_ref.c \ diff --git a/src/libsodium/crypto_aead/aegis256/aead_aegis256.c b/src/libsodium/crypto_aead/aegis256/aead_aegis256.c index dfcb587b..9fff6aea 100644 --- a/src/libsodium/crypto_aead/aegis256/aead_aegis256.c +++ b/src/libsodium/crypto_aead/aegis256/aead_aegis256.c @@ -3,6 +3,7 @@ #include #include "crypto_aead_aegis256.h" +#include "private/common.h" #include "randombytes.h" size_t diff --git a/src/libsodium/crypto_core/ed25519/core_ed25519.c b/src/libsodium/crypto_core/ed25519/core_ed25519.c index 0029a093..3d5a8b34 100644 --- a/src/libsodium/crypto_core/ed25519/core_ed25519.c +++ b/src/libsodium/crypto_core/ed25519/core_ed25519.c @@ -1,7 +1,10 @@ #include +#include +#include #include "crypto_core_ed25519.h" +#include "crypto_hash_sha512.h" #include "private/common.h" #include "private/ed25519_ref10.h" #include "randombytes.h" @@ -70,21 +73,95 @@ crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r) return 0; } -int -crypto_core_ed25519_from_hash(unsigned char *p, const unsigned char *h) -{ - ge25519_from_hash(p, h); +#define HASH_BYTES crypto_hash_sha512_BYTES +#define HASH_BLOCKBYTES 128U +#define HASH_L 48U +static int +_string_to_points(unsigned char * const px, size_t n, + const char *ctx, const unsigned char *msg, size_t msg_len) +{ + crypto_hash_sha512_state st; + unsigned char empty_block[128] = { 0 }; + unsigned char u0[HASH_BYTES], u[2 * HASH_BYTES]; + unsigned char t[3] = { 0U, n * HASH_L, 0U}; + unsigned char ctx_len_u8; + size_t ctx_len = ctx != NULL ? strlen(ctx) : 0U; + size_t i, j; + + if (n > 2U) { + abort(); /* LCOV_EXCL_LINE */ + } + COMPILER_ASSERT(2U * HASH_L <= 0xff); + if (ctx_len > (size_t) 0xff) { + crypto_hash_sha512_init(&st); + crypto_hash_sha512_update(&st, + (const unsigned char *) "H2C-OVERSIZE-DST-", + sizeof "H2C-OVERSIZE-DST-" - 1U); + crypto_hash_sha512_update(&st, (const unsigned char *) ctx, ctx_len); + crypto_hash_sha512_final(&st, u0); + ctx = (const char *) u0; + ctx_len = HASH_BYTES; + COMPILER_ASSERT(HASH_BYTES <= (size_t) 0xff); + } + ctx_len_u8 = (unsigned char) ctx_len; + crypto_hash_sha512_init(&st); + crypto_hash_sha512_update(&st, empty_block, sizeof empty_block); + crypto_hash_sha512_update(&st, msg, msg_len); + crypto_hash_sha512_update(&st, t, 3U); + crypto_hash_sha512_update(&st, (const unsigned char *) ctx, ctx_len); + crypto_hash_sha512_update(&st, &ctx_len_u8, 1U); + crypto_hash_sha512_final(&st, u0); + + for (i = 0U; i < n * HASH_BYTES; i += HASH_BYTES) { + memcpy(&u[i], u0, HASH_BYTES); + for (j = 0U; i > 0U && j < HASH_BYTES; j++) { + u[i + j] ^= u[i + j - HASH_BYTES]; + } + t[2]++; + crypto_hash_sha512_init(&st); + crypto_hash_sha512_update(&st, &u[i], HASH_BYTES); + crypto_hash_sha512_update(&st, &t[2], 1U); + crypto_hash_sha512_update(&st, (const unsigned char *) ctx, ctx_len); + crypto_hash_sha512_update(&st, &ctx_len_u8, 1U); + crypto_hash_sha512_final(&st, &u[i]); + } + for (i = 0U; i < n; i++) { + memset(u0, 0U, HASH_BYTES - HASH_L); + memcpy(u0 + HASH_BYTES - HASH_L, &u[i * HASH_L], HASH_L); + ge25519_from_hash(&px[i * crypto_core_ed25519_BYTES], u0); + } return 0; } +int +crypto_core_ed25519_from_string(unsigned char p[crypto_core_ed25519_BYTES], + const char *ctx, const unsigned char *msg, + size_t msg_len) +{ + return _string_to_points(p, 1, ctx, msg, msg_len); +} + +int +crypto_core_ed25519_from_string_ro(unsigned char p[crypto_core_ed25519_BYTES], + const char *ctx, const unsigned char *msg, + size_t msg_len) +{ + unsigned char px[2 * crypto_core_ed25519_BYTES]; + + if (_string_to_points(px, 2, ctx, msg, msg_len) != 0) { + return -1; + } + return crypto_core_ed25519_add(p, &px[0], &px[crypto_core_ed25519_BYTES]); +} + void crypto_core_ed25519_random(unsigned char *p) { - unsigned char h[crypto_core_ed25519_HASHBYTES]; + unsigned char h[crypto_core_ed25519_UNIFORMBYTES]; randombytes_buf(h, sizeof h); - (void) crypto_core_ed25519_from_hash(p, h); + (void) crypto_core_ed25519_from_uniform(p, h); } void diff --git a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c index dda67360..a775c37a 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c +++ b/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c @@ -50,13 +50,13 @@ load_4(const unsigned char *in) # include "fe_25_5/fe.h" #endif +/* + * Inversion - returns 0 if z=0 + */ void fe25519_invert(fe25519 out, const fe25519 z) { - fe25519 t0; - fe25519 t1; - fe25519 t2; - fe25519 t3; + fe25519 t0, t1, t2, t3; int i; fe25519_sq(t0, z); @@ -111,9 +111,7 @@ fe25519_invert(fe25519 out, const fe25519 z) static void fe25519_pow22523(fe25519 out, const fe25519 z) { - fe25519 t0; - fe25519 t1; - fe25519 t2; + fe25519 t0, t1, t2; int i; fe25519_sq(t0, z); @@ -179,6 +177,37 @@ fe25519_abs(fe25519 h, const fe25519 f) fe25519_cneg(h, f, fe25519_isnegative(f)); } +static void +fe25519_unchecked_sqrt(fe25519 x, const fe25519 x2) +{ + fe25519 p_root; + fe25519 m_root; + fe25519 m_root2; + fe25519 e; + + fe25519_pow22523(e, x); + fe25519_mul(p_root, e, x); + fe25519_mul(m_root, p_root, fe25519_sqrtm1); + fe25519_sq(m_root2, m_root); + fe25519_sub(e, x2, m_root2); + fe25519_copy(x, p_root); + fe25519_cmov(x, m_root, fe25519_iszero(e)); +} + +static int +fe25519_sqrt(fe25519 x, const fe25519 x2) +{ + fe25519 check; + fe25519 x2_copy; + + fe25519_copy(x2_copy, x2); + fe25519_unchecked_sqrt(x, x2); + fe25519_sq(check, x); + fe25519_sub(check, check, x2_copy); + + return fe25519_iszero(check) - 1; +} + /* r = p + q */ @@ -259,7 +288,7 @@ ge25519_frombytes(ge25519_p3 *h, const unsigned char *s) fe25519_frombytes(h->Y, s); fe25519_1(h->Z); fe25519_sq(u, h->Y); - fe25519_mul(v, u, d); + fe25519_mul(v, u, ed25519_d); fe25519_sub(u, u, h->Z); /* u = y^2-1 */ fe25519_add(v, v, h->Z); /* v = dy^2+1 */ @@ -279,7 +308,7 @@ ge25519_frombytes(ge25519_p3 *h, const unsigned char *s) fe25519_add(p_root_check, vxx, u); /* vx^2+u */ has_m_root = fe25519_iszero(m_root_check); has_p_root = fe25519_iszero(p_root_check); - fe25519_mul(x_sqrtm1, h->X, sqrtm1); /* x*sqrt(-1) */ + fe25519_mul(x_sqrtm1, h->X, fe25519_sqrtm1); /* x*sqrt(-1) */ fe25519_cmov(h->X, x_sqrtm1, 1 - has_m_root); fe25519_neg(negx, h->X); @@ -301,7 +330,7 @@ ge25519_frombytes_negate_vartime(ge25519_p3 *h, const unsigned char *s) fe25519_frombytes(h->Y, s); fe25519_1(h->Z); fe25519_sq(u, h->Y); - fe25519_mul(v, u, d); + fe25519_mul(v, u, ed25519_d); fe25519_sub(u, u, h->Z); /* u = y^2-1 */ fe25519_add(v, v, h->Z); /* v = dy^2+1 */ @@ -323,7 +352,7 @@ ge25519_frombytes_negate_vartime(ge25519_p3 *h, const unsigned char *s) if (fe25519_iszero(p_root_check) == 0) { return -1; } - fe25519_mul(h->X, h->X, sqrtm1); + fe25519_mul(h->X, h->X, fe25519_sqrtm1); } if (fe25519_isnegative(h->X) == (s[31] >> 7)) { @@ -457,7 +486,7 @@ ge25519_p3_to_cached(ge25519_cached *r, const ge25519_p3 *p) fe25519_add(r->YplusX, p->Y, p->X); fe25519_sub(r->YminusX, p->Y, p->X); fe25519_copy(r->Z, p->Z); - fe25519_mul(r->T2d, p->T, d2); + fe25519_mul(r->T2d, p->T, ed25519_d2); } static void @@ -474,7 +503,7 @@ ge25519_p3_to_precomp(ge25519_precomp *pi, const ge25519_p3 *p) fe25519_add(pi->yplusx, y, x); fe25519_sub(pi->yminusx, y, x); fe25519_mul(xy, x, y); - fe25519_mul(pi->xy2d, xy, d2); + fe25519_mul(pi->xy2d, xy, ed25519_d2); } /* @@ -980,7 +1009,7 @@ ge25519_is_on_curve(const ge25519_p3 *p) fe25519_mul(t0, t0, z2); fe25519_mul(t1, x2, y2); - fe25519_mul(t1, t1, d); + fe25519_mul(t1, t1, ed25519_d); fe25519_sq(z4, z2); fe25519_add(t1, t1, z4); fe25519_sub(t0, t0, t1); @@ -2483,7 +2512,6 @@ chi25519(fe25519 out, const fe25519 z) fe25519_mul(t2, t2, t0); fe25519_mul(t1, t2, z); fe25519_sq(t2, t1); - for (i = 1; i < 5; i++) { fe25519_sq(t2, t2); } @@ -2525,84 +2553,128 @@ chi25519(fe25519 out, const fe25519 z) fe25519_mul(out, t1, t0); } +/* montgomery to edwards */ static void -ge25519_elligator2(unsigned char s[32], const fe25519 r, const unsigned char x_sign) +ge25519_mont_to_ed(fe25519 xed, fe25519 yed, const fe25519 x, const fe25519 y) +{ + fe25519 one; + fe25519 x_plus_one; + fe25519 x_minus_one; + fe25519 x_plus_one_y_inv; + + fe25519_1(one); + fe25519_add(x_plus_one, x, one); + fe25519_sub(x_minus_one, x, one); + + /* xed = sqrt(-A-2)*x/y */ + fe25519_mul(x_plus_one_y_inv, x_plus_one, y); + fe25519_invert(x_plus_one_y_inv, x_plus_one_y_inv); /* 1/((x+1)*y) */ + fe25519_mul(xed, x, ed25519_sqrtam2); + fe25519_mul(xed, xed, x_plus_one_y_inv); /* sqrt(-A-2)*x/((x+1)*y) */ + fe25519_mul(xed, xed, x_plus_one); + + /* yed = (x-1)/(x+1) */ + fe25519_mul(yed, x_plus_one_y_inv, y); /* 1/(x+1) */ + fe25519_mul(yed, yed, x_minus_one); + fe25519_cmov(yed, one, fe25519_iszero(x_plus_one_y_inv)); +} + +/* montgomery -- recover y = sqrt(x^3 + A*x^2 + x) */ +static int +ge25519_xmont_to_ymont(fe25519 y, const fe25519 x) +{ + fe25519 x2; + fe25519 x3; + + fe25519_sq(x2, x); + fe25519_mul(x3, x, x2); + fe25519_mul32(x2, x2, ed25519_A_32); + fe25519_add(y, x3, x); + fe25519_add(y, y, x2); + + return fe25519_sqrt(y, y); +} + +/* multiply by the cofactor */ +static void +ge25519_clear_cofactor(ge25519_p3 *p3) { - fe25519 e; - fe25519 negx; - fe25519 rr2; - fe25519 x, x2, x3; - ge25519_p3 p3; ge25519_p1p1 p1; ge25519_p2 p2; - unsigned int e_is_minus_1; + + ge25519_p3_dbl(&p1, p3); + ge25519_p1p1_to_p2(&p2, &p1); + ge25519_p2_dbl(&p1, &p2); + ge25519_p1p1_to_p2(&p2, &p1); + ge25519_p2_dbl(&p1, &p2); + ge25519_p1p1_to_p3(p3, &p1); +} + +static void +ge25519_elligator2(fe25519 x, fe25519 y, const fe25519 r, int *was_square_p) +{ + fe25519 e; + fe25519 gx1; + fe25519 rr2; + fe25519 x2, x3, negx; + unsigned char s[32]; + int was_square; fe25519_sq2(rr2, r); rr2[0]++; fe25519_invert(rr2, rr2); - fe25519_mul(x, curve25519_A, rr2); - fe25519_neg(x, x); + fe25519_mul32(x, rr2, ed25519_A_32); + fe25519_neg(x, x); /* x=x1 */ fe25519_sq(x2, x); fe25519_mul(x3, x, x2); - fe25519_add(e, x3, x); - fe25519_mul(x2, x2, curve25519_A); - fe25519_add(e, x2, e); - - chi25519(e, e); + fe25519_mul32(x2, x2, ed25519_A_32); /* x2 = A*x1^2 */ + fe25519_add(gx1, x3, x); + fe25519_add(gx1, gx1, x2); /* gx1 = x1^3 + A*x1^2 + x1 */ + chi25519(e, gx1); fe25519_tobytes(s, e); - e_is_minus_1 = s[1] & 1; + was_square = s[1] & 1; + + /* e=-1 => x = -x1-A */ fe25519_neg(negx, x); - fe25519_cmov(x, negx, e_is_minus_1); + fe25519_cmov(x, negx, was_square); fe25519_0(x2); - fe25519_cmov(x2, curve25519_A, e_is_minus_1); + fe25519_cmov(x2, ed25519_A, was_square); fe25519_sub(x, x, x2); - /* yed = (x-1)/(x+1) */ - { - fe25519 one; - fe25519 x_plus_one; - fe25519 x_plus_one_inv; - fe25519 x_minus_one; - fe25519 yed; - - fe25519_1(one); - fe25519_add(x_plus_one, x, one); - fe25519_sub(x_minus_one, x, one); - fe25519_invert(x_plus_one_inv, x_plus_one); - fe25519_mul(yed, x_minus_one, x_plus_one_inv); - fe25519_tobytes(s, yed); + /* y = sqrt(gx1) or sqrt(gx2) with gx2 = gx1 * (A+x1) / -x1 */ + /* but it is about as fast to just recompute from the curve equation. */ + if (ge25519_xmont_to_ymont(y, x) != 0) { + abort(); } - - /* recover x */ - s[31] |= x_sign; - if (ge25519_frombytes(&p3, s) != 0) { - abort(); /* LCOV_EXCL_LINE */ - } - - /* multiply by the cofactor */ - ge25519_p3_dbl(&p1, &p3); - ge25519_p1p1_to_p2(&p2, &p1); - ge25519_p2_dbl(&p1, &p2); - ge25519_p1p1_to_p2(&p2, &p1); - ge25519_p2_dbl(&p1, &p2); - ge25519_p1p1_to_p3(&p3, &p1); - - ge25519_p3_tobytes(s, &p3); + *was_square_p = was_square; } void ge25519_from_uniform(unsigned char s[32], const unsigned char r[32]) { + ge25519_p3 p3; + fe25519 x, y, negxed; fe25519 r_fe; + int was_square; unsigned char x_sign; memcpy(s, r, 32); - x_sign = s[31] & 0x80; + x_sign = s[31] >> 7; s[31] &= 0x7f; fe25519_frombytes(r_fe, s); - ge25519_elligator2(s, r_fe, x_sign); + + ge25519_elligator2(x, y, r_fe, &was_square); + + ge25519_mont_to_ed(p3.X, p3.Y, x, y); + fe25519_neg(negxed, p3.X); + fe25519_cmov(p3.X, negxed, fe25519_isnegative(p3.X) ^ x_sign); + + fe25519_1(p3.Z); + fe25519_mul(p3.T, p3.X, p3.Y); + ge25519_clear_cofactor(&p3); + ge25519_p3_tobytes(s, &p3); } void @@ -2610,12 +2682,14 @@ ge25519_from_hash(unsigned char s[32], const unsigned char h[64]) { unsigned char fl[32]; unsigned char gl[32]; + ge25519_p3 p3; + fe25519 x, y, negy; fe25519 fe_f; fe25519 fe_g; size_t i; - unsigned char x_sign; + int was_square; + unsigned char y_sign; - x_sign = h[0] & 0x80; for (i = 0; i < 32; i++) { fl[i] = h[63 - i]; gl[i] = h[31 - i]; @@ -2629,7 +2703,19 @@ ge25519_from_hash(unsigned char s[32], const unsigned char h[64]) fe_f[i] += 38 * fe_g[i]; } fe25519_reduce(fe_f, fe_f); - ge25519_elligator2(s, fe_f, x_sign); + + ge25519_elligator2(x, y, fe_f, &was_square); + + y_sign = was_square; + fe25519_neg(negy, y); + fe25519_cmov(y, negy, fe25519_isnegative(y) ^ y_sign); + + ge25519_mont_to_ed(p3.X, p3.Y, x, y); + + fe25519_1(p3.Z); + fe25519_mul(p3.T, p3.X, p3.Y); + ge25519_clear_cofactor(&p3); + ge25519_p3_tobytes(s, &p3); } /* Ristretto group */ @@ -2657,12 +2743,12 @@ ristretto255_sqrt_ratio_m1(fe25519 x, const fe25519 u, const fe25519 v) fe25519_mul(vxx, vxx, v); /* vx^2 */ fe25519_sub(m_root_check, vxx, u); /* vx^2-u */ fe25519_add(p_root_check, vxx, u); /* vx^2+u */ - fe25519_mul(f_root_check, u, sqrtm1); /* u*sqrt(-1) */ + fe25519_mul(f_root_check, u, fe25519_sqrtm1); /* u*sqrt(-1) */ fe25519_add(f_root_check, vxx, f_root_check); /* vx^2+u*sqrt(-1) */ has_m_root = fe25519_iszero(m_root_check); has_p_root = fe25519_iszero(p_root_check); has_f_root = fe25519_iszero(f_root_check); - fe25519_mul(x_sqrtm1, x, sqrtm1); /* x*sqrt(-1) */ + fe25519_mul(x_sqrtm1, x, fe25519_sqrtm1); /* x*sqrt(-1) */ fe25519_cmov(x, x_sqrtm1, has_p_root | has_f_root); fe25519_abs(x, x); @@ -2675,6 +2761,7 @@ ristretto255_is_canonical(const unsigned char *s) { unsigned char c; unsigned char d; + unsigned char e; unsigned int i; c = (s[31] & 0x7f) ^ 0x7f; @@ -2683,8 +2770,9 @@ ristretto255_is_canonical(const unsigned char *s) } c = (((unsigned int) c) - 1U) >> 8; d = (0xed - 1U - (unsigned int) s[0]) >> 8; + e = s[31] >> 7; - return 1 - (((c & d) | s[0]) & 1); + return 1 - (((c & d) | e | s[0]) & 1); } int @@ -2714,7 +2802,7 @@ ristretto255_frombytes(ge25519_p3 *h, const unsigned char *s) fe25519_add(u2, u2, ss); /* u2 = 1+ss */ fe25519_sq(u2u2, u2); /* u2u2 = u2^2 */ - fe25519_mul(v, d, u1u1); /* v = d*u1^2 */ + fe25519_mul(v, ed25519_d, u1u1); /* v = d*u1^2 */ fe25519_neg(v, v); /* v = -d*u1^2 */ fe25519_sub(v, v, u2u2); /* v = -(d*u1^2)-u2^2 */ @@ -2771,9 +2859,9 @@ ristretto255_p3_tobytes(unsigned char *s, const ge25519_p3 *h) fe25519_mul(z_inv, den1, den2); /* z_inv = den1*den2 */ fe25519_mul(z_inv, z_inv, h->T); /* z_inv = den1*den2*T */ - fe25519_mul(ix, h->X, sqrtm1); /* ix = X*sqrt(-1) */ - fe25519_mul(iy, h->Y, sqrtm1); /* iy = Y*sqrt(-1) */ - fe25519_mul(eden, den1, invsqrtamd); /* eden = den1*sqrt(a-d) */ + fe25519_mul(ix, h->X, fe25519_sqrtm1); /* ix = X*sqrt(-1) */ + fe25519_mul(iy, h->Y, fe25519_sqrtm1); /* iy = Y*sqrt(-1) */ + fe25519_mul(eden, den1, ed25519_invsqrtamd); /* eden = den1*sqrt(a-d) */ fe25519_mul(t_z_inv, h->T, z_inv); /* t_z_inv = T*z_inv */ rotate = fe25519_isnegative(t_z_inv); @@ -2811,13 +2899,13 @@ ristretto255_elligator(ge25519_p3 *p, const fe25519 t) fe25519_1(one); fe25519_sq(r, t); /* r = t^2 */ - fe25519_mul(r, sqrtm1, r); /* r = sqrt(-1)*t^2 */ + fe25519_mul(r, fe25519_sqrtm1, r); /* r = sqrt(-1)*t^2 */ fe25519_add(u, r, one); /* u = r+1 */ - fe25519_mul(u, u, onemsqd); /* u = (r+1)*(1-d^2) */ + fe25519_mul(u, u, ed25519_onemsqd);/* u = (r+1)*(1-d^2) */ fe25519_1(c); fe25519_neg(c, c); /* c = -1 */ - fe25519_add(rpd, r, d); /* rpd = r*d */ - fe25519_mul(v, r, d); /* v = r*d */ + fe25519_add(rpd, r, ed25519_d); /* rpd = r*d */ + fe25519_mul(v, r, ed25519_d); /* v = r*d */ fe25519_sub(v, c, v); /* v = c-r*d */ fe25519_mul(v, v, rpd); /* v = (c-r*d)*(r+d) */ @@ -2830,12 +2918,12 @@ ristretto255_elligator(ge25519_p3 *p, const fe25519 t) fe25519_sub(n, r, one); /* n = r-1 */ fe25519_mul(n, n, c); /* n = c*(r-1) */ - fe25519_mul(n, n, sqdmone); /* n = c*(r-1)*(d-1)^2 */ + fe25519_mul(n, n, ed25519_sqdmone); /* n = c*(r-1)*(d-1)^2 */ fe25519_sub(n, n, v); /* n = c*(r-1)*(d-1)^2-v */ fe25519_add(w0, s, s); /* w0 = 2s */ fe25519_mul(w0, w0, v); /* w0 = 2s*v */ - fe25519_mul(w1, n, sqrtadm1); /* w1 = n*sqrt(ad-1) */ + fe25519_mul(w1, n, ed25519_sqrtadm1); /* w1 = n*sqrt(ad-1) */ fe25519_sq(ss, s); /* ss = s^2 */ fe25519_sub(w2, one, ss); /* w2 = 1-s^2 */ fe25519_add(w3, one, ss); /* w3 = 1+s^2 */ diff --git a/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/constants.h b/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/constants.h index dd6da1b8..faa8bc5c 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/constants.h +++ b/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/constants.h @@ -1,40 +1,46 @@ +/* sqrt(-1) */ +static const fe25519 fe25519_sqrtm1 = { + -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482 +}; + +/* sqrt(-486664) */ +static const fe25519 ed25519_sqrtam2 = { + -12222970, -8312128, -11511410, 9067497, -15300785, -241793, 25456130, 14121551, -12187136, 3972024 +}; + /* 37095705934669439343138083508754565189542113879843219016388785533085940283555 */ -static const fe25519 d = { +static const fe25519 ed25519_d = { -10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116 }; /* 2 * d = * 16295367250680780974490674513165176452449235426866156013048779062215315747161 */ -static const fe25519 d2 = { +static const fe25519 ed25519_d2 = { -21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199 }; -/* sqrt(-1) */ -static const fe25519 sqrtm1 = { - -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482 -}; - /* A = 486662 */ -static const fe25519 curve25519_A = { - 486662, 0, 0, 0, 0, 0, 0, 0, 0, 0 +#define ed25519_A_32 486662 +static const fe25519 ed25519_A = { + ed25519_A_32, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* sqrt(ad - 1) with a = -1 (mod p) */ -static const fe25519 sqrtadm1 = { +static const fe25519 ed25519_sqrtadm1 = { 24849947, -153582, -23613485, 6347715, -21072328, -667138, -25271143, -15367704, -870347, 14525639 }; /* 1 / sqrt(a - d) */ -static const fe25519 invsqrtamd = { +static const fe25519 ed25519_invsqrtamd = { 6111485, 4156064, -27798727, 12243468, -25904040, 120897, 20826367, -7060776, 6093568, -1986012 }; /* 1 - d ^ 2 */ -static const fe25519 onemsqd = { +static const fe25519 ed25519_onemsqd = { 6275446, -16617371, -22938544, -3773710, 11667077, 7397348, -27922721, 1766195, -24433858, 672203 }; /* (d - 1) ^ 2 */ -static const fe25519 sqdmone = { +static const fe25519 ed25519_sqdmone = { 15551795, -11097455, -13425098, -10125071, -11896535, 10178284, -26634327, 4729244, -5282110, -10116402 }; diff --git a/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/fe.h b/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/fe.h index 0b8b9756..fc814225 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/fe.h +++ b/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/fe.h @@ -1,7 +1,7 @@ #include "private/quirks.h" /* - Ignores top bit of h. + Ignores top bit of s. */ void diff --git a/src/libsodium/crypto_core/ed25519/ref10/fe_51/constants.h b/src/libsodium/crypto_core/ed25519/ref10/fe_51/constants.h index 24e5cb5e..e626689d 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/fe_51/constants.h +++ b/src/libsodium/crypto_core/ed25519/ref10/fe_51/constants.h @@ -1,41 +1,47 @@ +/* sqrt(-1) */ +static const fe25519 fe25519_sqrtm1 = { + 1718705420411056, 234908883556509, 2233514472574048, 2117202627021982, 765476049583133 +}; + +/* sqrt(-486664) */ +static const fe25519 ed25519_sqrtam2 = { + 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 +}; + /* 37095705934669439343138083508754565189542113879843219016388785533085940283555 */ -static const fe25519 d = { +static const fe25519 ed25519_d = { 929955233495203, 466365720129213, 1662059464998953, 2033849074728123, 1442794654840575 }; /* 2 * d = * 16295367250680780974490674513165176452449235426866156013048779062215315747161 */ -static const fe25519 d2 = { +static const fe25519 ed25519_d2 = { 1859910466990425, 932731440258426, 1072319116312658, 1815898335770999, 633789495995903 }; -/* sqrt(-1) */ -static const fe25519 sqrtm1 = { - 1718705420411056, 234908883556509, 2233514472574048, 2117202627021982, 765476049583133 -}; - /* A = 486662 */ -static const fe25519 curve25519_A = { - 486662, 0, 0, 0, 0 +#define ed25519_A_32 486662 +static const fe25519 ed25519_A = { + ed25519_A_32, 0, 0, 0, 0 }; /* sqrt(ad - 1) with a = -1 (mod p) */ -static const fe25519 sqrtadm1 = { +static const fe25519 ed25519_sqrtadm1 = { 2241493124984347, 425987919032274, 2207028919301688, 1220490630685848, 974799131293748 }; /* 1 / sqrt(a - d) */ -static const fe25519 invsqrtamd = { +static const fe25519 ed25519_invsqrtamd = { 278908739862762, 821645201101625, 8113234426968, 1777959178193151, 2118520810568447 }; /* 1 - d ^ 2 */ -static const fe25519 onemsqd = { +static const fe25519 ed25519_onemsqd = { 1136626929484150, 1998550399581263, 496427632559748, 118527312129759, 45110755273534 }; /* (d - 1) ^ 2 */ -static const fe25519 sqdmone = { +static const fe25519 ed25519_sqdmone = { 1507062230895904, 1572317787530805, 683053064812840, 317374165784489, 1572899562415810 }; diff --git a/src/libsodium/crypto_core/ed25519/ref10/fe_51/fe.h b/src/libsodium/crypto_core/ed25519/ref10/fe_51/fe.h index 868d1184..cfdb671b 100644 --- a/src/libsodium/crypto_core/ed25519/ref10/fe_51/fe.h +++ b/src/libsodium/crypto_core/ed25519/ref10/fe_51/fe.h @@ -1,7 +1,7 @@ #include "private/quirks.h" /* - Ignores top bit of h. + Ignores top bit of s. */ void diff --git a/src/libsodium/crypto_kdf/hkdf/kdf_hkdf_sha256.c b/src/libsodium/crypto_kdf/hkdf/kdf_hkdf_sha256.c new file mode 100644 index 00000000..736346b2 --- /dev/null +++ b/src/libsodium/crypto_kdf/hkdf/kdf_hkdf_sha256.c @@ -0,0 +1,96 @@ +#include +#include + +#include "crypto_auth_hmacsha256.h" +#include "crypto_kdf.h" +#include "crypto_kdf_hkdf_sha256.h" +#include "randombytes.h" +#include "utils.h" + +int +crypto_kdf_hkdf_sha256_extract( + unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES], + const unsigned char *salt, size_t salt_len, const unsigned char *ikm, + size_t ikm_len) +{ + crypto_auth_hmacsha256_state st; + + crypto_auth_hmacsha256_init(&st, salt, salt_len); + crypto_auth_hmacsha256_update(&st, ikm, ikm_len); + crypto_auth_hmacsha256_final(&st, prk); + sodium_memzero(&st, sizeof st); + + return 0; +} + +void +crypto_kdf_hkdf_sha256_keygen(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]) +{ + randombytes_buf(prk, crypto_kdf_hkdf_sha256_KEYBYTES); +} + +int +crypto_kdf_hkdf_sha256_expand(unsigned char *out, size_t out_len, + const char *ctx, size_t ctx_len, + const unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]) +{ + crypto_auth_hmacsha256_state st; + unsigned char tmp[crypto_auth_hmacsha256_BYTES]; + size_t i; + size_t left; + unsigned char counter = 1U; + + if (out_len > crypto_kdf_hkdf_sha256_BYTES_MAX) { + errno = EINVAL; + return -1; + } + for (i = (size_t) 0U; i + crypto_auth_hmacsha256_BYTES <= out_len; + i += crypto_auth_hmacsha256_BYTES) { + crypto_auth_hmacsha256_init(&st, prk, crypto_kdf_hkdf_sha256_KEYBYTES); + if (i != (size_t) 0U) { + crypto_auth_hmacsha256_update( + &st, &out[i - crypto_auth_hmacsha256_BYTES], + crypto_auth_hmacsha256_BYTES); + } + crypto_auth_hmacsha256_update(&st, + (const unsigned char *) ctx, ctx_len); + crypto_auth_hmacsha256_update(&st, &counter, (size_t) 1U); + crypto_auth_hmacsha256_final(&st, &out[i]); + counter++; + } + if ((left = out_len & (crypto_auth_hmacsha256_BYTES - 1U)) != (size_t) 0U) { + crypto_auth_hmacsha256_init(&st, prk, crypto_kdf_hkdf_sha256_KEYBYTES); + if (i != (size_t) 0U) { + crypto_auth_hmacsha256_update( + &st, &out[i - crypto_auth_hmacsha256_BYTES], + crypto_auth_hmacsha256_BYTES); + } + crypto_auth_hmacsha256_update(&st, + (const unsigned char *) ctx, ctx_len); + crypto_auth_hmacsha256_update(&st, &counter, (size_t) 1U); + crypto_auth_hmacsha256_final(&st, tmp); + memcpy(&out[i], tmp, left); + sodium_memzero(tmp, sizeof tmp); + } + sodium_memzero(&st, sizeof st); + + return 0; +} + +size_t +crypto_kdf_hkdf_sha256_keybytes(void) +{ + return crypto_kdf_hkdf_sha256_KEYBYTES; +} + +size_t +crypto_kdf_hkdf_sha256_bytes_min(void) +{ + return crypto_kdf_hkdf_sha256_BYTES_MIN; +} + +size_t +crypto_kdf_hkdf_sha256_bytes_max(void) +{ + return crypto_kdf_hkdf_sha256_BYTES_MAX; +} diff --git a/src/libsodium/crypto_kdf/hkdf/kdf_hkdf_sha512.c b/src/libsodium/crypto_kdf/hkdf/kdf_hkdf_sha512.c new file mode 100644 index 00000000..476d56be --- /dev/null +++ b/src/libsodium/crypto_kdf/hkdf/kdf_hkdf_sha512.c @@ -0,0 +1,96 @@ +#include +#include + +#include "crypto_auth_hmacsha512.h" +#include "crypto_kdf.h" +#include "crypto_kdf_hkdf_sha512.h" +#include "randombytes.h" +#include "utils.h" + +int +crypto_kdf_hkdf_sha512_extract( + unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES], + const unsigned char *salt, size_t salt_len, const unsigned char *ikm, + size_t ikm_len) +{ + crypto_auth_hmacsha512_state st; + + crypto_auth_hmacsha512_init(&st, salt, salt_len); + crypto_auth_hmacsha512_update(&st, ikm, ikm_len); + crypto_auth_hmacsha512_final(&st, prk); + sodium_memzero(&st, sizeof st); + + return 0; +} + +void +crypto_kdf_hkdf_sha512_keygen(unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES]) +{ + randombytes_buf(prk, crypto_kdf_hkdf_sha512_KEYBYTES); +} + +int +crypto_kdf_hkdf_sha512_expand(unsigned char *out, size_t out_len, + const char *ctx, size_t ctx_len, + const unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES]) +{ + crypto_auth_hmacsha512_state st; + unsigned char tmp[crypto_auth_hmacsha512_BYTES]; + size_t i; + size_t left; + unsigned char counter = 1U; + + if (out_len > crypto_kdf_hkdf_sha512_BYTES_MAX) { + errno = EINVAL; + return -1; + } + for (i = (size_t) 0U; i + crypto_auth_hmacsha512_BYTES <= out_len; + i += crypto_auth_hmacsha512_BYTES) { + crypto_auth_hmacsha512_init(&st, prk, crypto_kdf_hkdf_sha512_KEYBYTES); + if (i != (size_t) 0U) { + crypto_auth_hmacsha512_update( + &st, &out[i - crypto_auth_hmacsha512_BYTES], + crypto_auth_hmacsha512_BYTES); + } + crypto_auth_hmacsha512_update(&st, + (const unsigned char *) ctx, ctx_len); + crypto_auth_hmacsha512_update(&st, &counter, (size_t) 1U); + crypto_auth_hmacsha512_final(&st, &out[i]); + counter++; + } + if ((left = out_len & (crypto_auth_hmacsha512_BYTES - 1U)) != (size_t) 0U) { + crypto_auth_hmacsha512_init(&st, prk, crypto_kdf_hkdf_sha512_KEYBYTES); + if (i != (size_t) 0U) { + crypto_auth_hmacsha512_update( + &st, &out[i - crypto_auth_hmacsha512_BYTES], + crypto_auth_hmacsha512_BYTES); + } + crypto_auth_hmacsha512_update(&st, + (const unsigned char *) ctx, ctx_len); + crypto_auth_hmacsha512_update(&st, &counter, (size_t) 1U); + crypto_auth_hmacsha512_final(&st, tmp); + memcpy(&out[i], tmp, left); + sodium_memzero(tmp, sizeof tmp); + } + sodium_memzero(&st, sizeof st); + + return 0; +} + +size_t +crypto_kdf_hkdf_sha512_keybytes(void) +{ + return crypto_kdf_hkdf_sha512_KEYBYTES; +} + +size_t +crypto_kdf_hkdf_sha512_bytes_min(void) +{ + return crypto_kdf_hkdf_sha512_BYTES_MIN; +} + +size_t +crypto_kdf_hkdf_sha512_bytes_max(void) +{ + return crypto_kdf_hkdf_sha512_BYTES_MAX; +} diff --git a/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h b/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h index 2475bfa1..795a4244 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +++ b/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h @@ -200,7 +200,7 @@ poly1305_finish(poly1305_state_internal_t *st, unsigned char mac[16]) t0 = st->pad[0]; t1 = st->pad[1]; - h0 += ((t0) &0xfffffffffff); + h0 += ((t0) & 0xfffffffffff); c = (h0 >> 44); h0 &= 0xfffffffffff; h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff) + c; diff --git a/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c b/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c index e80c961d..961c3be0 100644 --- a/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +++ b/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c @@ -41,14 +41,14 @@ typedef struct poly1305_state_internal_t { union { uint64_t h[3]; uint32_t hh[10]; - } H; /* 40 bytes */ - uint32_t R[5]; /* 20 bytes */ - uint32_t R2[5]; /* 20 bytes */ - uint32_t R4[5]; /* 20 bytes */ - uint64_t pad[2]; /* 16 bytes */ - uint64_t flags; /* 8 bytes */ - unsigned long long leftover; /* 8 bytes */ - unsigned char buffer[poly1305_block_size]; /* 32 bytes */ + } H; /* 40 bytes */ + uint32_t R[5]; /* 20 bytes */ + uint32_t R2[5]; /* 20 bytes */ + uint32_t R4[5]; /* 20 bytes */ + uint64_t pad[2]; /* 16 bytes */ + uint64_t flags; /* 8 bytes */ + unsigned long long leftover; /* 8 bytes */ + unsigned char buffer[poly1305_block_size]; /* 32 bytes */ } poly1305_state_internal_t; /* 164 bytes total */ /* diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index 3108fb8f..af7b4b58 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -132,29 +132,6 @@ allocate_memory(block_region **region, uint32_t m_cost) /*********Memory functions*/ -/* Clears memory - * @param instance pointer to the current instance - * @param clear_memory indicates if we clear the memory with zeros. - */ -static void clear_memory(argon2_instance_t *instance, int clear); - -static void -clear_memory(argon2_instance_t *instance, int clear) -{ - /* LCOV_EXCL_START */ - if (clear) { - if (instance->region != NULL) { - sodium_memzero(instance->region->memory, - sizeof(block) * instance->memory_blocks); - } - if (instance->pseudo_rands != NULL) { - sodium_memzero(instance->pseudo_rands, - sizeof(uint64_t) * instance->segment_length); - } - } - /* LCOV_EXCL_STOP */ -} - /* Deallocates memory * @param memory pointer to the blocks */ @@ -163,7 +140,7 @@ static void free_memory(block_region *region); static void free_memory(block_region *region) { - if (region && region->base) { + if (region != NULL && region->base != NULL) { #if defined(MAP_ANON) && defined(HAVE_MMAP) if (munmap(region->base, region->size)) { return; /* LCOV_EXCL_LINE */ @@ -178,9 +155,6 @@ free_memory(block_region *region) static void argon2_free_instance(argon2_instance_t *instance, int flags) { - /* Clear memory */ - clear_memory(instance, flags & ARGON2_FLAG_CLEAR_MEMORY); - /* Deallocate the memory */ free(instance->pseudo_rands); instance->pseudo_rands = NULL; diff --git a/src/libsodium/crypto_pwhash/argon2/argon2.h b/src/libsodium/crypto_pwhash/argon2/argon2.h index 264a35e5..a6a8d861 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2.h +++ b/src/libsodium/crypto_pwhash/argon2/argon2.h @@ -70,7 +70,6 @@ #define ARGON2_FLAG_CLEAR_PASSWORD (UINT32_C(1) << 0) #define ARGON2_FLAG_CLEAR_SECRET (UINT32_C(1) << 1) -#define ARGON2_FLAG_CLEAR_MEMORY (UINT32_C(1) << 2) #define ARGON2_DEFAULT_FLAGS (UINT32_C(0)) /* Error codes */ diff --git a/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c b/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c index 4272ae24..9eaf0235 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +++ b/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c @@ -123,7 +123,7 @@ crypto_scalarmult_curve25519_ref10(unsigned char *q, fe25519_mul(x2, tmp1, tmp0); fe25519_sub(tmp1, tmp1, tmp0); fe25519_sq(z2, z2); - fe25519_scalar_product(z3, tmp1, 121666); + fe25519_mul32(z3, tmp1, 121666); fe25519_sq(x3, x3); fe25519_add(tmp0, tmp0, z3); fe25519_mul(z3, x1, z2); diff --git a/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c b/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c deleted file mode 100644 index 64ded79e..00000000 --- a/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +++ /dev/null @@ -1,118 +0,0 @@ - -#include -#include -#include - -#include "crypto_hash_sha512.h" -#include "crypto_sign_edwards25519sha512batch.h" -#include "crypto_verify_32.h" -#include "private/ed25519_ref10.h" -#include "randombytes.h" -#include "utils.h" - -/* LCOV_EXCL_START */ -int -crypto_sign_edwards25519sha512batch_keypair(unsigned char *pk, - unsigned char *sk) -{ - ge25519_p3 A; - - randombytes_buf(sk, 32); - crypto_hash_sha512(sk, sk, 32); - sk[0] &= 248; - sk[31] &= 127; - sk[31] |= 64; - ge25519_scalarmult_base(&A, sk); - ge25519_p3_tobytes(pk, &A); - - return 0; -} - -int -crypto_sign_edwards25519sha512batch(unsigned char *sm, - unsigned long long *smlen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *sk) -{ - crypto_hash_sha512_state hs; - unsigned char nonce[64]; - unsigned char hram[64]; - unsigned char sig[64]; - ge25519_p3 A; - ge25519_p3 R; - - crypto_hash_sha512_init(&hs); - crypto_hash_sha512_update(&hs, sk + 32, 32); - crypto_hash_sha512_update(&hs, m, mlen); - crypto_hash_sha512_final(&hs, nonce); - ge25519_scalarmult_base(&A, sk); - ge25519_p3_tobytes(sig + 32, &A); - sc25519_reduce(nonce); - ge25519_scalarmult_base(&R, nonce); - ge25519_p3_tobytes(sig, &R); - crypto_hash_sha512_init(&hs); - crypto_hash_sha512_update(&hs, sig, 32); - crypto_hash_sha512_update(&hs, m, mlen); - crypto_hash_sha512_final(&hs, hram); - sc25519_reduce(hram); - sc25519_muladd(sig + 32, hram, nonce, sk); - sodium_memzero(hram, sizeof hram); - memmove(sm + 32, m, (size_t) mlen); - memcpy(sm, sig, 32); - memcpy(sm + 32 + mlen, sig + 32, 32); - *smlen_p = mlen + 64U; - - return 0; -} - -int -crypto_sign_edwards25519sha512batch_open(unsigned char *m, - unsigned long long *mlen_p, - const unsigned char *sm, - unsigned long long smlen, - const unsigned char *pk) -{ - unsigned char h[64]; - unsigned char t1[32], t2[32]; - unsigned long long mlen; - ge25519_cached Ai; - ge25519_p1p1 csa; - ge25519_p2 cs; - ge25519_p3 A; - ge25519_p3 R; - ge25519_p3 cs3; - - *mlen_p = 0; - if (smlen < 64 || smlen - 64 > crypto_sign_edwards25519sha512batch_MESSAGEBYTES_MAX) { - return -1; - } - mlen = smlen - 64; - if (sm[smlen - 1] & 224) { - return -1; - } - if (ge25519_has_small_order(pk) != 0 || - ge25519_frombytes_negate_vartime(&A, pk) != 0 || - ge25519_has_small_order(sm) != 0 || - ge25519_frombytes_negate_vartime(&R, sm) != 0) { - return -1; - } - ge25519_p3_to_cached(&Ai, &A); - crypto_hash_sha512(h, sm, mlen + 32); - sc25519_reduce(h); - ge25519_scalarmult(&cs3, h, &R); - ge25519_add(&csa, &cs3, &Ai); - ge25519_p1p1_to_p2(&cs, &csa); - ge25519_tobytes(t1, &cs); - t1[31] ^= 1 << 7; - ge25519_scalarmult_base(&R, sm + 32 + mlen); - ge25519_p3_tobytes(t2, &R); - if (crypto_verify_32(t1, t2) != 0) { - return -1; - } - *mlen_p = mlen; - memmove(m, sm + 32, mlen); - - return 0; -} -/* LCOV_EXCL_END */ diff --git a/src/libsodium/crypto_verify/sodium/verify.c b/src/libsodium/crypto_verify/sodium/verify.c index ffebf220..2dfa7121 100644 --- a/src/libsodium/crypto_verify/sodium/verify.c +++ b/src/libsodium/crypto_verify/sodium/verify.c @@ -5,6 +5,7 @@ #include "crypto_verify_16.h" #include "crypto_verify_32.h" #include "crypto_verify_64.h" +#include "private/common.h" size_t crypto_verify_16_bytes(void) diff --git a/src/libsodium/include/Makefile.am b/src/libsodium/include/Makefile.am index 7a779e1a..b9978776 100644 --- a/src/libsodium/include/Makefile.am +++ b/src/libsodium/include/Makefile.am @@ -27,6 +27,8 @@ SODIUM_EXPORT = \ sodium/crypto_hash_sha512.h \ sodium/crypto_kdf.h \ sodium/crypto_kdf_blake2b.h \ + sodium/crypto_kdf_hkdf_sha256.h \ + sodium/crypto_kdf_hkdf_sha512.h \ sodium/crypto_kx.h \ sodium/crypto_onetimeauth.h \ sodium/crypto_onetimeauth_poly1305.h \ @@ -46,7 +48,6 @@ SODIUM_EXPORT = \ sodium/crypto_shorthash_siphash24.h \ sodium/crypto_sign.h \ sodium/crypto_sign_ed25519.h \ - sodium/crypto_sign_edwards25519sha512batch.h \ sodium/crypto_stream.h \ sodium/crypto_stream_chacha20.h \ sodium/crypto_stream_salsa20.h \ diff --git a/src/libsodium/include/sodium.h b/src/libsodium/include/sodium.h index b881f574..e0ffedf2 100644 --- a/src/libsodium/include/sodium.h +++ b/src/libsodium/include/sodium.h @@ -58,6 +58,8 @@ # include "sodium/crypto_box_curve25519xchacha20poly1305.h" # include "sodium/crypto_core_ed25519.h" # include "sodium/crypto_core_ristretto255.h" +# include "sodium/crypto_kdf_hkdf_sha256.h" +# include "sodium/crypto_kdf_hkdf_sha512.h" # include "sodium/crypto_scalarmult_ed25519.h" # include "sodium/crypto_scalarmult_ristretto255.h" # include "sodium/crypto_secretbox_xchacha20poly1305.h" diff --git a/src/libsodium/include/sodium/crypto_box.h b/src/libsodium/include/sodium/crypto_box.h index e060dd29..0008e020 100644 --- a/src/libsodium/include/sodium/crypto_box.h +++ b/src/libsodium/include/sodium/crypto_box.h @@ -141,34 +141,34 @@ int crypto_box_seal_open(unsigned char *m, const unsigned char *c, #define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES SODIUM_EXPORT -size_t crypto_box_zerobytes(void); +size_t crypto_box_zerobytes(void) __attribute__ ((deprecated)); #define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES SODIUM_EXPORT -size_t crypto_box_boxzerobytes(void); +size_t crypto_box_boxzerobytes(void) __attribute__ ((deprecated)); SODIUM_EXPORT int crypto_box(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *pk, const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6))); + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6))); SODIUM_EXPORT int crypto_box_open(unsigned char *m, const unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *pk, const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6))); + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6))); SODIUM_EXPORT int crypto_box_afternm(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, - const unsigned char *k) __attribute__ ((nonnull(1, 4, 5))); + const unsigned char *k) __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5))); SODIUM_EXPORT int crypto_box_open_afternm(unsigned char *m, const unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); + __attribute__ ((warn_unused_result)) __attribute__ ((deprecated)) __attribute__ ((nonnull(2, 4, 5))); #ifdef __cplusplus } diff --git a/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h b/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h index e733f499..2c9b5d6e 100644 --- a/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +++ b/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h @@ -69,7 +69,8 @@ size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void); (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \ crypto_box_curve25519xsalsa20poly1305_MACBYTES) SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void); +size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void) + __attribute__ ((deprecated)); SODIUM_EXPORT int crypto_box_curve25519xsalsa20poly1305(unsigned char *c, @@ -78,7 +79,7 @@ int crypto_box_curve25519xsalsa20poly1305(unsigned char *c, const unsigned char *n, const unsigned char *pk, const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6))); + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6))); SODIUM_EXPORT int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m, @@ -87,7 +88,7 @@ int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m, const unsigned char *n, const unsigned char *pk, const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6))); + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6))); SODIUM_EXPORT int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c, @@ -95,7 +96,7 @@ int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c, unsigned long long mlen, const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull(1, 4, 5))); + __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5))); SODIUM_EXPORT int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m, @@ -103,7 +104,7 @@ int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m, unsigned long long clen, const unsigned char *n, const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); #ifdef __cplusplus } diff --git a/src/libsodium/include/sodium/crypto_core_ed25519.h b/src/libsodium/include/sodium/crypto_core_ed25519.h index 3eae00c4..3aeb538a 100644 --- a/src/libsodium/include/sodium/crypto_core_ed25519.h +++ b/src/libsodium/include/sodium/crypto_core_ed25519.h @@ -47,8 +47,16 @@ int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r) __attribute__ ((nonnull)); SODIUM_EXPORT -int crypto_core_ed25519_from_hash(unsigned char *p, const unsigned char *h) - __attribute__ ((nonnull)); +int crypto_core_ed25519_from_string(unsigned char p[crypto_core_ed25519_BYTES], + const char *ctx, const unsigned char *msg, + size_t msg_len) + __attribute__ ((nonnull(1))); + +SODIUM_EXPORT +int crypto_core_ed25519_from_string_ro(unsigned char p[crypto_core_ed25519_BYTES], + const char *ctx, const unsigned char *msg, + size_t msg_len) + __attribute__ ((nonnull(1))); SODIUM_EXPORT void crypto_core_ed25519_random(unsigned char *p) diff --git a/src/libsodium/include/sodium/crypto_kdf_blake2b.h b/src/libsodium/include/sodium/crypto_kdf_blake2b.h index 3ae47dd3..489c7c20 100644 --- a/src/libsodium/include/sodium/crypto_kdf_blake2b.h +++ b/src/libsodium/include/sodium/crypto_kdf_blake2b.h @@ -3,8 +3,8 @@ #include #include +#include -#include "crypto_kdf_blake2b.h" #include "export.h" #ifdef __cplusplus diff --git a/src/libsodium/include/sodium/crypto_kdf_hkdf_sha256.h b/src/libsodium/include/sodium/crypto_kdf_hkdf_sha256.h new file mode 100644 index 00000000..899a6316 --- /dev/null +++ b/src/libsodium/include/sodium/crypto_kdf_hkdf_sha256.h @@ -0,0 +1,48 @@ +#ifndef crypto_kdf_hkdf_sha256_H +#define crypto_kdf_hkdf_sha256_H + +#include +#include +#include + +#include "crypto_kdf.h" +#include "crypto_auth_hmacsha256.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_kdf_hkdf_sha256_KEYBYTES crypto_auth_hmacsha256_BYTES +SODIUM_EXPORT +size_t crypto_kdf_hkdf_sha256_keybytes(void); + +#define crypto_kdf_hkdf_sha256_BYTES_MIN 0U +SODIUM_EXPORT +size_t crypto_kdf_hkdf_sha256_bytes_min(void); + +#define crypto_kdf_hkdf_sha256_BYTES_MAX (0xff * crypto_auth_hmacsha256_BYTES) +SODIUM_EXPORT +size_t crypto_kdf_hkdf_sha256_bytes_max(void); + +SODIUM_EXPORT +int crypto_kdf_hkdf_sha256_extract(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES], + const unsigned char *salt, size_t salt_len, + const unsigned char *ikm, size_t ikm_len); + +SODIUM_EXPORT +void crypto_kdf_hkdf_sha256_keygen(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]); + +SODIUM_EXPORT +int crypto_kdf_hkdf_sha256_expand(unsigned char *out, size_t out_len, + const char *ctx, size_t ctx_len, + const unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/libsodium/include/sodium/crypto_kdf_hkdf_sha512.h b/src/libsodium/include/sodium/crypto_kdf_hkdf_sha512.h new file mode 100644 index 00000000..3fa6868c --- /dev/null +++ b/src/libsodium/include/sodium/crypto_kdf_hkdf_sha512.h @@ -0,0 +1,51 @@ +#ifndef crypto_kdf_hkdf_sha512_H +#define crypto_kdf_hkdf_sha512_H + +#include +#include +#include + +#include "crypto_kdf.h" +#include "crypto_auth_hmacsha512.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_kdf_hkdf_sha512_KEYBYTES crypto_auth_hmacsha512_BYTES +SODIUM_EXPORT +size_t crypto_kdf_hkdf_sha512_keybytes(void); + +#define crypto_kdf_hkdf_sha512_BYTES_MIN 0U +SODIUM_EXPORT +size_t crypto_kdf_hkdf_sha512_bytes_min(void); + +#define crypto_kdf_hkdf_sha512_BYTES_MAX (0xff * crypto_auth_hmacsha512_BYTES) +SODIUM_EXPORT +size_t crypto_kdf_hkdf_sha512_bytes_max(void); + +SODIUM_EXPORT +int crypto_kdf_hkdf_sha512_extract(unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES], + const unsigned char *salt, size_t salt_len, + const unsigned char *ikm, size_t ikm_len) + __attribute__ ((nonnull(1))); + +SODIUM_EXPORT +void crypto_kdf_hkdf_sha512_keygen(unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES]) + __attribute__ ((nonnull)); + +SODIUM_EXPORT +int crypto_kdf_hkdf_sha512_expand(unsigned char *out, size_t out_len, + const char *ctx, size_t ctx_len, + const unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES]) + __attribute__ ((nonnull(1))); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/libsodium/include/sodium/crypto_secretbox.h b/src/libsodium/include/sodium/crypto_secretbox.h index 1d3709db..68024b45 100644 --- a/src/libsodium/include/sodium/crypto_secretbox.h +++ b/src/libsodium/include/sodium/crypto_secretbox.h @@ -69,22 +69,23 @@ void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES]) #define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES SODIUM_EXPORT -size_t crypto_secretbox_zerobytes(void); +size_t crypto_secretbox_zerobytes(void) __attribute__ ((deprecated)); #define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES SODIUM_EXPORT -size_t crypto_secretbox_boxzerobytes(void); +size_t crypto_secretbox_boxzerobytes(void) __attribute__ ((deprecated)); SODIUM_EXPORT int crypto_secretbox(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, - const unsigned char *k) __attribute__ ((nonnull(1, 4, 5))); + const unsigned char *k) + __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5))); SODIUM_EXPORT int crypto_secretbox_open(unsigned char *m, const unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); #ifdef __cplusplus } diff --git a/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h b/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h index be0874cb..81bff3d6 100644 --- a/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +++ b/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h @@ -30,22 +30,6 @@ size_t crypto_secretbox_xsalsa20poly1305_macbytes(void); SODIUM_EXPORT size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max(void); -SODIUM_EXPORT -int crypto_secretbox_xsalsa20poly1305(unsigned char *c, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull(1, 4, 5))); - -SODIUM_EXPORT -int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m, - const unsigned char *c, - unsigned long long clen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); - SODIUM_EXPORT void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES]) __attribute__ ((nonnull)); @@ -54,13 +38,31 @@ void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_x #define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void); +size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void) + __attribute__ ((deprecated)); #define crypto_secretbox_xsalsa20poly1305_ZEROBYTES \ (crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + \ crypto_secretbox_xsalsa20poly1305_MACBYTES) SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void); +size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +int crypto_secretbox_xsalsa20poly1305(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5))); + +SODIUM_EXPORT +int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); #ifdef __cplusplus } diff --git a/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h b/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h deleted file mode 100644 index eed158aa..00000000 --- a/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef crypto_sign_edwards25519sha512batch_H -#define crypto_sign_edwards25519sha512batch_H - -/* - * WARNING: This construction was a prototype, which should not be used - * any more in new projects. - * - * crypto_sign_edwards25519sha512batch is provided for applications - * initially built with NaCl, but as recommended by the author of this - * construction, new applications should use ed25519 instead. - * - * In Sodium, you should use the high-level crypto_sign_*() functions instead. - */ - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_sign_edwards25519sha512batch_BYTES 64U -#define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES 32U -#define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES (32U + 32U) -#define crypto_sign_edwards25519sha512batch_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_edwards25519sha512batch_BYTES) - -SODIUM_EXPORT -int crypto_sign_edwards25519sha512batch(unsigned char *sm, - unsigned long long *smlen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *sk) - __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 5))); - -SODIUM_EXPORT -int crypto_sign_edwards25519sha512batch_open(unsigned char *m, - unsigned long long *mlen_p, - const unsigned char *sm, - unsigned long long smlen, - const unsigned char *pk) - __attribute__ ((deprecated)) __attribute__ ((nonnull(3, 5))); - -SODIUM_EXPORT -int crypto_sign_edwards25519sha512batch_keypair(unsigned char *pk, - unsigned char *sk) - __attribute__ ((deprecated)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libsodium/include/sodium/private/ed25519_ref10_fe_25_5.h b/src/libsodium/include/sodium/private/ed25519_ref10_fe_25_5.h index a20801f4..8515f5e4 100644 --- a/src/libsodium/include/sodium/private/ed25519_ref10_fe_25_5.h +++ b/src/libsodium/include/sodium/private/ed25519_ref10_fe_25_5.h @@ -148,29 +148,35 @@ fe25519_neg(fe25519 h, const fe25519 f) static void fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b) { - const uint32_t mask = (uint32_t) (-(int32_t) b); + uint32_t mask = (uint32_t) (-(int32_t) b); + int32_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; + int32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; + f5 = f[5]; + f6 = f[6]; + f7 = f[7]; + f8 = f[8]; + f9 = f[9]; - int32_t x0 = f0 ^ g[0]; - int32_t x1 = f1 ^ g[1]; - int32_t x2 = f2 ^ g[2]; - int32_t x3 = f3 ^ g[3]; - int32_t x4 = f4 ^ g[4]; - int32_t x5 = f5 ^ g[5]; - int32_t x6 = f6 ^ g[6]; - int32_t x7 = f7 ^ g[7]; - int32_t x8 = f8 ^ g[8]; - int32_t x9 = f9 ^ g[9]; + x0 = f0 ^ g[0]; + x1 = f1 ^ g[1]; + x2 = f2 ^ g[2]; + x3 = f3 ^ g[3]; + x4 = f4 ^ g[4]; + x5 = f5 ^ g[5]; + x6 = f6 ^ g[6]; + x7 = f7 ^ g[7]; + x8 = f8 ^ g[8]; + x9 = f9 ^ g[9]; + +#ifdef HAVE_INLINE_ASM + __asm__ __volatile__("" : "+r"(mask)); +#endif x0 &= mask; x1 &= mask; @@ -198,40 +204,47 @@ fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b) static void fe25519_cswap(fe25519 f, fe25519 g, unsigned int b) { - const uint32_t mask = (uint32_t) (-(int64_t) b); + uint32_t mask = (uint32_t) (-(int64_t) b); + int32_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; + int32_t g0, g1, g2, g3, g4, g5, g6, g7, g8, g9; + int32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9; - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; + f5 = f[5]; + f6 = f[6]; + f7 = f[7]; + f8 = f[8]; + f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; + g0 = g[0]; + g1 = g[1]; + g2 = g[2]; + g3 = g[3]; + g4 = g[4]; + g5 = g[5]; + g6 = g[6]; + g7 = g[7]; + g8 = g[8]; + g9 = g[9]; - int32_t x0 = f0 ^ g0; - int32_t x1 = f1 ^ g1; - int32_t x2 = f2 ^ g2; - int32_t x3 = f3 ^ g3; - int32_t x4 = f4 ^ g4; - int32_t x5 = f5 ^ g5; - int32_t x6 = f6 ^ g6; - int32_t x7 = f7 ^ g7; - int32_t x8 = f8 ^ g8; - int32_t x9 = f9 ^ g9; + x0 = f0 ^ g0; + x1 = f1 ^ g1; + x2 = f2 ^ g2; + x3 = f3 ^ g3; + x4 = f4 ^ g4; + x5 = f5 ^ g5; + x6 = f6 ^ g6; + x7 = f7 ^ g7; + x8 = f8 ^ g8; + x9 = f9 ^ g9; + +#ifdef HAVE_INLINE_ASM + __asm__ __volatile__("" : "+r"(mask)); +#endif x0 &= mask; x1 &= mask; @@ -274,27 +287,7 @@ fe25519_cswap(fe25519 f, fe25519 g, unsigned int b) static inline void fe25519_copy(fe25519 h, const fe25519 f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - - h[0] = f0; - h[1] = f1; - h[2] = f2; - h[3] = f3; - h[4] = f4; - h[5] = f5; - h[6] = f6; - h[7] = f7; - h[8] = f8; - h[9] = f9; + memcpy(h, f, 10 * 4); } /* @@ -979,8 +972,8 @@ fe25519_sq2(fe25519 h, const fe25519 f) h[9] = (int32_t) h9; } -static void -fe25519_scalar_product(fe25519 h, const fe25519 f, uint32_t n) +static inline void +fe25519_mul32(fe25519 h, const fe25519 f, uint32_t n) { int64_t sn = (int64_t) n; int32_t f0 = f[0]; diff --git a/src/libsodium/include/sodium/private/ed25519_ref10_fe_51.h b/src/libsodium/include/sodium/private/ed25519_ref10_fe_51.h index 6a5c0121..dfa55a92 100644 --- a/src/libsodium/include/sodium/private/ed25519_ref10_fe_51.h +++ b/src/libsodium/include/sodium/private/ed25519_ref10_fe_51.h @@ -109,19 +109,50 @@ fe25519_neg(fe25519 h, const fe25519 f) static void fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b) { - const uint64_t mask = (uint64_t) (-(int64_t) b); +#ifdef HAVE_AMD64_ASM + uint64_t t0, t1, t2; - uint64_t f0 = f[0]; - uint64_t f1 = f[1]; - uint64_t f2 = f[2]; - uint64_t f3 = f[3]; - uint64_t f4 = f[4]; + __asm__ __volatile__ + ( + "test %[c], %[c]\n" + "movq (%[b]), %[t0]\n" + "cmoveq (%[a]), %[t0]\n" + "movq 8(%[b]), %[t1]\n" + "cmoveq 8(%[a]), %[t1]\n" + "movq 16(%[b]), %[t2]\n" + "cmoveq 16(%[a]), %[t2]\n" + "movq %[t0], (%[a])\n" + "movq %[t1], 8(%[a])\n" + "movq 24(%[b]), %[t0]\n" + "cmoveq 24(%[a]), %[t0]\n" + "movq 32(%[b]), %[t1]\n" + "cmoveq 32(%[a]), %[t1]\n" + "movq %[t2], 16(%[a])\n" + "movq %[t0], 24(%[a])\n" + "movq %[t1], 32(%[a])\n" + : [ t0 ] "=&r"(t0), [ t1 ] "=&r"(t1), [ t2 ] "=&r"(t2) + : [ a ] "r"(f), [ b ] "r"(g), [ c ] "r"(b) + : "cc"); +#else + uint64_t mask = (uint64_t) (-(int64_t) b); + uint64_t f0, f1, f2, f3, f4; + uint64_t x0, x1, x2, x3, x4; - uint64_t x0 = f0 ^ g[0]; - uint64_t x1 = f1 ^ g[1]; - uint64_t x2 = f2 ^ g[2]; - uint64_t x3 = f3 ^ g[3]; - uint64_t x4 = f4 ^ g[4]; + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; + + x0 = f0 ^ g[0]; + x1 = f1 ^ g[1]; + x2 = f2 ^ g[2]; + x3 = f3 ^ g[3]; + x4 = f4 ^ g[4]; + +# ifdef HAVE_INLINE_ASM + __asm__ __volatile__("" : "+r"(mask)); +# endif x0 &= mask; x1 &= mask; @@ -134,6 +165,7 @@ fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b) f[2] = f2 ^ x2; f[3] = f3 ^ x3; f[4] = f4 ^ x4; +#endif } /* @@ -146,25 +178,32 @@ Preconditions: b in {0,1}. static void fe25519_cswap(fe25519 f, fe25519 g, unsigned int b) { - const uint64_t mask = (uint64_t) (-(int64_t) b); + uint64_t mask = (uint64_t) (-(int64_t) b); + uint64_t f0, f1, f2, f3, f4; + uint64_t g0, g1, g2, g3, g4; + uint64_t x0, x1, x2, x3, x4; - uint64_t f0 = f[0]; - uint64_t f1 = f[1]; - uint64_t f2 = f[2]; - uint64_t f3 = f[3]; - uint64_t f4 = f[4]; + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; - uint64_t g0 = g[0]; - uint64_t g1 = g[1]; - uint64_t g2 = g[2]; - uint64_t g3 = g[3]; - uint64_t g4 = g[4]; + g0 = g[0]; + g1 = g[1]; + g2 = g[2]; + g3 = g[3]; + g4 = g[4]; - uint64_t x0 = f0 ^ g0; - uint64_t x1 = f1 ^ g1; - uint64_t x2 = f2 ^ g2; - uint64_t x3 = f3 ^ g3; - uint64_t x4 = f4 ^ g4; + x0 = f0 ^ g0; + x1 = f1 ^ g1; + x2 = f2 ^ g2; + x3 = f3 ^ g3; + x4 = f4 ^ g4; + +# ifdef HAVE_INLINE_ASM + __asm__ __volatile__("" : "+r"(mask)); +# endif x0 &= mask; x1 &= mask; @@ -192,17 +231,7 @@ fe25519_cswap(fe25519 f, fe25519 g, unsigned int b) static inline void fe25519_copy(fe25519 h, const fe25519 f) { - uint64_t f0 = f[0]; - uint64_t f1 = f[1]; - uint64_t f2 = f[2]; - uint64_t f3 = f[3]; - uint64_t f4 = f[4]; - - h[0] = f0; - h[1] = f1; - h[2] = f2; - h[3] = f3; - h[4] = f4; + memcpy(h, f, 5 * 8); } /* @@ -490,8 +519,8 @@ fe25519_sq2(fe25519 h, const fe25519 f) h[4] = r04; } -static void -fe25519_scalar_product(fe25519 h, const fe25519 f, uint32_t n) +static inline void +fe25519_mul32(fe25519 h, const fe25519 f, uint32_t n) { const uint64_t mask = 0x7ffffffffffffULL; uint128_t a; diff --git a/src/libsodium/include/sodium/utils.h b/src/libsodium/include/sodium/utils.h index 14a00894..ac801512 100644 --- a/src/libsodium/include/sodium/utils.h +++ b/src/libsodium/include/sodium/utils.h @@ -158,12 +158,6 @@ int sodium_mprotect_readonly(void *ptr) __attribute__ ((nonnull)); SODIUM_EXPORT int sodium_mprotect_readwrite(void *ptr) __attribute__ ((nonnull)); -SODIUM_EXPORT -int sodium_mshield(void *ptr) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int sodium_munshield(void *ptr) __attribute__ ((nonnull)); - SODIUM_EXPORT int sodium_pad(size_t *padded_buflen_p, unsigned char *buf, size_t unpadded_buflen, size_t blocksize, size_t max_buflen) diff --git a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c index 6657e8e6..ffe35c7c 100644 --- a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +++ b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c @@ -1,4 +1,3 @@ - #include #include #include diff --git a/src/libsodium/sodium/core.c b/src/libsodium/sodium/core.c index 7a6943d1..ba875855 100644 --- a/src/libsodium/sodium/core.c +++ b/src/libsodium/sodium/core.c @@ -151,7 +151,9 @@ sodium_crit_enter(void) # ifdef HAVE_NANOSLEEP (void) nanosleep(&q, NULL); # elif defined(__x86_64__) || defined(__i386__) - __asm__ __volatile__ ("pause"); + __asm__ __volatile__ ("pause":::"memory"); +# elif defined(__aarch64__) + __asm__ __volatile__ ("yield":::"memory"); # endif } return 0; diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index cd88e2f6..0604b284 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -61,8 +61,6 @@ void *alloca (size_t); #define CANARY_SIZE 16U #define GARBAGE_VALUE 0xdb -#define SHIELDING_PREKEY_SIZE 16384U - #ifndef MAP_NOCORE # ifdef MAP_CONCEAL # define MAP_NOCORE MAP_CONCEAL @@ -100,7 +98,6 @@ void *alloca (size_t); static size_t page_size = DEFAULT_PAGE_SIZE; static unsigned char canary[CANARY_SIZE]; -static unsigned char shielding_prekey[SHIELDING_PREKEY_SIZE]; /* LCOV_EXCL_START */ #ifdef HAVE_WEAK_SYMBOLS @@ -418,11 +415,7 @@ _sodium_alloc_init(void) sodium_misuse(); /* LCOV_EXCL_LINE */ } #endif - COMPILER_ASSERT(sizeof shielding_prekey >= randombytes_SEEDBYTES); - randombytes_buf(shielding_prekey, randombytes_SEEDBYTES); - randombytes_buf_deterministic(canary, sizeof canary, shielding_prekey); - shielding_prekey[0] ^= 0x01; - randombytes_buf_deterministic(shielding_prekey, sizeof shielding_prekey, shielding_prekey); + randombytes_buf(canary, CANARY_SIZE); return 0; } @@ -735,48 +728,6 @@ sodium_mprotect_readwrite(void *ptr) return _sodium_mprotect(ptr, _mprotect_readwrite); } -#ifndef HAVE_PAGE_PROTECTION -int -sodium_mshield(void *ptr) -{ - (void) ptr; - errno = ENOSYS; - return -1; -} -#else -int -sodium_mshield(void *ptr) -{ - unsigned char shielding_key[crypto_stream_KEYBYTES]; - unsigned char nonce[crypto_stream_NONCEBYTES]; - unsigned char *base_ptr; - unsigned char *unprotected_ptr; - size_t unprotected_size; - - unprotected_ptr = _unprotected_ptr_from_user_ptr(ptr); - base_ptr = unprotected_ptr - page_size * 2U; - memcpy(&unprotected_size, base_ptr, sizeof unprotected_size); - - crypto_generichash(shielding_key, sizeof shielding_key, - shielding_prekey, sizeof shielding_prekey, NULL, 0); - COMPILER_ASSERT(sizeof nonce >= (sizeof unprotected_ptr) + (sizeof unprotected_size)); - memset(nonce, 0, sizeof nonce); - memcpy(nonce, &unprotected_ptr, sizeof unprotected_ptr); - memcpy(nonce + sizeof unprotected_ptr, &unprotected_size, sizeof unprotected_size); - crypto_stream_xor(unprotected_ptr, unprotected_ptr, unprotected_size, nonce, shielding_key); - sodium_memzero(shielding_key, sizeof shielding_key); - sodium_memzero(nonce, sizeof nonce); - - return 0; -} -#endif - -int -sodium_munshield(void *ptr) -{ - return sodium_mshield(ptr); -} - int sodium_pad(size_t *padded_buflen_p, unsigned char *buf, size_t unpadded_buflen, size_t blocksize, size_t max_buflen) diff --git a/test/constcheck.sh b/test/constcheck.sh index 994c1642..7beef1ba 100755 --- a/test/constcheck.sh +++ b/test/constcheck.sh @@ -6,8 +6,7 @@ echo '#include ' > "$CT" echo '#include ' >> "$CT" echo 'int main(void) {' >> "$CT" for macro in $(egrep -r '#define crypto_.*BYTES(_[A-Z]+)? ' src/libsodium/include | \ - cut -d: -f2- | cut -d' ' -f2 | \ - fgrep -v edwards25519sha512batch | sort -u); do + cut -d: -f2- | cut -d' ' -f2 | sort -u); do func=$(echo "$macro" | tr A-Z a-z) echo " assert($func() == $macro);" >> "$CT" done diff --git a/test/default/Makefile.am b/test/default/Makefile.am index 4d32c1ca..147982ae 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -27,6 +27,7 @@ EXTRA_DIST = \ chacha20.exp \ codecs.exp \ core_ed25519.exp \ + core_ed25519_h2c.exp \ core_ristretto255.exp \ core1.exp \ core2.exp \ @@ -42,6 +43,7 @@ EXTRA_DIST = \ hash2.exp \ hash3.exp \ kdf.exp \ + kdf_hkdf.exp \ keygen.exp \ kx.exp \ metamorphic.exp \ @@ -108,6 +110,7 @@ DISTCLEANFILES = \ chacha20.res \ codecs.res \ core_ed25519.res \ + core_ed25519_h2c.res \ core_ristretto255.res \ core1.res \ core2.res \ @@ -123,6 +126,7 @@ DISTCLEANFILES = \ hash2.res \ hash3.res \ kdf.res \ + kdf_hkdf.res \ keygen.res \ kx.res \ metamorphic.res \ @@ -327,6 +331,9 @@ codecs_LDADD = $(TESTS_LDADD) core_ed25519_SOURCE = cmptest.h core_ed25519.c core_ed25519_LDADD = $(TESTS_LDADD) +core_ed25519_h2c_SOURCE = cmptest.h core_ed25519_h2c.c +core_ed25519_h2c_LDADD = $(TESTS_LDADD) + core_ristretto255_SOURCE = cmptest.h core_ristretto255.c core_ristretto255_LDADD = $(TESTS_LDADD) @@ -369,6 +376,9 @@ hash3_LDADD = $(TESTS_LDADD) kdf_SOURCE = cmptest.h kdf.c kdf_LDADD = $(TESTS_LDADD) +kdf_hkdf_SOURCE = cmptest.h kdf_hkdf.c +kdf_hkdf_LDADD = $(TESTS_LDADD) + keygen_SOURCE = cmptest.h keygen.c keygen_LDADD = $(TESTS_LDADD) @@ -495,7 +505,9 @@ xchacha20_LDADD = $(TESTS_LDADD) if !MINIMAL TESTS_TARGETS += \ core_ed25519 \ + core_ed25519_h2c \ core_ristretto255 \ + kdf_hkdf \ pwhash_scrypt \ pwhash_scrypt_ll \ scalarmult_ed25519 \ diff --git a/test/default/chacha20.c b/test/default/chacha20.c index d92b11e8..8b88745a 100644 --- a/test/default/chacha20.c +++ b/test/default/chacha20.c @@ -137,7 +137,7 @@ void tv_ietf(void) assert(66 <= sizeof out); for (plen = 1U; plen < 66; plen += 3) { memset(out, (int) (plen & 0xff), sizeof out); - crypto_stream_chacha20(out, plen, nonce, key); + crypto_stream_chacha20_ietf(out, plen, nonce, key); sodium_bin2hex(out_hex, sizeof out_hex, out, sizeof out); printf("[%s]\n", out_hex); } diff --git a/test/default/chacha20.exp b/test/default/chacha20.exp index 1b2017c7..aafaf29c 100644 --- a/test/default/chacha20.exp +++ b/test/default/chacha20.exp @@ -36,28 +36,28 @@ [c2c64d378cd536374ae204b9ef933fcd1a8b2288b3dfa49672ab765b54ee27c78a970e0e955c14f3a88e741b97c286f75f8fc299e8148362fa198a39531bed6d1a91288c874ec254f322c2a197340c55bb3e9b3998f7de2309486a0bb494abd20c9c5ef99c1370d61e77f408ac5514f49202bcc6828d45409d2d1416f8ae106b06ebd2541256264fa415bd54cb12e1d4449ed85299a1b7a249b75ff6c89b2e3f] [10f1e7e4d13b5915500fdd1fa32071c4c7d1f4c733c068030422aa9ac3d46c4ed2826446079faa0914c2d705d98b02a2b5129cd1de164eb9cbd083e8a2503c4e0a88837739d7bf4ef8ccacb0ea2bb9d69d56c394aa351dfda5bf459f0a2e9fe8e721f89255f9c486bf21679c683d4f9c5cf2fa27865526005b06ca374c86af3bdcbfbdcb83be65862ed5c20eae5a43241d6a92da6dca9a156be25297f51c2718] [75924bad7831b25662dbac54b46827990b6168ae990e7bd7e1fd2ad282bf23ef052c7d1a0a6c1ef862070943a0d4da24705fbc006dfb85e2af18c0a264d772a44c70fbedac9d6a6867ff6be0a32826507f2c784101583211c9e2453d4cc8b283d5e86682bd4bf511271b91dbd351415f5a009d1f78b64085a9a4341be7d42e2679d57e2747097f0129950e2c9e9ca1356022d45da252af71ac37f351a2e77911] -[61010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101] -[6146f256040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404] -[6146f2564fe1bd070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707] -[6146f2564fe1bdf9bccd0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a] -[6146f2564fe1bdf9bccd0fe1ed0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d] -[6146f2564fe1bdf9bccd0fe1edf0da5d101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb00161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af1021c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7081f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f6222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c2973032e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c297303ace1e2313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c297303ace1e2e34130343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c297303ace1e2e3413018ff7e373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c297303ace1e2e3413018ff7ed87cfa3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c297303ace1e2e3413018ff7ed87cfa95b60f3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d] -[6146f2564fe1bdf9bccd0fe1edf0da5d92f1fa76cb002937ba9af10230a7085f55f67bf6ab410fba060c2c297303ace1e2e3413018ff7ed87cfa95b60f094ee5404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040] +[8a010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101] +[8adc91fd040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404] +[8adc91fd9ff4f0070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707] +[8adc91fd9ff4f0f51b0f0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a] +[8adc91fd9ff4f0f51b0fad50ff0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d] +[8adc91fd9ff4f0f51b0fad50ff15d637101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efd131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919191919] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a742001c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c151f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd98222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525252525] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d5282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f492e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69c313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1f343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1ff9e939373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1ff9e939a755843a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1ff9e939a75584c52d693d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d] +[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1ff9e939a75584c52d690a35d4404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040] [8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1ff9e939a75584c52d690a35d410f1e7e4d13b5915500fdd1fa32071c4c7d1f4c733c068030422aa9ac3d46c4ed2826446079faa0914c2d705d98b02a2b5129cd1de164eb9cbd083e8a2503c4e0a88837739d7bf4ef8ccacb0ea2bb9d69d56c394aa351dfda5bf459f0a2e9fe8] [c89ed3bfddb6b2b7594def12bd579475a64cbfe0448e1085c1e50042127e57c08fda71743f4816973f7edcdbcd0b4ca4dee10e5dbbab7be517c6876f2b48779652b3a5a693791b57124d9f5de16233868593b68571822a414660e8d881962e0c90c0260445dde84b568095479bc940e0f750de939c540cfb8992c1aae0127e0c48cac1357b95fd0cba8eeef2a869fb94df1481d6e8775fbfe7fd07dd486cddaa] [42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242] diff --git a/test/default/core_ed25519.c b/test/default/core_ed25519.c index e3f39c38..30abe092 100644 --- a/test/default/core_ed25519.c +++ b/test/default/core_ed25519.c @@ -48,6 +48,7 @@ main(void) unsigned char *p, *p2, *p3; unsigned char *sc, *sc2, *sc3; unsigned char *sc64; + unsigned char *seed; char *hex; unsigned int i, j; @@ -62,15 +63,6 @@ main(void) if (crypto_core_ed25519_is_valid_point(p) == 0) { printf("crypto_core_ed25519_from_uniform() returned an invalid point\n"); } - - randombytes_buf(h, crypto_core_ed25519_HASHBYTES); - if (crypto_core_ed25519_from_hash(p, h) != 0) { - printf("crypto_core_ed25519_from_hash() failed\n"); - } - if (crypto_core_ed25519_is_valid_point(p) == 0) { - printf("crypto_core_ed25519_from_hash() returned an invalid point\n"); - } - crypto_core_ed25519_random(p); if (crypto_core_ed25519_is_valid_point(p) == 0) { printf("crypto_core_ed25519_random() returned an invalid point\n"); @@ -387,6 +379,20 @@ main(void) crypto_core_ed25519_scalar_mul(sc3, sc, sc2); assert(memcmp(sc3, sc, crypto_core_ed25519_SCALARBYTES) != 0); } + + seed = (unsigned char *) sodium_malloc(randombytes_SEEDBYTES); + for (i = 0; i < 15; i++) { + randombytes_buf_deterministic(r, crypto_core_ed25519_UNIFORMBYTES, seed); + if (crypto_core_ed25519_from_uniform(p, r) != 0) { + printf("crypto_core_ed25519_from_uniform() failed\n"); + } + sodium_bin2hex(hex, crypto_core_ed25519_SCALARBYTES * 2 + 1, + p, crypto_core_ed25519_BYTES); + printf("from_uniform_deterministic (%u): %s\n", i, hex); + sodium_increment(seed, randombytes_SEEDBYTES); + } + + sodium_free(seed); sodium_free(hex); sodium_free(sc64); sodium_free(sc3); diff --git a/test/default/core_ed25519.exp b/test/default/core_ed25519.exp index 65295bfa..95651c5c 100644 --- a/test/default/core_ed25519.exp +++ b/test/default/core_ed25519.exp @@ -15,4 +15,19 @@ sub1: f67c79849de0253ba142949e1db6224b13121212121212121212121212121202 add2: b02e8581ce62f69922427c23f970f7e951525252525252525252525252525202 sub2: 3da570db4b001cbeb35a7b7fe588e72aaeadadadadadadadadadadadadadad0d mul: 4453ef38408c06677c1b810e4bf8b1991f01c88716fbfa2f075a518b77da400b +from_uniform_deterministic (0): b18e62cf804b022fec392b0e2d6539d0f059732616c11913f510f73ae2544ebc +from_uniform_deterministic (1): b9d23004e78c58e22da72e109550133e3d3bb9e46afcc066b82326319653d62c +from_uniform_deterministic (2): 14063782c8b8a677dce09c4e51719b1cf942bf71bc765c1ec9832a8b4446983c +from_uniform_deterministic (3): 02d6dbac70f6a14de72f4e17386016b08d6506336a086f10e719fbad8831d550 +from_uniform_deterministic (4): 11c851408e7892c2eae37584423a8f9c797e3649d45946b53e64319318a750b0 +from_uniform_deterministic (5): d4b9eaf70ffdc238c88725e294bdd02a6ce85577c5e7add7ca07041873019842 +from_uniform_deterministic (6): 740a6141079285c1b9e84ed463dcce5d3d40a167fa13129463eaf97d2a7bf654 +from_uniform_deterministic (7): e504a3e00bbf506cbe388784d85e85b10c428c37eba04ebd19a60948b71ad2cf +from_uniform_deterministic (8): 67cd50902c40c943f22c479c587fb3e5da2f8f1ad402049ac49ddc45ec20884c +from_uniform_deterministic (9): 658bffa23b425a91268ee17559073c4b1548209054ed7cf00ffe582696dda8dc +from_uniform_deterministic (10): b55b93e7a0fe554f86f1f4c991871a27756fee359a8c6bb7554ec91d5d552c49 +from_uniform_deterministic (11): fbc2bb45df1d806489a5a6415898c719c45c932d3467b6ce948ee80c0e8122c9 +from_uniform_deterministic (12): 93164e57b5e3ae6826ac9e0c31ddecf94e21a39a29ba9d1d24e9e588fe065d95 +from_uniform_deterministic (13): 16824d74c9482890dc57b0ec843a0a5231b581d2ce3909934d7658389f169093 +from_uniform_deterministic (14): 2f5b0336c7f0af520badeae99450f92835c27224ab4cd117f55b176afb6f0001 OK diff --git a/test/default/core_ed25519_h2c.c b/test/default/core_ed25519_h2c.c new file mode 100644 index 00000000..80cdbb5d --- /dev/null +++ b/test/default/core_ed25519_h2c.c @@ -0,0 +1,128 @@ +#define TEST_NAME "core_ed25519_h2c" +#include "cmptest.h" + +typedef struct TestData_ { + int ro; + const char *msg; + const char tv_y[64 + 1]; +} TestData; + +static TestData test_data[] = { + { 0, "", + "4af6284e3cc7116df104f6708e0c44d79b0e294ccd89b87c4c3c892ebd2f03b1" }, + { 0, "abc", + "23e704500ac22fd7106ceedd86bfcc8d50351a6303be22b2724fcc1280d00544" }, + { 0, "abcdef0123456789", + "34b8a16b923101f2d4caa48d9bb86fef4f92be0ce0f55c8ba9db55da23ad623e" }, + { 0, + "a512_" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaa", + "31e648bbade3b272b7676f82da905d27de37f41581b1d170250dd9d56f95413c" }, + + { 1, "", + "5c307efcdf7f0822428f932e66b46b3d88f59880772a1ab07fac5231609c5f76" }, + { 1, "abc", + "4bc72bbd27a3207ad932ea6e218b257875ad2cb34695d964da83a57f4807394d" }, + { 1, "abcdef0123456789", + "3c67b98967527a551ea54e4de791689834552009a7a40393fd4a23d1f04061ef" }, + { 1, + "a512_" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaa", + "6ce3485dc2cd37462e08e46f9931b16bb272280aea3efc38fb96d2d2df4870bd" } +}; + +int +main(void) +{ + unsigned char *expected_yr, *expected_y, *y; + char * expected_y_hex, *y_hex; + char * oversized_ctx; + size_t i, j; + size_t oversized_ctx_len = 500U; + + expected_yr = (unsigned char *) sodium_malloc(crypto_core_ed25519_BYTES); + expected_y = (unsigned char *) sodium_malloc(crypto_core_ed25519_BYTES); + y = (unsigned char *) sodium_malloc(crypto_core_ed25519_BYTES); + expected_y_hex = + (char *) sodium_malloc(crypto_core_ed25519_BYTES * 2U + 1U); + y_hex = (char *) sodium_malloc(crypto_core_ed25519_BYTES * 2U + 1U); + for (i = 0U; i < (sizeof test_data) / (sizeof test_data[0]); i++) { + sodium_hex2bin(expected_yr, crypto_core_ed25519_BYTES, + test_data[i].tv_y, (size_t) -1U, NULL, NULL, NULL); + for (j = 0; j < crypto_core_ed25519_BYTES; j++) { + expected_y[j] = expected_yr[crypto_core_ed25519_BYTES - 1U - j]; + } + if (test_data[i].ro == 0) { + if (crypto_core_ed25519_from_string( + y, "edwards25519_XMD:SHA-512_ELL2_NU_TESTGEN", + (const unsigned char *) test_data[i].msg, + strlen(test_data[i].msg)) != 0) { + printf("crypto_core_ed25519_from_string() failed\n"); + } + } else { + if (crypto_core_ed25519_from_string_ro( + y, "edwards25519_XMD:SHA-512_ELL2_RO_TESTGEN", + (const unsigned char *) test_data[i].msg, + strlen(test_data[i].msg)) != 0) { + printf("crypto_core_ed25519_from_string_ro() failed\n"); + } + } + y[crypto_core_ed25519_BYTES - 1U] &= 0x7f; + if (memcmp(y, expected_y, crypto_core_ed25519_BYTES) != 0) { + sodium_bin2hex(expected_y_hex, crypto_core_ed25519_BYTES * 2U + 1U, + expected_y, crypto_core_ed25519_BYTES); + sodium_bin2hex(y_hex, crypto_core_ed25519_BYTES * 2U + 1U, y, + crypto_core_ed25519_BYTES); + printf("Test #%u failed - expected [%s] got [%s]\n", (unsigned) i, + expected_y_hex, y_hex); + } + } + + if (crypto_core_ed25519_from_string(y, NULL, (const unsigned char *) "msg", + 3U) != 0 || + crypto_core_ed25519_from_string(y, "", guard_page, 0U) != 0 || + crypto_core_ed25519_from_string_ro( + y, NULL, (const unsigned char *) "msg", 3U) != 0 || + crypto_core_ed25519_from_string_ro(y, "", guard_page, 0U) != 0) { + printf("Failed with empty parameters"); + } + + oversized_ctx = (char *) sodium_malloc(oversized_ctx_len); + memset(oversized_ctx, 'X', oversized_ctx_len - 1U); + oversized_ctx[oversized_ctx_len - 1U] = 0; + crypto_core_ed25519_from_string(y, oversized_ctx, + (const unsigned char *) "msg", 3U); + sodium_bin2hex(y_hex, crypto_core_ed25519_BYTES * 2U + 1U, y, + crypto_core_ed25519_BYTES); + printf("NU with oversized context: %s\n", y_hex); + crypto_core_ed25519_from_string_ro(y, oversized_ctx, + (const unsigned char *) "msg", 3U); + sodium_bin2hex(y_hex, crypto_core_ed25519_BYTES * 2U + 1U, y, + crypto_core_ed25519_BYTES); + printf("RO with oversized context: %s\n", y_hex); + + sodium_free(oversized_ctx); + sodium_free(y_hex); + sodium_free(expected_y_hex); + sodium_free(y); + sodium_free(expected_y); + sodium_free(expected_yr); + + printf("OK\n"); + + return 0; +} diff --git a/test/default/core_ed25519_h2c.exp b/test/default/core_ed25519_h2c.exp new file mode 100644 index 00000000..8ccaa0ad --- /dev/null +++ b/test/default/core_ed25519_h2c.exp @@ -0,0 +1,3 @@ +NU with oversized context: 998ca2fdd0ade350cb6c279173dfd4a6a42f46ca5c2928871aacff60c1654663 +RO with oversized context: 5ed4ae2ab665a7a9543f6e9887dc8f8f68a7720fdf32b971f3be71d9c9549f74 +OK diff --git a/test/default/core_ristretto255.c b/test/default/core_ristretto255.c index bd67f71d..2367f8a2 100644 --- a/test/default/core_ristretto255.c +++ b/test/default/core_ristretto255.c @@ -10,6 +10,7 @@ tv1(void) "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "f3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", + "0100000000000000000000000000000000000000000000000000000000000080", /* Negative field elements */ "0100000000000000000000000000000000000000000000000000000000000000", diff --git a/test/default/kdf.c b/test/default/kdf.c index f10f034e..dc9a2475 100644 --- a/test/default/kdf.c +++ b/test/default/kdf.c @@ -15,7 +15,7 @@ tv_kdf(void) context = (char *) sodium_malloc(crypto_kdf_CONTEXTBYTES); master_key = (unsigned char *) sodium_malloc(crypto_kdf_KEYBYTES); - memcpy(context, "KDF test", sizeof "KDF test" -1U); + memcpy(context, "KDF test", sizeof "KDF test" - 1U); for (i = 0; i < crypto_kdf_KEYBYTES; i++) { master_key[i] = i; } diff --git a/test/default/kdf_hkdf.c b/test/default/kdf_hkdf.c new file mode 100644 index 00000000..8fb07fe5 --- /dev/null +++ b/test/default/kdf_hkdf.c @@ -0,0 +1,100 @@ + +#define TEST_NAME "kdf_hkdf" +#include "cmptest.h" + +static void +tv_kdf_hkdf(void) +{ + unsigned char *master_key; + size_t master_key_len = 66; + unsigned char *prk256; + size_t prk256_len = crypto_kdf_hkdf_sha256_KEYBYTES; + unsigned char *prk512; + size_t prk512_len = crypto_kdf_hkdf_sha512_KEYBYTES; + unsigned char *salt; + size_t salt_len = 77; + char *context; + size_t context_len = 88; + unsigned char *out; + size_t out_len = 99; + char hex[99 * 2 + 1]; + size_t i; + int ret; + + master_key = (unsigned char *) sodium_malloc(master_key_len); + prk256 = (unsigned char *) sodium_malloc(prk256_len); + prk512 = (unsigned char *) sodium_malloc(prk512_len); + salt = (unsigned char *) sodium_malloc(salt_len); + context = (char *) sodium_malloc(context_len); + out = (unsigned char *) sodium_malloc(out_len); + for (i = 0; i < master_key_len; i++) { + master_key[i] = i; + } + for (i = 0; i < salt_len; i++) { + salt[i] = (unsigned char) ~i; + } + for (i = 0; i < context_len; i++) { + context[i] = (unsigned char) (i + 111); + } + + printf("\nHKDF/SHA-256:\n"); + crypto_kdf_hkdf_sha256_keygen(prk256); + if (crypto_kdf_hkdf_sha256_extract(prk256, salt, salt_len, + master_key, master_key_len) != 0) { + printf("hkdf_sha256_extract() failed\n"); + } + printf("PRK: %s\n", sodium_bin2hex(hex, sizeof hex, prk256, prk256_len)); + + for (i = 0; i < out_len; i++) { + context[0] = i; + if (crypto_kdf_hkdf_sha256_expand(out, i, + context, context_len, prk256) != 0) { + printf("hkdf_sha256_expand() failed\n"); + } + printf("%s\n", sodium_bin2hex(hex, sizeof hex, out, i)); + } + + printf("\nHKDF/SHA-512:\n"); + crypto_kdf_hkdf_sha256_keygen(prk512); + if (crypto_kdf_hkdf_sha512_extract(prk512, salt, salt_len, + master_key, master_key_len) != 0) { + printf("hkdf_sha512_extract() failed\n"); + } + printf("PRK: %s\n", sodium_bin2hex(hex, sizeof hex, prk512, prk512_len)); + + for (i = 0; i < out_len; i++) { + context[0] = i; + if (crypto_kdf_hkdf_sha512_expand(out, i, + context, context_len, prk512) != 0) { + printf("hkdf_sha512_expand() failed\n"); + } + printf("%s\n", sodium_bin2hex(hex, sizeof hex, out, i)); + } + + sodium_free(out); + sodium_free(context); + sodium_free(salt); + sodium_free(master_key); + sodium_free(prk512); + sodium_free(prk256); + + assert(crypto_kdf_hkdf_sha512_bytes_min() == crypto_kdf_hkdf_sha512_BYTES_MIN); + assert(crypto_kdf_hkdf_sha512_bytes_max() == crypto_kdf_hkdf_sha512_BYTES_MAX); + assert(crypto_kdf_hkdf_sha512_keybytes() == crypto_kdf_hkdf_sha512_KEYBYTES); + + assert(crypto_kdf_hkdf_sha256_bytes_min() == crypto_kdf_hkdf_sha256_BYTES_MIN); + assert(crypto_kdf_hkdf_sha256_bytes_max() == crypto_kdf_hkdf_sha256_BYTES_MAX); + assert(crypto_kdf_hkdf_sha256_keybytes() == crypto_kdf_hkdf_sha256_KEYBYTES); + + assert(crypto_kdf_hkdf_sha256_KEYBYTES < crypto_kdf_hkdf_sha512_KEYBYTES); + + printf("tv_kdf_hkdf: ok\n"); +} + +int +main(void) +{ + tv_kdf_hkdf(); + + return 0; +} diff --git a/test/default/kdf_hkdf.exp b/test/default/kdf_hkdf.exp new file mode 100644 index 00000000..57bd5713 --- /dev/null +++ b/test/default/kdf_hkdf.exp @@ -0,0 +1,205 @@ + +HKDF/SHA-256: +PRK: 8c3725c0ea8e14106d8c342887ccd1218cc205acecd8095ae1efc099ec195e7e + +92 +2ebf +e29531 +8e563a1b +1fa58d77ee +50f1a4e15ba2 +4fb3724b7d4174 +d10853ceb46b11db +0fdf31228221242833 +98acb29e0993ec45f8cc +f4481a5e6d263d7bdc59ed +e620eb399337a9aace16765c +dbe8924351577475584731979f +371a112305dfd4264feb29c28a2f +d0a4b022f748c96141ec6b4aac6dcb +d2b38fe15e0f95bcff87822ff4df3d90 +e4bf8fde7d77899a5f85d68b039ee7119b +6766b092971ec2e616286925708c7ed6c9e9 +c4f9d36cddfe89b3194282a084881e6c429099 +49be5bc10c278f39b5be391a55e765560deca0ad +6e7d3031d08c5658a19a7d647dad0250418435febc +07cb6356aa7f978cbab87e7814fa90af9ce729aa2b3f +2ea1c08eb04c75806f80ccf0fca683a8998bb663e99993 +bb111699f6c32263474dc5569a6950c767e3b8201f838345 +e81e9086d3e035cc1a288fa521ce8b43b7f93d3d9bbac5085b +29c398bfafa672bc315e192110575691607118759f9e7669f3c5 +60840e8bc6d86733752787232a0321257c82d691722bfba07af839 +b0ec22e547dae3f04fc6ef146203604f0d604a8ce8a20fce229a688f +81ae6add3344b25d14115a38bc10553a75ce0a4be3aa8f3579299227f7 +242c65f95ee0bce1c5e1b01b1ff68e8634fac096edb18997dfd3baf3817d +14b5afe2cc0d8fe10e5359667b2b310365fba93d62f7fd3df2dddfc34c1de5 +24a79d4c0c69e0a524ca91f356e64ab40345973ba82ce68992dbdd16bf161cbe +3edbfc22f9a1e3a5c774cfec8fff3cc4febdfc61d98aecedf6a16eca0546316b56 +b8bad2b04b9b382f9ad2559afc33b8dece4a7fe9b8ac9d74557dfc51ed8949b78ee8 +1d01316d7767f068171f08a8c2f05d2cd571f623fd5fc9916b3476115aac9d7f635cb4 +a7c5763a3b678ee2fa05a57dab377b67e448a38f94531ce83bab9eff8035e105e8889b91 +ab6721825aefb2cb9f9d0ce5123882573abebe94404e0e3a923a7aac84efc084f84ee5b2ed +4815da740c872a9816850c8757be64cb3096dca7994f3af7bd8c10e83a2d3bbb14b40da93d40 +abb141fbb64faec34c09e9c784b1e8aba15b6e916f70996ad803b963d2de676669ebff3ed4b711 +231a7a47a81c21dd6a0969c67b6ff446a73a145fb1d4f0a2d268af8fd56ac6d67b6ef55d13194440 +74e40130ca102c22acc109cc6b8b66d840b984fe729c156edd05eb4f44d1869e6ae6260b41931179ff +3817d2cf7b7c7c7bfe4ab51e9178343f31fa8eea20899ec96d21eebdbf55f44327e7dc23cf669e215c02 +d5ab755f5631d08b70718d2ba3e2775fbc3cdfe69b7ac74afcc73ffbd7b91b9d3a7fef364cda9816c8c367 +93c15afc2cf1baec84b8e3c89f50a3e4cc3a2c1b72aeaa894a45bf09f22aac0711994f0873ac69b099e47d02 +7b359dd2abb995a8bb0d1a01a986bfcf28d47b9215f000b240f5080dc78a84cc65e34ff098074ae237a0238b6f +182ec78776f5ba3818c2ccc7b84aa7bb1a54386134b3215e8f8f709757f3c8e4f9bef3800e3a9eda8b9794e95f8a +0cf1874215b38ab1900ce7137d9b8817fbe99d3196eab5b845971a46a38c479d81fc8033a641533e2c39dd550e672a +3f5a283ca862e6a5f79c5ab39f8d4984b54a86e132d40adcca249f6419caf5b61fbbf61d54d80e78af3e613adfea5f9e +ce6bceffd4ae50e8465c3d5179c661da2f18dcb37f95f9cc66808d2f848b55dd0c1d2201bb37a2e339e9385233e687a711 +7ce3f4575d3edab2f989b0a975b279ac21af117184130911dba4e7c70e19f96b5595ec8910e737c019f3392390f8b9af6439 +9c1b37296ed2ad9b556938d30814c47f822807be8cf9bfb26a05651061015493d4ed551f8a6f1a5cef7df88dd7426f03681935 +0d1f6f49c38c4d6fbc57103193b544ec1a73f40ed8aaac53da2b1a28a4a35838036ec9d50d719af22f3f89ebb7f340f50ce8c180 +fe6786d7d7728a1ed057c329f68cf698b163ae1e6c1b48290e6ba2c325740155f0f90f216111f3bc16d61b8338d910d429241899c4 +c729c63757fa5a421704ba88f8c13f23606e59cb1e7d2396a130742c31b98dc9461cc1fa9d8d24f79f7303dd416bf66adbb08562f832 +44cf07d63adc85de7c0aa524962c29dfad1b37b253fc9559fd1f5b8237d8bd6e6449e5f3997d6b0571ae50da1e164be845523c8630b1df +c1040513a53f652e0ba7bc30f84deaaec13a15919855dd76148ae1fc86cd147ba686ff0ee025f9a00cbf7b6e190c7b87ea458974cf147ae3 +0a67afc69f00ddbdd6794ed7b06285c00d70fd86fb8b959bd8c686e96c72032f2726c4f0fb607a7f4d4f66b410eff17354b6db803c9c910a72 +faad9414932446902309147f8f2c1d2d48c95a7ddb8856219aa36ed30f971e160542ed8272ef9bdf72551cd059ca6c81ea76b5a3b49cbfb07738 +14ee2fc3899650164beb828a557afc7253e4b89cba8a1908d3641d47eb23d50ef34a0dafaa1388328fc33b1db37f2f74db6934d398bacbec785f03 +2333128e004f61ba45c524dbf72a9973fdcc288d76236402f63b0f4a39867b18e73135f35945f1791ae537b215c69941194258103419558c0a477fa9 +70f1a4c027d950573c5ea8f9b34069d1b85ac0b6daabc9de5c4cd1844d6781c0b15ca7b01c2a33dd06272e7c8729b74ea71a0f35486252461a3d83bc62 +8b9199ebc5ae61365d6cc78c9d1b1a466565639c50c317cddcdc13db96b4f6ec612bbc1c6e5d2479147040f313a168e4471b9093f47548899265d8472aab +5f420864258d597766beb7c55ef0dc9c85aab5e296677e1fd9201a8c8a0c7b74b573276b0ce11f797a5816e5ed7ea3a02ca5c338f78c0c6a41322e0cdbb5d6 +13029325fb0fbbe2221caaa6c3797a967335c4a857fafe23b4fb221433afc84da6876cbd74ac631d18f2478aae8def5a85a227b3bb496a81e9d29171a5b501fc +44ef825de340dbcb1b2ce9325eb78650d574d1c9fc13ed3b4517ee3f2f95bd97c8ab62988455a1639d0e4b2e404d661c3881dbdb52d86b7bd5593713b10e8d1086 +2c67d0e2fbdb55cf649c97e1053c717636c526ee4f58f86e9671a1086e5ef6ef7ae109eca2cd482affb1add956aad7225debca3420c4cae6cf590e8e8c1a0398a9cd +6900b97c5783d5856e4eda7816e27326cb71f8c9cda3bfdc88c4a5aa49b580aa4341cd100fd3084b447a24c9d521c8ddb7a55af52c998c4a9b53bae6c86caa02424df6 +c63f43dd3d29e0e92fc2adf18a50e33f11dbe9746f16bfc518397e0df3bd4eff491963cd2a0d25022c535a425fe3cfcea4ffd7dfbe98e2ae9fb40a007012acc31460ef25 +dd61268207f4452ce4a1f212aa4f4ffff1d0cd4df9ac1730b0f4acc07f75e86afb02c0d99aeb512bf3bb138183364a4b800af446b403add2b30d73eca024fb5e3eeebf10dc +4eb2c6dc6159bb82eba32aa839bc4b3d46be87cd358f47aeb7b488d91230414a40fe35a2c0bcde81de243b6974c49ac0af113904a8995928931e867f5b7d131c2c9caf4adde5 +22cef8bbb9f6874c1be53adc6687e3b28d0b9b8574d22212e4d60074585d17751fdcb80a1ed6143a7471fd3b1a0dddbce5b8b1ae859441413d99b069252f39c3a0b7eafc65ab34 +6f0a07f43c6d00649b516cc986fce770aed949875a17164beed5305ceaf74131574eb2cf489dc13fad53e2b10cb757b69eecb481a76a8d99a7cfb2e0aee40dde6f7d44c2be5a5e63 +bf701b835481d47ee85d390caa8f63bd3e7dfa48f4307d51989b4660e465de31329589bd5e3293f75b63d320b8f53211cf1209e426869c3c3b506dde3f819cae07672af9ef74f36de6 +92cc25c67b65fc9c57381457e7752441782dc4d2d62828c13992a7c2eda57811fe7c2de66b725e08f361fee4d8370d3dff2cdba6c603cd03ae54d813e44793387ded1add2c006b320058 +e3ec7f8ccf313fac832d3ef5c3b8b10f1faf5ae8ec32bce0f5f98b9f4464624a58b0f74ffdb827d52d94fa77a8456ca550017f3c31d8e8e6827b6a9ac9664355bc57e9b46cc66b6e396a50 +636ffbeb1cb2e834ae37213247ca8e615fc52f00e79c13f37874edc549f4b629901312b685f3e1ae3394a6beebc5e0c1364c562b3579f34cbbe9ed80c5cc045b9ab7a749950d005e785832e0 +3ae686a5e1abf936d472963d6272226f920c8df4eed5c4b26d9afc910f509c205ffb56a0289fb62d38790dca4f85028f76b4339e9eee32c1c2690abd02c74ef9a7cc822f901ae596ef1b2f2f42 +e542066a18aed627ea3feea7a962b9c69a9a2f00bc0f22c7186c389701283807801d2cd79d678010d91379cfc6d72cf30830a34fd9983a0c011e775be61eb0d093a1432493abb703c8b5bf99ad63 +1392b4676365c1ee01f75811cabe0fa989faa6a222b65e72bf4016f7767c0e9f822de2ad0034098dd9867a787abe9b97adb1a345e96b345aea898682d71fc3febc0e2ef579874da073285d0ba4edc4 +2ddd472dd4090528036d7bf01cacfca7c71ce3d89bab2299b3d6f1b987c51e5f884cfed55ca25008811fa4f44d9bb8563d83cfeccc580865978972cec981f431e4b74857e2a565e5d6e0bc9f0a3c45ec +d2a855d0e2a912ce3ff5ffa99c464c215d9ae1195e92b022d4518dde9fa5ecbdbac4f1877c1a94df35421a122a04073dbe7fce959c87497cb30774bac3441140089b4b714e025509fa3cd41d683ab46edf +00bcf365897640b9268fad068977a11b7eb3006482b51c97543ba4359db31adcd18497d174844c9ec47a0f6132b16d14aa5a02c42583aabd033e520a8a9c5c430cc6708e8b9cdd4fd56c1023a744af67fd14 +0e20beb1a84e9c252b54c4db895324e85436f29e4855cdfa5bf4bbe7868bdbc51b7f0ac428ce54750e2cd16829051e95cd97f2f40c5a1a3db17f90b68570a05ac55a9eaa7c8bf377c7a752666de779ef46764f +20ddf3ccd89c8bf4c084324858c0f0c7d4dcfd4a76a7526183a5bf4344f62320f29e7c0650d3c55ad587128e667d5d4e69689850fa741b49d3ceef45b134327ac89186248d1157aa4b16263731138777811e508b +2a8fadda7001128cf59e3fcc93dc5c98e75ac92d66d536330eb90a558920e4416c210658b3bf44a451db23c62caac1a79fad1437a81d66ab98e4423d8a1ce9ed9a0586a160c4819a019a93781775c6510c6ed09cb9 +9049524d223052ee507450e65112e1f4331c4d7fd71e8237b8f79feb2fa30504c856d6907cc4eb814694e9a7b8a8b10d85f956df72062c5f4752dc42d37f164eae1a3155a11ecb413f92a0e49e0a89d398c21d76e100 +86a92236b4e0dc16e0a17e92825e31b66a417784b7f6c0a53c274ca5100847a929c0a30430ff67e6c8913a41c3437d8313fd11b2c0eebc75e5bdffeb95a4d100c7eb36216494f3c7a8f19403080941e3d1c9e319ede000 +4b15b094db5789ff78fafabdd0f0aa06d3f4ded903c89e8ae22982d152017295de63ad0b43d3d303243de1bbf2637e8e0c042024e307739ab3b02a5b7d299167909edd51f82229c0093a68768d56c2e774285ed95bdc24d9 +9bbca463a5142ea7dad0522f073eabc7eed63e4baea13efec9d7c198b75a9c4db88623c406edc5bf61ec61e047357358541aa66e44a364b779b6a8842c1b1e8131c594ac8298755ba532937b5bdbcbbd1f2c2152d03af55120 +edc5fe50b3f3a7de5ddc14b467e41ec0ce68a44f734c4cd46b5ee1d98337d8a917cf1dd13e09946d22918eaf31f83de1e035209a6f2de32bb7caf119d0db73e4075cb9a714adb84b4d0a6163aac56bb4299a71e8979a97e363f4 +e2770541945a0395fbf597fb58cc4e6f6a2883b707aa79df9c2da5a7165a8838b1e7f4736b5418bd2f99d3eb8020f9b4cb7ff3a620f8bef276f22f3e98ffe20adeac2f62a9e5758136d222a9c562f81f151d3980bdad54f52dbf55 +248474ddc86ce5e07be50fdd3a6a113ab7f2319e3fb86f1d2d361372fa1d89926ef501c5a62b9d2efeb409d0be8fb67f12c1624d04bcf9d555dad09dffdba76948b0eecba430110ab9e738db70e51c4e2f27350a49aecf1282410ab8 +37d75ee27cc14c95c9d930bb1324d8aa6cc77ba833504253d91002fb622d9e578a3f3b1439dad7d9d7af8ea17cebee86fe13c59f316434d46208c019c2e673168b5aaa397525cbce3a0b2f1c59c853600711e719218311e15d1ab9a0cf +981461afd5756cc5d6a953c188b0a537fbcd18b41034cc4f40870cc2c97bcc48e3e4d563c2ee1d60d8c9f714996fc32e2977aaf7c3544e437f40f61d7281548efc22d7c298853304444c4184605b7b55148c24e88f362e41a8c919bf0288 +d65ac485824f9490c5f70fe674fe1da39b4583b25f3580b636a06135761eb0fb5e36a59dcb070dd9bfd5b2d69503a5c3ef295eb9cb3a9346578556d56fdd0c81cbdd960d292f8410681643af154b2550e2d586119b82cb17a79c1447cb26f6 +cdd5bd495ed8c2c41dc511577051ffa30ee02eddb95b3650337e8aeae161d2b81a9ebc1514524c52dbe2c4d0739706dbdcea1a7ba21d9cab36ca10f753fc82b218c01094e288bbcd96d6678e06e1a03f55c3bc6aea67b9637e87a4ce8e2aa0e8 +1d07389dad745981eb7ae03162bf249996cb836316872a4de4241d1fea49044541b9ababc2a10f7d5455ad3c0519997698a52039fd5517c53f7963aea8917e1b8ce3c63c5a2b23331cc473c1ff0986b08e8dd1257847256ded17e6d0409855f8e5 +a1245e0117a0e7c3cfbcd3d3eeb21a5aa7f2a73aea4465f4d83c8d0c6237c5c093ada99ada6ad75dcf18d1eb58982c7316d5c366ce5128a832d433c960e6bf7be42e4dce2747e3cc78101ed44aebcdbbf6bcd42f5160ca40784ea3ee3dd6be537475 + +HKDF/SHA-512: +PRK: 2502bc897dc1b23f9f2d8c35d519c5280ea960bf9154ebb07d377a12a81a4794ea8bdc0cb6ec59ab3303f5cbd713027825715f8af2ac0203e560fd2e55f4ff2b + +4c +abec +6d7647 +a3397e73 +15b3f69cec +fb5c266f8785 +7147d8a6bff246 +1dd7f9b2ab2583ab +725aee4e2d8d7f1f90 +046f63a1e2d606d7893e +fc2026603b032dc6c862de +03127d298ea441e3ae1d3781 +a8f163b5b9476eb50dcb304bc2 +9430c3aa31857951320feaa65e4e +14e4918f7b7eaa9c6d39dc08e9abc1 +3480c9854b8f0bb4a97920338dce7573 +42714ad1af787467b0388cb6663864ba89 +700cd7f28075fc3a28d98672207b45df5b20 +528c93053c63c5fa5ff1f0a6e7cde8d4aec5a8 +d225940fcd325eecf827666ebcb9ea3881dbfc3f +0341475a114b87cdae767a4a68432889145748b0aa +bbbf499a74a2c22dc4a2295bc904fdcd7d4e91b32060 +deb06fe0b094b65da9febfed81f990ae77fd3f458a1bf3 +f64b7ac1473232a727ff461af2f650cc8a8419d7c97b7298 +3ca9c302e1096302185e2288beb6d91124c6abc9f9f97d5a4f +81dfa7213143feb429dae2c641d25bf913aca03feead6ab7df10 +5d428190aad0539c0c2e6037e7745218dbf4e5c5aa0102996ceead +7e76c9dcd614d730eaab145be60584c7bbe925bddc64d9dccde16142 +4b2be1c3dd5cd41d53ead2ce0aa220823ec4f3cf8656b14449e50cb48b +4ceb80935422dba37af63ba59a460204dcd6639741d478185fd1a1e48de6 +633e555556c5288d808b2483d7e99bcc9876b42b61cbcc4d3e9ed42bcaee33 +0d28411da5a660b2eb063af0ed7e031c463a64eddd6c48882add6fad4cc9da92 +30b734f5768d26c4f8d641037b3e425c3d75c5c0c97cf8a3e684d1d2f1ba4f37b6 +970db4152321c2bac15898927aa25db90246c494017765b01ff21ae9a6aef7b89b88 +f168959f62696ea32a46ee67cdd3375684533f799e346fd1d26ad29aecd51de7c2c473 +76a81fa4b90ee1d1b05986c837f10f098cf1ac8f7d6be8097caec980b125185e8f9ee56d +ed95ff4a9919f45c08151fb7f610f5155dac10c92e84bebf2a6bf0fc653585158c19ef59fe +16ff87fb87760dfbaa53a2820c9ef365ee3b539b4a7fd1a4e626d313f24db495319f98c247d3 +f514b605b74bb3a35b86f8c96fb08e751d916b3ecd8b5e84b364e57f1fb6e5928a3a46f4cf7b1a +ecef871f30ca56fbd6b242b9d095a33b9d60472da4914af80dbb8672a84d8ba4640ff1b459cb9b1d +9220ed520c628b7e7e249c334573ff2402d573e34b27c25c4ba22e2b472ccdd2ef4d060eeef5387dc6 +b431fd9eaba69bc20967d1d02014913637df29c855faa6e93a8571ea3c27ad2c542700c77f9f3d19e5bb +7ebd91db579ec5879f81a922c58ee82a91b8cb648294f63b97f728a53411438f54157cb6459ae762b5ef3f +c28a1322e46a89f7a2b6b3dd6d39cbcaa84368bca33a53c04bb7bc90c3f51065143d8e93a279a403aea8ca8a +089ca5fb6e4de86c77cac49f92c8d3356697a1fa51c8e4a207ec44428c4da0b82aadad5f196510d0ae7abc25ab +31b08873dafc0d8c11afacb5efd3fcabbb7cc5ff7aab6e1d40a7451ec715de4a4a6e7e15f9d1f9f832a0e1bc39d7 +984f57235036e6d44777a7bf41fa4333f3077d3f2d92b46bc36c29b123de8580d81e22b2969d9a5abf3bb5fb7b422d +2730edbf85f4e35152af0f22fbc4f23f7968cb430fde9685cf4e1bb64611ba6459acedad777fe1a6d70c88733d83661f +0eb2a97a6d6a5901535399caa5ccb7192e1f1488f9a06d3150ccafe1eeaa8d6e50e039a9344f68d1783973fcb34719c2fa +24d7e154d4b7382daa4d1fb47a8badf0d1020e97f75efe74f302b983584e26bc1865d44c3761b65c4d745766da0bfce5682a +cb7503ad874932bfc2c7b18176d3e03f3e66666613e3e8e2ac83a29965b56afb0aa74d1080ac2ffeb1c43ee160c9f120cc4c61 +0ad5086f6cf363dfbf14c13e82faf14dde185b7142bd0ae44da8692339ed31f47f10773578af23cd7a632352087d07a7f4133474 +72873f68ad5874e1146a70e96c98360ccf0e5e9a5e31e4e38c7829241a531b0712eee8f22729e244da3d94d92703d975e54d84c36c +b05200d914edd05309a7aaafcde50cfbc201d988387d2b7fb7b7315b56d58ecaebc2f7c7b5d2607d041dfd3486e849cf2535c8ef76f4 +6324ea52a00274312457f451953302d02e3e9107aed0a4007c04d26f4b5ce37f31fbc5a2606575a464f64b507691646e2d773c62aac387 +e0c68ed5571a90bc8db36c948b5ffd9179cd80218ae47b86cc7bf4aa4adccc438ddf670ea817d324ca709b612522d510913eb64012462acb +61d3ec6537c084df5981a79545847cbf204c3a267080e2cba06a29b4fa591bc43668f701cc0d9e33e123b774b066e212fd1989d253120bfdf6 +7b74db37484227d237eb7d4039ddade342827d0075322c14de32985d616ffe38c4786e2e0df89de856051796e1f922b6b47578c3428fade6b372 +feea8d891c65fb37dc20095946b9f5db5aa936a2331fc9609ea45ee146107bf561710edceef2cea29e7c25032cb6764bc361eac0c148553e62ca5d +a95341f8f7536d95f14181e4aa01c540a345bd172b67279f5b6dfebe2c8fb7b366edb8ad7e4545eed29903eeb6f486fa9f9d825185a0333eeddd2b45 +5b7fd7b9d6623c25d508712d585fd541089c8b4721b9dc219baa9cfe14022b5ffb0ded9a546ddf183c543d1f26f9c4183f4c7ff012d61de8cb822bccb4 +fa0fc08f49144cf85dcefd25717f37de8469a943fdeaa8c764bbf483af7a37b0dcf1f50451b20e693635e94976c44ead0ef83ac632eec781e9d50efb2f9d +6ec1e621af3a878ad836aeb322e67752de29a310d7e6fbe6d164bb79e8f939d7a8f9f77a72733482d323c50ae7dc2170b90a48c59da782865eb7a9e254aba3 +10d13645bc853dcac6b71dadf4327ea0c7497822a6e0691d93a5e9d32cbafb883f9ff0c245126e391666fed31747e92c81ab886d5e75bb057faac5b3b0f1afa8 +dfb3872da01656cddd9abcb389e75a4a01d89d0d49f571e77655ad1ae0c14c87d4146accaf59f3e402767e6666228ef8e52aa32cd18306f69666769159423d8141 +d3a86236f119fa35c480d5b4b71d3aec93e226db5d2173c04e5d1d88c696594f51ec36470487fb72044a039cc081607be2a99e5d8f1c653848176f97cd2e9d50a742 +0d1f5a47c4917f6158b039e68fdeda5fa3889bbac6dff571f6353f83ada55c26bb99dac4416b2dea7d0fec2b585877aed2709f2b25516551004fee20b68e21efded761 +79a910c7f74b303d5844b609148a5a723e31c6b00d16a773547fb6d97fd35bf4a452eefd7ac3466ea520d61be4b75493156c9ae39ce6698e7120e92ebb366adeafb21d09 +a893878e100dc628ec674c4b48556c067419a3c317be94ed37cfd8ed8cae2ff035985579238f4dc13576677d527f21cde829a54466a911ab81888016c2094fda50e6dab622 +6faefe6e6bad59fab2a801aefd26d05ea3ac3ce546b0abfff524ec2ea80f3cc5c8c7015d18ae766cc84a2de75bc4c8a44cafb3743c6147e934d5de803d74ff8ca507d505065b +ef32b102fb18681c02cee796ba8bb602d927d3428c4387150a5c342532380d3234d69e58a607396af5802cfeece1554de5722931f4e09fe51ae4b74dcd7e851e9a95cf4218f96e +efe653c021ff38cabba1a76f8df2b0737ccffe6dba0506074143c88f6547afb06bcf1a36ba8e48bad9e7ee76c70717e089e1c31f052ee8859f65d6cc0d4bdccf845c8a8955d316bb +8bf54ff6ef8b0f73a569d908ef432227d7fff0e1300503c1d41f3b2618b089ba76873cc5abd22039f3bffd2bb88b4a169e1f55b8280ba8b474aee9a19a93710cdc05a51062ea5970a2 +126a003e4194b577fbf4070e8ecd47f3807afc7d9e733760a23b350649e924ebe702eaefedb70490b77fc8dbccd068baab02bcd64517aee6005d37a496f8dd92093ec34f5ec6af703836 +3b025057a1a889389b105956cffae970b21e3a1179382bb626856c793727ba9ca14706741b94b4704ce0089a378c1efadb7961fbbfd146d657b6ee605231d9ffc60eadcc6af32c43ec7e75 +0c2eadac7883bb59c278aa115b10b8d1459066b9e0061b7e4e2e1ec4caca02c6fc443e5f78c80779360f260507bc2d49beae6bf7470da5c8dca5ee51d251ed1db892db23a43c62fe088d07fc +2f40a09aea1a9b7c32e7b68845de40452c9b753c31c46118d14d3b34c8c7f3eae0f3c0018300ce4d583715debeb9bac31de392080fe2630225a0f0e0d4c5b6e19ff1fa5bf5a0cb8840fed794fc +155e5eef1e32ec06bd7a51741fbeafcbd82bddbb18fc34a984e9018f4b62d1b7ed4fc0b0d7843d4e8983ccdba6bb30d28f964994650e692a5b0b746171563be70a0c622f6a022ac4c655f216bb68 +142e1d62a31895b3a916453a0c01ca2a096d9b0747b3a2c9584822819cbffdab6c6461d4e4374e4d9363f8cc52861e2be1f4ad4edbdf4a72f1fc3667903df83a32a8810398e156ea8dd3385d416e9a +08a01d87455bfb057d64a6374f8da7ae52f4575af5085e7aa3c390de0fe528c14767525b9af87e7e5ef053bf03b2390c98f7eef36161ae1c0d9eba83c4a78d9ae5d4322cbd0b3f7aaed183f18616e49d +1c8ccae6d387f360c2fca138f1c65410918ca0cb47c15cbdee931ed03cbcec6e871f11f2692a9b9136f82b274a338805e863f87c5c0f99604c03484b1a2020732e5473bec84ced8ba05cd9490e75563628 +ac3916dc874442f05ca2409bd5c63957bca4c5363dda23846a5901010818c57874aff1787bd7c554c95aae8e354ec55beb1b79966bae64197d4383c894485c8a509064957abe7f3fa4154dc0f0e958121fcc +f0b7a82a962c7faa238acb98ebe4b904e8d5998e1856dbf68aea0933dfb3d80a44f0eaad678dacf31ee5c985fe6f9844f9490319745e89bf790d3e0cf2a788a177de8401119ebc9f7e48f58c279ef723fda7cc +6d87c3942bc4ebbc224fac383f1b22af13a4ccdfae5ee66ab8f954ebbb874f583ef07152872ce03de5c3584574b91d91d2f6fc4b14625e3e2bdfd04fc7b9441d73f9c09411f08938429c9f12e31caea17e094d9d +2e0d7c7f1c03ce9d4479fa800645abda4aade87bca0bbe547e889f8d32af7530d212171baae32831ecbd84cc27bb3da8496982a183e2785a0731220677341bcf75ae345ddb8bcdb7dccd2c4e1094d33ca53b0768cf +9bec3f01c35ba5436e44b01a96077f41aa61516dff5cef6185818e7f57d2dd0b9d9ebfeb35a0cff1ae8d98975a0cdcf2b626dd7b1f8fa2534ffc058abc1b81e1c68aaeaf8e9b255c3eabe1d675399220d4b6d967fc5f +b0d54ba8f86b01d511acb7ddb567198dabe835512d0033991a221b2bdf815d8063d073d1bbf5704f954df8f73a4ecec48417c2fec643f9e15d1d41b51f955f2422a69a2a8f73b6154881e6f6721f8e73a80efa5bfb1717 +cd41ad000e15e9b261e52b459bf79c7f7ffeb281629fba3c986c08b90a058abf76799dc72e430a1df8b64641cc2e03339ebb37fe7eabced490f77b58b3dcf492f981687036dcb94328cd9ad9f4e489de5d06bbd3671a9bf1 +21233d332c3fa9b056520c06fe55aa388773ee12ae893395df1d75c4932b54a5d679637d33930f2f8afa22be2fb4b1fd36a6c83b51057611c8119bd8cdb1efd8ee7063d5f13c09d2f8e5f8888eda3ece738e34f667aee451b9 +86418350d07d8f9d8b7e1190eb13634dc0a59f267730afe9409cecab0ac4f57feacaee8dec7321b8512991d51d4fe3b7cc2cbb5e6728ba115f022087606d15b39810032b3945e052574c7464c2b2434b2a54a801991d093f9390 +5501bfd8c7b1784515a192c0db6516b1fda893702ed45db7a5c07b32b3d9d41f396f9ed61cc4f9a143d4b4ab16c9f6975ee0a8851c62f80ddd4fdfef6c9f6f27c130a13109cd20779e4bab78200129900ecedae564c790153d2227 +7d45d142bdeff8e1b941537dab8685697988e60cd0ca0926dacc9a227de9f33e0dca5c7c17bcb3f3d3a1f39c4999313786933cb931c725b6359a1b10e31b77cd30f28e3bd4ebe898ef0ae1ee5e3a28a911fdc3759d04929c74321a9d +36f11d276af5958a737c5f457ae997455025cde0503ecf1431ea68b6567530cf3abeee2391c1c549fd3bb274120b0613828839ae74b6a071ee9d29b6247ca6a8a1cd2195d24c6215f58be04e197b541828b99e3a71d0991be8245303ad +efe64e5b4341239a2e60d342b89a302c2b8cbd45a33a5301936a051f69dd1644164bf7e24d269d341285a2c22aaa93517b1e9ae6a3d6b18961d4b1f58b357a113a12e9c6519ce7533f602b026dbd885c0584f21e099e74516d5db197dec0 +e5d90cf622738f73973fc448b7be40b044fac3dfc65d36db47f3fa9d01d41fb9808ad83e51729c0c2c35cc08226fbcd20a988ea24bb8373991e702c911d1764b309eda4d1500592ce0fee42fe111e9f9e346734b9e2758194ff9f0713613d1 +1444dfb0694d36937eb77a0b1f04c2e29e9904d1dcf03cf8d420315c5cb38463f8f3327df5cd34485b0e6db3eefedcd9015f4953a99c125f3ee803c4727c10e0ca943408d82a0c6c1b797a7a3a9e6446df53b8de29894309e81d09a321564b40 +171e9fb9e3867ac3ae4cbe09884cccb7561c2c0773ea8200c492ac338512f2017bc843b1ae5fb998c7d1f155b01b707f70dcbf68dab56d74a561b5fe7759788b5651a9ab0fe7006d0c096cacbc9ba93736bda0b967b7f1ebfb4c7a032e73f40392 +db14a6d9c6311aadd73d9fb5b38b654bf306e0ea3880d22a12032971115d22dc38f9bf03ac83a177a0e36be7f710d4a903934601d15911942f11364692d77958be02be75eb6c697e3d963f6ca2c26449272bd05cd3ec41b884a6a97381f57f19d70c +tv_kdf_hkdf: ok diff --git a/test/default/scalarmult.c b/test/default/scalarmult.c index 0e055380..b410fcd1 100644 --- a/test/default/scalarmult.c +++ b/test/default/scalarmult.c @@ -52,6 +52,12 @@ main(void) sodium_bin2hex(hex, sizeof hex, k, crypto_scalarmult_BYTES); printf("%s\n", hex); + alicepk[31] ^= 0x80; + ret = crypto_scalarmult(k, bobsk, alicepk); + assert(ret == 0); + sodium_bin2hex(hex, sizeof hex, k, crypto_scalarmult_BYTES); + printf("%s\n", hex); + ret = crypto_scalarmult(k, bobsk, small_order_p); assert(ret == -1); diff --git a/test/default/scalarmult.exp b/test/default/scalarmult.exp index 1a38d891..df1d2736 100644 --- a/test/default/scalarmult.exp +++ b/test/default/scalarmult.exp @@ -2,3 +2,4 @@ de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f 4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 +4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 diff --git a/test/default/scalarmult2.c b/test/default/scalarmult2.c index 58776cf5..d1bb83d5 100644 --- a/test/default/scalarmult2.c +++ b/test/default/scalarmult2.c @@ -8,25 +8,16 @@ static unsigned char bobsk[32] = { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb }; -static unsigned char bobpk[32]; - int main(void) { - int i; + unsigned char bobpk[32]; + char hex[65]; + int i; crypto_scalarmult_base(bobpk, bobsk); + sodium_bin2hex(hex, sizeof hex, bobpk, sizeof bobpk); + printf("%s\n", hex); - for (i = 0; i < 32; ++i) { - if (i > 0) { - printf(","); - } else { - printf(" "); - } - printf("0x%02x", (unsigned int) bobpk[i]); - if (i % 8 == 7) { - printf("\n"); - } - } return 0; } diff --git a/test/default/scalarmult2.exp b/test/default/scalarmult2.exp index b5391865..9804b113 100644 --- a/test/default/scalarmult2.exp +++ b/test/default/scalarmult2.exp @@ -1,4 +1 @@ - 0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4 -,0xd3,0x5b,0x61,0xc2,0xec,0xe4,0x35,0x37 -,0x3f,0x83,0x43,0xc8,0x5b,0x78,0x67,0x4d -,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f +de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f diff --git a/test/default/scalarmult5.c b/test/default/scalarmult5.c index f92aa408..adeda87f 100644 --- a/test/default/scalarmult5.c +++ b/test/default/scalarmult5.c @@ -14,27 +14,18 @@ static unsigned char bobpk[32] = { 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f }; -static unsigned char k[32]; - int main(void) { - int i; - int ret; + unsigned char k[32]; + char hex[65]; + int i; + int ret; ret = crypto_scalarmult(k, alicesk, bobpk); assert(ret == 0); + sodium_bin2hex(hex, sizeof hex, k, sizeof k); + printf("%s\n", hex); - for (i = 0; i < 32; ++i) { - if (i > 0) { - printf(","); - } else { - printf(" "); - } - printf("0x%02x", (unsigned int) k[i]); - if (i % 8 == 7) { - printf("\n"); - } - } return 0; } diff --git a/test/default/scalarmult5.exp b/test/default/scalarmult5.exp index bec21130..e66cca17 100644 --- a/test/default/scalarmult5.exp +++ b/test/default/scalarmult5.exp @@ -1,4 +1 @@ - 0x4a,0x5d,0x9d,0x5b,0xa4,0xce,0x2d,0xe1 -,0x72,0x8e,0x3b,0xf4,0x80,0x35,0x0f,0x25 -,0xe0,0x7e,0x21,0xc9,0x47,0xd1,0x9e,0x33 -,0x76,0xf0,0x9b,0x3c,0x1e,0x16,0x17,0x42 +4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 diff --git a/test/default/sodium_utils2.c b/test/default/sodium_utils2.c index e02fae33..e2cccc8b 100644 --- a/test/default/sodium_utils2.c +++ b/test/default/sodium_utils2.c @@ -41,32 +41,9 @@ int main(void) { void *buf; - void *buf2; size_t size; unsigned int i; - size = randombytes_uniform(100U); - if ((buf = sodium_malloc(size)) == NULL || - (buf2 = sodium_malloc(size)) == NULL) { - return 1; - } - randombytes_buf(buf, size); - memcpy(buf2, buf, size); - errno = EINVAL; - if (sodium_mshield(buf) != 0) { - assert(errno == ENOSYS); - } else { - assert(size == 0U || memcmp(buf, buf2, size) != 0); - } - errno = EINVAL; - if (sodium_munshield(buf) != 0) { - assert(errno == ENOSYS); - } else { - assert(size == 0U || memcmp(buf, buf2, size) == 0); - } - sodium_free(buf2); - sodium_free(buf); - if (sodium_malloc(SIZE_MAX - 1U) != NULL) { return 1; } diff --git a/test/symbols/all-symbols.txt b/test/symbols/all-symbols.txt index df177457..98dcb523 100644 --- a/test/symbols/all-symbols.txt +++ b/test/symbols/all-symbols.txt @@ -190,7 +190,8 @@ crypto_box_seedbytes crypto_box_zerobytes crypto_core_ed25519_add crypto_core_ed25519_bytes -crypto_core_ed25519_from_hash +crypto_core_ed25519_from_string +crypto_core_ed25519_from_string_ro crypto_core_ed25519_from_uniform crypto_core_ed25519_hashbytes crypto_core_ed25519_is_valid_point @@ -302,6 +303,18 @@ crypto_kdf_bytes_max crypto_kdf_bytes_min crypto_kdf_contextbytes crypto_kdf_derive_from_key +crypto_kdf_hkdf_sha256_bytes_max +crypto_kdf_hkdf_sha256_bytes_min +crypto_kdf_hkdf_sha256_expand +crypto_kdf_hkdf_sha256_extract +crypto_kdf_hkdf_sha256_keybytes +crypto_kdf_hkdf_sha256_keygen +crypto_kdf_hkdf_sha512_bytes_max +crypto_kdf_hkdf_sha512_bytes_min +crypto_kdf_hkdf_sha512_expand +crypto_kdf_hkdf_sha512_extract +crypto_kdf_hkdf_sha512_keybytes +crypto_kdf_hkdf_sha512_keygen crypto_kdf_keybytes crypto_kdf_keygen crypto_kdf_primitive @@ -522,9 +535,6 @@ crypto_sign_ed25519ph_final_verify crypto_sign_ed25519ph_init crypto_sign_ed25519ph_statebytes crypto_sign_ed25519ph_update -crypto_sign_edwards25519sha512batch -crypto_sign_edwards25519sha512batch_keypair -crypto_sign_edwards25519sha512batch_open crypto_sign_final_create crypto_sign_final_verify crypto_sign_init @@ -675,9 +685,7 @@ sodium_mlock sodium_mprotect_noaccess sodium_mprotect_readonly sodium_mprotect_readwrite -sodium_mshield sodium_munlock -sodium_munshield sodium_pad sodium_runtime_has_aesni sodium_runtime_has_armcrypto