Browse Source

Merge branch 'master' into coverity_scan

* master: (58 commits)
  Don't ignore azure-pipelines.yml
  Disable getentropy() on Apple devices
  lucetc will eventually use --opt-level fast instead of --opt-level best
  Ignore azure-pipelines.yml
  Bump
  Update ChangeLog
  Use Azure Pipelines to produce WASI binaries
  Update status badge
  Add Azure Pipelines build status
  Name things consistently
  Conditions don't apply to scripts
  Parallelize MinGW builds
  Reserve a branch for testing the next version
  Don't trigger Azure Pipelines on PRs, keep Appveyor for this
  Azure Pipelines: build MinGW binaries
  azure-pipelines: remove the packages job
  Add Azure Pipelines rules
  Indent Appveyor rules
  Support the enterprise version of Visual Studio
  Revert "Limit resources when running tests"
  ...
coverity_scan
Frank Denis 5 years ago
parent
commit
856d21e514
  1. 29
      ChangeLog
  2. 1
      README.markdown
  3. 3
      appveyor.yml
  4. 31
      autogen.sh
  5. 153
      azure-pipelines.yml
  6. 41
      builds/msvc/build/buildbase.bat
  7. 4
      builds/msvc/resource.rc
  8. 4
      builds/msvc/version.h
  9. 12
      configure.ac
  10. 429
      contrib/Findsodium.cmake
  11. 9
      dist-build/emscripten-symbols.def
  12. 24
      dist-build/emscripten.sh
  13. 6
      dist-build/wasm32-wasi.sh
  14. 4
      msvc-scripts/process.bat
  15. 10
      packaging/dotnet-core/README.md
  16. 14
      packaging/dotnet-core/prepare.py
  17. 2
      packaging/nuget/package.config
  18. 25
      src/libsodium/crypto_core/ed25519/core_ed25519.c
  19. 17
      src/libsodium/crypto_core/ed25519/core_ristretto255.c
  20. 78
      src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
  21. 4
      src/libsodium/crypto_core/salsa/ref/core_salsa_ref.c
  22. 16
      src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.h
  23. 126
      src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-avx2.h
  24. 4
      src/libsodium/crypto_pwhash/argon2/argon2-core.c
  25. 4
      src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c
  26. 4
      src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
  27. 3
      src/libsodium/crypto_scalarmult/ristretto255/ref10/scalarmult_ristretto255_ref10.c
  28. 2
      src/libsodium/crypto_sign/ed25519/ref10/obsolete.c
  29. 2
      src/libsodium/crypto_sign/ed25519/ref10/sign.c
  30. 2
      src/libsodium/include/sodium/crypto_aead_aes256gcm.h
  31. 12
      src/libsodium/include/sodium/crypto_core_ed25519.h
  32. 12
      src/libsodium/include/sodium/crypto_core_ristretto255.h
  33. 2
      src/libsodium/include/sodium/private/common.h
  34. 4
      src/libsodium/include/sodium/private/ed25519_ref10.h
  35. 12
      src/libsodium/randombytes/internal/randombytes_internal_random.c
  36. 2
      src/libsodium/sodium/runtime.c
  37. 6
      test/default/aead_xchacha20poly1305.c
  38. 65
      test/default/box_seal.c
  39. 4
      test/default/box_seal.exp
  40. 43
      test/default/core_ed25519.c
  41. 99
      test/default/core_ristretto255.c
  42. 2
      test/default/pwhash_scrypt.c
  43. 1
      test/default/pwhash_scrypt.exp
  44. 12
      test/default/scalarmult_ed25519.c
  45. 4
      test/default/scalarmult_ristretto255.c
  46. 8
      test/default/wasi-test-wrapper.sh

29
ChangeLog

@ -1,4 +1,33 @@
* Version 1.0.18
- The Enterprise versions of Visual Studio are now supported.
- Visual Studio 2019 is now supported.
- 32-bit binaries for Visual Studio 2010 are now provided.
- A test that didn't work properly on Linux systems with overcommit
memory turned on has been removed. This fixes Ansible builds.
- Emscripten: `print` and `printErr` functions are overridden to send
errors to the console, if there is one.
- Emscripten: `UTF8ToString()` is now exported since `Pointer_stringify()`
has been deprecated.
- Libsodium version detection has been fixed in the CMake recipe.
- Generic hashing got a 10% speedup on AVX2.
- New target: WebAssembly/WASI (compile with `dist-builds/wasm32-wasi.sh`).
- New functions to map a hash to an edwards25519 point or get a random point:
`core_ed25519_from_hash()` and `core_ed25519_random()`.
- `crypto_core_ed25519_scalar_mul()` has been implemented for `scalar*scalar`
`(mod L)` multiplication.
- Support for the Ristretto group has been implemented, for compatibility
with wasm-crypto.
- Improvements have been made to the test suite.
- Portability improvements has been made.
- `getentropy()` is now used on systems providing this system call.
- `randombytes_salsa20 has been renamed to `randombytes_internal`.
- Support for (p)nacl has been removed.
- Most `((nonnull))` attributes have been relaxed to allow 0-length inputs
to be `NULL`.
- The `-ftree-vectorize` and `-ftree-slp-vectorize` compiler switches are
now used, if available, for optimized builds.
* Version 1.0.17
- Bug fix: `sodium_pad()` didn't properly support block sizes >= 256 bytes.
- JS/WebAssembly: some old iOS versions can't instantiate the WebAssembly

1
README.markdown

@ -1,6 +1,7 @@
[![Build Status](https://travis-ci.org/jedisct1/libsodium.svg?branch=master)](https://travis-ci.org/jedisct1/libsodium?branch=master)
[![Windows build status](https://ci.appveyor.com/api/projects/status/fu8s2elx25il98hj?svg=true)](https://ci.appveyor.com/project/jedisct1/libsodium)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/2397/badge.svg)](https://scan.coverity.com/projects/2397)
[![Azure build status](https://jedisct1.visualstudio.com/Libsodium/_apis/build/status/jedisct1.libsodium?branchName=stable)](https://jedisct1.visualstudio.com/Libsodium/_build/latest?definitionId=3&branchName=stable)
![libsodium](https://raw.github.com/jedisct1/libsodium/master/logo.png)
============

3
appveyor.yml

@ -16,8 +16,7 @@ environment:
matrix:
fast_finish: false
init:
msbuild /version
init: msbuild /version
build:
parallel: true

31
autogen.sh

@ -1,6 +1,6 @@
#! /bin/sh
if glibtoolize --version > /dev/null 2>&1; then
if glibtoolize --version >/dev/null 2>&1; then
LIBTOOLIZE='glibtoolize'
else
LIBTOOLIZE='libtoolize'
@ -26,11 +26,28 @@ command -v automake >/dev/null 2>&1 || {
exit 1
}
if autoreconf --version > /dev/null 2>&1 ; then
exec autoreconf -ivf
if autoreconf --version >/dev/null 2>&1; then
autoreconf -ivf
else
$LIBTOOLIZE &&
aclocal &&
automake --add-missing --force-missing --include-deps &&
autoconf
fi
$LIBTOOLIZE && \
aclocal && \
automake --add-missing --force-missing --include-deps && \
autoconf
[ -z "$DO_NOT_UPDATE_CONFIG_SCRIPTS" ] &&
command -v curl >/dev/null 2>&1 && {
echo "Downloading config.guess and config.sub..."
curl -sL -o config.guess \
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' &&
mv -f config.guess build-aux/config.guess
curl -sL -o config.sub \
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' &&
mv -f config.sub build-aux/config.sub
echo "Done."
}
rm -f config.guess config.sub

153
azure-pipelines.yml

@ -0,0 +1,153 @@
trigger:
- stable
- next
pr: none
jobs:
- job: "wasi"
pool:
vmImage: "ubuntu-16.04"
steps:
- script: |
sudo apt-get install build-essential curl cmake
displayName: Install system packages
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
source ${HOME}/.cargo/env
git clone --recursive https://github.com/wasmerio/wasmer.git
(cd wasmer && cargo install --path .)
displayName: Install wasmer
- script: |
curl -sL -o wasi-sdk.deb https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-5/wasi-sdk_5.0_amd64.deb
sudo dpkg -i wasi-sdk.deb && rm -f wasi-sdk.deb
sudo ln -s /opt/wasi-sdk/share/*sysroot* /opt/wasi-sysroot
displayName: Install the WASI SDK
- script: |
env PATH=/opt/wasi-sdk/bin:${HOME}/.cargo/bin:$PATH dist-build/wasm32-wasi.sh
displayName: Compile libsodium
- task: PublishBuildArtifacts@1
condition: not(canceled())
inputs:
pathToPublish: libsodium-wasm32-wasi
artifactName: libsodium-wasm32-wasi
- job: "windows"
pool:
vmImage: "windows-2019"
steps:
- powershell: |
cd builds\msvc\build
& .\buildbase.bat ..\vs2019\libsodium.sln 16
displayName: Compile it all
- powershell: |
mkdir bin\include\sodium
Copy-Item "src\libsodium\include\sodium\*.h" -Destination "bin\include\sodium" -Recurse
Copy-Item "src\libsodium\include\*.h" -Destination "bin\include\"
displayName: Copy header files
- task: PublishBuildArtifacts@1
condition: not(canceled())
inputs:
pathToPublish: bin
artifactName: libsodium
- job: "windows_old"
pool:
vmImage: "vs2017-win2016"
steps:
- powershell: |
cd builds\msvc\build
& .\buildbase.bat ..\vs2017\libsodium.sln 15
displayName: Compile it all
- task: PublishBuildArtifacts@1
condition: not(canceled())
inputs:
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"
steps:
- script: |
git clone https://github.com/msys2/msys2-ci-base.git %CD:~0,2%\msys64
%CD:~0,2%\msys64\usr\bin\rm -rf %CD:~0,2%\msys64\.git
displayName: Install MSYS2
- script: |
set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syuu
displayName: Update MSYS2
- script: |
set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S base-devel mingw-w64-x86_64-toolchain
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc
%CD:~0,2%\msys64\usr\bin\sed -i "s|#CacheDir.*|CacheDir=/c/Users/%USERNAME%/AppData/Local/Temp|g" /etc/pacman.conf
displayName: Install Toolchain
- script: |
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;%CD:~0,2%\msys64\usr\bin;%CD:~0,2%\msys64\bin
set MSYS2_ROOT=%CD:~0,2%\msys64
set MSYSTEM=MINGW64
%MSYS2_ROOT%\cmd\msystem MINGW64
%CD:~0,2%\msys64\usr\bin\bash -lc dist-build/msys2-win64.sh
env:
CHERE_INVOKING: yes
MSYS2_ARCH: x86_64
displayName: Compile libsodium
- task: PublishBuildArtifacts@1
condition: not(canceled())
inputs:
pathToPublish: libsodium-win64
artifactName: libsodium-win64
- job: mingw32
pool:
vmImage: "windows-2019"
steps:
- script: |
git clone https://github.com/msys2/msys2-ci-base.git %CD:~0,2%\msys64
%CD:~0,2%\msys64\usr\bin\rm -rf %CD:~0,2%\msys64\.git
displayName: Install MSYS2
- script: |
set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syyuu
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Syuu
displayName: Update MSYS2
- script: |
set PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm --needed -S base-devel mingw-w64-i686-toolchain
%CD:~0,2%\msys64\usr\bin\pacman --noconfirm -Scc
%CD:~0,2%\msys64\usr\bin\sed -i "s|#CacheDir.*|CacheDir=/c/Users/%USERNAME%/AppData/Local/Temp|g" /etc/pacman.conf
displayName: Install Toolchain
- script: |
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;%CD:~0,2%\msys64\usr\bin;%CD:~0,2%\msys64\bin
set MSYS2_ROOT=%CD:~0,2%\msys64
set MSYSTEM=MINGW32
%MSYS2_ROOT%\cmd\msystem MINGW32
%CD:~0,2%\msys64\usr\bin\bash -lc dist-build/msys2-win32.sh
env:
CHERE_INVOKING: yes
MSYS2_ARCH: x86_64
displayName: Compile libsodium
- task: PublishBuildArtifacts@1
condition: not(canceled())
inputs:
pathToPublish: libsodium-win32
artifactName: libsodium-win32

41
builds/msvc/build/buildbase.bat

@ -1,19 +1,44 @@
@ECHO OFF
REM Usage: [buildbase.bat ..\vs2019\mysolution.sln 16]
SETLOCAL enabledelayedexpansion
SET solution=%1
SET version=%2
SET log=build_%version%.log
SET tools=Microsoft Visual Studio %version%.0\VC\vcvarsall.bat
IF %version% == 16 SET tools=Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat
IF %version% == 15 SET tools=Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
SET environment="%programfiles(x86)%\%tools%"
IF NOT EXIST %environment% SET environment="%programfiles%\%tools%"
IF NOT EXIST %environment% GOTO no_tools
IF %version% == 16 (
SET tools=Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
SET environment="%programfiles%\!tools!"
IF NOT EXIST !environment! (
SET environment="%programfiles(x86)%\!tools!"
IF NOT EXIST !environment! (
SET tools=Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat
)
)
)
IF %version% == 15 (
SET tools=Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
SET environment="%programfiles%\!tools!"
IF NOT EXIST !environment! (
SET environment="%programfiles(x86)%\!tools!"
IF NOT EXIST !environment! (
SET tools=Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
)
)
)
SET environment="%programfiles%\!tools!"
IF NOT EXIST !environment! SET environment="%programfiles(x86)%\!tools!"
ECHO Environment: !environment!
IF NOT EXIST !environment! GOTO no_tools
ECHO Building: %solution%
CALL %environment% x86 > nul
CALL !environment! x86 > nul
ECHO Platform=x86
ECHO Configuration=DynDebug
@ -35,7 +60,7 @@ ECHO Configuration=StaticRelease
msbuild /m /v:n /p:Configuration=StaticRelease /p:Platform=Win32 %solution% >> %log%
IF errorlevel 1 GOTO error
CALL %environment% x86_amd64 > nul
CALL !environment! x86_amd64 > nul
ECHO Platform=x64
ECHO Configuration=DynDebug
@ -65,7 +90,7 @@ ECHO *** ERROR, build terminated early, see: %log%
GOTO end
:no_tools
ECHO *** ERROR, build tools not found: %tools%
ECHO *** ERROR, build tools not found: !tools!
:end

4
builds/msvc/resource.rc

@ -4,8 +4,8 @@
#include "windows.h"
//specify the version numbers for the dll's
#define LIBSODIUM_VERSION_STRING "1.0.17.0"
#define LIBSODIUM_VERSION_BIN 1,0,17,0
#define LIBSODIUM_VERSION_STRING "1.0.18.0"
#define LIBSODIUM_VERSION_BIN 1,0,18,0
//specify the product name for the dlls based on the platform we are compiling for
#if defined(x64)

4
builds/msvc/version.h

@ -4,10 +4,10 @@
#include "export.h"
#define SODIUM_VERSION_STRING "1.0.17"
#define SODIUM_VERSION_STRING "1.0.18"
#define SODIUM_LIBRARY_VERSION_MAJOR 10
#define SODIUM_LIBRARY_VERSION_MINOR 2
#define SODIUM_LIBRARY_VERSION_MINOR 3
#ifdef __cplusplus
extern "C" {

12
configure.ac

@ -1,5 +1,5 @@
AC_PREREQ([2.65])
AC_INIT([libsodium],[1.0.17],
AC_INIT([libsodium],[1.0.18],
[https://github.com/jedisct1/libsodium/issues],
[libsodium],
[https://github.com/jedisct1/libsodium])
@ -15,9 +15,9 @@ AM_DEP_TRACK
AC_SUBST(VERSION)
SODIUM_LIBRARY_VERSION_MAJOR=10
SODIUM_LIBRARY_VERSION_MINOR=2
DLL_VERSION=23
SODIUM_LIBRARY_VERSION=25:0:2
SODIUM_LIBRARY_VERSION_MINOR=3
DLL_VERSION=24
SODIUM_LIBRARY_VERSION=26:0:3
# | | |
# +------+ | +---+
# | | |
@ -825,6 +825,10 @@ unsigned char buf;
# include <sys/random.h>
#endif
]], [[
#ifdef __APPLE__
# error getentropy() is currently disabled on Apple operating systems
#endif
unsigned char buf;
(void) getentropy((void *) &buf, 1U);
]])],

429
contrib/Findsodium.cmake

@ -1,107 +1,101 @@
# Written in 2016 by Henrik Steffen Gaßmann <henrik@gassmann.onl>
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication
# along with this software. If not, see
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see
#
# http://creativecommons.org/publicdomain/zero/1.0/
# http://creativecommons.org/publicdomain/zero/1.0/
#
########################################################################
# ##############################################################################
# Tries to find the local libsodium installation.
#
# On Windows the sodium_DIR environment variable is used as a default
# hint which can be overridden by setting the corresponding cmake variable.
# On Windows the sodium_DIR environment variable is used as a default hint which
# can be overridden by setting the corresponding cmake variable.
#
# Once done the following variables will be defined:
#
# sodium_FOUND
# sodium_INCLUDE_DIR
# sodium_LIBRARY_DEBUG
# sodium_LIBRARY_RELEASE
#
# sodium_FOUND sodium_INCLUDE_DIR sodium_LIBRARY_DEBUG sodium_LIBRARY_RELEASE
# sodium_VERSION_STRING
#
# Furthermore an imported "sodium" target is created.
#
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(_GCC_COMPATIBLE 1)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(_GCC_COMPATIBLE 1)
endif()
# static library option
if (NOT DEFINED sodium_USE_STATIC_LIBS)
option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
if(NOT DEFINED sodium_USE_STATIC_LIBS)
option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
endif()
if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST))
unset(sodium_LIBRARY CACHE)
unset(sodium_LIBRARY_DEBUG CACHE)
unset(sodium_LIBRARY_RELEASE CACHE)
unset(sodium_DLL_DEBUG CACHE)
unset(sodium_DLL_RELEASE CACHE)
set(sodium_USE_STATIC_LIBS_LAST ${sodium_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
unset(sodium_LIBRARY CACHE)
unset(sodium_LIBRARY_DEBUG CACHE)
unset(sodium_LIBRARY_RELEASE CACHE)
unset(sodium_DLL_DEBUG CACHE)
unset(sodium_DLL_RELEASE CACHE)
set(sodium_USE_STATIC_LIBS_LAST
${sodium_USE_STATIC_LIBS}
CACHE INTERNAL "internal change tracking variable")
endif()
########################################################################
# ##############################################################################
# UNIX
if (UNIX)
# import pkg-config
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(sodium_PKG QUIET libsodium)
endif()
if(UNIX)
# import pkg-config
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(sodium_PKG QUIET libsodium)
endif()
if(sodium_USE_STATIC_LIBS)
if (sodium_PKG_STATIC_LIBRARIES)
foreach(_libname ${sodium_PKG_STATIC_LIBRARIES})
if (NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending with .a
list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a")
endif()
endforeach()
list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES)
else()
# if pkgconfig for libsodium doesn't provide
# static lib info, then override PKG_STATIC here..
set(sodium_PKG_STATIC_LIBRARIES libsodium.a)
if(sodium_USE_STATIC_LIBS)
if(sodium_PKG_STATIC_LIBRARIES)
foreach(_libname ${sodium_PKG_STATIC_LIBRARIES})
if(NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending
# with .a
list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a")
endif()
set(XPREFIX sodium_PKG_STATIC)
endforeach()
list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES)
else()
if (sodium_PKG_LIBRARIES STREQUAL "")
set(sodium_PKG_LIBRARIES sodium)
endif()
# if pkgconfig for libsodium doesn't provide static lib info, then
# override PKG_STATIC here..
set(sodium_PKG_STATIC_LIBRARIES libsodium.a)
endif()
set(XPREFIX sodium_PKG)
set(XPREFIX sodium_PKG_STATIC)
else()
if(sodium_PKG_LIBRARIES STREQUAL "")
set(sodium_PKG_LIBRARIES sodium)
endif()
find_path(sodium_INCLUDE_DIR sodium.h
HINTS ${${XPREFIX}_INCLUDE_DIRS}
)
find_library(sodium_LIBRARY_DEBUG NAMES ${${XPREFIX}_LIBRARIES}
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
find_library(sodium_LIBRARY_RELEASE NAMES ${${XPREFIX}_LIBRARIES}
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
set(XPREFIX sodium_PKG)
endif()
find_path(sodium_INCLUDE_DIR sodium.h HINTS ${${XPREFIX}_INCLUDE_DIRS})
find_library(sodium_LIBRARY_DEBUG
NAMES ${${XPREFIX}_LIBRARIES}
HINTS ${${XPREFIX}_LIBRARY_DIRS})
find_library(sodium_LIBRARY_RELEASE
NAMES ${${XPREFIX}_LIBRARIES}
HINTS ${${XPREFIX}_LIBRARY_DIRS})
########################################################################
# Windows
elseif (WIN32)
set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
mark_as_advanced(sodium_DIR)
# ############################################################################
# Windows
elseif(WIN32)
set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
mark_as_advanced(sodium_DIR)
find_path(sodium_INCLUDE_DIR sodium.h
HINTS ${sodium_DIR}
PATH_SUFFIXES include
)
find_path(sodium_INCLUDE_DIR sodium.h
HINTS ${sodium_DIR}
PATH_SUFFIXES include)
if (MSVC)
# detect target architecture
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.c" [=[
if(MSVC)
# detect target architecture
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.c" [=[
#if defined _M_IX86
#error ARCH_VALUE x86_32
#elif defined _M_X64
@ -109,180 +103,191 @@ elseif (WIN32)
#endif
#error ARCH_VALUE unknown
]=])
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.c"
OUTPUT_VARIABLE _COMPILATION_LOG
)
string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}")
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/arch.c"
OUTPUT_VARIABLE _COMPILATION_LOG)
string(REGEX
REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*"
"\\1"
_TARGET_ARCH
"${_COMPILATION_LOG}")
# construct library path
if (_TARGET_ARCH STREQUAL "x86_32")
string(APPEND _PLATFORM_PATH "Win32")
elseif(_TARGET_ARCH STREQUAL "x86_64")
string(APPEND _PLATFORM_PATH "x64")
else()
message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.")
endif()
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
# construct library path
if(_TARGET_ARCH STREQUAL "x86_32")
string(APPEND _PLATFORM_PATH "Win32")
elseif(_TARGET_ARCH STREQUAL "x86_64")
string(APPEND _PLATFORM_PATH "x64")
else()
message(
FATAL_ERROR
"the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake."
)
endif()
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
if (MSVC_VERSION LESS 1900)
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
else()
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
endif()
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
if(MSVC_VERSION LESS 1900)
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
else()
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
endif()
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
if (sodium_USE_STATIC_LIBS)
string(APPEND _PLATFORM_PATH "/static")
else()
string(APPEND _PLATFORM_PATH "/dynamic")
endif()
if(sodium_USE_STATIC_LIBS)
string(APPEND _PLATFORM_PATH "/static")
else()
string(APPEND _PLATFORM_PATH "/dynamic")
endif()
string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}")
string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}")
string(REPLACE "$$CONFIG$$"
"Debug"
_DEBUG_PATH_SUFFIX
"${_PLATFORM_PATH}")
string(REPLACE "$$CONFIG$$"
"Release"
_RELEASE_PATH_SUFFIX
"${_PLATFORM_PATH}")
find_library(sodium_LIBRARY_DEBUG libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
)
find_library(sodium_LIBRARY_RELEASE libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
)
if (NOT sodium_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
find_library(sodium_DLL_DEBUG libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
)
find_library(sodium_DLL_RELEASE libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
endif()
elseif(_GCC_COMPATIBLE)
if (sodium_USE_STATIC_LIBS)
find_library(sodium_LIBRARY_DEBUG libsodium.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
find_library(sodium_LIBRARY_RELEASE libsodium.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
else()
find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
find_library(sodium_LIBRARY_DEBUG libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX})
find_library(sodium_LIBRARY_RELEASE libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX})
if(NOT sodium_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
find_library(sodium_DLL_DEBUG libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX})
find_library(sodium_DLL_RELEASE libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX})
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
endif()
file(GLOB _DLL
LIST_DIRECTORIES false
RELATIVE "${sodium_DIR}/bin"
"${sodium_DIR}/bin/libsodium*.dll"
)
find_library(sodium_DLL_DEBUG ${_DLL} libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES bin
)
find_library(sodium_DLL_RELEASE ${_DLL} libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES bin
)
endif()
elseif(_GCC_COMPATIBLE)
if(sodium_USE_STATIC_LIBS)
find_library(sodium_LIBRARY_DEBUG libsodium.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib)
find_library(sodium_LIBRARY_RELEASE libsodium.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib)
else()
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
endif()
find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib)
find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib)
file(GLOB _DLL
LIST_DIRECTORIES false
RELATIVE "${sodium_DIR}/bin"
"${sodium_DIR}/bin/libsodium*.dll")
find_library(sodium_DLL_DEBUG ${_DLL} libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES bin)
find_library(sodium_DLL_RELEASE ${_DLL} libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES bin)
endif()
else()
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
endif()
########################################################################
# unsupported
# ############################################################################
# unsupported
else()
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
endif()
########################################################################
# ##############################################################################
# common stuff
# extract sodium version
if (sodium_INCLUDE_DIR)
set(_VERSION_HEADER "${_INCLUDE_DIR}/sodium/version.h")
if (EXISTS _VERSION_HEADER)
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" "\\1"
sodium_VERSION "${_VERSION_HEADER_CONTENT}")
set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE)
endif()
if(sodium_INCLUDE_DIR)
set(_VERSION_HEADER "${sodium_INCLUDE_DIR}/sodium/version.h")
if(EXISTS "${_VERSION_HEADER}")
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
string(
REGEX
REPLACE
".*#[ \t]*define[ \t]*sodium_VERSION_STRING_STRING[ \t]*\"([^\n]*)\".*"
"\\1"
sodium_VERSION_STRING
"${_VERSION_HEADER_CONTENT}")
set(sodium_VERSION_STRING "${sodium_VERSION_STRING}")
endif()
endif()
# communicate results
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(sodium
REQUIRED_VARS
sodium_LIBRARY_RELEASE
sodium_LIBRARY_DEBUG
sodium_INCLUDE_DIR
VERSION_VAR
sodium_VERSION
)
REQUIRED_VARS
sodium_LIBRARY_RELEASE
sodium_LIBRARY_DEBUG
sodium_INCLUDE_DIR
VERSION_VAR
sodium_VERSION_STRING)
# mark file paths as advanced
mark_as_advanced(sodium_INCLUDE_DIR)
mark_as_advanced(sodium_LIBRARY_DEBUG)
mark_as_advanced(sodium_LIBRARY_RELEASE)
if (WIN32)
mark_as_advanced(sodium_DLL_DEBUG)
mark_as_advanced(sodium_DLL_RELEASE)
if(WIN32)
mark_as_advanced(sodium_DLL_DEBUG)
mark_as_advanced(sodium_DLL_RELEASE)
endif()
# create imported target
if(sodium_USE_STATIC_LIBS)
set(_LIB_TYPE STATIC)
set(_LIB_TYPE STATIC)
else()
set(_LIB_TYPE SHARED)
set(_LIB_TYPE SHARED)
endif()
add_library(sodium ${_LIB_TYPE} IMPORTED)
set_target_properties(sodium PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${sodium_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
)
set_target_properties(sodium
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${sodium_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES
"C")
if (sodium_USE_STATIC_LIBS)
set_target_properties(sodium PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "SODIUM_STATIC"
IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}"
)
if(sodium_USE_STATIC_LIBS)
set_target_properties(sodium
PROPERTIES INTERFACE_COMPILE_DEFINITIONS
"SODIUM_STATIC"
IMPORTED_LOCATION
"${sodium_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG
"${sodium_LIBRARY_DEBUG}")
else()
if (UNIX)
set_target_properties(sodium PROPERTIES
IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}"
)
elseif (WIN32)
set_target_properties(sodium PROPERTIES
IMPORTED_IMPLIB "${sodium_LIBRARY_RELEASE}"
IMPORTED_IMPLIB_DEBUG "${sodium_LIBRARY_DEBUG}"
)
if (NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND"))
set_target_properties(sodium PROPERTIES
IMPORTED_LOCATION_DEBUG "${sodium_DLL_DEBUG}"
)
endif()
if (NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND"))
set_target_properties(sodium PROPERTIES
IMPORTED_LOCATION_RELWITHDEBINFO "${sodium_DLL_RELEASE}"
IMPORTED_LOCATION_MINSIZEREL "${sodium_DLL_RELEASE}"
IMPORTED_LOCATION_RELEASE "${sodium_DLL_RELEASE}"
)
endif()
if(UNIX)
set_target_properties(sodium
PROPERTIES IMPORTED_LOCATION
"${sodium_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG
"${sodium_LIBRARY_DEBUG}")
elseif(WIN32)
set_target_properties(sodium
PROPERTIES IMPORTED_IMPLIB
"${sodium_LIBRARY_RELEASE}"
IMPORTED_IMPLIB_DEBUG
"${sodium_LIBRARY_DEBUG}")
if(NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND"))
set_target_properties(sodium
PROPERTIES IMPORTED_LOCATION_DEBUG
"${sodium_DLL_DEBUG}")
endif()
if(NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND"))
set_target_properties(sodium
PROPERTIES IMPORTED_LOCATION_RELWITHDEBINFO
"${sodium_DLL_RELEASE}"
IMPORTED_LOCATION_MINSIZEREL
"${sodium_DLL_RELEASE}"
IMPORTED_LOCATION_RELEASE
"${sodium_DLL_RELEASE}")
endif()
endif()
endif()

9
dist-build/emscripten-symbols.def

@ -145,12 +145,16 @@ _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_uniform 0 1
_crypto_core_ed25519_hashbytes 0 1
_crypto_core_ed25519_is_valid_point 0 1
_crypto_core_ed25519_nonreducedscalarbytes 0 1
_crypto_core_ed25519_random 0 1
_crypto_core_ed25519_scalar_add 0 1
_crypto_core_ed25519_scalar_complement 0 1
_crypto_core_ed25519_scalar_invert 0 1
_crypto_core_ed25519_scalar_mul 0 1
_crypto_core_ed25519_scalar_negate 0 1
_crypto_core_ed25519_scalar_random 0 1
_crypto_core_ed25519_scalar_reduce 0 1
@ -170,12 +174,15 @@ _crypto_core_hsalsa20_keybytes 0 1
_crypto_core_hsalsa20_outputbytes 0 1
_crypto_core_ristretto255_add 0 1
_crypto_core_ristretto255_bytes 0 1
_crypto_core_ristretto255_from_uniform 0 1
_crypto_core_ristretto255_from_hash 0 1
_crypto_core_ristretto255_hashbytes 0 1
_crypto_core_ristretto255_is_valid_point 0 1
_crypto_core_ristretto255_nonreducedscalarbytes 0 1
_crypto_core_ristretto255_random 0 1
_crypto_core_ristretto255_scalar_add 0 1
_crypto_core_ristretto255_scalar_complement 0 1
_crypto_core_ristretto255_scalar_invert 0 1
_crypto_core_ristretto255_scalar_mul 0 1
_crypto_core_ristretto255_scalar_negate 0 1
_crypto_core_ristretto255_scalar_random 0 1
_crypto_core_ristretto255_scalar_reduce 0 1

24
dist-build/emscripten.sh

File diff suppressed because one or more lines are too long

6
dist-build/wasm32-wasi.sh

@ -11,7 +11,7 @@ export PREFIX="$(pwd)/libsodium-wasm32-wasi"
mkdir -p $PREFIX || exit 1
export CC="clang"
export CFLAGS="--target=wasm32-unknkown-wasi --sysroot=${WASI_SYSROOT} -O2"
export CFLAGS="-DED25519_NONDETERMINISTIC=1 --target=wasm32-wasi --sysroot=${WASI_SYSROOT} -O2"
export LDFLAGS="-s -Wl,--no-threads"
export NM="llvm-nm"
export AR="llvm-ar"
@ -20,7 +20,7 @@ export STRIP="llvm-strip"
make distclean > /dev/null
grep -q -F -- '-wasi' build-aux/config.sub || \
grep -q -F -- 'wasi' build-aux/config.sub || \
sed -i -e 's/-nacl\*)/-nacl*|-wasi)/' build-aux/config.sub
if [ "x$1" = "x--bench" ]; then
@ -36,7 +36,7 @@ fi
./configure ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
--prefix="$PREFIX" --with-sysroot="$WASI_SYSROOT" \
--host=wasm32-unknown-wasi \
--host=wasm32-wasi \
--disable-ssp --disable-shared || exit 1
NPROCESSORS=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)

4
msvc-scripts/process.bat

@ -1,5 +1,5 @@
cscript msvc-scripts/rep.vbs //Nologo s/@VERSION@/1.0.17/ < src\libsodium\include\sodium\version.h.in > tmp
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@/2/ < tmp2 > tmp3
cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MINOR@/3/ < tmp2 > tmp3
cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_MINIMAL_DEF@// < tmp3 > src\libsodium\include\sodium\version.h
del tmp tmp2 tmp3

10
packaging/dotnet-core/README.md

@ -31,15 +31,15 @@ Version numbers for the packages for .NET Core consist of three components:
It may be necessary to release more than one package for a libsodium version,
e.g., when adding support for a new platform or if a release contains a broken
binary. In this case, a package revision number is added as a fourth part to
the libsodium version, starting at `1`. For example, `1.0.17` is the initial
release of the package for libsodium 1.0.17 and `1.0.17.5` is the fifth
the libsodium version, starting at `1`. For example, `1.0.18` is the initial
release of the package for libsodium 1.0.18 and `1.0.18.5` is the fifth
revision (sixth release) of that package.
* *pre-release label*
If a package is a pre-release, a label is appended to the version number in
`-preview-##` format where `##` is the number of the pre-release, starting at
`01`. For example, `1.0.17-preview-01` is the first pre-release of the package
for libsodium 1.0.17 and `1.0.17.5-preview-02` the second pre-release of the
fifth revision of the package for libsodium 1.0.17.
`01`. For example, `1.0.18-preview-01` is the first pre-release of the package
for libsodium 1.0.18 and `1.0.18.5-preview-02` the second pre-release of the
fifth revision of the package for libsodium 1.0.18.
**Making a release**

14
packaging/dotnet-core/prepare.py

@ -203,13 +203,13 @@ def main(args):
print(" python3 prepare.py <version>")
print()
print("Examples:")
print(" python3 prepare.py 1.0.17-preview-01")
print(" python3 prepare.py 1.0.17-preview-02")
print(" python3 prepare.py 1.0.17-preview-03")
print(" python3 prepare.py 1.0.17")
print(" python3 prepare.py 1.0.17.1-preview-01")
print(" python3 prepare.py 1.0.17.1")
print(" python3 prepare.py 1.0.17.2")
print(" python3 prepare.py 1.0.18-preview-01")
print(" python3 prepare.py 1.0.18-preview-02")
print(" python3 prepare.py 1.0.18-preview-03")
print(" python3 prepare.py 1.0.18")
print(" python3 prepare.py 1.0.18.1-preview-01")
print(" python3 prepare.py 1.0.18.1")
print(" python3 prepare.py 1.0.18.2")
return 1
version = Version(m.group(2), m.group(0))

2
packaging/nuget/package.config

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- These values are populated into the package.gsl templates by package.bat. -->
<!-- The target attribute controls path and file name only, id controls package naming. -->
<package id="libsodium_vc120" target="libsodium" version = "1.0.17.0" pathversion="1_0_17_0" platformtoolset="v120" />
<package id="libsodium_vc120" target="libsodium" version = "1.0.18.0" pathversion="1_0_18_0" platformtoolset="v120" />

25
src/libsodium/crypto_core/ed25519/core_ed25519.c

@ -67,7 +67,24 @@ crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r)
{
ge25519_from_uniform(p, r);
return - ge25519_has_small_order(p);
return 0;
}
int
crypto_core_ed25519_from_hash(unsigned char *p, const unsigned char *h)
{
ge25519_from_hash(p, h);
return 0;
}
void
crypto_core_ed25519_random(unsigned char *p)
{
unsigned char h[crypto_core_ed25519_HASHBYTES];
randombytes_buf(h, sizeof h);
(void) crypto_core_ed25519_from_hash(p, h);
}
void
@ -195,6 +212,12 @@ crypto_core_ed25519_uniformbytes(void)
return crypto_core_ed25519_UNIFORMBYTES;
}
size_t
crypto_core_ed25519_hashbytes(void)
{
return crypto_core_ed25519_HASHBYTES;
}
size_t
crypto_core_ed25519_scalarbytes(void)
{

17
src/libsodium/crypto_core/ed25519/core_ristretto255.c

@ -60,13 +60,22 @@ crypto_core_ristretto255_sub(unsigned char *r,
}
int
crypto_core_ristretto255_from_uniform(unsigned char *p, const unsigned char *r)
crypto_core_ristretto255_from_hash(unsigned char *p, const unsigned char *r)
{
ristretto255_from_uniform(p, r);
ristretto255_from_hash(p, r);
return 0;
}
void
crypto_core_ristretto255_random(unsigned char *p)
{
unsigned char h[crypto_core_ristretto255_HASHBYTES];
randombytes_buf(h, sizeof h);
(void) crypto_core_ristretto255_from_hash(p, h);
}
void
crypto_core_ristretto255_scalar_random(unsigned char *r)
{
@ -135,9 +144,9 @@ crypto_core_ristretto255_nonreducedscalarbytes(void)
}
size_t
crypto_core_ristretto255_uniformbytes(void)
crypto_core_ristretto255_hashbytes(void)
{
return crypto_core_ristretto255_UNIFORMBYTES;
return crypto_core_ristretto255_HASHBYTES;
}
size_t

78
src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c

@ -2525,27 +2525,19 @@ chi25519(fe25519 out, const fe25519 z)
fe25519_mul(out, t1, t0);
}
void
ge25519_from_uniform(unsigned char s[32], const unsigned char r[32])
static void
ge25519_elligator2(unsigned char s[32], const fe25519 r, const unsigned char x_sign)
{
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;
unsigned char x_sign;
memcpy(s, r, 32);
x_sign = s[31] & 0x80;
s[31] &= 0x7f;
fe25519_frombytes(rr2, s);
/* elligator */
fe25519_sq2(rr2, rr2);
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;
fe25519_sq2(rr2, r);
rr2[0]++;
fe25519_invert(rr2, rr2);
fe25519_mul(x, curve25519_A, rr2);
@ -2600,6 +2592,46 @@ ge25519_from_uniform(unsigned char s[32], const unsigned char r[32])
ge25519_p3_tobytes(s, &p3);
}
void
ge25519_from_uniform(unsigned char s[32], const unsigned char r[32])
{
fe25519 r_fe;
unsigned char x_sign;
memcpy(s, r, 32);
x_sign = s[31] & 0x80;
s[31] &= 0x7f;
fe25519_frombytes(r_fe, s);
ge25519_elligator2(s, r_fe, x_sign);
}
void
ge25519_from_hash(unsigned char s[32], const unsigned char h[64])
{
unsigned char fl[32];
unsigned char gl[32];
fe25519 fe_f;
fe25519 fe_g;
size_t i;
unsigned char x_sign;
x_sign = h[0] & 0x80;
for (i = 0; i < 32; i++) {
fl[i] = h[63 - i];
gl[i] = h[31 - i];
}
fl[31] &= 0x7f;
gl[31] &= 0x7f;
fe25519_frombytes(fe_f, fl);
fe25519_frombytes(fe_g, gl);
fe_f[0] += (h[32] >> 7) * 19;
for (i = 0; i < sizeof (fe25519) / sizeof fe_f[0]; i++) {
fe_f[i] += 38 * fe_g[i];
}
fe25519_reduce(fe_f, fe_f);
ge25519_elligator2(s, fe_f, x_sign);
}
/* Ristretto group */
static int
@ -2815,7 +2847,7 @@ ristretto255_elligator(ge25519_p3 *p, const fe25519 t)
}
void
ristretto255_from_uniform(unsigned char s[32], const unsigned char r[64])
ristretto255_from_hash(unsigned char s[32], const unsigned char h[64])
{
fe25519 r0, r1;
ge25519_cached p1_cached;
@ -2823,8 +2855,8 @@ ristretto255_from_uniform(unsigned char s[32], const unsigned char r[64])
ge25519_p3 p0, p1;
ge25519_p3 p;
fe25519_frombytes(r0, r);
fe25519_frombytes(r1, r + 32);
fe25519_frombytes(r0, h);
fe25519_frombytes(r1, h + 32);
ristretto255_elligator(&p0, r0);
ristretto255_elligator(&p1, r1);
ge25519_p3_to_cached(&p1_cached, &p1);

4
src/libsodium/crypto_core/salsa/ref/core_salsa_ref.c

@ -127,7 +127,7 @@ crypto_core_salsa20_constbytes(void)
}
#ifndef MINIMAL
/* LCOV_EXCL_START */
int
crypto_core_salsa2012(unsigned char *out, const unsigned char *in,
const unsigned char *k, const unsigned char *c)
@ -191,5 +191,5 @@ crypto_core_salsa208_constbytes(void)
{
return crypto_core_salsa208_CONSTBYTES;
}
/* LCOV_EXCL_END */
#endif

16
src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.h

@ -68,17 +68,17 @@ LOADU64(const void *p)
#define BLAKE2B_DIAG_V1(a, b, c, d) \
do { \
d = _mm256_permute4x64_epi64(d, _MM_SHUFFLE(2, 1, 0, 3)); \
c = _mm256_permute4x64_epi64(c, _MM_SHUFFLE(1, 0, 3, 2)); \
b = _mm256_permute4x64_epi64(b, _MM_SHUFFLE(0, 3, 2, 1)); \
} while (0)
a = _mm256_permute4x64_epi64(a, _MM_SHUFFLE(2, 1, 0, 3)); \
d = _mm256_permute4x64_epi64(d, _MM_SHUFFLE(1, 0, 3, 2)); \
c = _mm256_permute4x64_epi64(c, _MM_SHUFFLE(0, 3, 2, 1)); \
} while(0)
#define BLAKE2B_UNDIAG_V1(a, b, c, d) \
do { \
d = _mm256_permute4x64_epi64(d, _MM_SHUFFLE(0, 3, 2, 1)); \
c = _mm256_permute4x64_epi64(c, _MM_SHUFFLE(1, 0, 3, 2)); \
b = _mm256_permute4x64_epi64(b, _MM_SHUFFLE(2, 1, 0, 3)); \
} while (0)
a = _mm256_permute4x64_epi64(a, _MM_SHUFFLE(0, 3, 2, 1)); \
d = _mm256_permute4x64_epi64(d, _MM_SHUFFLE(1, 0, 3, 2)); \
c = _mm256_permute4x64_epi64(c, _MM_SHUFFLE(2, 1, 0, 3)); \
} while(0)
#include "blake2b-load-avx2.h"

126
src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-avx2.h

@ -17,15 +17,15 @@
#define BLAKE2B_LOAD_MSG_0_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m4, m5); \
t1 = _mm256_unpacklo_epi64(m6, m7); \
t0 = _mm256_unpacklo_epi64(m7, m4); \
t1 = _mm256_unpacklo_epi64(m5, m6); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_0_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m4, m5); \
t1 = _mm256_unpackhi_epi64(m6, m7); \
t0 = _mm256_unpackhi_epi64(m7, m4); \
t1 = _mm256_unpackhi_epi64(m5, m6); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -43,17 +43,17 @@
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_1_3(b0) \
do { \
t0 = _mm256_shuffle_epi32(m0, _MM_SHUFFLE(1, 0, 3, 2)); \
t1 = _mm256_unpackhi_epi64(m5, m2); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
#define BLAKE2B_LOAD_MSG_1_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m2, m0); \
t1 = _mm256_blend_epi32(m5, m0, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_1_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m6, m1); \
t1 = _mm256_unpackhi_epi64(m3, m1); \
t0 = _mm256_alignr_epi8(m6, m1, 8); \
t1 = _mm256_blend_epi32(m3, m1, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -73,15 +73,15 @@
#define BLAKE2B_LOAD_MSG_2_3(b0) \
do { \
t0 = _mm256_blend_epi32(m1, m5, 0x33); \
t1 = _mm256_unpackhi_epi64(m3, m4); \
t0 = _mm256_alignr_epi8(m5, m4, 8); \
t1 = _mm256_unpackhi_epi64(m1, m3); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_2_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m7, m3); \
t1 = _mm256_alignr_epi8(m2, m0, 8); \
t0 = _mm256_unpacklo_epi64(m2, m7); \
t1 = _mm256_blend_epi32(m0, m3, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -99,17 +99,17 @@
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_3_3(b0) \
do { \
t0 = _mm256_blend_epi32(m2, m1, 0x33); \
t1 = _mm256_blend_epi32(m7, m2, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
#define BLAKE2B_LOAD_MSG_3_3(b0) \
do { \
t0 = _mm256_alignr_epi8(m1, m7, 8); \
t1 = _mm256_shuffle_epi32(m2, _MM_SHUFFLE(1, 0, 3, 2)); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_3_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m3, m5); \
t1 = _mm256_unpacklo_epi64(m0, m4); \
t0 = _mm256_unpacklo_epi64(m4, m3); \
t1 = _mm256_unpacklo_epi64(m5, m0); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -129,15 +129,15 @@
#define BLAKE2B_LOAD_MSG_4_3(b0) \
do { \
t0 = _mm256_blend_epi32(m5, m7, 0x33); \
t1 = _mm256_blend_epi32(m1, m3, 0x33); \
t0 = _mm256_alignr_epi8(m7, m1, 8); \
t1 = _mm256_alignr_epi8(m3, m5, 8); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_4_4(b0) \
do { \
t0 = _mm256_alignr_epi8(m6, m0, 8); \
t1 = _mm256_blend_epi32(m6, m4, 0x33); \
t0 = _mm256_unpackhi_epi64(m6, m0); \
t1 = _mm256_unpacklo_epi64(m6, m4); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -157,15 +157,15 @@
#define BLAKE2B_LOAD_MSG_5_3(b0) \
do { \
t0 = _mm256_blend_epi32(m3, m2, 0x33); \
t1 = _mm256_unpackhi_epi64(m7, m0); \
t0 = _mm256_alignr_epi8(m2, m0, 8); \
t1 = _mm256_unpackhi_epi64(m3, m7); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_5_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m6, m2); \
t1 = _mm256_blend_epi32(m4, m7, 0x33); \
t0 = _mm256_unpackhi_epi64(m4, m6); \
t1 = _mm256_alignr_epi8(m7, m2, 8); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -183,20 +183,20 @@
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_6_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m0, m3); \
t1 = _mm256_shuffle_epi32(m4, _MM_SHUFFLE(1, 0, 3, 2)); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_6_4(b0) \
#define BLAKE2B_LOAD_MSG_6_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m3, m1); \
t1 = _mm256_blend_epi32(m5, m1, 0x33); \
t0 = _mm256_unpacklo_epi64(m4, m0); \
t1 = _mm256_blend_epi32(m4, m3, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_6_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m5, m3); \
t1 = _mm256_shuffle_epi32(m1, _MM_SHUFFLE(1, 0, 3, 2)); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_7_1(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m6, m3); \
@ -213,15 +213,15 @@
#define BLAKE2B_LOAD_MSG_7_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m2, m7); \
t1 = _mm256_unpacklo_epi64(m4, m1); \
t0 = _mm256_blend_epi32(m2, m1, 0x33); \
t1 = _mm256_alignr_epi8(m4, m7, 8); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_7_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m0, m2); \
t1 = _mm256_unpacklo_epi64(m3, m5); \
t0 = _mm256_unpacklo_epi64(m5, m0); \
t1 = _mm256_unpacklo_epi64(m2, m3); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -241,15 +241,15 @@
#define BLAKE2B_LOAD_MSG_8_3(b0) \
do { \
t0 = m6; \
t1 = _mm256_alignr_epi8(m5, m0, 8); \
t0 = _mm256_unpacklo_epi64(m5, m6); \
t1 = _mm256_unpackhi_epi64(m6, m0); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_8_4(b0) \
do { \
t0 = _mm256_blend_epi32(m3, m1, 0x33); \
t1 = m2; \
t0 = _mm256_alignr_epi8(m1, m2, 8); \
t1 = _mm256_alignr_epi8(m2, m3, 8); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -269,15 +269,15 @@
#define BLAKE2B_LOAD_MSG_9_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m7, m4); \
t1 = _mm256_unpackhi_epi64(m1, m6); \
t0 = _mm256_unpackhi_epi64(m6, m7); \
t1 = _mm256_unpackhi_epi64(m4, m1); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_9_4(b0) \
do { \
t0 = _mm256_alignr_epi8(m7, m5, 8); \
t1 = _mm256_unpacklo_epi64(m6, m0); \
t0 = _mm256_blend_epi32(m5, m0, 0x33); \
t1 = _mm256_unpacklo_epi64(m7, m6); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -297,15 +297,15 @@
#define BLAKE2B_LOAD_MSG_10_3(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m4, m5); \
t1 = _mm256_unpacklo_epi64(m6, m7); \
t0 = _mm256_unpacklo_epi64(m7, m4); \
t1 = _mm256_unpacklo_epi64(m5, m6); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_10_4(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m4, m5); \
t1 = _mm256_unpackhi_epi64(m6, m7); \
t0 = _mm256_unpackhi_epi64(m7, m4); \
t1 = _mm256_unpackhi_epi64(m5, m6); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
@ -323,17 +323,17 @@
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_11_3(b0) \
do { \
t0 = _mm256_shuffle_epi32(m0, _MM_SHUFFLE(1, 0, 3, 2)); \
t1 = _mm256_unpackhi_epi64(m5, m2); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
#define BLAKE2B_LOAD_MSG_11_3(b0) \
do { \
t0 = _mm256_unpackhi_epi64(m2, m0); \
t1 = _mm256_blend_epi32(m5, m0, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)
#define BLAKE2B_LOAD_MSG_11_4(b0) \
do { \
t0 = _mm256_unpacklo_epi64(m6, m1); \
t1 = _mm256_unpackhi_epi64(m3, m1); \
t0 = _mm256_alignr_epi8(m6, m1, 8); \
t1 = _mm256_blend_epi32(m3, m1, 0x33); \
b0 = _mm256_blend_epi32(t0, t1, 0xF0); \
} while (0)

4
src/libsodium/crypto_pwhash/argon2/argon2-core.c

@ -113,9 +113,11 @@ allocate_memory(block_region **region, uint32_t m_cost)
}
#endif
if (base == NULL) {
/* LCOV_EXCL_START */
free(*region);
*region = NULL;
return ARGON2_MEMORY_ALLOCATION_ERROR; /* LCOV_EXCL_LINE */
return ARGON2_MEMORY_ALLOCATION_ERROR;
/* LCOV_EXCL_STOP */
}
(*region)->base = base;
(*region)->memory = memory;

4
src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c

@ -305,6 +305,10 @@ escrypt_kdf_nosse(escrypt_local_t *local, const uint8_t *passwd,
uint32_t i;
/* Sanity-check parameters. */
if (r == 0 || p == 0) {
errno = EINVAL;
return -1;
}
#if SIZE_MAX > UINT32_MAX
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {
errno = EFBIG;

4
src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c

@ -317,6 +317,10 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
uint32_t i;
/* Sanity-check parameters. */
if (r == 0 || p == 0) {
errno = EINVAL;
return -1;
}
# if SIZE_MAX > UINT32_MAX
/* LCOV_EXCL_START */
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {

3
src/libsodium/crypto_scalarmult/ristretto255/ref10/scalarmult_ristretto255_ref10.c

@ -8,7 +8,7 @@
int
crypto_scalarmult_ristretto255(unsigned char *q, const unsigned char *n,
const unsigned char *p)
const unsigned char *p)
{
unsigned char *t = q;
ge25519_p3 Q;
@ -49,6 +49,7 @@ crypto_scalarmult_ristretto255_base(unsigned char *q,
}
return 0;
}
size_t
crypto_scalarmult_ristretto255_bytes(void)
{

2
src/libsodium/crypto_sign/ed25519/ref10/obsolete.c

@ -10,6 +10,7 @@
#include "randombytes.h"
#include "utils.h"
/* LCOV_EXCL_START */
int
crypto_sign_edwards25519sha512batch_keypair(unsigned char *pk,
unsigned char *sk)
@ -114,3 +115,4 @@ crypto_sign_edwards25519sha512batch_open(unsigned char *m,
return 0;
}
/* LCOV_EXCL_END */

2
src/libsodium/crypto_sign/ed25519/ref10/sign.c

@ -76,7 +76,7 @@ _crypto_sign_ed25519_detached(unsigned char *sig, unsigned long long *siglen_p,
crypto_hash_sha512(az, sk, 32);
#ifdef ED25519_NONDETERMINISTIC
_crypto_sign_ed25519_synthetic_r_hv(&hs, nonce, az);
_crypto_sign_ed25519_synthetic_r_hv(&hs, nonce /* Z */, az);
#else
crypto_hash_sha512_update(&hs, az + 32, 32);
#endif

2
src/libsodium/include/sodium/crypto_aead_aes256gcm.h

@ -56,7 +56,7 @@ size_t crypto_aead_aes256gcm_abytes(void);
SODIUM_EXPORT
size_t crypto_aead_aes256gcm_messagebytes_max(void);
typedef CRYPTO_ALIGN(16) struct crypto_aead_aes256gcm_state_ {
typedef struct CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state_ {
unsigned char opaque[512];
} crypto_aead_aes256gcm_state;

12
src/libsodium/include/sodium/crypto_core_ed25519.h

@ -16,6 +16,10 @@ size_t crypto_core_ed25519_bytes(void);
SODIUM_EXPORT
size_t crypto_core_ed25519_uniformbytes(void);
#define crypto_core_ed25519_HASHBYTES 64
SODIUM_EXPORT
size_t crypto_core_ed25519_hashbytes(void);
#define crypto_core_ed25519_SCALARBYTES 32
SODIUM_EXPORT
size_t crypto_core_ed25519_scalarbytes(void);
@ -42,6 +46,14 @@ SODIUM_EXPORT
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));
SODIUM_EXPORT
void crypto_core_ed25519_random(unsigned char *p)
__attribute__ ((nonnull));
SODIUM_EXPORT
void crypto_core_ed25519_scalar_random(unsigned char *r)
__attribute__ ((nonnull));

12
src/libsodium/include/sodium/crypto_core_ristretto255.h

@ -12,9 +12,9 @@ extern "C" {
SODIUM_EXPORT
size_t crypto_core_ristretto255_bytes(void);
#define crypto_core_ristretto255_UNIFORMBYTES 64
#define crypto_core_ristretto255_HASHBYTES 64
SODIUM_EXPORT
size_t crypto_core_ristretto255_uniformbytes(void);
size_t crypto_core_ristretto255_hashbytes(void);
#define crypto_core_ristretto255_SCALARBYTES 32
SODIUM_EXPORT
@ -39,8 +39,12 @@ int crypto_core_ristretto255_sub(unsigned char *r,
__attribute__ ((nonnull));
SODIUM_EXPORT
int crypto_core_ristretto255_from_uniform(unsigned char *p,
const unsigned char *r)
int crypto_core_ristretto255_from_hash(unsigned char *p,
const unsigned char *r)
__attribute__ ((nonnull));
SODIUM_EXPORT
void crypto_core_ristretto255_random(unsigned char *p)
__attribute__ ((nonnull));
SODIUM_EXPORT

2
src/libsodium/include/sodium/private/common.h

@ -1,7 +1,7 @@
#ifndef common_H
#define common_H 1
#if !defined(_MSC_VER) && !defined(DEV_MODE) && 1
#if !defined(_MSC_VER) && !defined(DEV_MODE) && 0
# warning *** This is unstable, untested, development code.
# warning It might not compile. It might not work as expected.
# warning It might be totally insecure.

4
src/libsodium/include/sodium/private/ed25519_ref10.h

@ -110,6 +110,8 @@ int ge25519_has_small_order(const unsigned char s[32]);
void ge25519_from_uniform(unsigned char s[32], const unsigned char r[32]);
void ge25519_from_hash(unsigned char s[32], const unsigned char h[64]);
/*
Ristretto group
*/
@ -118,7 +120,7 @@ int ristretto255_frombytes(ge25519_p3 *h, const unsigned char *s);
void ristretto255_p3_tobytes(unsigned char *s, const ge25519_p3 *h);
void ristretto255_from_uniform(unsigned char s[32], const unsigned char r[64]);
void ristretto255_from_hash(unsigned char s[32], const unsigned char h[64]);
/*
The set of scalars is \Z/l

12
src/libsodium/randombytes/internal/randombytes_internal_random.c

@ -152,7 +152,7 @@ sodium_hrtime(void)
static uint64_t
sodium_hrtime(void)
{
struct timeval tv;
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0) {
sodium_misuse(); /* LCOV_EXCL_LINE */
@ -181,7 +181,7 @@ _randombytes_getentropy(void * const buf, const size_t size)
{
assert(size <= 256U);
if (getentropy(buf, size) != 0) {
return -1;
return -1; /* LCOV_EXCL_LINE */
}
return 0;
}
@ -198,7 +198,7 @@ randombytes_getentropy(void * const buf_, size_t size)
assert(chunk_size > (size_t) 0U);
}
if (_randombytes_getentropy(buf, chunk_size) != 0) {
return -1;
return -1; /* LCOV_EXCL_LINE */
}
size -= chunk_size;
buf += chunk_size;
@ -273,10 +273,10 @@ randombytes_block_on_dev_random(void)
}
# endif
/* LCOV_EXCL_START */
static int
randombytes_internal_random_random_dev_open(void)
{
/* LCOV_EXCL_START */
struct stat st;
static const char *devices[] = {
# ifndef USE_BLOCKING_RANDOM
@ -310,8 +310,8 @@ randombytes_internal_random_random_dev_open(void)
errno = EIO;
return -1;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
static ssize_t
safe_read(const int fd, void * const buf_, size_t size)
@ -369,6 +369,7 @@ randombytes_internal_random_init(void)
}
}
# endif
/* LCOV_EXCL_START */
# if !defined(NONEXISTENT_DEV_RANDOM)
assert((global.getentropy_available | global.getrandom_available) == 0);
if ((global.random_data_source_fd =
@ -378,6 +379,7 @@ randombytes_internal_random_init(void)
errno = errno_save;
return;
# endif
/* LCOV_EXCL_STOP */
# ifndef HAVE_SAFE_ARC4RANDOM
sodium_misuse();
# endif

2
src/libsodium/sodium/runtime.c

@ -203,11 +203,13 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
unsigned int cpu_info7[4];
_cpuid(cpu_info7, 0x00000007);
/* LCOV_EXCL_START */
if ((cpu_info7[1] & CPUID_EBX_AVX512F) == CPUID_EBX_AVX512F &&
(xcr0 & (XCR0_OPMASK | XCR0_ZMM_HI256 | XCR0_HI16_ZMM))
== (XCR0_OPMASK | XCR0_ZMM_HI256 | XCR0_HI16_ZMM)) {
cpu_features->has_avx512f = 1;
}
/* LCOV_EXCL_STOP */
}
#endif

6
test/default/aead_xchacha20poly1305.c

@ -20,7 +20,7 @@ tv(void)
};
#undef MESSAGE
#define MESSAGE "Ladies and Gentlemen of the class of '99: If I could offer you " \
"only one tip for the future, sunscreen would be it."
"only one tip for the future, sunscreen would be it."
unsigned char *m = (unsigned char *) sodium_malloc(MLEN);
static const unsigned char nonce[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES]
= { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
@ -64,6 +64,10 @@ tv(void)
printf("detached ciphertext is bogus\n");
}
if (crypto_aead_xchacha20poly1305_ietf_decrypt(NULL, 0, NULL, c, CLEN, ad,
ADLEN, nonce, firstkey) != 0) {
printf("crypto_aead_xchacha20poly1305_ietf_decrypt() tag-only verification failed\n");
}
if (crypto_aead_xchacha20poly1305_ietf_decrypt(m2, &m2len, NULL, c, CLEN, ad,
ADLEN, nonce, firstkey) != 0) {
printf("crypto_aead_xchacha20poly1305_ietf_decrypt() failed\n");

65
test/default/box_seal.c

@ -2,8 +2,8 @@
#define TEST_NAME "box_seal"
#include "cmptest.h"
int
main(void)
static
void tv1(void)
{
unsigned char pk[crypto_box_PUBLICKEYBYTES];
unsigned char sk[crypto_box_SECRETKEYBYTES];
@ -22,11 +22,11 @@ main(void)
randombytes_buf(m, m_len);
if (crypto_box_seal(c, m, m_len, pk) != 0) {
printf("crypto_box_seal() failure\n");
return 1;
return;
}
if (crypto_box_seal_open(m2, c, c_len, pk, sk) != 0) {
printf("crypto_box_seal_open() failure\n");
return 1;
return;
}
printf("%d\n", memcmp(m, m2, m_len));
@ -39,6 +39,63 @@ main(void)
sodium_free(m2);
assert(crypto_box_sealbytes() == crypto_box_SEALBYTES);
}
#ifndef SODIUM_LIBRARY_MINIMAL
static
void tv2(void)
{
unsigned char pk[crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES];
unsigned char sk[crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES];
unsigned char *c;
unsigned char *m;
unsigned char *m2;
size_t m_len;
size_t c_len;
crypto_box_curve25519xchacha20poly1305_keypair(pk, sk);
m_len = (size_t) randombytes_uniform(1000);
c_len = crypto_box_curve25519xchacha20poly1305_SEALBYTES + m_len;
m = (unsigned char *) sodium_malloc(m_len);
m2 = (unsigned char *) sodium_malloc(m_len);
c = (unsigned char *) sodium_malloc(c_len);
randombytes_buf(m, m_len);
if (crypto_box_curve25519xchacha20poly1305_seal(c, m, m_len, pk) != 0) {
printf("crypto_box_curve25519xchacha20poly1305_seal() failure\n");
return;
}
if (crypto_box_curve25519xchacha20poly1305_seal_open(m2, c, c_len, pk, sk) != 0) {
printf("crypto_box_curve25519xchacha20poly1305_seal_open() failure\n");
return;
}
printf("%d\n", memcmp(m, m2, m_len));
printf("%d\n", crypto_box_curve25519xchacha20poly1305_seal_open(m, c, 0U, pk, sk));
printf("%d\n", crypto_box_curve25519xchacha20poly1305_seal_open(m, c, c_len - 1U, pk, sk));
printf("%d\n", crypto_box_curve25519xchacha20poly1305_seal_open(m, c, c_len, sk, pk));
sodium_free(c);
sodium_free(m);
sodium_free(m2);
assert(crypto_box_curve25519xchacha20poly1305_sealbytes() ==
crypto_box_curve25519xchacha20poly1305_SEALBYTES);
}
#else
static
void tv2(void)
{
printf("0\n-1\n-1\n-1\n");
}
#endif
int
main(void)
{
tv1();
tv2();
return 0;
}

4
test/default/box_seal.exp

@ -2,3 +2,7 @@
-1
-1
-1
0
-1
-1
-1

43
test/default/core_ed25519.c

@ -44,29 +44,43 @@ add_l64(unsigned char * const S)
int
main(void)
{
unsigned char *h;
unsigned char *h, *r;
unsigned char *p, *p2, *p3;
unsigned char *sc, *sc2, *sc3;
unsigned char *sc64;
char *hex;
unsigned int i, j;
h = (unsigned char *) sodium_malloc(crypto_core_ed25519_UNIFORMBYTES);
h = (unsigned char *) sodium_malloc(crypto_core_ed25519_HASHBYTES);
r = (unsigned char *) sodium_malloc(crypto_core_ed25519_UNIFORMBYTES);
p = (unsigned char *) sodium_malloc(crypto_core_ed25519_BYTES);
for (i = 0; i < 1000; i++) {
randombytes_buf(h, crypto_core_ed25519_UNIFORMBYTES);
if (crypto_core_ed25519_from_uniform(p, h) != 0) {
for (i = 0; i < 500; i++) {
randombytes_buf(r, crypto_core_ed25519_UNIFORMBYTES);
if (crypto_core_ed25519_from_uniform(p, r) != 0) {
printf("crypto_core_ed25519_from_uniform() failed\n");
}
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");
}
}
p2 = (unsigned char *) sodium_malloc(crypto_core_ed25519_BYTES);
p3 = (unsigned char *) sodium_malloc(crypto_core_ed25519_BYTES);
randombytes_buf(h, crypto_core_ed25519_UNIFORMBYTES);
crypto_core_ed25519_from_uniform(p2, h);
crypto_core_ed25519_random(p2);
j = 1 + (unsigned int) randombytes_uniform(100);
memcpy(p3, p, crypto_core_ed25519_BYTES);
@ -145,8 +159,7 @@ main(void)
assert(crypto_core_ed25519_sub(p3, non_canonical_invalid_p, p3) == -1);
for (i = 0; i < 1000; i++) {
randombytes_buf(h, crypto_core_ed25519_UNIFORMBYTES);
crypto_core_ed25519_from_uniform(p, h);
crypto_core_ed25519_random(p);
do {
crypto_core_ed25519_scalar_random(sc);
} while (sodium_is_zero(sc, crypto_core_ed25519_SCALARBYTES));
@ -177,8 +190,8 @@ main(void)
printf("crypto_core_ed25519_scalar_reduce() failed\n");
}
randombytes_buf(h, crypto_core_ed25519_UNIFORMBYTES);
crypto_core_ed25519_from_uniform(p, h);
randombytes_buf(r, crypto_core_ed25519_UNIFORMBYTES);
crypto_core_ed25519_from_uniform(p, r);
memcpy(p2, p, crypto_core_ed25519_BYTES);
crypto_core_ed25519_scalar_random(sc);
if (crypto_scalarmult_ed25519_noclamp(p, sc, p) != 0) {
@ -189,15 +202,14 @@ main(void)
printf("crypto_scalarmult_ed25519_noclamp() failed (2)\n");
}
crypto_core_ed25519_add(p3, p, p2);
crypto_core_ed25519_from_uniform(p, h);
crypto_core_ed25519_from_uniform(p, r);
crypto_core_ed25519_sub(p, p, p3);
assert(p[0] == 0x01);
for (i = 1; i < crypto_core_ed25519_BYTES; i++) {
assert(p[i] == 0);
}
randombytes_buf(h, crypto_core_ed25519_UNIFORMBYTES);
crypto_core_ed25519_from_uniform(p, h);
crypto_core_ed25519_random(p);
memcpy(p2, p, crypto_core_ed25519_BYTES);
crypto_core_ed25519_scalar_random(sc);
if (crypto_scalarmult_ed25519_noclamp(p, sc, p) != 0) {
@ -383,6 +395,7 @@ main(void)
sodium_free(p3);
sodium_free(p2);
sodium_free(p);
sodium_free(r);
sodium_free(h);
assert(crypto_core_ed25519_BYTES == crypto_core_ed25519_bytes());
@ -391,6 +404,8 @@ main(void)
assert(crypto_core_ed25519_NONREDUCEDSCALARBYTES >= crypto_core_ed25519_SCALARBYTES);
assert(crypto_core_ed25519_UNIFORMBYTES == crypto_core_ed25519_uniformbytes());
assert(crypto_core_ed25519_UNIFORMBYTES >= crypto_core_ed25519_BYTES);
assert(crypto_core_ed25519_HASHBYTES == crypto_core_ed25519_hashbytes());
assert(crypto_core_ed25519_HASHBYTES >= 2 * crypto_core_ed25519_BYTES);
printf("OK\n");

99
test/default/core_ristretto255.c

@ -62,7 +62,7 @@ tv1(void)
static void
tv2(void)
{
static const char *uniform_hex[] = {
static const char *hash_hex[] = {
"5d1be09e3d0c82fc538112490e35701979d99e06ca3e2b5b54bffe8b4dc772c1"
"4d98b696a1bbfb5ca32c436cc61c16563790306c79eaca7705668b47dffe5bb6",
@ -90,13 +90,13 @@ tv2(void)
size_t i;
s = (unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES);
u = (unsigned char *) sodium_malloc(crypto_core_ristretto255_UNIFORMBYTES);
u = (unsigned char *) sodium_malloc(crypto_core_ristretto255_HASHBYTES);
hex = (char *) sodium_malloc(crypto_core_ristretto255_BYTES * 2 + 1);
for (i = 0; i < sizeof uniform_hex / sizeof uniform_hex[0]; i++) {
sodium_hex2bin(u, crypto_core_ristretto255_UNIFORMBYTES, uniform_hex[i],
crypto_core_ristretto255_UNIFORMBYTES * 2 + 1,
for (i = 0; i < sizeof hash_hex / sizeof hash_hex[0]; i++) {
sodium_hex2bin(u, crypto_core_ristretto255_HASHBYTES, hash_hex[i],
crypto_core_ristretto255_HASHBYTES * 2 + 1,
NULL, NULL, NULL);
crypto_core_ristretto255_from_uniform(s, u);
crypto_core_ristretto255_from_hash(s, u);
sodium_bin2hex(hex, crypto_core_ristretto255_BYTES * 2 + 1,
s, crypto_core_ristretto255_BYTES);
printf("%s\n", hex);
@ -120,7 +120,7 @@ tv3(void)
unsigned char *r_inv =
(unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES);
unsigned char *ru =
(unsigned char *) sodium_malloc(crypto_core_ristretto255_UNIFORMBYTES);
(unsigned char *) sodium_malloc(crypto_core_ristretto255_HASHBYTES);
unsigned char *s =
(unsigned char *) sodium_malloc(crypto_core_ristretto255_BYTES);
unsigned char *s_ =
@ -135,13 +135,17 @@ tv3(void)
crypto_core_ristretto255_is_valid_point(s) != 1) {
printf("crypto_scalarmult_ristretto255_base() failed\n");
}
crypto_core_ristretto255_random(s);
if (crypto_core_ristretto255_is_valid_point(s) != 1) {
printf("crypto_core_ristretto255_random() failed\n");
}
if (crypto_scalarmult_ristretto255(s, l, s) == 0) {
printf("s*l != inf (1)\n");
}
randombytes_buf(ru, crypto_core_ristretto255_UNIFORMBYTES);
if (crypto_core_ristretto255_from_uniform(s, ru) != 0 ||
randombytes_buf(ru, crypto_core_ristretto255_HASHBYTES);
if (crypto_core_ristretto255_from_hash(s, ru) != 0 ||
crypto_core_ristretto255_is_valid_point(s) != 1) {
printf("crypto_core_ristretto255_from_uniform() failed\n");
printf("crypto_core_ristretto255_from_hash() failed\n");
}
if (crypto_scalarmult_ristretto255(s2, l, s) == 0) {
printf("s*l != inf (2)\n");
@ -163,8 +167,37 @@ tv3(void)
if (crypto_scalarmult_ristretto255(s2, l, s2) == 0) {
printf("s*l != inf (3)\n");
}
if (crypto_core_ristretto255_add(s2, s, s_) != 0) {
printf("addition failed");
}
if (crypto_core_ristretto255_sub(s2, s2, s_) != 0) {
printf("substraction failed");
}
if (crypto_core_ristretto255_is_valid_point(s2) == 0) {
printf("invalid point");
}
if (memcmp(s, s2, crypto_core_ristretto255_BYTES) != 0) {
printf("s2 + s - s_ != s\n");
}
if (crypto_core_ristretto255_sub(s2, s2, s) != 0) {
printf("substraction failed");
}
if (crypto_core_ristretto255_is_valid_point(s2) == -1) {
printf("s + s' - s - s' != 0");
}
}
crypto_core_ristretto255_random(s);
memset(s_, 0xfe, crypto_core_ristretto255_BYTES);
assert(crypto_core_ristretto255_add(s2, s_, s) == -1);
assert(crypto_core_ristretto255_add(s2, s, s_) == -1);
assert(crypto_core_ristretto255_add(s2, s_, s_) == -1);
assert(crypto_core_ristretto255_add(s2, s, s) == 0);
assert(crypto_core_ristretto255_sub(s2, s_, s) == -1);
assert(crypto_core_ristretto255_sub(s2, s, s_) == -1);
assert(crypto_core_ristretto255_sub(s2, s_, s_) == -1);
assert(crypto_core_ristretto255_sub(s2, s, s) == 0);
sodium_free(s2);
sodium_free(s_);
sodium_free(s);
@ -173,23 +206,63 @@ tv3(void)
sodium_free(r);
}
static void
tv4(void)
{
unsigned char *r;
unsigned char *s1;
unsigned char *s2;
unsigned char *s3;
unsigned char *s4;
r = (unsigned char *) sodium_malloc(crypto_core_ristretto255_NONREDUCEDSCALARBYTES);
s1 = (unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES);
s2 = (unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES);
s3 = (unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES);
s4 = (unsigned char *) sodium_malloc(crypto_core_ristretto255_SCALARBYTES);
crypto_core_ristretto255_scalar_random(s1);
randombytes_buf(r, crypto_core_ristretto255_NONREDUCEDSCALARBYTES);
crypto_core_ristretto255_scalar_reduce(s2, r);
memcpy(s4, s1, crypto_core_ristretto255_SCALARBYTES);
crypto_core_ristretto255_scalar_add(s3, s1, s2);
crypto_core_ristretto255_scalar_sub(s4, s1, s2);
crypto_core_ristretto255_scalar_add(s2, s3, s4);
crypto_core_ristretto255_scalar_sub(s2, s2, s1);
crypto_core_ristretto255_scalar_mul(s2, s3, s2);
crypto_core_ristretto255_scalar_invert(s4, s3);
crypto_core_ristretto255_scalar_mul(s2, s2, s4);
crypto_core_ristretto255_scalar_negate(s1, s1);
crypto_core_ristretto255_scalar_add(s2, s2, s1);
crypto_core_ristretto255_scalar_complement(s1, s2);
s1[0]--;
assert(sodium_is_zero(s1, crypto_core_ristretto255_SCALARBYTES));
sodium_free(s1);
sodium_free(s2);
sodium_free(s3);
sodium_free(s4);
sodium_free(r);
}
int
main(void)
{
tv1();
tv2();
tv3();
tv4();
assert(crypto_core_ristretto255_BYTES == crypto_core_ristretto255_bytes());
assert(crypto_core_ristretto255_SCALARBYTES == crypto_core_ristretto255_scalarbytes());
assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ristretto255_nonreducedscalarbytes());
assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES >= crypto_core_ristretto255_SCALARBYTES);
assert(crypto_core_ristretto255_UNIFORMBYTES == crypto_core_ristretto255_uniformbytes());
assert(crypto_core_ristretto255_UNIFORMBYTES >= crypto_core_ristretto255_BYTES);
assert(crypto_core_ristretto255_HASHBYTES == crypto_core_ristretto255_hashbytes());
assert(crypto_core_ristretto255_HASHBYTES >= crypto_core_ristretto255_BYTES);
assert(crypto_core_ristretto255_BYTES == crypto_core_ed25519_BYTES);
assert(crypto_core_ristretto255_SCALARBYTES == crypto_core_ed25519_SCALARBYTES);
assert(crypto_core_ristretto255_NONREDUCEDSCALARBYTES == crypto_core_ed25519_NONREDUCEDSCALARBYTES);
assert(crypto_core_ristretto255_UNIFORMBYTES > crypto_core_ed25519_UNIFORMBYTES);
assert(crypto_core_ristretto255_HASHBYTES >= 2 * crypto_core_ed25519_UNIFORMBYTES);
printf("OK\n");

2
test/default/pwhash_scrypt.c

@ -265,8 +265,6 @@ tv3(void)
"$7$.6..../.....lgPchkGHqbeONR/xtuXyjCrt9kUSg6NlKFQO0OSxo/$.DbajbPYH9T7sg3fOtcgxvJzzfIgJBIxMkeQ8b24YQ." },
{ "test",
"$7$z6..../.....lgPchkGHqbeONR/xtuXyjCrt9kUSg6NlKFQO0OSxo/$.DbajbPYH9T7sg3fOtcgxvJzzfIgJBIxMkeQ8b24YQ." },
{ "test",
"$7$8zzzzz/.....lgPchkGHqbeONR/xtuXyjCrt9kUSg6NlKFQO0OSxo/$.DbajbPYH9T7sg3fOtcgxvJzzfIgJBIxMkeQ8b24YQ." },
{ "test",
"$7$8zzzzzzzzzz.lgPchkGHqbeONR/xtuXyjCrt9kUSg6NlKFQO0OSxo/$.DbajbPYH9T7sg3fOtcgxvJzzfIgJBIxMkeQ8b24YQ." },
{ "test",

1
test/default/pwhash_scrypt.exp

@ -34,5 +34,4 @@ pwhash_str failure: [29]
pwhash_str failure: [30]
pwhash_str failure: [31]
pwhash_str failure: [32]
pwhash_str failure: [33]
OK

12
test/default/scalarmult_ed25519.c

@ -83,6 +83,18 @@ main(void)
if (memcmp(q, q2, crypto_scalarmult_ed25519_BYTES) == 0) {
printf("clamping not applied\n");
}
n[0] = 9;
if (crypto_scalarmult_ed25519_base(q, n) != 0) {
printf("crypto_scalarmult_ed25519_base() failed\n");
}
if (crypto_scalarmult_ed25519_base_noclamp(q2, n) != 0) {
printf("crypto_scalarmult_ed25519_base_noclamp() failed\n");
}
if (memcmp(q, q2, crypto_scalarmult_ed25519_BYTES) == 0) {
printf("clamping not applied\n");
}
n[0] = 8;
n[31] = 64;
if (crypto_scalarmult_ed25519_noclamp(q2, n, p) != 0) {

4
test/default/scalarmult_ristretto255.c

@ -32,6 +32,10 @@ main(void)
assert(memcmp(p, p2, crypto_scalarmult_ristretto255_BYTES) == 0);
sodium_increment(n, crypto_scalarmult_ristretto255_SCALARBYTES);
}
memset(p, 0xfe, crypto_scalarmult_ristretto255_BYTES);
assert(crypto_scalarmult_ristretto255(guard_page, n, p) == -1);
sodium_free(hex);
sodium_free(p2);
sodium_free(p);

8
test/default/wasi-test-wrapper.sh

@ -1,6 +1,6 @@
#! /bin/sh
MAX_MEMORY_MB="128"
MAX_MEMORY_TESTS="67108864"
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "wasmtime" ]; then
if command -v wasmtime >/dev/null; then
@ -11,9 +11,9 @@ fi
if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "lucet" ]; then
if command -v lucetc-wasi >/dev/null && command -v lucet-wasi >/dev/null; then
lucetc-wasi \
--min-reserved-size "${MAX_MEMORY_MB}MiB" \
-o "${1}.so" --opt-level best "$1" &&
lucet-wasi --dir=.:. "${1}.so" &&
--reserved-size "${MAX_MEMORY_TESTS}" \
-o "${1}.so" --opt-level fast "$1" &&
lucet-wasi --dir=.:. --max-heap-size "${MAX_MEMORY_TESTS}" "${1}.so" &&
rm -f "${1}.so" && exit 0
fi
fi

Loading…
Cancel
Save