diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b034bcd83..00579aefac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: sudo apt-add-repository -y "deb http://apt.llvm.org/$osname/ llvm-toolchain-$osname-${{ matrix.cfg.version }} main" - name: Install apt packages - run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt update && sudo apt-get install -y ${{ matrix.cfg.package }} pkg-config libsodium-dev libopus-dev zlib1g-dev rpm + run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt update && sudo apt-get install -y ${{ matrix.cfg.package }} pkg-config libopus-dev zlib1g-dev rpm - name: Generate CMake run: cmake -B build -DDPP_NO_VCPKG=ON -DAVX_TYPE=AVX0 -DCMAKE_BUILD_TYPE=Release ${{matrix.cfg.cmake-flags}} @@ -150,7 +150,7 @@ jobs: xcode-version: ${{ matrix.cfg.xcode-version }} - name: Install homebrew packages - run: brew install cmake make libsodium opus openssl pkg-config + run: brew install cmake make opus openssl pkg-config - name: Generate CMake run: cmake -B build -DDPP_NO_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DDPP_CORO=ON -DAVX_TYPE=AVX0 diff --git a/.github/workflows/test-docs-examples.yml b/.github/workflows/test-docs-examples.yml index 4b5dfb4758..648916d6b3 100644 --- a/.github/workflows/test-docs-examples.yml +++ b/.github/workflows/test-docs-examples.yml @@ -35,7 +35,7 @@ jobs: submodules: recursive - name: Install apt packages - run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt-get update && sudo apt-get install -y g++-12 libsodium-dev libopus-dev zlib1g-dev libmpg123-dev liboggz-dev cmake libfmt-dev libopusfile-dev + run: sudo sed -i 's/azure\.//' /etc/apt/sources.list && sudo apt-get update && sudo apt-get install -y g++-12 libopus-dev zlib1g-dev libmpg123-dev liboggz-dev cmake libfmt-dev libopusfile-dev - name: Generate CMake run: mkdir build && cd build && cmake -DDPP_NO_VCPKG=ON -DAVX_TYPE=T_fallback -DDPP_CORO=ON -DCMAKE_BUILD_TYPE=Debug .. diff --git a/Dockerfile b/Dockerfile index 780c2e2af9..5ae726414a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:noble@sha256:b359f1067efa76f37863778f7b6d0e8d911e3ee8efa807ad01fbf5dc1ef9006b -RUN apt-get update && apt-get install --no-install-recommends -y libssl-dev zlib1g-dev libsodium-dev libopus-dev cmake pkg-config g++ gcc git make && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install --no-install-recommends -y libssl-dev zlib1g-dev libopus-dev cmake pkg-config g++ gcc git make && apt-get clean && rm -rf /var/lib/apt/lists/* WORKDIR /usr/src/DPP diff --git a/README.md b/README.md index f2ae8a4bd7..953da47cb6 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ You can find more examples in our [example page](https://dpp.dev/example-program ## 💻 Supported Systems +We support the following OS families, as long as they are still officially supported by their provider. **We will provide no support for operating systems past end-of-life**. + ### Linux The library runs ideally on **Linux**. @@ -155,10 +157,9 @@ Other compilers may work (either newer versions of those listed above, or differ #### Optional Dependencies -For **voice support** you require both of: +For **voice support** you require: * [libopus](https://www.opus-codec.org) (For audio encoding/decoding) -* [libsodium](https://libsodium.org/) (For transport layer encryption) -* Note that our **windows zips** come packaged with copies of both libraries - you do not need to install them yourself! +* Note that our **windows zips** come packaged with copies of this library - you do not need to install it yourself! ### Included Dependencies (Packaged with the library) diff --git a/buildtools/classes/Packager/Vcpkg.php b/buildtools/classes/Packager/Vcpkg.php index 1790cbefc2..f677ba6675 100644 --- a/buildtools/classes/Packager/Vcpkg.php +++ b/buildtools/classes/Packager/Vcpkg.php @@ -170,7 +170,6 @@ function constructPortAndVersionFile(string $sha512 = "0"): string "license": "Apache-2.0", "supports": "((windows & !static & !uwp) | linux | osx)", "dependencies": [ - "libsodium", "nlohmann-json", "openssl", "opus", diff --git a/cmake/ARM64ToolChain.cmake b/cmake/ARM64ToolChain.cmake index 8087e3f375..d9caf02693 100644 --- a/cmake/ARM64ToolChain.cmake +++ b/cmake/ARM64ToolChain.cmake @@ -47,6 +47,5 @@ EXECUTE_PROCESS(COMMAND sudo mv TMPFILE /etc/apt/sources.list) EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture arm64) EXECUTE_PROCESS(COMMAND sudo apt-add-repository -y ppa:canonical-kernel-team/ppa) EXECUTE_PROCESS(COMMAND sudo apt update) -EXECUTE_PROCESS(COMMAND sudo apt install -y cmake gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu libc6-dev-arm64-cross zlib1g-dev:arm64 libssl-dev:arm64 libopus-dev:arm64 libsodium-dev:arm64) -EXECUTE_PROCESS(COMMAND sudo mv /usr/lib/aarch64-linux-gnu/pkgconfig/libsodium.pc /usr/lib/pkgconfig/) +EXECUTE_PROCESS(COMMAND sudo apt install -y cmake gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu libc6-dev-arm64-cross zlib1g-dev:arm64 libssl-dev:arm64 libopus-dev:arm64) diff --git a/cmake/ARMv7ToolChain.cmake b/cmake/ARMv7ToolChain.cmake index 7b9bacf3bc..215df7e0ce 100644 --- a/cmake/ARMv7ToolChain.cmake +++ b/cmake/ARMv7ToolChain.cmake @@ -46,6 +46,4 @@ EXECUTE_PROCESS(COMMAND printf "deb [arch=amd64] http://archive.ubuntu.com/ubunt EXECUTE_PROCESS(COMMAND sudo mv TMPFILE /etc/apt/sources.list) EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture armhf) EXECUTE_PROCESS(COMMAND sudo apt update) -EXECUTE_PROCESS(COMMAND sudo apt install -y cmake gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf zlib1g-dev:armhf libssl-dev:armhf libopus-dev:armhf libsodium-dev:armhf) -EXECUTE_PROCESS(COMMAND sudo mv /usr/lib/arm-linux-gnueabihf/pkgconfig/libsodium.pc /usr/lib/pkgconfig/) - +EXECUTE_PROCESS(COMMAND sudo apt install -y cmake gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf zlib1g-dev:armhf libssl-dev:armhf libopus-dev:armhf) diff --git a/cmake/CPackSetup.cmake b/cmake/CPackSetup.cmake index fcdcf156af..047b7600ff 100644 --- a/cmake/CPackSetup.cmake +++ b/cmake/CPackSetup.cmake @@ -50,8 +50,8 @@ set(CPACK_FREEBSD_PACKAGE_MAINTAINER "bsd@dpp.dev") set(CPACK_FREEBSD_PACKAGE_ORIGIN "misc/libdpp") set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0") set(CPACK_PACKAGE_CONTACT "https://discord.gg/dpp") # D++ Development Discord -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsodium23 (>= 1.0.17-1), libopus0 (>= 1.3-1)") -set(CPACK_RPM_PACKAGE_REQUIRES "libsodium >= 1.0.20-1, opus >= 1.3.1") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libopus0 (>= 1.3-1)") +set(CPACK_RPM_PACKAGE_REQUIRES "opus >= 1.3.1") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "An incredibly lightweight C++ Discord library") set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") set(CPACK_DEBIAN_PACKAGE_SECTION "libs") diff --git a/cmake/FindSodium.cmake b/cmake/FindSodium.cmake deleted file mode 100644 index fbcc45ad11..0000000000 --- a/cmake/FindSodium.cmake +++ /dev/null @@ -1,293 +0,0 @@ -# Written in 2016 by Henrik Steffen Gaßmann -# -# 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 -# -# 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. -# -# Once done the following variables will be defined: -# -# 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) -endif() - -# static library option -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") -endif() - -# ############################################################################## -# UNIX -if(UNIX) - # import pkg-config - find_package(PkgConfig) - 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) - endif() - - set(XPREFIX sodium_PKG_STATIC) - else() - if(sodium_PKG_LIBRARIES STREQUAL "") - set(sodium_PKG_LIBRARIES sodium) - endif() - - 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) - - 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.cpp" [=[ - #if defined _M_IX86 - #error ARCH_VALUE x86_32 - #elif defined _M_X64 - #error ARCH_VALUE x86_64 - #endif - #error ARCH_VALUE unknown - ]=]) - try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" - 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$$") - - 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() - - 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) - - 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 -else() - message(FATAL_ERROR "this platform is not supported by FindSodium.cmake") -endif() - -# ############################################################################## -# common stuff - -# extract sodium version -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 - ".*#define[ \t]*SODIUM_VERSION_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_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) -endif() - -# create imported target -if(sodium_USE_STATIC_LIBS) - set(_LIB_TYPE STATIC) -else() - 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") - -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() - endif() -endif() diff --git a/cmake/LINUXx86ToolChain.cmake b/cmake/LINUXx86ToolChain.cmake index 240eb269aa..e943b2aafd 100644 --- a/cmake/LINUXx86ToolChain.cmake +++ b/cmake/LINUXx86ToolChain.cmake @@ -26,7 +26,7 @@ set(T_AVX_EXITCODE "0" CACHE STRING INTERNAL FORCE) EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture i386) EXECUTE_PROCESS(COMMAND sudo apt-get update) -EXECUTE_PROCESS(COMMAND sudo apt-get install -qq -y g++-10 gcc-10-multilib glibc-*:i386 libc6-dev-i386 g++-10-multilib zlib1g-dev:i386 libssl-dev:i386 libopus-dev:i386 libsodium-dev:i386) +EXECUTE_PROCESS(COMMAND sudo apt-get install -qq -y g++-10 gcc-10-multilib glibc-*:i386 libc6-dev-i386 g++-10-multilib zlib1g-dev:i386 libssl-dev:i386 libopus-dev:i386) EXECUTE_PROCESS(COMMAND export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/) set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") diff --git a/cmake/Win32Toolchain.cmake b/cmake/Win32Toolchain.cmake index 7b1ab655ad..ec20c1ab8a 100644 --- a/cmake/Win32Toolchain.cmake +++ b/cmake/Win32Toolchain.cmake @@ -10,17 +10,12 @@ ADD_DEFINITIONS(/bigobj) link_libraries("${PROJECT_SOURCE_DIR}/win32/32/lib/libssl.lib") link_libraries("${PROJECT_SOURCE_DIR}/win32/32/lib/libcrypto.lib") link_libraries("${PROJECT_SOURCE_DIR}/win32/32/lib/zlib.lib") -link_libraries("${PROJECT_SOURCE_DIR}/win32/32/lib/libsodium.lib") link_libraries("${PROJECT_SOURCE_DIR}/win32/32/lib/opus.lib") set(OPUS_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/win32/include") set(OPUS_LIBRARIES "${PROJECT_SOURCE_DIR}/win32/32/lib/opus.lib") -set(sodium_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/win32/include") -set(sodium_LIBRARY_DEBUG "${PROJECT_SOURCE_DIR}/win32/32/lib/libsodium.lib") -set(sodium_LIBRARY_RELEASE "${PROJECT_SOURCE_DIR}/win32/32/lib/libsodium.lib") set(HAVE_OPUS_OPUS_H "${PROJECT_SOURCE_DIR}/win32/include/opus/opus.h") set(OPUS_FOUND 1) -SET(sodium_VERSION_STRING "win32 bundled") include_directories("${PROJECT_SOURCE_DIR}/win32/include") diff --git a/docpages/01_frequently_asked_questions.md b/docpages/01_frequently_asked_questions.md index 8c82b46f6d..62336d6ff9 100644 --- a/docpages/01_frequently_asked_questions.md +++ b/docpages/01_frequently_asked_questions.md @@ -68,7 +68,7 @@ All functions within D++ are multi-threaded. You should still avoid doing long o ## Does this library support voice? -Yes! This library supports voice and will automatically enable voice if your system has the libopus and libsodium libraries. When running `cmake` the script will identify if these libraries are found. See the example programs for information on how to send audio. +Yes! This library supports voice and will automatically enable voice if your system has the libopus library. When running `cmake` the script will identify if this library is found. See the example programs for information on how to send audio. ## Does this library support sharding? @@ -94,10 +94,6 @@ No, the library only requires C++17. We have some optional features such as \ref To fix this issue, run `ldconfig`: `sudo ldconfig` as root. Log out if your SSH session and log back in, and the bot should be able to find the library. -## When compiling with voice support, I get an error: "No rule to make target 'sodium_LIBRARY_DEBUG-NOTFOUND', needed by 'libdpp.so'. Stop." - -The libsodium package requires pkg-config, but does not check for it when installed. Install it as root, e.g. `sudo apt install pkg-config`. Rerun cmake, and rebuild the library. - ## When I try to instantiate a dpp::cluster in windows, I get "D++ Debug/Release mismatch" If this happens, ensure you are using the correct precompiled build of the library. Our precompiled binaries are built in two forms, **release mode** and **debug mode** for Visual Studio 2019/2022. These two versions of the library are not cross-compatible due to differences in the debug and release STL (Microsoft standard library implementation). You should not need to build your own copy, but please see the section about \ref buildwindows for more information on how to build your own copy, if needed. diff --git a/docpages/advanced_reference/voice_model.md b/docpages/advanced_reference/voice_model.md index ca4525d174..15864fa0ed 100644 --- a/docpages/advanced_reference/voice_model.md +++ b/docpages/advanced_reference/voice_model.md @@ -11,7 +11,7 @@ initial connection to this secondary websocket. Every connection to a voice chan Once connected to this websocket, the library negotiates which protocols it supports and what encryption schemes to use. If you enabled DAVE (Discord's end-to-end encryption scheme) this is negotiated first. An MLS (message layer security) group is joined or created. If you did not enable DAVE, this step is bypassed. -The secondary websocket then gives the library a shared encryption secret and the hostname of an RTP server, which is used to encrypt RTP packets using libsodium. +The secondary websocket then gives the library a shared encryption secret and the hostname of an RTP server, which is used to encrypt RTP packets using libssl. This is stored for later. The next step is to send an initial packet to the RTP server so that the library can detect the public IP where the bot is running. Once the RTP server replies, @@ -153,9 +153,9 @@ digraph "Example Directory" { "discord_voice_client::send_audio_*()" -> "Dave encryption on"; "discord_voice_client::send_audio_*()" -> "Dave encryption off"; "Dave encryption on" -> "AES AEAD encryption\nof OPUS stream\nusing ratchet"; - "AES AEAD encryption\nof OPUS stream\nusing ratchet" -> "SODIUM encryption (xchacha20_poly1305_aead)"; - "Dave encryption off" -> "SODIUM encryption (xchacha20_poly1305_aead)"; - "SODIUM encryption (xchacha20_poly1305_aead)" -> "UDP sendto"; + "AES AEAD encryption\nof OPUS stream\nusing ratchet" -> "XChaCha20-Poly1305 encryption"; + "Dave encryption off" -> "XChaCha20-Poly1305 encryption"; + "XChaCha20-Poly1305 encryption" -> "UDP sendto"; "UDP sendto" -> "Discord RTP server"; "DAVE enabled" -> "MLS send key package"; "MLS send key package" -> "MLS receive external sender"; diff --git a/docpages/building/freebsd.md b/docpages/building/freebsd.md index f8ca1a87e1..b6ec50ed99 100644 --- a/docpages/building/freebsd.md +++ b/docpages/building/freebsd.md @@ -12,21 +12,13 @@ pkg install cmake ## 2. Install Voice Dependencies (Optional) -If you wish to use voice support, you'll need to install opus and libsodium: +If you wish to use voice support, you'll need to install opus: -First, you need to install opus. ```bash cd /usr/ports/audio/opus make && make install ``` -Then, you need to install libsodium. - -```bash -cd /usr/ports/security/libsodium -make && make install -``` - ## 3. Build Source Code ```bash diff --git a/docpages/building/openbsd.md b/docpages/building/openbsd.md index a289d75f13..34953cccc9 100644 --- a/docpages/building/openbsd.md +++ b/docpages/building/openbsd.md @@ -15,7 +15,7 @@ pkg_add cmake If you wish to use voice support, you'll need to do the following: ```bash -pkg_add libsodium opus pkgconf +pkg_add opus ``` ## 3. Build Source Code diff --git a/docpages/building/osx.md b/docpages/building/osx.md index b43a99e9e1..059c77fca0 100644 --- a/docpages/building/osx.md +++ b/docpages/building/osx.md @@ -15,10 +15,10 @@ brew install openssl pkgconfig \note Usually, you do not need pkgconfig. However, it seems that it throws errors about openssl without. -For voice support, additional dependencies are required: +For voice support, additional dependency is required: ```bash -brew install libsodium opus +brew install opus ``` ## 3. Build Source Code diff --git a/docpages/example_code/CMakeLists.txt b/docpages/example_code/CMakeLists.txt index 87c7713f2b..57f4fee152 100644 --- a/docpages/example_code/CMakeLists.txt +++ b/docpages/example_code/CMakeLists.txt @@ -33,7 +33,7 @@ project(documentation_tests) string(ASCII 27 Esc) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDPP_CORO -std=c++20 -pthread -O0 -fPIC -rdynamic -DFMT_HEADER_ONLY -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDPP_CORO -std=c++20 -pthread -O0 -fPIC -rdynamic -DFMT_HEADER_ONLY -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-deprecated-declarations") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") file(GLOB example_list ./*.cpp) diff --git a/docpages/images/audioframe.svg b/docpages/images/audioframe.svg index 302f65b0db..b17e104c49 100755 --- a/docpages/images/audioframe.svg +++ b/docpages/images/audioframe.svg @@ -173,7 +173,7 @@ sodipodi:role="line" id="tspan3010" x="748.91284" - y="835.92316">DAVE (AES 128 GCM AEAD) + y="835.92316">DAVE OPUS AUDIO (AES 128 GCM AEAD) SODIUM (CHACHA20 POLY1305) + y="912.60059">RTP CONTENT (CHACHA20 POLY1305 AEAD) __cdecl `int __cdecl main( 1>...\windows-bot-template-main\x64\Debug\MyBot.exe : fatal error LNK1120: 1 unresolved externals 1>Done building project "MyBot.vcxproj" -- FAILED. \endcode Make sure your don't have another version of the library installed through vcpkg. The template uses a slightly different version of D++ that has coroutines, while the vcpkg version does not, and the latter overwrites it! Uninstalling the library through vcpkg should fix this issue. -- If you get an error that a DLL is missing (e.g. `dpp.dll` or `opus.dll`) when starting your bot, then simply copy all DLLs from the **bin** directory of where you cloned the D++ repository to, into the same directory where your bot's executable is. You only need to do this once. There should be several of these DLL files: `dpp.dll`, `zlib.dll`, `openssl.dll` and `libcrypto.dll` (or similarly named SSL related files), `libsodium.dll` and `opus.dll`. Note the template project does this for you, so you should never encounter this issue. +- If you get an error that a DLL is missing (e.g. `dpp.dll` or `opus.dll`) when starting your bot, then simply copy all DLLs from the **bin** directory of where you cloned the D++ repository to, into the same directory where your bot's executable is. You only need to do this once. There should be several of these DLL files: `dpp.dll`, `zlib.dll`, `openssl.dll` and `libcrypto.dll` (or similarly named SSL related files), and `opus.dll`. Note the template project does this for you, so you should never encounter this issue. - If you get an error that says "Debug/Release mismatch", **you are using the wrong configuration of the D++ dll**. Your bot's executable and the dpp.dll file should both be built in the same configuration (Release or Debug), you get this error if they are different. **This also means you altered the template in a significant way,** we recommend you undo your modifications or reinstall the template. - Stuck? You can find us on the [official Discord server](https://discord.gg/dpp) - ask away! We don't bite! diff --git a/docpages/make_a_bot/windows_wsl.md b/docpages/make_a_bot/windows_wsl.md index 455073bb20..e09ea7400e 100644 --- a/docpages/make_a_bot/windows_wsl.md +++ b/docpages/make_a_bot/windows_wsl.md @@ -8,7 +8,7 @@ This tutorial teaches you how to create a lightweight environment for D++ develo 2. Now open PowerShell as Administrator and type `wsl` to start up your subsystem. You may also type `ubuntu` into your search bar and open it that way. 3. Head on over to your home directory using `cd ~`. 4. Download the latest build for your distro using `wget [url here]`. In this guide we will use the latest build for 64 bit Ubuntu: `wget -O libdpp.deb https://dl.dpp.dev/latest`. -5. Finally install all required dependencies and the library itself using `sudo apt-get install libopus0 libopus-dev libsodium-dev && sudo dpkg -i libdpp.deb && rm libdpp.deb`. +5. Finally install all required dependencies and the library itself using `sudo apt-get install libopus0 libopus-dev && sudo dpkg -i libdpp.deb && rm libdpp.deb`. 6. Congratulations, you've successfully installed all dependencies! Now comes the real fun: Setting up the environment! For this tutorial we'll use a as small as possible setup, so you might create a more advanced one for production bots. 7. Create a new directory, inside your home directory, using `mkdir MyBot`. Then, you want to open that directory using `cd MyBot`. 8. Now that you've a directory to work in, type `touch mybot.cxx` to create a file you can work in! diff --git a/include/dpp/cluster.h b/include/dpp/cluster.h index 4dad2327f2..5264d83d30 100644 --- a/include/dpp/cluster.h +++ b/include/dpp/cluster.h @@ -133,6 +133,38 @@ class DPP_EXPORT cluster { */ timer_next_t next_timer; + /** + * @brief Mutex to work with named_commands and synchronize read write access + */ + std::shared_mutex named_commands_mutex; + + /** + * @brief Typedef for slashcommand handler type + */ + using slashcommand_handler_t = std::function; + +#ifdef DPP_CORO + /** + * @brief Typedef for coroutines based slashcommand handler type + */ + using co_slashcommand_handler_t = std::function(const slashcommand_t&)>; + + /** + * @brief Typedef for variant of coroutines based slashcommand handler type and regular version of it + */ + using slashcommand_handler_variant = std::variant; + + /** + * @brief Container to store relation between command name and it's handler + */ + std::map named_commands; +#else + /** + * @brief Container to store relation between command name and it's handler + */ + std::map named_commands; +#endif + /** * @brief Tick active timers */ @@ -436,6 +468,49 @@ class DPP_EXPORT cluster { /* Functions for attaching to event handlers */ + /** + * @brief Register a slash command handler. + * + * @param name The name of the slash command to register + * @param handler A handler function of type `slashcommand_handler_t` + * + * @return bool Returns `true` if the command was registered successfully, or `false` if + * the command with the same name already exists + */ + bool register_command(const std::string& name, const slashcommand_handler_t handler); + +#ifdef DPP_CORO + /** + * @brief Register a coroutine-based slash command handler. + * + * @param name The name of the slash command to register. + * @param handler A coroutine handler function of type `co_slashcommand_handler_t`. + * + * @return bool Returns `true` if the command was registered successfully, or `false` if + * the command with the same name already exists. + */ + template + std::enable_if_t, dpp::task>, bool> + register_command(const std::string& name, F&& handler){ + std::unique_lock lk(named_commands_mutex); + auto [_, inserted] = named_commands.try_emplace(name, std::forward(handler)); + return inserted; + }; +#endif + + /** + * @brief Unregister a slash command. + * + * This function unregisters (removes) a previously registered slash command by name. + * If the command is successfully removed, it returns `true`. + * + * @param name The name of the slash command to unregister. + * + * @return bool Returns `true` if the command was successfully unregistered, or `false` + * if the command was not found. + */ + bool unregister_command(const std::string& name); + /** * @brief on voice state update event * @@ -1246,7 +1321,7 @@ class DPP_EXPORT cluster { /** * @brief Called when packets are sent from the voice buffer. * The voice buffer contains packets that are already encoded with Opus and encrypted - * with Sodium, and merged into packets by the repacketizer, which is done in the + * with XChaCha20-Poly1305, and merged into packets by the repacketizer, which is done in the * dpp::discord_voice_client::send_audio method. You should use the buffer size properties * of dpp::voice_buffer_send_t to determine if you should fill the buffer with more * content. diff --git a/include/dpp/commandhandler.h b/include/dpp/commandhandler.h index 724f38f577..1958bc43d4 100644 --- a/include/dpp/commandhandler.h +++ b/include/dpp/commandhandler.h @@ -253,7 +253,7 @@ struct DPP_EXPORT command_info_t { * functions. * @deprecated commandhandler and message commands are deprecated and dpp::slashcommand is encouraged as a replacement. */ -class DPP_EXPORT commandhandler { +class DPP_EXPORT DPP_DEPRECATED("commandhandler should not be used. Please consider using dpp::cluster::register_command instead.") commandhandler { private: /** * @brief List of guild commands to bulk register diff --git a/include/dpp/discordvoiceclient.h b/include/dpp/discordvoiceclient.h index b84399625f..6ce21bf309 100644 --- a/include/dpp/discordvoiceclient.h +++ b/include/dpp/discordvoiceclient.h @@ -134,7 +134,7 @@ enum dave_version_t : uint8_t { */ dave_version_none = 0, /** - * @brief DAVE enabled, version 1 (E2EE encryption on top of sodium) + * @brief DAVE enabled, version 1 (E2EE encryption on top of openssl) */ dave_version_1 = 1, }; @@ -696,12 +696,6 @@ class DPP_EXPORT discord_voice_client : public websocket_client */ class dpp::cluster* creator; - /** - * @brief This needs to be static, we only initialise libsodium once per program start, - * so initialising it on first use in a voice connection is best. - */ - static bool sodium_initialised; - /** * @brief True when the thread is shutting down */ @@ -876,7 +870,7 @@ class DPP_EXPORT discord_voice_client : public websocket_client * @param _session_id The voice session id to identify with * @param _host The voice server hostname to connect to (hostname:port format) * @param enable_dave Enable DAVE E2EE - * @throw dpp::voice_exception Sodium or Opus failed to initialise, or D++ is not compiled with voice support + * @throw dpp::voice_exception Opus failed to initialise, or D++ is not compiled with voice support * @warning DAVE E2EE is an EXPERIMENTAL feature! */ discord_voice_client(dpp::cluster* _cluster, snowflake _channel_id, snowflake _server_id, const std::string &_token, const std::string &_session_id, const std::string &_host, bool enable_dave = false); @@ -911,7 +905,7 @@ class DPP_EXPORT discord_voice_client : public websocket_client * * You should send an audio packet of `send_audio_raw_max_length` (11520) bytes. * Note that this function can be costly as it has to opus encode - * the PCM audio on the fly, and also encrypt it with libsodium. + * the PCM audio on the fly, and also encrypt it with openssl. * * @note Because this function encrypts and encodes packets before * pushing them onto the output queue, if you have a complete stream @@ -951,7 +945,7 @@ class DPP_EXPORT discord_voice_client : public websocket_client * Some containers such as .ogg may contain OPUS * encoded data already. In this case, we don't need to encode the * frames using opus here. We can bypass the codec, only applying - * libsodium to the stream. + * openssl to the stream. * * @param opus_packet Opus packets. Discord expects opus frames * to be encoded at 48000Hz @@ -979,7 +973,7 @@ class DPP_EXPORT discord_voice_client : public websocket_client * Some containers such as .ogg may contain OPUS * encoded data already. In this case, we don't need to encode the * frames using opus here. We can bypass the codec, only applying - * libsodium to the stream. + * opens to the stream. * * Duration is calculated internally * diff --git a/include/dpp/exception.h b/include/dpp/exception.h index 9584e8e86d..1c60084240 100644 --- a/include/dpp/exception.h +++ b/include/dpp/exception.h @@ -31,7 +31,7 @@ namespace dpp { * @brief Exception error codes possible for dpp::exception::code() * * This list is a combined list of Discord's error codes, HTTP error codes, - * zlib, opus, sodium and C library codes (e.g. DNS, socket etc). You may + * zlib, opus and C library codes (e.g. DNS, socket etc). You may * use these to easily identify a type of exception without having to resort * to string comparison against dpp::exception::what() * @@ -98,7 +98,6 @@ enum exception_error_code { err_no_voice_support = 29, err_invalid_voice_packet_length = 30, err_opus = 31, - err_sodium = 32, err_etf = 33, err_cache = 34, err_icon_size = 35, @@ -591,6 +590,8 @@ class exception : public std::exception derived_exception(file_exception, exception); derived_exception(connection_exception, exception); derived_exception(voice_exception, exception); + derived_exception(encryption_exception, voice_exception); + derived_exception(decryption_exception, voice_exception); derived_exception(rest_exception, exception); derived_exception(invalid_token_exception, rest_exception); derived_exception(length_exception, exception); diff --git a/include/dpp/utility.h b/include/dpp/utility.h index 0dcb974972..6654606fc3 100644 --- a/include/dpp/utility.h +++ b/include/dpp/utility.h @@ -574,7 +574,7 @@ double DPP_EXPORT time_f(); /** * @brief Returns true if D++ was built with voice support * - * @return bool True if voice support is compiled in (libsodium/libopus) + * @return bool True if voice support is compiled in (libopus) */ bool DPP_EXPORT has_voice(); diff --git a/include/dpp/version.h b/include/dpp/version.h index d047704e86..e94dc4af7b 100644 --- a/include/dpp/version.h +++ b/include/dpp/version.h @@ -21,10 +21,10 @@ ************************************************************************************/ #pragma once -#if !defined(DPP_VERSION_LONG) -#define DPP_VERSION_LONG 0x00100032 -#define DPP_VERSION_SHORT 100032 -#define DPP_VERSION_TEXT "D++ 10.0.32 (22-Sep-2024)" +#ifndef DPP_VERSION_LONG +#define DPP_VERSION_LONG 0x00100033 +#define DPP_VERSION_SHORT 100033 +#define DPP_VERSION_TEXT "D++ 10.0.33 (13-Oct-2024)" #define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16) #define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8) diff --git a/library-vcpkg/CMakeLists.txt b/library-vcpkg/CMakeLists.txt index 0d7d0ac995..16df61f4f5 100644 --- a/library-vcpkg/CMakeLists.txt +++ b/library-vcpkg/CMakeLists.txt @@ -18,12 +18,7 @@ add_compile_definitions(HAVE_VOICE) -if (HAVE_VOICE) - file(GLOB THE_SOURCES "${DPP_ROOT_PATH}/src/dpp/events/*.cpp" "${modules_dir}/dpp/voice/enabled/*.cpp" "${DPP_ROOT_PATH}/dpp/dave/*.cpp" "${DPP_ROOT_PATH}/src/dpp/cluster/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.rc") -else() - file(GLOB THE_SOURCES "${DPP_ROOT_PATH}/src/dpp/events/*.cpp" "${modules_dir}/dpp/voice/stub/*.cpp" "${DPP_ROOT_PATH}/src/dpp/cluster/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.rc") -endif() - +file(GLOB THE_SOURCES "${DPP_ROOT_PATH}/src/dpp/events/*.cpp" "${modules_dir}/dpp/voice/enabled/*.cpp" "${DPP_ROOT_PATH}/dpp/dave/*.cpp" "${DPP_ROOT_PATH}/src/dpp/cluster/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.cpp" "${DPP_ROOT_PATH}/src/dpp/*.rc") set(LIB_NAME "${PROJECT_NAME}") @@ -87,12 +82,10 @@ target_include_directories( "$" ) -if (HAVE_VOICE) - add_subdirectory("${DPP_ROOT_PATH}/mlspp" "mlspp") - include_directories("${DPP_ROOT_PATH}/mlspp/include") - include_directories("${DPP_ROOT_PATH}/mlspp/lib/bytes/include") - include_directories("${DPP_ROOT_PATH}/mlspp/lib/hpke/include") -endif() +add_subdirectory("${DPP_ROOT_PATH}/mlspp" "mlspp") +include_directories("${DPP_ROOT_PATH}/mlspp/include") +include_directories("${DPP_ROOT_PATH}/mlspp/lib/bytes/include") +include_directories("${DPP_ROOT_PATH}/mlspp/lib/hpke/include") set_target_properties( "${LIB_NAME}" PROPERTIES @@ -108,7 +101,6 @@ target_link_options( find_package(nlohmann_json CONFIG REQUIRED) find_package(OpenSSL REQUIRED) find_package(Opus CONFIG REQUIRED) -find_package(unofficial-sodium CONFIG REQUIRED) find_package(ZLIB REQUIRED) target_link_libraries( @@ -117,22 +109,19 @@ target_link_libraries( $<$:OpenSSL::SSL> $<$:OpenSSL::Crypto> $<$:Opus::opus> - $<$:unofficial-sodium::sodium> $<$:ZLIB::ZLIB> $<$:Threads::Threads> ) -if (HAVE_VOICE) - # Private statically linked dependencies - target_link_libraries( - ${LIB_NAME} PRIVATE - mlspp - mls_vectors - bytes - tls_syntax - hpke - ) -endif() +# Private statically linked dependencies +target_link_libraries( + ${LIB_NAME} PRIVATE + mlspp + mls_vectors + bytes + tls_syntax + hpke +) set(CONFIG_FILE_NAME "${PROJECT_NAME}Config.cmake") set(EXPORTED_TARGETS_NAME "${PROJECT_NAME}Targets") diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 5d328f295c..0cabd74161 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -63,17 +63,12 @@ if(WIN32 AND NOT MINGW) link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib") link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib") link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") - link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") link_libraries("${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") set(OPUS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") set(OPUS_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib") - set(sodium_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") - set(sodium_LIBRARY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") - set(sodium_LIBRARY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib") set(HAVE_OPUS_OPUS_H "${CMAKE_CURRENT_SOURCE_DIR}/../win32/include/opus/opus.h") set(OPUS_FOUND 1) - SET(sodium_VERSION_STRING "win32 bundled") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../win32/include") @@ -123,7 +118,6 @@ if(NOT BUILD_SHARED_LIBS) endif() set(OPENSSL_USE_STATIC_LIBS ON) - set(sodium_USE_STATIC_LIBS ON) set(OPUS_USE_STATIC_LIBS TRUE) else() message(WARNING "-- Building of static library not supported on non UNIX systems.") @@ -132,30 +126,19 @@ endif() if (BUILD_VOICE_SUPPORT) if (MINGW OR NOT WIN32) - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindSodium.cmake") - else() - message("-- Could not detect ${Green}libsodium${ColourReset} due to missing ${Green}pkgconfig${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") - endif() - include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") + include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/FindOpus.cmake") endif() - if(DEFINED OPUS_FOUND) + if(HAVE_OPUS_OPUS_H) message("-- Found Opus ${Green}${OPUS_LIBRARIES}${ColourReset}") - if((WIN32 OR PKG_CONFIG_FOUND) AND DEFINED sodium_VERSION_STRING AND DEFINED sodium_LIBRARY_RELEASE) - add_compile_definitions(HAVE_VOICE) - - message("-- Sodium ${Green}${sodium_VERSION_STRING}${ColourReset}") - - set(HAVE_VOICE 1) - endif() + add_compile_definitions(HAVE_VOICE) + set(HAVE_VOICE 1) endif() if(HAVE_VOICE) - message("-- Detected ${Green}libsodium${ColourReset} and ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") + message("-- Detected ${Green}libopus${ColourReset}. VOICE support will be ${Green}enabled${ColourReset}") else(HAVE_VOICE) - message("-- Could not detect ${Green}libsodium${ColourReset} and/or ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") + message("-- Could not detect ${Green}libopus${ColourReset}. VOICE support will be ${Red}disabled${ColourReset}") endif(HAVE_VOICE) else() message("-- Voice support disabled by cmake option") @@ -275,13 +258,11 @@ foreach (fullmodname ${subdirlist}) if (NOT WINDOWS_32_BIT) target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libssl.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libcrypto.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/libsodium.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/opus.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/lib/zlib.lib") else() target_link_libraries(${modname} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libssl.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libcrypto.lib" - "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/libsodium.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/opus.lib" "${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/lib/zlib.lib") endif() @@ -305,9 +286,8 @@ foreach (fullmodname ${subdirlist}) endif() if (HAVE_VOICE) - target_link_libraries(${modname} PUBLIC ${sodium_LIBRARY_RELEASE} ${OPUS_LIBRARIES}) - - include_directories(${OPUS_INCLUDE_DIRS} ${sodium_INCLUDE_DIR}) + target_link_libraries(${modname} PUBLIC ${OPUS_LIBRARIES}) + include_directories(${OPUS_INCLUDE_DIRS}) endif() endforeach() @@ -425,13 +405,11 @@ if(WIN32 AND NOT MINGW) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libcrypto-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libssl-1_1-x64.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) else() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/zlib1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libcrypto-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libssl-1_1.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/libsodium.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../win32/32/bin/opus.dll" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" COPYONLY) endif() endif() diff --git a/src/dpp/cluster.cpp b/src/dpp/cluster.cpp index ff7345428c..26e333d194 100644 --- a/src/dpp/cluster.cpp +++ b/src/dpp/cluster.cpp @@ -120,6 +120,40 @@ cluster::cluster(const std::string &_token, uint32_t _intents, uint32_t _shards, i_message_content, "You have attached an event to cluster::on_message_update() but have not specified the privileged intent dpp::i_message_content. Message content, embeds, attachments, and components on received guild messages will be empty.") ); + + /* Add slashcommand callback for named commands. */ +#ifdef DPP_CORO + on_slashcommand([this](const slashcommand_t& event) -> task { + slashcommand_handler_variant copy; + { + std::shared_lock lk(named_commands_mutex); + auto it = named_commands.find(event.command.get_command_name()); + if (it == named_commands.end()) { + co_return; + } + copy = it->second; + } + if (std::holds_alternative(copy)) { + co_await std::get(copy)(event); + } else if (std::holds_alternative(copy)) { + std::get(copy)(event); + } + co_return; + }); +#else + on_slashcommand([this](const slashcommand_t& event) { + slashcommand_handler_t copy; + { + std::shared_lock lk(named_commands_mutex); + auto it = named_commands.find(event.command.get_command_name()); + if (it == named_commands.end()) { + return; + } + copy = it->second; + } + copy(event); + }); +#endif } cluster::~cluster() @@ -466,4 +500,15 @@ cluster& cluster::set_request_timeout(uint16_t timeout) { return *this; } +bool cluster::register_command(const std::string &name, const slashcommand_handler_t handler) { + std::unique_lock lk(named_commands_mutex); + auto [_, inserted] = named_commands.try_emplace(name, handler); + return inserted; +} + +bool cluster::unregister_command(const std::string &name) { + std::unique_lock lk(named_commands_mutex); + return named_commands.erase(name) == 1; +} + }; diff --git a/src/dpp/discordvoiceclient.cpp b/src/dpp/discordvoiceclient.cpp index 11f2e10b09..1b8fe7b95f 100644 --- a/src/dpp/discordvoiceclient.cpp +++ b/src/dpp/discordvoiceclient.cpp @@ -68,8 +68,6 @@ moving_averager::operator float() { return 0.0f; } -bool discord_voice_client::sodium_initialised = false; - discord_voice_client::~discord_voice_client() { cleanup(); diff --git a/src/dpp/thread.cpp b/src/dpp/thread.cpp index 8cfe5d618a..af661fe663 100644 --- a/src/dpp/thread.cpp +++ b/src/dpp/thread.cpp @@ -46,12 +46,14 @@ thread& thread::fill_from_json_impl(json* j) { set_int8_not_null(j, "member_count", this->member_count); set_bool_not_null(j, "newly_created", this->newly_created); - auto json_metadata = (*j)["thread_metadata"]; - metadata.archived = bool_not_null(&json_metadata, "archived"); - metadata.archive_timestamp = ts_not_null(&json_metadata, "archive_timestamp"); - metadata.auto_archive_duration = int16_not_null(&json_metadata, "auto_archive_duration"); - metadata.locked = bool_not_null(&json_metadata, "locked"); - metadata.invitable = bool_not_null(&json_metadata, "invitable"); + if (j->contains("thread_metadata")) { + auto json_metadata = (*j)["thread_metadata"]; + metadata.archived = bool_not_null(&json_metadata, "archived"); + metadata.archive_timestamp = ts_not_null(&json_metadata, "archive_timestamp"); + metadata.auto_archive_duration = int16_not_null(&json_metadata, "auto_archive_duration"); + metadata.locked = bool_not_null(&json_metadata, "locked"); + metadata.invitable = bool_not_null(&json_metadata, "invitable"); + } /* Only certain events set this */ if (j->contains("member")) { diff --git a/src/dpp/voice/enabled/audio_mix.cpp b/src/dpp/voice/enabled/audio_mix.cpp index a411623f6d..6d0f128e8c 100644 --- a/src/dpp/voice/enabled/audio_mix.cpp +++ b/src/dpp/voice/enabled/audio_mix.cpp @@ -29,8 +29,6 @@ #include #include #include - -#include #include namespace dpp { diff --git a/src/dpp/voice/enabled/constructor.cpp b/src/dpp/voice/enabled/constructor.cpp index 1e0a20b8f3..fc8e16d0d5 100644 --- a/src/dpp/voice/enabled/constructor.cpp +++ b/src/dpp/voice/enabled/constructor.cpp @@ -26,11 +26,8 @@ #include #include #include - -#include #include #include "../../dave/encryptor.h" - #include "enabled.h" namespace dpp { @@ -64,12 +61,6 @@ discord_voice_client::discord_voice_client(dpp::cluster* _cluster, snowflake _ch server_id(_server_id), channel_id(_channel_id) { - if (!discord_voice_client::sodium_initialised) { - if (sodium_init() < 0) { - throw dpp::voice_exception(err_sodium, "discord_voice_client::discord_voice_client; sodium_init() failed"); - } - discord_voice_client::sodium_initialised = true; - } int opusError = 0; encoder = opus_encoder_create(opus_sample_rate_hz, opus_channel_count, OPUS_APPLICATION_VOIP, &opusError); if (opusError) { diff --git a/src/dpp/voice/enabled/enabled.h b/src/dpp/voice/enabled/enabled.h index ccd7f99067..10df19081c 100644 --- a/src/dpp/voice/enabled/enabled.h +++ b/src/dpp/voice/enabled/enabled.h @@ -52,7 +52,6 @@ #include #include #include -#include #include #include "../../dave/session.h" #include "../../dave/decryptor.h" @@ -146,7 +145,7 @@ struct rtp_header { }; /** -* @brief Transport encryption type (libsodium) +* @brief Transport encryption type (libssl) */ constexpr std::string_view transport_encryption_protocol = "aead_xchacha20_poly1305_rtpsize"; @@ -155,3 +154,48 @@ std::string generate_displayable_code(const std::vector &data, size_t d size_t audio_mix(discord_voice_client &client, audio_mixer &mixer, opus_int32 *pcm_mix, const opus_int16 *pcm, size_t park_count, int samples, int &max_samples); } + +/** + * @brief OpenSSL based reimplementation of sodium's crypto_aead_xchacha20poly1305_ietf_encrypt + * @note Parameters and types are intended to match sodium as to be a drop-in replacement. + * @param c Ciphertext + Tag output + * @param clen Ciphertext length output + * @param m Message (plaintext) input + * @param mlen Message length + * @param ad Additional authenticated data (AAD) + * @param adlen Authenticated data length + * @param nsec Secret nonce (optional, nullptr to not use) + * @param npub Public nonce (24 bytes) + * @param k Key (32 bytes) + * @return 0 on success, -1 on error + */ +int ssl_crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c, unsigned long long *clen, const unsigned char *m, unsigned long long mlen, const unsigned char *ad, unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k); + +/** + * @brief OpenSSL based reimplementation of sodium's crypto_aead_xchacha20poly1305_ietf_decrypt + * @note Parameters and types are intended to match sodium as to be a drop-in replacement. + * @param m Message (plaintext) output + * @param mlen message length output + * @param nsec Secret nonce (optional, nullptr to not use) + * @param c Ciphertext + Tag input + * @param clen Ciphertext length + * @param ad Additional authenticated data (AAD) + * @param adlen Additional authenticated data length + * @param npub Public nonce (24 bytes) + * @param k Key (32 bytes) + * @return 0 on success, -1 on error + */ +int ssl_crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m, unsigned long long *mlen, unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k); + +/** + * @brief Size of public nonce (24 bytes) + * @note This constant is a drop-in replacement for one in libsodium + */ +inline constexpr unsigned int ssl_crypto_aead_xchacha20poly1305_ietf_NPUBBYTES = 24U; + +/** + * @brief AAD size + * @note This constant is a drop-in replacement for one in libsodium + */ +inline constexpr unsigned int ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES = 16U; + diff --git a/src/dpp/voice/enabled/handle_frame.cpp b/src/dpp/voice/enabled/handle_frame.cpp index 3740181e84..5331285ad4 100644 --- a/src/dpp/voice/enabled/handle_frame.cpp +++ b/src/dpp/voice/enabled/handle_frame.cpp @@ -394,23 +394,27 @@ bool discord_voice_client::handle_frame(const std::string &data, ws_opcode opcod bool ready_now = false; if (dave_version != dave_version_none) { + /* DAVE ready later */ if (j["d"]["dave_protocol_version"] != static_cast(dave_version)) { log(ll_error, "We requested DAVE E2EE but didn't receive it from the server, downgrading..."); dave_version = dave_version_none; ready_now = true; + } else { + if (mls_state == nullptr) { + mls_state = std::make_unique(); + } + if (mls_state->dave_session == nullptr) { + mls_state->dave_session = std::make_unique( + *creator, + nullptr, "", [this](std::string const &s1, std::string const &s2) { + log(ll_debug, "DAVE: " + s1 + ", " + s2); + }); + } + this->reinit_dave_mls_group(); } - - if (mls_state == nullptr) { - mls_state = std::make_unique(); - } - if (mls_state->dave_session == nullptr) { - mls_state->dave_session = std::make_unique( - *creator, - nullptr, "", [this](std::string const& s1, std::string const& s2) { - log(ll_debug, "Dave session constructor callback: " + s1 + ", " + s2); - }); - } - this->reinit_dave_mls_group(); + } else { + /* Non-DAVE ready immediately */ + ready_now = true; } if (ready_now) { diff --git a/src/dpp/voice/enabled/opus.cpp b/src/dpp/voice/enabled/opus.cpp index 2834624b77..d99a3776d0 100644 --- a/src/dpp/voice/enabled/opus.cpp +++ b/src/dpp/voice/enabled/opus.cpp @@ -24,7 +24,6 @@ #include #include #include - #include #include "../../dave/array_view.h" #include "../../dave/encryptor.h" @@ -114,7 +113,7 @@ discord_voice_client& discord_voice_client::send_audio_opus(uint8_t* opus_packet rtp_header header(sequence, timestamp, (uint32_t)ssrc); /* Expected payload size is unencrypted header + encrypted opus packet + unencrypted 32 bit nonce */ - size_t packet_siz = sizeof(header) + (encoded_audio_length + crypto_aead_xchacha20poly1305_IETF_ABYTES) + sizeof(packet_nonce); + size_t packet_siz = sizeof(header) + (encoded_audio_length + ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES) + sizeof(packet_nonce); std::vector payload(packet_siz); @@ -125,13 +124,14 @@ discord_voice_client& discord_voice_client::send_audio_opus(uint8_t* opus_packet uint32_t noncel = htonl(packet_nonce); /* 24 byte is needed for encrypting, discord just want 4 byte so just fill up the rest with null */ - unsigned char encrypt_nonce[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] = { '\0' }; + unsigned char encrypt_nonce[ssl_crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] = { '\0' }; memcpy(encrypt_nonce, &noncel, sizeof(noncel)); - /* Execute */ - crypto_aead_xchacha20poly1305_ietf_encrypt( + /* Execute */ + unsigned long long int clen{0}; + if (ssl_crypto_aead_xchacha20poly1305_ietf_encrypt( payload.data() + sizeof(header), - nullptr, + &clen, encoded_audio.data(), encoded_audio_length, /* The RTP Header as Additional Data */ @@ -140,7 +140,9 @@ discord_voice_client& discord_voice_client::send_audio_opus(uint8_t* opus_packet nullptr, static_cast(encrypt_nonce), secret_key.data() - ); + ) != 0) { + log(dpp::ll_debug, "XChaCha20 Encryption failed"); + } /* Append the 4 byte nonce to the resulting payload */ std::memcpy(payload.data() + payload.size() - sizeof(noncel), &noncel, sizeof(noncel)); diff --git a/src/dpp/voice/enabled/read_ready.cpp b/src/dpp/voice/enabled/read_ready.cpp index 51a817fbed..95ac598160 100644 --- a/src/dpp/voice/enabled/read_ready.cpp +++ b/src/dpp/voice/enabled/read_ready.cpp @@ -120,7 +120,7 @@ void discord_voice_client::read_ready() uint8_t decrypted[65535] = { 0 }; unsigned long long opus_packet_len = 0; - if (crypto_aead_xchacha20poly1305_ietf_decrypt( + if (ssl_crypto_aead_xchacha20poly1305_ietf_decrypt( decrypted, &opus_packet_len, nullptr, ciphertext, ciphertext_len, diff --git a/src/dpp/voice/enabled/xchacha20.cpp b/src/dpp/voice/enabled/xchacha20.cpp new file mode 100644 index 0000000000..cff2cc1eb9 --- /dev/null +++ b/src/dpp/voice/enabled/xchacha20.cpp @@ -0,0 +1,234 @@ +/************************************************************************************ + * + * D++, A Lightweight C++ library for Discord + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright 2021 Craig Edwards and D++ contributors + * (https://github.com/brainboxdotcc/DPP/graphs/contributors) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contains macros from BoringSSL, Copyright (c) 2014, Google Inc. + * Adapted from the public domain, estream code by D. Bernstein. + * + ************************************************************************************/ + +#include +#include +#include +#include +#include "enabled.h" + +/** + * @brief ChaCha static constant + * For some reason this is the ASCII string 'expand 32-byte k'. + * It is specified by the standard, and cannot be changed. + */ +constexpr uint8_t CHACHA20_CONSTANT_SEED[16] = {'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' }; + +/** + * XChaCha20-Poly1305 key size + */ +constexpr size_t KEY_SIZE = 32; + +/** + * @brief ChaCha20-Poly1305 nonce size + */ +constexpr size_t CHACHA_NONCE_SIZE = 12; + +/** + * @brief Rotates the bits of a 32-bit unsigned integer to the left by a specified number of positions. + * @note From Google's BoringSSL, but made constexpr + * + * @param value value to shift + * @param shift number of bits to shift left by + * @return shifted value + */ +constexpr uint32_t rotl_u32(uint32_t value, int shift) { + return (value << shift) | (value >> ((-shift) & 31)); +} + +/** + * @brief Updates a, b, c, and d with a ChaCha20 quarter round. + * @note This is based on black box voodoo from BoringSSL. + * + * @param x an array forming part of an XChaCha20 nonce + * @param a First word of the quarter-round. + * @param b Second word of the quarter-round. + * @param c Third word of the quarter-round. + * @param d Fourth word of the quarter-round. + */ +constexpr void quarter_round(uint32_t* x, int a, int b, int c, int d) { + x[a] += x[b]; + x[d] = rotl_u32(x[d] ^ x[a], 16); + x[c] += x[d]; + x[b] = rotl_u32(x[b] ^ x[c], 12); + x[a] += x[b]; + x[d] = rotl_u32(x[d] ^ x[a], 8); + x[c] += x[d]; + x[b] = rotl_u32(x[b] ^ x[c], 7); +} + +/** + * @brief key derivation function that takes a 256-bit key and a 128-bit nonce, producing a 256-bit subkey. + * + * This subkey is then used in the XChaCha20 algorithm to extend the nonce size to 192 bits. + * @note This based on the function from BoringSSL. Do not mess with it. + * @param out output 32 byte subkey + * @param key input 32 byte key + * @param nonce input 16 byte nonce + */ +void hchacha20(unsigned char out[KEY_SIZE], const unsigned char key[KEY_SIZE], const unsigned char nonce[16]) { + uint32_t x[16]; + std::memcpy(x, CHACHA20_CONSTANT_SEED, sizeof(CHACHA20_CONSTANT_SEED)); + std::memcpy(&x[4], key, KEY_SIZE); + std::memcpy(&x[CHACHA_NONCE_SIZE], nonce, 16); + for (size_t i = 0; i < 20; i += 2) { + quarter_round(x, 0, 4, 8, 12); + quarter_round(x, 1, 5, 9, 13); + quarter_round(x, 2, 6, 10, 14); + quarter_round(x, 3, 7, 11, 15); + quarter_round(x, 0, 5, 10, 15); + quarter_round(x, 1, 6, 11, 12); + quarter_round(x, 2, 7, 8, 13); + quarter_round(x, 3, 4, 9, 14); + } + std::memcpy(out, &x[0], sizeof(uint32_t) * 4); + std::memcpy(&out[16], &x[CHACHA_NONCE_SIZE], sizeof(uint32_t) * 4); +} + +int ssl_crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c, unsigned long long *clen, const unsigned char *m, unsigned long long mlen, const unsigned char *ad, unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k) { + unsigned char sub_key[KEY_SIZE]; + /* Regular ChaCha20-Poly1305 uses 12-byte nonce */ + unsigned char chacha_nonce[CHACHA_NONCE_SIZE] = {0}; + EVP_CIPHER_CTX *ctx = nullptr; + int len = 0; + int ciphertext_len = 0; + + try { + /* Derive the sub-key using HChaCha20 */ + hchacha20(sub_key, k, npub); + + /* Use the last 8 bytes of the 24-byte XChaCha20 nonce */ + std::memcpy(chacha_nonce + 4, npub + ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES, 8); + + /* Initialize encryption context with ChaCha20-Poly1305 */ + ctx = EVP_CIPHER_CTX_new(); + if ((ctx == nullptr) || (EVP_EncryptInit_ex(ctx, EVP_chacha20_poly1305(), nullptr, nullptr, nullptr) == 0)) { + throw dpp::encryption_exception("Error initializing encryption context"); + } + + /* Set key and nonce */ + if (EVP_EncryptInit_ex(ctx, nullptr, nullptr, sub_key, chacha_nonce) == 0) { + throw dpp::encryption_exception("Error setting key and nonce"); + } + + /* Set additional authenticated data (AAD) */ + if (EVP_EncryptUpdate(ctx, nullptr, &len, ad, static_cast(adlen)) == 0) { + throw dpp::encryption_exception("Error setting additional authenticated data"); + } + + /* Encrypt the plaintext */ + if (EVP_EncryptUpdate(ctx, c, &len, m, static_cast(mlen)) == 0) { + throw dpp::encryption_exception("Error during encryption"); + } + ciphertext_len = len; + + if (EVP_EncryptFinal_ex(ctx, c + len, &len) == 0) { + throw dpp::encryption_exception("Error finalizing encryption"); + } + ciphertext_len += len; + + /* Get the authentication tag */ + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES, c + ciphertext_len) == 0) { + throw dpp::encryption_exception("Error getting authentication tag"); + } + + /* Total ciphertext length (ciphertext + tag) */ + if (clen != nullptr) { + *clen = ciphertext_len + ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES; + } + + } catch (const dpp::encryption_exception& e) { + EVP_CIPHER_CTX_free(ctx); + return -1; + } + + EVP_CIPHER_CTX_free(ctx); + return 0; +} + +int ssl_crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m, unsigned long long *mlen, [[maybe_unused]] unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k) { + unsigned char sub_key[KEY_SIZE]; + /* Regular ChaCha20-Poly1305 uses 12-byte nonce */ + unsigned char chacha_nonce[CHACHA_NONCE_SIZE] = {0}; + EVP_CIPHER_CTX *ctx = nullptr; + int len = 0; + int plaintext_len = 0; + + if (clen < ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES) { + /* Ciphertext length must include at least the tag (16 bytes) */ + return -1; + } + + try { + /* Derive the sub-key using HChaCha20 */ + hchacha20(sub_key, k, npub); + + /* Use the last 8 bytes of the 24-byte XChaCha20 nonce */ + std::memcpy(chacha_nonce + 4, npub + ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES, 8); + + /* Initialize decryption context with ChaCha20-Poly1305 */ + ctx = EVP_CIPHER_CTX_new(); + if (!ctx || (EVP_DecryptInit_ex(ctx, EVP_chacha20_poly1305(), nullptr, nullptr, nullptr) == 0)) { + throw dpp::decryption_exception("Error initializing decryption context"); + } + + /* Set key and nonce */ + if (EVP_DecryptInit_ex(ctx, nullptr, nullptr, sub_key, chacha_nonce) == 0) { + throw dpp::decryption_exception("Error setting key and nonce"); + } + + /* Set additional authenticated data (AAD) */ + if (EVP_DecryptUpdate(ctx, nullptr, &len, ad, static_cast(adlen)) == 0) { + throw dpp::decryption_exception("Error setting additional authenticated data"); + } + + /* Decrypt the ciphertext (excluding the tag) */ + if (EVP_DecryptUpdate(ctx, m, &len, c, static_cast(clen - ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES)) == 0) { + throw dpp::decryption_exception("Error during decryption"); + } + plaintext_len = len; + + /* Set the expected tag */ + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES, const_cast(c + clen - ssl_crypto_aead_xchacha20poly1305_IETF_ABYTES)) == 0) { + throw dpp::decryption_exception("Error setting authentication tag"); + } + + /* Check tag */ + int ret = EVP_DecryptFinal_ex(ctx, m + len, &len); + if (ret > 0) { + /* Tag is valid, finalize plaintext length */ + *mlen = plaintext_len + len; + } else { + throw dpp::decryption_exception("Authentication failed"); + } + + } catch (const dpp::decryption_exception& e) { + EVP_CIPHER_CTX_free(ctx); + return -1; + } + + EVP_CIPHER_CTX_free(ctx); + return 0; +} diff --git a/vcpkg/ports/dpp/vcpkg.json b/vcpkg/ports/dpp/vcpkg.json index cc9cc114f3..743b89dd0b 100644 --- a/vcpkg/ports/dpp/vcpkg.json +++ b/vcpkg/ports/dpp/vcpkg.json @@ -6,7 +6,6 @@ "license": "Apache-2.0", "supports": "(windows & !static & !uwp) | linux | osx", "dependencies": [ - "libsodium", "nlohmann-json", "openssl", "opus", diff --git a/win32/32/bin/libsodium.dll b/win32/32/bin/libsodium.dll deleted file mode 100755 index 09d2e51792..0000000000 Binary files a/win32/32/bin/libsodium.dll and /dev/null differ diff --git a/win32/bin/libsodium.dll b/win32/bin/libsodium.dll deleted file mode 100644 index 0fc90b1231..0000000000 Binary files a/win32/bin/libsodium.dll and /dev/null differ diff --git a/win32/include/sodium.h b/win32/include/sodium.h deleted file mode 100644 index 295f911cff..0000000000 --- a/win32/include/sodium.h +++ /dev/null @@ -1,69 +0,0 @@ - -#ifndef sodium_H -#define sodium_H - -#include "sodium/version.h" - -#include "sodium/core.h" -#include "sodium/crypto_aead_aes256gcm.h" -#include "sodium/crypto_aead_chacha20poly1305.h" -#include "sodium/crypto_aead_xchacha20poly1305.h" -#include "sodium/crypto_auth.h" -#include "sodium/crypto_auth_hmacsha256.h" -#include "sodium/crypto_auth_hmacsha512.h" -#include "sodium/crypto_auth_hmacsha512256.h" -#include "sodium/crypto_box.h" -#include "sodium/crypto_box_curve25519xsalsa20poly1305.h" -#include "sodium/crypto_core_hsalsa20.h" -#include "sodium/crypto_core_hchacha20.h" -#include "sodium/crypto_core_salsa20.h" -#include "sodium/crypto_core_salsa2012.h" -#include "sodium/crypto_core_salsa208.h" -#include "sodium/crypto_generichash.h" -#include "sodium/crypto_generichash_blake2b.h" -#include "sodium/crypto_hash.h" -#include "sodium/crypto_hash_sha256.h" -#include "sodium/crypto_hash_sha512.h" -#include "sodium/crypto_kdf.h" -#include "sodium/crypto_kdf_blake2b.h" -#include "sodium/crypto_kx.h" -#include "sodium/crypto_onetimeauth.h" -#include "sodium/crypto_onetimeauth_poly1305.h" -#include "sodium/crypto_pwhash.h" -#include "sodium/crypto_pwhash_argon2i.h" -#include "sodium/crypto_scalarmult.h" -#include "sodium/crypto_scalarmult_curve25519.h" -#include "sodium/crypto_secretbox.h" -#include "sodium/crypto_secretbox_xsalsa20poly1305.h" -#include "sodium/crypto_secretstream_xchacha20poly1305.h" -#include "sodium/crypto_shorthash.h" -#include "sodium/crypto_shorthash_siphash24.h" -#include "sodium/crypto_sign.h" -#include "sodium/crypto_sign_ed25519.h" -#include "sodium/crypto_stream.h" -#include "sodium/crypto_stream_chacha20.h" -#include "sodium/crypto_stream_salsa20.h" -#include "sodium/crypto_stream_xsalsa20.h" -#include "sodium/crypto_verify_16.h" -#include "sodium/crypto_verify_32.h" -#include "sodium/crypto_verify_64.h" -#include "sodium/randombytes.h" -#include "sodium/randombytes_internal_random.h" -#include "sodium/randombytes_sysrandom.h" -#include "sodium/runtime.h" -#include "sodium/utils.h" - -#ifndef SODIUM_LIBRARY_MINIMAL -# include "sodium/crypto_box_curve25519xchacha20poly1305.h" -# include "sodium/crypto_core_ed25519.h" -# include "sodium/crypto_core_ristretto255.h" -# include "sodium/crypto_scalarmult_ed25519.h" -# include "sodium/crypto_scalarmult_ristretto255.h" -# include "sodium/crypto_secretbox_xchacha20poly1305.h" -# include "sodium/crypto_pwhash_scryptsalsa208sha256.h" -# include "sodium/crypto_stream_salsa2012.h" -# include "sodium/crypto_stream_salsa208.h" -# include "sodium/crypto_stream_xchacha20.h" -#endif - -#endif diff --git a/win32/include/sodium/core.h b/win32/include/sodium/core.h deleted file mode 100644 index dd088d2cae..0000000000 --- a/win32/include/sodium/core.h +++ /dev/null @@ -1,28 +0,0 @@ - -#ifndef sodium_core_H -#define sodium_core_H - -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -SODIUM_EXPORT -int sodium_init(void) - __attribute__ ((warn_unused_result)); - -/* ---- */ - -SODIUM_EXPORT -int sodium_set_misuse_handler(void (*handler)(void)); - -SODIUM_EXPORT -void sodium_misuse(void) - __attribute__ ((noreturn)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_aead_aes256gcm.h b/win32/include/sodium/crypto_aead_aes256gcm.h deleted file mode 100644 index 9baeb3f19f..0000000000 --- a/win32/include/sodium/crypto_aead_aes256gcm.h +++ /dev/null @@ -1,179 +0,0 @@ -#ifndef crypto_aead_aes256gcm_H -#define crypto_aead_aes256gcm_H - -/* - * WARNING: Despite being the most popular AEAD construction due to its - * use in TLS, safely using AES-GCM in a different context is tricky. - * - * No more than ~ 350 GB of input data should be encrypted with a given key. - * This is for ~ 16 KB messages -- Actual figures vary according to - * message sizes. - * - * In addition, nonces are short and repeated nonces would totally destroy - * the security of this scheme. - * - * Nonces should thus come from atomic counters, which can be difficult to - * set up in a distributed environment. - * - * Unless you absolutely need AES-GCM, use crypto_aead_xchacha20poly1305_ietf_*() - * instead. It doesn't have any of these limitations. - * Or, if you don't need to authenticate additional data, just stick to - * crypto_secretbox(). - */ - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -SODIUM_EXPORT -int crypto_aead_aes256gcm_is_available(void); - -#define crypto_aead_aes256gcm_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_aead_aes256gcm_keybytes(void); - -#define crypto_aead_aes256gcm_NSECBYTES 0U -SODIUM_EXPORT -size_t crypto_aead_aes256gcm_nsecbytes(void); - -#define crypto_aead_aes256gcm_NPUBBYTES 12U -SODIUM_EXPORT -size_t crypto_aead_aes256gcm_npubbytes(void); - -#define crypto_aead_aes256gcm_ABYTES 16U -SODIUM_EXPORT -size_t crypto_aead_aes256gcm_abytes(void); - -#define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \ - SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \ - (16ULL * ((1ULL << 32) - 2ULL))) -SODIUM_EXPORT -size_t crypto_aead_aes256gcm_messagebytes_max(void); - -typedef struct CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state_ { - unsigned char opaque[512]; -} crypto_aead_aes256gcm_state; - -SODIUM_EXPORT -size_t crypto_aead_aes256gcm_statebytes(void); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_encrypt(unsigned char *c, - unsigned long long *clen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_decrypt(unsigned char *m, - unsigned long long *mlen_p, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c, - unsigned char *mac, - unsigned long long *maclen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 9, 10))); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *mac, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9))); - -/* -- Precomputation interface -- */ - -SODIUM_EXPORT -int crypto_aead_aes256gcm_beforenm(crypto_aead_aes256gcm_state *ctx_, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c, - unsigned long long *clen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const crypto_aead_aes256gcm_state *ctx_) - __attribute__ ((nonnull(1, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m, - unsigned long long *mlen_p, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const crypto_aead_aes256gcm_state *ctx_) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c, - unsigned char *mac, - unsigned long long *maclen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const crypto_aead_aes256gcm_state *ctx_) - __attribute__ ((nonnull(1, 2, 9, 10))); - -SODIUM_EXPORT -int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *mac, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const crypto_aead_aes256gcm_state *ctx_) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9))); - -SODIUM_EXPORT -void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_aead_chacha20poly1305.h b/win32/include/sodium/crypto_aead_chacha20poly1305.h deleted file mode 100644 index 5d671df142..0000000000 --- a/win32/include/sodium/crypto_aead_chacha20poly1305.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef crypto_aead_chacha20poly1305_H -#define crypto_aead_chacha20poly1305_H - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -/* -- IETF ChaCha20-Poly1305 construction with a 96-bit nonce and a 32-bit internal counter -- */ - -#define crypto_aead_chacha20poly1305_ietf_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_ietf_keybytes(void); - -#define crypto_aead_chacha20poly1305_ietf_NSECBYTES 0U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_ietf_nsecbytes(void); - -#define crypto_aead_chacha20poly1305_ietf_NPUBBYTES 12U - -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_ietf_npubbytes(void); - -#define crypto_aead_chacha20poly1305_ietf_ABYTES 16U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_ietf_abytes(void); - -#define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \ - SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \ - (64ULL * ((1ULL << 32) - 1ULL))) -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c, - unsigned long long *clen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m, - unsigned long long *mlen_p, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c, - unsigned char *mac, - unsigned long long *maclen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 9, 10))); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *mac, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9))); - -SODIUM_EXPORT -void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]) - __attribute__ ((nonnull)); - -/* -- Original ChaCha20-Poly1305 construction with a 64-bit nonce and a 64-bit internal counter -- */ - -#define crypto_aead_chacha20poly1305_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_keybytes(void); - -#define crypto_aead_chacha20poly1305_NSECBYTES 0U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_nsecbytes(void); - -#define crypto_aead_chacha20poly1305_NPUBBYTES 8U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_npubbytes(void); - -#define crypto_aead_chacha20poly1305_ABYTES 16U -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_abytes(void); - -#define crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX \ - (SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ABYTES) -SODIUM_EXPORT -size_t crypto_aead_chacha20poly1305_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_encrypt(unsigned char *c, - unsigned long long *clen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_decrypt(unsigned char *m, - unsigned long long *mlen_p, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c, - unsigned char *mac, - unsigned long long *maclen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 9, 10))); - -SODIUM_EXPORT -int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *mac, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9))); - -SODIUM_EXPORT -void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]) - __attribute__ ((nonnull)); - -/* Aliases */ - -#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES -#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES -#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES -#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES -#define crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_aead_xchacha20poly1305.h b/win32/include/sodium/crypto_aead_xchacha20poly1305.h deleted file mode 100644 index 6643b0cbf5..0000000000 --- a/win32/include/sodium/crypto_aead_xchacha20poly1305.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef crypto_aead_xchacha20poly1305_H -#define crypto_aead_xchacha20poly1305_H - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_aead_xchacha20poly1305_ietf_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_aead_xchacha20poly1305_ietf_keybytes(void); - -#define crypto_aead_xchacha20poly1305_ietf_NSECBYTES 0U -SODIUM_EXPORT -size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes(void); - -#define crypto_aead_xchacha20poly1305_ietf_NPUBBYTES 24U -SODIUM_EXPORT -size_t crypto_aead_xchacha20poly1305_ietf_npubbytes(void); - -#define crypto_aead_xchacha20poly1305_ietf_ABYTES 16U -SODIUM_EXPORT -size_t crypto_aead_xchacha20poly1305_ietf_abytes(void); - -#define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \ - (SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES) -SODIUM_EXPORT -size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c, - unsigned long long *clen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m, - unsigned long long *mlen_p, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9))); - -SODIUM_EXPORT -int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c, - unsigned char *mac, - unsigned long long *maclen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *nsec, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 9, 10))); - -SODIUM_EXPORT -int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m, - unsigned char *nsec, - const unsigned char *c, - unsigned long long clen, - const unsigned char *mac, - const unsigned char *ad, - unsigned long long adlen, - const unsigned char *npub, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9))); - -SODIUM_EXPORT -void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]) - __attribute__ ((nonnull)); - -/* Aliases */ - -#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES -#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES -#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES -#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES -#define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_auth.h b/win32/include/sodium/crypto_auth.h deleted file mode 100644 index 540aee0e8d..0000000000 --- a/win32/include/sodium/crypto_auth.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef crypto_auth_H -#define crypto_auth_H - -#include - -#include "crypto_auth_hmacsha512256.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES -SODIUM_EXPORT -size_t crypto_auth_bytes(void); - -#define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES -SODIUM_EXPORT -size_t crypto_auth_keybytes(void); - -#define crypto_auth_PRIMITIVE "hmacsha512256" -SODIUM_EXPORT -const char *crypto_auth_primitive(void); - -SODIUM_EXPORT -int crypto_auth(unsigned char *out, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_auth_verify(const unsigned char *h, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_auth_hmacsha256.h b/win32/include/sodium/crypto_auth_hmacsha256.h deleted file mode 100644 index 3da864c7d2..0000000000 --- a/win32/include/sodium/crypto_auth_hmacsha256.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef crypto_auth_hmacsha256_H -#define crypto_auth_hmacsha256_H - -#include -#include "crypto_hash_sha256.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_auth_hmacsha256_BYTES 32U -SODIUM_EXPORT -size_t crypto_auth_hmacsha256_bytes(void); - -#define crypto_auth_hmacsha256_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_auth_hmacsha256_keybytes(void); - -SODIUM_EXPORT -int crypto_auth_hmacsha256(unsigned char *out, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_auth_hmacsha256_verify(const unsigned char *h, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -/* ------------------------------------------------------------------------- */ - -typedef struct crypto_auth_hmacsha256_state { - crypto_hash_sha256_state ictx; - crypto_hash_sha256_state octx; -} crypto_auth_hmacsha256_state; - -SODIUM_EXPORT -size_t crypto_auth_hmacsha256_statebytes(void); - -SODIUM_EXPORT -int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state, - const unsigned char *key, - size_t keylen) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state, - unsigned char *out) __attribute__ ((nonnull)); - - -SODIUM_EXPORT -void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_auth_hmacsha512.h b/win32/include/sodium/crypto_auth_hmacsha512.h deleted file mode 100644 index d992cb8163..0000000000 --- a/win32/include/sodium/crypto_auth_hmacsha512.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef crypto_auth_hmacsha512_H -#define crypto_auth_hmacsha512_H - -#include -#include "crypto_hash_sha512.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_auth_hmacsha512_BYTES 64U -SODIUM_EXPORT -size_t crypto_auth_hmacsha512_bytes(void); - -#define crypto_auth_hmacsha512_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_auth_hmacsha512_keybytes(void); - -SODIUM_EXPORT -int crypto_auth_hmacsha512(unsigned char *out, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_auth_hmacsha512_verify(const unsigned char *h, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -/* ------------------------------------------------------------------------- */ - -typedef struct crypto_auth_hmacsha512_state { - crypto_hash_sha512_state ictx; - crypto_hash_sha512_state octx; -} crypto_auth_hmacsha512_state; - -SODIUM_EXPORT -size_t crypto_auth_hmacsha512_statebytes(void); - -SODIUM_EXPORT -int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state, - const unsigned char *key, - size_t keylen) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state, - const unsigned char *in, - unsigned long long inlen) __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state, - unsigned char *out) __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_auth_hmacsha512256.h b/win32/include/sodium/crypto_auth_hmacsha512256.h deleted file mode 100644 index 3fb5263892..0000000000 --- a/win32/include/sodium/crypto_auth_hmacsha512256.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef crypto_auth_hmacsha512256_H -#define crypto_auth_hmacsha512256_H - -#include -#include "crypto_auth_hmacsha512.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_auth_hmacsha512256_BYTES 32U -SODIUM_EXPORT -size_t crypto_auth_hmacsha512256_bytes(void); - -#define crypto_auth_hmacsha512256_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_auth_hmacsha512256_keybytes(void); - -SODIUM_EXPORT -int crypto_auth_hmacsha512256(unsigned char *out, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_auth_hmacsha512256_verify(const unsigned char *h, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -/* ------------------------------------------------------------------------- */ - -typedef crypto_auth_hmacsha512_state crypto_auth_hmacsha512256_state; - -SODIUM_EXPORT -size_t crypto_auth_hmacsha512256_statebytes(void); - -SODIUM_EXPORT -int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state, - const unsigned char *key, - size_t keylen) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state, - const unsigned char *in, - unsigned long long inlen) __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state, - unsigned char *out) __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_box.h b/win32/include/sodium/crypto_box.h deleted file mode 100644 index e060dd29fc..0000000000 --- a/win32/include/sodium/crypto_box.h +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef crypto_box_H -#define crypto_box_H - -/* - * THREAD SAFETY: crypto_box_keypair() is thread-safe, - * provided that sodium_init() was called before. - * - * Other functions are always thread-safe. - */ - -#include - -#include "crypto_box_curve25519xsalsa20poly1305.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_box_SEEDBYTES crypto_box_curve25519xsalsa20poly1305_SEEDBYTES -SODIUM_EXPORT -size_t crypto_box_seedbytes(void); - -#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES -SODIUM_EXPORT -size_t crypto_box_publickeybytes(void); - -#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES -SODIUM_EXPORT -size_t crypto_box_secretkeybytes(void); - -#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES -SODIUM_EXPORT -size_t crypto_box_noncebytes(void); - -#define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES -SODIUM_EXPORT -size_t crypto_box_macbytes(void); - -#define crypto_box_MESSAGEBYTES_MAX crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX -SODIUM_EXPORT -size_t crypto_box_messagebytes_max(void); - -#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305" -SODIUM_EXPORT -const char *crypto_box_primitive(void); - -SODIUM_EXPORT -int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk, - const unsigned char *seed) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_keypair(unsigned char *pk, unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_easy(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))); - -SODIUM_EXPORT -int crypto_box_open_easy(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))); - -SODIUM_EXPORT -int crypto_box_detached(unsigned char *c, unsigned char *mac, - 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, 2, 5, 6, 7))); - -SODIUM_EXPORT -int crypto_box_open_detached(unsigned char *m, const unsigned char *c, - const unsigned char *mac, - unsigned long long clen, - const unsigned char *n, - const unsigned char *pk, - const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7))); - -/* -- Precomputation interface -- */ - -#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES -SODIUM_EXPORT -size_t crypto_box_beforenmbytes(void); - -SODIUM_EXPORT -int crypto_box_beforenm(unsigned char *k, const unsigned char *pk, - const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_easy_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))); - -SODIUM_EXPORT -int crypto_box_open_easy_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))); - -SODIUM_EXPORT -int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac, - const unsigned char *m, unsigned long long mlen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull(1, 2, 5, 6))); - -SODIUM_EXPORT -int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c, - const unsigned char *mac, - unsigned long long clen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6))); - -/* -- Ephemeral SK interface -- */ - -#define crypto_box_SEALBYTES (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES) -SODIUM_EXPORT -size_t crypto_box_sealbytes(void); - -SODIUM_EXPORT -int crypto_box_seal(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *pk) - __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_box_seal_open(unsigned char *m, const unsigned char *c, - unsigned long long clen, - const unsigned char *pk, const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); - -/* -- NaCl compatibility interface ; Requires padding -- */ - -#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES -SODIUM_EXPORT -size_t crypto_box_zerobytes(void); - -#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES -SODIUM_EXPORT -size_t crypto_box_boxzerobytes(void); - -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))); - -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))); - -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))); - -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))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_box_curve25519xchacha20poly1305.h b/win32/include/sodium/crypto_box_curve25519xchacha20poly1305.h deleted file mode 100644 index 26a3d31efa..0000000000 --- a/win32/include/sodium/crypto_box_curve25519xchacha20poly1305.h +++ /dev/null @@ -1,164 +0,0 @@ - -#ifndef crypto_box_curve25519xchacha20poly1305_H -#define crypto_box_curve25519xchacha20poly1305_H - -#include -#include "crypto_stream_xchacha20.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_box_curve25519xchacha20poly1305_SEEDBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void); - -#define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void); - -#define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void); - -#define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void); - -#define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void); - -#define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_macbytes(void); - -#define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \ - (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES) -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk, - unsigned char *sk, - const unsigned char *seed) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk, - unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_easy(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))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_open_easy(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))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c, - unsigned char *mac, - 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, 2, 5, 6, 7))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m, - const unsigned char *c, - const unsigned char *mac, - unsigned long long clen, - const unsigned char *n, - const unsigned char *pk, - const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7))); - -/* -- Precomputation interface -- */ - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k, - const unsigned char *pk, - const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_easy_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))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_open_easy_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))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c, - unsigned char *mac, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 5, 6))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m, - const unsigned char *c, - const unsigned char *mac, - unsigned long long clen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6))); - -/* -- Ephemeral SK interface -- */ - -#define crypto_box_curve25519xchacha20poly1305_SEALBYTES \ - (crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \ - crypto_box_curve25519xchacha20poly1305_MACBYTES) - -SODIUM_EXPORT -size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *pk) - __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m, - const unsigned char *c, - unsigned long long clen, - const unsigned char *pk, - const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_box_curve25519xsalsa20poly1305.h b/win32/include/sodium/crypto_box_curve25519xsalsa20poly1305.h deleted file mode 100644 index e733f49995..0000000000 --- a/win32/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef crypto_box_curve25519xsalsa20poly1305_H -#define crypto_box_curve25519xsalsa20poly1305_H - -#include -#include "crypto_stream_xsalsa20.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void); - -#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void); - -#define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void); - -#define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 32U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void); - -#define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 24U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void); - -#define crypto_box_curve25519xsalsa20poly1305_MACBYTES 16U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void); - -/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ -#define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \ - (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES) -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk, - unsigned char *sk, - const unsigned char *seed) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk, - unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k, - const unsigned char *pk, - const unsigned char *sk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -/* -- NaCl compatibility interface ; Requires padding -- */ - -#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void); - -#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES \ - (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \ - crypto_box_curve25519xsalsa20poly1305_MACBYTES) -SODIUM_EXPORT -size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305(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))); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_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))); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_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))); - -SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_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))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_ed25519.h b/win32/include/sodium/crypto_core_ed25519.h deleted file mode 100644 index 3eae00c456..0000000000 --- a/win32/include/sodium/crypto_core_ed25519.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef crypto_core_ed25519_H -#define crypto_core_ed25519_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_ed25519_BYTES 32 -SODIUM_EXPORT -size_t crypto_core_ed25519_bytes(void); - -#define crypto_core_ed25519_UNIFORMBYTES 32 -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); - -#define crypto_core_ed25519_NONREDUCEDSCALARBYTES 64 -SODIUM_EXPORT -size_t crypto_core_ed25519_nonreducedscalarbytes(void); - -SODIUM_EXPORT -int crypto_core_ed25519_is_valid_point(const unsigned char *p) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_core_ed25519_add(unsigned char *r, - const unsigned char *p, const unsigned char *q) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_core_ed25519_sub(unsigned char *r, - const unsigned char *p, const unsigned char *q) - __attribute__ ((nonnull)); - -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)); - -SODIUM_EXPORT -int crypto_core_ed25519_scalar_invert(unsigned char *recip, const unsigned char *s) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ed25519_scalar_negate(unsigned char *neg, const unsigned char *s) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ed25519_scalar_complement(unsigned char *comp, const unsigned char *s) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ed25519_scalar_add(unsigned char *z, const unsigned char *x, - const unsigned char *y) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ed25519_scalar_sub(unsigned char *z, const unsigned char *x, - const unsigned char *y) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ed25519_scalar_mul(unsigned char *z, const unsigned char *x, - const unsigned char *y) - __attribute__ ((nonnull)); - -/* - * The interval `s` is sampled from should be at least 317 bits to ensure almost - * uniformity of `r` over `L`. - */ -SODIUM_EXPORT -void crypto_core_ed25519_scalar_reduce(unsigned char *r, const unsigned char *s) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_hchacha20.h b/win32/include/sodium/crypto_core_hchacha20.h deleted file mode 100644 index ece141b09b..0000000000 --- a/win32/include/sodium/crypto_core_hchacha20.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef crypto_core_hchacha20_H -#define crypto_core_hchacha20_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_hchacha20_OUTPUTBYTES 32U -SODIUM_EXPORT -size_t crypto_core_hchacha20_outputbytes(void); - -#define crypto_core_hchacha20_INPUTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_hchacha20_inputbytes(void); - -#define crypto_core_hchacha20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_core_hchacha20_keybytes(void); - -#define crypto_core_hchacha20_CONSTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_hchacha20_constbytes(void); - -SODIUM_EXPORT -int crypto_core_hchacha20(unsigned char *out, const unsigned char *in, - const unsigned char *k, const unsigned char *c) - __attribute__ ((nonnull(1, 2, 3))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_hsalsa20.h b/win32/include/sodium/crypto_core_hsalsa20.h deleted file mode 100644 index 4bf7a48786..0000000000 --- a/win32/include/sodium/crypto_core_hsalsa20.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef crypto_core_hsalsa20_H -#define crypto_core_hsalsa20_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_hsalsa20_OUTPUTBYTES 32U -SODIUM_EXPORT -size_t crypto_core_hsalsa20_outputbytes(void); - -#define crypto_core_hsalsa20_INPUTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_hsalsa20_inputbytes(void); - -#define crypto_core_hsalsa20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_core_hsalsa20_keybytes(void); - -#define crypto_core_hsalsa20_CONSTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_hsalsa20_constbytes(void); - -SODIUM_EXPORT -int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in, - const unsigned char *k, const unsigned char *c) - __attribute__ ((nonnull(1, 2, 3))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_ristretto255.h b/win32/include/sodium/crypto_core_ristretto255.h deleted file mode 100644 index f2820e5576..0000000000 --- a/win32/include/sodium/crypto_core_ristretto255.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef crypto_core_ristretto255_H -#define crypto_core_ristretto255_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_ristretto255_BYTES 32 -SODIUM_EXPORT -size_t crypto_core_ristretto255_bytes(void); - -#define crypto_core_ristretto255_HASHBYTES 64 -SODIUM_EXPORT -size_t crypto_core_ristretto255_hashbytes(void); - -#define crypto_core_ristretto255_SCALARBYTES 32 -SODIUM_EXPORT -size_t crypto_core_ristretto255_scalarbytes(void); - -#define crypto_core_ristretto255_NONREDUCEDSCALARBYTES 64 -SODIUM_EXPORT -size_t crypto_core_ristretto255_nonreducedscalarbytes(void); - -SODIUM_EXPORT -int crypto_core_ristretto255_is_valid_point(const unsigned char *p) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_core_ristretto255_add(unsigned char *r, - const unsigned char *p, const unsigned char *q) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_core_ristretto255_sub(unsigned char *r, - const unsigned char *p, const unsigned char *q) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -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 -void crypto_core_ristretto255_scalar_random(unsigned char *r) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_core_ristretto255_scalar_invert(unsigned char *recip, - const unsigned char *s) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ristretto255_scalar_negate(unsigned char *neg, - const unsigned char *s) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ristretto255_scalar_complement(unsigned char *comp, - const unsigned char *s) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ristretto255_scalar_add(unsigned char *z, - const unsigned char *x, - const unsigned char *y) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ristretto255_scalar_sub(unsigned char *z, - const unsigned char *x, - const unsigned char *y) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_core_ristretto255_scalar_mul(unsigned char *z, - const unsigned char *x, - const unsigned char *y) - __attribute__ ((nonnull)); - -/* - * The interval `s` is sampled from should be at least 317 bits to ensure almost - * uniformity of `r` over `L`. - */ -SODIUM_EXPORT -void crypto_core_ristretto255_scalar_reduce(unsigned char *r, - const unsigned char *s) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_salsa20.h b/win32/include/sodium/crypto_core_salsa20.h deleted file mode 100644 index bd79fd9f54..0000000000 --- a/win32/include/sodium/crypto_core_salsa20.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef crypto_core_salsa20_H -#define crypto_core_salsa20_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_salsa20_OUTPUTBYTES 64U -SODIUM_EXPORT -size_t crypto_core_salsa20_outputbytes(void); - -#define crypto_core_salsa20_INPUTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_salsa20_inputbytes(void); - -#define crypto_core_salsa20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_core_salsa20_keybytes(void); - -#define crypto_core_salsa20_CONSTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_salsa20_constbytes(void); - -SODIUM_EXPORT -int crypto_core_salsa20(unsigned char *out, const unsigned char *in, - const unsigned char *k, const unsigned char *c) - __attribute__ ((nonnull(1, 2, 3))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_salsa2012.h b/win32/include/sodium/crypto_core_salsa2012.h deleted file mode 100644 index 05957591ca..0000000000 --- a/win32/include/sodium/crypto_core_salsa2012.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef crypto_core_salsa2012_H -#define crypto_core_salsa2012_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_salsa2012_OUTPUTBYTES 64U -SODIUM_EXPORT -size_t crypto_core_salsa2012_outputbytes(void); - -#define crypto_core_salsa2012_INPUTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_salsa2012_inputbytes(void); - -#define crypto_core_salsa2012_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_core_salsa2012_keybytes(void); - -#define crypto_core_salsa2012_CONSTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_salsa2012_constbytes(void); - -SODIUM_EXPORT -int crypto_core_salsa2012(unsigned char *out, const unsigned char *in, - const unsigned char *k, const unsigned char *c) - __attribute__ ((nonnull(1, 2, 3))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_core_salsa208.h b/win32/include/sodium/crypto_core_salsa208.h deleted file mode 100644 index d2f216af26..0000000000 --- a/win32/include/sodium/crypto_core_salsa208.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef crypto_core_salsa208_H -#define crypto_core_salsa208_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_core_salsa208_OUTPUTBYTES 64U -SODIUM_EXPORT -size_t crypto_core_salsa208_outputbytes(void) - __attribute__ ((deprecated)); - -#define crypto_core_salsa208_INPUTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_salsa208_inputbytes(void) - __attribute__ ((deprecated)); - -#define crypto_core_salsa208_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_core_salsa208_keybytes(void) - __attribute__ ((deprecated)); - -#define crypto_core_salsa208_CONSTBYTES 16U -SODIUM_EXPORT -size_t crypto_core_salsa208_constbytes(void) - __attribute__ ((deprecated)); - -SODIUM_EXPORT -int crypto_core_salsa208(unsigned char *out, const unsigned char *in, - const unsigned char *k, const unsigned char *c) - __attribute__ ((nonnull(1, 2, 3))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_generichash.h b/win32/include/sodium/crypto_generichash.h deleted file mode 100644 index d897e5d26c..0000000000 --- a/win32/include/sodium/crypto_generichash.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef crypto_generichash_H -#define crypto_generichash_H - -#include - -#include "crypto_generichash_blake2b.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_generichash_BYTES_MIN crypto_generichash_blake2b_BYTES_MIN -SODIUM_EXPORT -size_t crypto_generichash_bytes_min(void); - -#define crypto_generichash_BYTES_MAX crypto_generichash_blake2b_BYTES_MAX -SODIUM_EXPORT -size_t crypto_generichash_bytes_max(void); - -#define crypto_generichash_BYTES crypto_generichash_blake2b_BYTES -SODIUM_EXPORT -size_t crypto_generichash_bytes(void); - -#define crypto_generichash_KEYBYTES_MIN crypto_generichash_blake2b_KEYBYTES_MIN -SODIUM_EXPORT -size_t crypto_generichash_keybytes_min(void); - -#define crypto_generichash_KEYBYTES_MAX crypto_generichash_blake2b_KEYBYTES_MAX -SODIUM_EXPORT -size_t crypto_generichash_keybytes_max(void); - -#define crypto_generichash_KEYBYTES crypto_generichash_blake2b_KEYBYTES -SODIUM_EXPORT -size_t crypto_generichash_keybytes(void); - -#define crypto_generichash_PRIMITIVE "blake2b" -SODIUM_EXPORT -const char *crypto_generichash_primitive(void); - -/* - * Important when writing bindings for other programming languages: - * the state address should be 64-bytes aligned. - */ -typedef crypto_generichash_blake2b_state crypto_generichash_state; - -SODIUM_EXPORT -size_t crypto_generichash_statebytes(void); - -SODIUM_EXPORT -int crypto_generichash(unsigned char *out, size_t outlen, - const unsigned char *in, unsigned long long inlen, - const unsigned char *key, size_t keylen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_init(crypto_generichash_state *state, - const unsigned char *key, - const size_t keylen, const size_t outlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_update(crypto_generichash_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_final(crypto_generichash_state *state, - unsigned char *out, const size_t outlen) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_generichash_blake2b.h b/win32/include/sodium/crypto_generichash_blake2b.h deleted file mode 100644 index fee9d8ad19..0000000000 --- a/win32/include/sodium/crypto_generichash_blake2b.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef crypto_generichash_blake2b_H -#define crypto_generichash_blake2b_H - -#include -#include -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# pragma pack(1) -#else -# pragma pack(push, 1) -#endif - -typedef struct CRYPTO_ALIGN(64) crypto_generichash_blake2b_state { - unsigned char opaque[384]; -} crypto_generichash_blake2b_state; - -#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# pragma pack() -#else -# pragma pack(pop) -#endif - -#define crypto_generichash_blake2b_BYTES_MIN 16U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_bytes_min(void); - -#define crypto_generichash_blake2b_BYTES_MAX 64U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_bytes_max(void); - -#define crypto_generichash_blake2b_BYTES 32U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_bytes(void); - -#define crypto_generichash_blake2b_KEYBYTES_MIN 16U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_keybytes_min(void); - -#define crypto_generichash_blake2b_KEYBYTES_MAX 64U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_keybytes_max(void); - -#define crypto_generichash_blake2b_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_keybytes(void); - -#define crypto_generichash_blake2b_SALTBYTES 16U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_saltbytes(void); - -#define crypto_generichash_blake2b_PERSONALBYTES 16U -SODIUM_EXPORT -size_t crypto_generichash_blake2b_personalbytes(void); - -SODIUM_EXPORT -size_t crypto_generichash_blake2b_statebytes(void); - -SODIUM_EXPORT -int crypto_generichash_blake2b(unsigned char *out, size_t outlen, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *key, size_t keylen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *key, - size_t keylen, - const unsigned char *salt, - const unsigned char *personal) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state, - const unsigned char *key, - const size_t keylen, const size_t outlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_blake2b_init_salt_personal(crypto_generichash_blake2b_state *state, - const unsigned char *key, - const size_t keylen, const size_t outlen, - const unsigned char *salt, - const unsigned char *personal) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_blake2b_update(crypto_generichash_blake2b_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state, - unsigned char *out, - const size_t outlen) __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_generichash_blake2b_keygen(unsigned char k[crypto_generichash_blake2b_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_hash.h b/win32/include/sodium/crypto_hash.h deleted file mode 100644 index 8752f9cafe..0000000000 --- a/win32/include/sodium/crypto_hash.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef crypto_hash_H -#define crypto_hash_H - -/* - * WARNING: Unless you absolutely need to use SHA512 for interoperatibility, - * purposes, you might want to consider crypto_generichash() instead. - * Unlike SHA512, crypto_generichash() is not vulnerable to length - * extension attacks. - */ - -#include - -#include "crypto_hash_sha512.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_hash_BYTES crypto_hash_sha512_BYTES -SODIUM_EXPORT -size_t crypto_hash_bytes(void); - -SODIUM_EXPORT -int crypto_hash(unsigned char *out, const unsigned char *in, - unsigned long long inlen) __attribute__ ((nonnull(1))); - -#define crypto_hash_PRIMITIVE "sha512" -SODIUM_EXPORT -const char *crypto_hash_primitive(void) - __attribute__ ((warn_unused_result)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_hash_sha256.h b/win32/include/sodium/crypto_hash_sha256.h deleted file mode 100644 index b18217e18d..0000000000 --- a/win32/include/sodium/crypto_hash_sha256.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef crypto_hash_sha256_H -#define crypto_hash_sha256_H - -/* - * WARNING: Unless you absolutely need to use SHA256 for interoperatibility, - * purposes, you might want to consider crypto_generichash() instead. - * Unlike SHA256, crypto_generichash() is not vulnerable to length - * extension attacks. - */ - -#include -#include -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -typedef struct crypto_hash_sha256_state { - uint32_t state[8]; - uint64_t count; - uint8_t buf[64]; -} crypto_hash_sha256_state; - -SODIUM_EXPORT -size_t crypto_hash_sha256_statebytes(void); - -#define crypto_hash_sha256_BYTES 32U -SODIUM_EXPORT -size_t crypto_hash_sha256_bytes(void); - -SODIUM_EXPORT -int crypto_hash_sha256(unsigned char *out, const unsigned char *in, - unsigned long long inlen) __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_hash_sha256_init(crypto_hash_sha256_state *state) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_hash_sha256_update(crypto_hash_sha256_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_hash_sha256_final(crypto_hash_sha256_state *state, - unsigned char *out) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_hash_sha512.h b/win32/include/sodium/crypto_hash_sha512.h deleted file mode 100644 index 8efa7193ad..0000000000 --- a/win32/include/sodium/crypto_hash_sha512.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef crypto_hash_sha512_H -#define crypto_hash_sha512_H - -/* - * WARNING: Unless you absolutely need to use SHA512 for interoperatibility, - * purposes, you might want to consider crypto_generichash() instead. - * Unlike SHA512, crypto_generichash() is not vulnerable to length - * extension attacks. - */ - -#include -#include -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -typedef struct crypto_hash_sha512_state { - uint64_t state[8]; - uint64_t count[2]; - uint8_t buf[128]; -} crypto_hash_sha512_state; - -SODIUM_EXPORT -size_t crypto_hash_sha512_statebytes(void); - -#define crypto_hash_sha512_BYTES 64U -SODIUM_EXPORT -size_t crypto_hash_sha512_bytes(void); - -SODIUM_EXPORT -int crypto_hash_sha512(unsigned char *out, const unsigned char *in, - unsigned long long inlen) __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_hash_sha512_init(crypto_hash_sha512_state *state) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_hash_sha512_update(crypto_hash_sha512_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_hash_sha512_final(crypto_hash_sha512_state *state, - unsigned char *out) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_kdf.h b/win32/include/sodium/crypto_kdf.h deleted file mode 100644 index ac2fc6183c..0000000000 --- a/win32/include/sodium/crypto_kdf.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef crypto_kdf_H -#define crypto_kdf_H - -#include -#include - -#include "crypto_kdf_blake2b.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_kdf_BYTES_MIN crypto_kdf_blake2b_BYTES_MIN -SODIUM_EXPORT -size_t crypto_kdf_bytes_min(void); - -#define crypto_kdf_BYTES_MAX crypto_kdf_blake2b_BYTES_MAX -SODIUM_EXPORT -size_t crypto_kdf_bytes_max(void); - -#define crypto_kdf_CONTEXTBYTES crypto_kdf_blake2b_CONTEXTBYTES -SODIUM_EXPORT -size_t crypto_kdf_contextbytes(void); - -#define crypto_kdf_KEYBYTES crypto_kdf_blake2b_KEYBYTES -SODIUM_EXPORT -size_t crypto_kdf_keybytes(void); - -#define crypto_kdf_PRIMITIVE "blake2b" -SODIUM_EXPORT -const char *crypto_kdf_primitive(void) - __attribute__ ((warn_unused_result)); - -SODIUM_EXPORT -int crypto_kdf_derive_from_key(unsigned char *subkey, size_t subkey_len, - uint64_t subkey_id, - const char ctx[crypto_kdf_CONTEXTBYTES], - const unsigned char key[crypto_kdf_KEYBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_kdf_blake2b.h b/win32/include/sodium/crypto_kdf_blake2b.h deleted file mode 100644 index 3ae47dd32c..0000000000 --- a/win32/include/sodium/crypto_kdf_blake2b.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef crypto_kdf_blake2b_H -#define crypto_kdf_blake2b_H - -#include -#include - -#include "crypto_kdf_blake2b.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_kdf_blake2b_BYTES_MIN 16 -SODIUM_EXPORT -size_t crypto_kdf_blake2b_bytes_min(void); - -#define crypto_kdf_blake2b_BYTES_MAX 64 -SODIUM_EXPORT -size_t crypto_kdf_blake2b_bytes_max(void); - -#define crypto_kdf_blake2b_CONTEXTBYTES 8 -SODIUM_EXPORT -size_t crypto_kdf_blake2b_contextbytes(void); - -#define crypto_kdf_blake2b_KEYBYTES 32 -SODIUM_EXPORT -size_t crypto_kdf_blake2b_keybytes(void); - -SODIUM_EXPORT -int crypto_kdf_blake2b_derive_from_key(unsigned char *subkey, size_t subkey_len, - uint64_t subkey_id, - const char ctx[crypto_kdf_blake2b_CONTEXTBYTES], - const unsigned char key[crypto_kdf_blake2b_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_kx.h b/win32/include/sodium/crypto_kx.h deleted file mode 100644 index 347132c320..0000000000 --- a/win32/include/sodium/crypto_kx.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef crypto_kx_H -#define crypto_kx_H - -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_kx_PUBLICKEYBYTES 32 -SODIUM_EXPORT -size_t crypto_kx_publickeybytes(void); - -#define crypto_kx_SECRETKEYBYTES 32 -SODIUM_EXPORT -size_t crypto_kx_secretkeybytes(void); - -#define crypto_kx_SEEDBYTES 32 -SODIUM_EXPORT -size_t crypto_kx_seedbytes(void); - -#define crypto_kx_SESSIONKEYBYTES 32 -SODIUM_EXPORT -size_t crypto_kx_sessionkeybytes(void); - -#define crypto_kx_PRIMITIVE "x25519blake2b" -SODIUM_EXPORT -const char *crypto_kx_primitive(void); - -SODIUM_EXPORT -int crypto_kx_seed_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES], - unsigned char sk[crypto_kx_SECRETKEYBYTES], - const unsigned char seed[crypto_kx_SEEDBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_kx_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES], - unsigned char sk[crypto_kx_SECRETKEYBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES], - unsigned char tx[crypto_kx_SESSIONKEYBYTES], - const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES], - const unsigned char client_sk[crypto_kx_SECRETKEYBYTES], - const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES]) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5))); - -SODIUM_EXPORT -int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES], - unsigned char tx[crypto_kx_SESSIONKEYBYTES], - const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES], - const unsigned char server_sk[crypto_kx_SECRETKEYBYTES], - const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES]) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_onetimeauth.h b/win32/include/sodium/crypto_onetimeauth.h deleted file mode 100644 index 7cd7b07060..0000000000 --- a/win32/include/sodium/crypto_onetimeauth.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef crypto_onetimeauth_H -#define crypto_onetimeauth_H - -#include - -#include "crypto_onetimeauth_poly1305.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -typedef crypto_onetimeauth_poly1305_state crypto_onetimeauth_state; - -SODIUM_EXPORT -size_t crypto_onetimeauth_statebytes(void); - -#define crypto_onetimeauth_BYTES crypto_onetimeauth_poly1305_BYTES -SODIUM_EXPORT -size_t crypto_onetimeauth_bytes(void); - -#define crypto_onetimeauth_KEYBYTES crypto_onetimeauth_poly1305_KEYBYTES -SODIUM_EXPORT -size_t crypto_onetimeauth_keybytes(void); - -#define crypto_onetimeauth_PRIMITIVE "poly1305" -SODIUM_EXPORT -const char *crypto_onetimeauth_primitive(void); - -SODIUM_EXPORT -int crypto_onetimeauth(unsigned char *out, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_onetimeauth_init(crypto_onetimeauth_state *state, - const unsigned char *key) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_onetimeauth_update(crypto_onetimeauth_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_onetimeauth_final(crypto_onetimeauth_state *state, - unsigned char *out) __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_onetimeauth_poly1305.h b/win32/include/sodium/crypto_onetimeauth_poly1305.h deleted file mode 100644 index f3e34d86df..0000000000 --- a/win32/include/sodium/crypto_onetimeauth_poly1305.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef crypto_onetimeauth_poly1305_H -#define crypto_onetimeauth_poly1305_H - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#include -#include -#include - -#include - -#include "export.h" - -typedef struct CRYPTO_ALIGN(16) crypto_onetimeauth_poly1305_state { - unsigned char opaque[256]; -} crypto_onetimeauth_poly1305_state; - -SODIUM_EXPORT -size_t crypto_onetimeauth_poly1305_statebytes(void); - -#define crypto_onetimeauth_poly1305_BYTES 16U -SODIUM_EXPORT -size_t crypto_onetimeauth_poly1305_bytes(void); - -#define crypto_onetimeauth_poly1305_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_onetimeauth_poly1305_keybytes(void); - -SODIUM_EXPORT -int crypto_onetimeauth_poly1305(unsigned char *out, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) - __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_onetimeauth_poly1305_verify(const unsigned char *h, - const unsigned char *in, - unsigned long long inlen, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state, - const unsigned char *key) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state, - const unsigned char *in, - unsigned long long inlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state, - unsigned char *out) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_onetimeauth_poly1305_keygen(unsigned char k[crypto_onetimeauth_poly1305_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_pwhash.h b/win32/include/sodium/crypto_pwhash.h deleted file mode 100644 index 585a993efd..0000000000 --- a/win32/include/sodium/crypto_pwhash.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef crypto_pwhash_H -#define crypto_pwhash_H - -#include - -#include "crypto_pwhash_argon2i.h" -#include "crypto_pwhash_argon2id.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_pwhash_ALG_ARGON2I13 crypto_pwhash_argon2i_ALG_ARGON2I13 -SODIUM_EXPORT -int crypto_pwhash_alg_argon2i13(void); - -#define crypto_pwhash_ALG_ARGON2ID13 crypto_pwhash_argon2id_ALG_ARGON2ID13 -SODIUM_EXPORT -int crypto_pwhash_alg_argon2id13(void); - -#define crypto_pwhash_ALG_DEFAULT crypto_pwhash_ALG_ARGON2ID13 -SODIUM_EXPORT -int crypto_pwhash_alg_default(void); - -#define crypto_pwhash_BYTES_MIN crypto_pwhash_argon2id_BYTES_MIN -SODIUM_EXPORT -size_t crypto_pwhash_bytes_min(void); - -#define crypto_pwhash_BYTES_MAX crypto_pwhash_argon2id_BYTES_MAX -SODIUM_EXPORT -size_t crypto_pwhash_bytes_max(void); - -#define crypto_pwhash_PASSWD_MIN crypto_pwhash_argon2id_PASSWD_MIN -SODIUM_EXPORT -size_t crypto_pwhash_passwd_min(void); - -#define crypto_pwhash_PASSWD_MAX crypto_pwhash_argon2id_PASSWD_MAX -SODIUM_EXPORT -size_t crypto_pwhash_passwd_max(void); - -#define crypto_pwhash_SALTBYTES crypto_pwhash_argon2id_SALTBYTES -SODIUM_EXPORT -size_t crypto_pwhash_saltbytes(void); - -#define crypto_pwhash_STRBYTES crypto_pwhash_argon2id_STRBYTES -SODIUM_EXPORT -size_t crypto_pwhash_strbytes(void); - -#define crypto_pwhash_STRPREFIX crypto_pwhash_argon2id_STRPREFIX -SODIUM_EXPORT -const char *crypto_pwhash_strprefix(void); - -#define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_argon2id_OPSLIMIT_MIN -SODIUM_EXPORT -size_t crypto_pwhash_opslimit_min(void); - -#define crypto_pwhash_OPSLIMIT_MAX crypto_pwhash_argon2id_OPSLIMIT_MAX -SODIUM_EXPORT -size_t crypto_pwhash_opslimit_max(void); - -#define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_argon2id_MEMLIMIT_MIN -SODIUM_EXPORT -size_t crypto_pwhash_memlimit_min(void); - -#define crypto_pwhash_MEMLIMIT_MAX crypto_pwhash_argon2id_MEMLIMIT_MAX -SODIUM_EXPORT -size_t crypto_pwhash_memlimit_max(void); - -#define crypto_pwhash_OPSLIMIT_INTERACTIVE crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE -SODIUM_EXPORT -size_t crypto_pwhash_opslimit_interactive(void); - -#define crypto_pwhash_MEMLIMIT_INTERACTIVE crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE -SODIUM_EXPORT -size_t crypto_pwhash_memlimit_interactive(void); - -#define crypto_pwhash_OPSLIMIT_MODERATE crypto_pwhash_argon2id_OPSLIMIT_MODERATE -SODIUM_EXPORT -size_t crypto_pwhash_opslimit_moderate(void); - -#define crypto_pwhash_MEMLIMIT_MODERATE crypto_pwhash_argon2id_MEMLIMIT_MODERATE -SODIUM_EXPORT -size_t crypto_pwhash_memlimit_moderate(void); - -#define crypto_pwhash_OPSLIMIT_SENSITIVE crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE -SODIUM_EXPORT -size_t crypto_pwhash_opslimit_sensitive(void); - -#define crypto_pwhash_MEMLIMIT_SENSITIVE crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE -SODIUM_EXPORT -size_t crypto_pwhash_memlimit_sensitive(void); - -/* - * With this function, do not forget to store all parameters, including the - * algorithm identifier in order to produce deterministic output. - * The crypto_pwhash_* definitions, including crypto_pwhash_ALG_DEFAULT, - * may change. - */ -SODIUM_EXPORT -int crypto_pwhash(unsigned char * const out, unsigned long long outlen, - const char * const passwd, unsigned long long passwdlen, - const unsigned char * const salt, - unsigned long long opslimit, size_t memlimit, int alg) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -/* - * The output string already includes all the required parameters, including - * the algorithm identifier. The string is all that has to be stored in - * order to verify a password. - */ -SODIUM_EXPORT -int crypto_pwhash_str(char out[crypto_pwhash_STRBYTES], - const char * const passwd, unsigned long long passwdlen, - unsigned long long opslimit, size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES], - const char * const passwd, unsigned long long passwdlen, - unsigned long long opslimit, size_t memlimit, int alg) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES], - const char * const passwd, - unsigned long long passwdlen) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES], - unsigned long long opslimit, size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#define crypto_pwhash_PRIMITIVE "argon2i" -SODIUM_EXPORT -const char *crypto_pwhash_primitive(void) - __attribute__ ((warn_unused_result)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_pwhash_argon2i.h b/win32/include/sodium/crypto_pwhash_argon2i.h deleted file mode 100644 index 88ff6221d6..0000000000 --- a/win32/include/sodium/crypto_pwhash_argon2i.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef crypto_pwhash_argon2i_H -#define crypto_pwhash_argon2i_H - -#include -#include -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_pwhash_argon2i_ALG_ARGON2I13 1 -SODIUM_EXPORT -int crypto_pwhash_argon2i_alg_argon2i13(void); - -#define crypto_pwhash_argon2i_BYTES_MIN 16U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_bytes_min(void); - -#define crypto_pwhash_argon2i_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U) -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_bytes_max(void); - -#define crypto_pwhash_argon2i_PASSWD_MIN 0U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_passwd_min(void); - -#define crypto_pwhash_argon2i_PASSWD_MAX 4294967295U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_passwd_max(void); - -#define crypto_pwhash_argon2i_SALTBYTES 16U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_saltbytes(void); - -#define crypto_pwhash_argon2i_STRBYTES 128U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_strbytes(void); - -#define crypto_pwhash_argon2i_STRPREFIX "$argon2i$" -SODIUM_EXPORT -const char *crypto_pwhash_argon2i_strprefix(void); - -#define crypto_pwhash_argon2i_OPSLIMIT_MIN 3U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_min(void); - -#define crypto_pwhash_argon2i_OPSLIMIT_MAX 4294967295U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_max(void); - -#define crypto_pwhash_argon2i_MEMLIMIT_MIN 8192U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_memlimit_min(void); - -#define crypto_pwhash_argon2i_MEMLIMIT_MAX \ - ((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U) -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_memlimit_max(void); - -#define crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE 4U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_interactive(void); - -#define crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE 33554432U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_memlimit_interactive(void); - -#define crypto_pwhash_argon2i_OPSLIMIT_MODERATE 6U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_moderate(void); - -#define crypto_pwhash_argon2i_MEMLIMIT_MODERATE 134217728U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_memlimit_moderate(void); - -#define crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE 8U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_sensitive(void); - -#define crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE 536870912U -SODIUM_EXPORT -size_t crypto_pwhash_argon2i_memlimit_sensitive(void); - -SODIUM_EXPORT -int crypto_pwhash_argon2i(unsigned char * const out, - unsigned long long outlen, - const char * const passwd, - unsigned long long passwdlen, - const unsigned char * const salt, - unsigned long long opslimit, size_t memlimit, - int alg) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_argon2i_str(char out[crypto_pwhash_argon2i_STRBYTES], - const char * const passwd, - unsigned long long passwdlen, - unsigned long long opslimit, size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_argon2i_str_verify(const char str[crypto_pwhash_argon2i_STRBYTES], - const char * const passwd, - unsigned long long passwdlen) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_argon2i_str_needs_rehash(const char str[crypto_pwhash_argon2i_STRBYTES], - unsigned long long opslimit, size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_pwhash_argon2id.h b/win32/include/sodium/crypto_pwhash_argon2id.h deleted file mode 100644 index 7183abd186..0000000000 --- a/win32/include/sodium/crypto_pwhash_argon2id.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef crypto_pwhash_argon2id_H -#define crypto_pwhash_argon2id_H - -#include -#include -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_pwhash_argon2id_ALG_ARGON2ID13 2 -SODIUM_EXPORT -int crypto_pwhash_argon2id_alg_argon2id13(void); - -#define crypto_pwhash_argon2id_BYTES_MIN 16U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_bytes_min(void); - -#define crypto_pwhash_argon2id_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U) -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_bytes_max(void); - -#define crypto_pwhash_argon2id_PASSWD_MIN 0U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_passwd_min(void); - -#define crypto_pwhash_argon2id_PASSWD_MAX 4294967295U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_passwd_max(void); - -#define crypto_pwhash_argon2id_SALTBYTES 16U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_saltbytes(void); - -#define crypto_pwhash_argon2id_STRBYTES 128U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_strbytes(void); - -#define crypto_pwhash_argon2id_STRPREFIX "$argon2id$" -SODIUM_EXPORT -const char *crypto_pwhash_argon2id_strprefix(void); - -#define crypto_pwhash_argon2id_OPSLIMIT_MIN 1U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_min(void); - -#define crypto_pwhash_argon2id_OPSLIMIT_MAX 4294967295U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_max(void); - -#define crypto_pwhash_argon2id_MEMLIMIT_MIN 8192U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_memlimit_min(void); - -#define crypto_pwhash_argon2id_MEMLIMIT_MAX \ - ((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U) -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_memlimit_max(void); - -#define crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE 2U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_interactive(void); - -#define crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE 67108864U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_memlimit_interactive(void); - -#define crypto_pwhash_argon2id_OPSLIMIT_MODERATE 3U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_moderate(void); - -#define crypto_pwhash_argon2id_MEMLIMIT_MODERATE 268435456U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_memlimit_moderate(void); - -#define crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE 4U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_sensitive(void); - -#define crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE 1073741824U -SODIUM_EXPORT -size_t crypto_pwhash_argon2id_memlimit_sensitive(void); - -SODIUM_EXPORT -int crypto_pwhash_argon2id(unsigned char * const out, - unsigned long long outlen, - const char * const passwd, - unsigned long long passwdlen, - const unsigned char * const salt, - unsigned long long opslimit, size_t memlimit, - int alg) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES], - const char * const passwd, - unsigned long long passwdlen, - unsigned long long opslimit, size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES], - const char * const passwd, - unsigned long long passwdlen) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_argon2id_str_needs_rehash(const char str[crypto_pwhash_argon2id_STRBYTES], - unsigned long long opslimit, size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_pwhash_scryptsalsa208sha256.h b/win32/include/sodium/crypto_pwhash_scryptsalsa208sha256.h deleted file mode 100644 index 5c0bf7d390..0000000000 --- a/win32/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef crypto_pwhash_scryptsalsa208sha256_H -#define crypto_pwhash_scryptsalsa208sha256_H - -#include -#include -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_pwhash_scryptsalsa208sha256_BYTES_MIN 16U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_bytes_min(void); - -#define crypto_pwhash_scryptsalsa208sha256_BYTES_MAX \ - SODIUM_MIN(SODIUM_SIZE_MAX, 0x1fffffffe0ULL) -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_bytes_max(void); - -#define crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN 0U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_passwd_min(void); - -#define crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX SODIUM_SIZE_MAX -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_passwd_max(void); - -#define crypto_pwhash_scryptsalsa208sha256_SALTBYTES 32U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_saltbytes(void); - -#define crypto_pwhash_scryptsalsa208sha256_STRBYTES 102U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_strbytes(void); - -#define crypto_pwhash_scryptsalsa208sha256_STRPREFIX "$7$" -SODIUM_EXPORT -const char *crypto_pwhash_scryptsalsa208sha256_strprefix(void); - -#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN 32768U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_min(void); - -#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX 4294967295U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max(void); - -#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN 16777216U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_memlimit_min(void); - -#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX \ - SODIUM_MIN(SIZE_MAX, 68719476736ULL) -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max(void); - -#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE 524288U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void); - -#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE 16777216U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void); - -#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE 33554432U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void); - -#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE 1073741824U -SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive(void); - -SODIUM_EXPORT -int crypto_pwhash_scryptsalsa208sha256(unsigned char * const out, - unsigned long long outlen, - const char * const passwd, - unsigned long long passwdlen, - const unsigned char * const salt, - unsigned long long opslimit, - size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES], - const char * const passwd, - unsigned long long passwdlen, - unsigned long long opslimit, - size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES], - const char * const passwd, - unsigned long long passwdlen) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen, - const uint8_t * salt, size_t saltlen, - uint64_t N, uint32_t r, uint32_t p, - uint8_t * buf, size_t buflen) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES], - unsigned long long opslimit, - size_t memlimit) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_scalarmult.h b/win32/include/sodium/crypto_scalarmult.h deleted file mode 100644 index 1c68585378..0000000000 --- a/win32/include/sodium/crypto_scalarmult.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef crypto_scalarmult_H -#define crypto_scalarmult_H - -#include - -#include "crypto_scalarmult_curve25519.h" -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES -SODIUM_EXPORT -size_t crypto_scalarmult_bytes(void); - -#define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES -SODIUM_EXPORT -size_t crypto_scalarmult_scalarbytes(void); - -#define crypto_scalarmult_PRIMITIVE "curve25519" -SODIUM_EXPORT -const char *crypto_scalarmult_primitive(void); - -SODIUM_EXPORT -int crypto_scalarmult_base(unsigned char *q, const unsigned char *n) - __attribute__ ((nonnull)); - -/* - * NOTE: Do not use the result of this function directly for key exchange. - * - * Hash the result with the public keys in order to compute a shared - * secret key: H(q || client_pk || server_pk) - * - * Or unless this is not an option, use the crypto_kx() API instead. - */ -SODIUM_EXPORT -int crypto_scalarmult(unsigned char *q, const unsigned char *n, - const unsigned char *p) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_scalarmult_curve25519.h b/win32/include/sodium/crypto_scalarmult_curve25519.h deleted file mode 100644 index 60e9d0c5a4..0000000000 --- a/win32/include/sodium/crypto_scalarmult_curve25519.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef crypto_scalarmult_curve25519_H -#define crypto_scalarmult_curve25519_H - -#include - -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_scalarmult_curve25519_BYTES 32U -SODIUM_EXPORT -size_t crypto_scalarmult_curve25519_bytes(void); - -#define crypto_scalarmult_curve25519_SCALARBYTES 32U -SODIUM_EXPORT -size_t crypto_scalarmult_curve25519_scalarbytes(void); - -/* - * NOTE: Do not use the result of this function directly for key exchange. - * - * Hash the result with the public keys in order to compute a shared - * secret key: H(q || client_pk || server_pk) - * - * Or unless this is not an option, use the crypto_kx() API instead. - */ -SODIUM_EXPORT -int crypto_scalarmult_curve25519(unsigned char *q, const unsigned char *n, - const unsigned char *p) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_scalarmult_curve25519_base(unsigned char *q, - const unsigned char *n) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_scalarmult_ed25519.h b/win32/include/sodium/crypto_scalarmult_ed25519.h deleted file mode 100644 index 2dfa4d7073..0000000000 --- a/win32/include/sodium/crypto_scalarmult_ed25519.h +++ /dev/null @@ -1,51 +0,0 @@ - -#ifndef crypto_scalarmult_ed25519_H -#define crypto_scalarmult_ed25519_H - -#include - -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_scalarmult_ed25519_BYTES 32U -SODIUM_EXPORT -size_t crypto_scalarmult_ed25519_bytes(void); - -#define crypto_scalarmult_ed25519_SCALARBYTES 32U -SODIUM_EXPORT -size_t crypto_scalarmult_ed25519_scalarbytes(void); - -/* - * NOTE: Do not use the result of this function directly for key exchange. - * - * Hash the result with the public keys in order to compute a shared - * secret key: H(q || client_pk || server_pk) - * - * Or unless this is not an option, use the crypto_kx() API instead. - */ -SODIUM_EXPORT -int crypto_scalarmult_ed25519(unsigned char *q, const unsigned char *n, - const unsigned char *p) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_scalarmult_ed25519_noclamp(unsigned char *q, const unsigned char *n, - const unsigned char *p) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_scalarmult_ed25519_base(unsigned char *q, const unsigned char *n) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_scalarmult_ed25519_base_noclamp(unsigned char *q, const unsigned char *n) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_scalarmult_ristretto255.h b/win32/include/sodium/crypto_scalarmult_ristretto255.h deleted file mode 100644 index 40a45ccef0..0000000000 --- a/win32/include/sodium/crypto_scalarmult_ristretto255.h +++ /dev/null @@ -1,43 +0,0 @@ - -#ifndef crypto_scalarmult_ristretto255_H -#define crypto_scalarmult_ristretto255_H - -#include - -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_scalarmult_ristretto255_BYTES 32U -SODIUM_EXPORT -size_t crypto_scalarmult_ristretto255_bytes(void); - -#define crypto_scalarmult_ristretto255_SCALARBYTES 32U -SODIUM_EXPORT -size_t crypto_scalarmult_ristretto255_scalarbytes(void); - -/* - * NOTE: Do not use the result of this function directly for key exchange. - * - * Hash the result with the public keys in order to compute a shared - * secret key: H(q || client_pk || server_pk) - * - * Or unless this is not an option, use the crypto_kx() API instead. - */ -SODIUM_EXPORT -int crypto_scalarmult_ristretto255(unsigned char *q, const unsigned char *n, - const unsigned char *p) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_scalarmult_ristretto255_base(unsigned char *q, - const unsigned char *n) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_secretbox.h b/win32/include/sodium/crypto_secretbox.h deleted file mode 100644 index 1d3709db12..0000000000 --- a/win32/include/sodium/crypto_secretbox.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef crypto_secretbox_H -#define crypto_secretbox_H - -#include - -#include "crypto_secretbox_xsalsa20poly1305.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES -SODIUM_EXPORT -size_t crypto_secretbox_keybytes(void); - -#define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES -SODIUM_EXPORT -size_t crypto_secretbox_noncebytes(void); - -#define crypto_secretbox_MACBYTES crypto_secretbox_xsalsa20poly1305_MACBYTES -SODIUM_EXPORT -size_t crypto_secretbox_macbytes(void); - -#define crypto_secretbox_PRIMITIVE "xsalsa20poly1305" -SODIUM_EXPORT -const char *crypto_secretbox_primitive(void); - -#define crypto_secretbox_MESSAGEBYTES_MAX crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX -SODIUM_EXPORT -size_t crypto_secretbox_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_secretbox_easy(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_open_easy(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 -int crypto_secretbox_detached(unsigned char *c, unsigned char *mac, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 5, 6))); - -SODIUM_EXPORT -int crypto_secretbox_open_detached(unsigned char *m, - const unsigned char *c, - const unsigned char *mac, - unsigned long long clen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6))); - -SODIUM_EXPORT -void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES]) - __attribute__ ((nonnull)); - -/* -- NaCl compatibility interface ; Requires padding -- */ - -#define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES -SODIUM_EXPORT -size_t crypto_secretbox_zerobytes(void); - -#define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES -SODIUM_EXPORT -size_t crypto_secretbox_boxzerobytes(void); - -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))); - -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))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_secretbox_xchacha20poly1305.h b/win32/include/sodium/crypto_secretbox_xchacha20poly1305.h deleted file mode 100644 index 6ec674e310..0000000000 --- a/win32/include/sodium/crypto_secretbox_xchacha20poly1305.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef crypto_secretbox_xchacha20poly1305_H -#define crypto_secretbox_xchacha20poly1305_H - -#include -#include "crypto_stream_xchacha20.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_secretbox_xchacha20poly1305_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_secretbox_xchacha20poly1305_keybytes(void); - -#define crypto_secretbox_xchacha20poly1305_NONCEBYTES 24U -SODIUM_EXPORT -size_t crypto_secretbox_xchacha20poly1305_noncebytes(void); - -#define crypto_secretbox_xchacha20poly1305_MACBYTES 16U -SODIUM_EXPORT -size_t crypto_secretbox_xchacha20poly1305_macbytes(void); - -#define crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX \ - (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_secretbox_xchacha20poly1305_MACBYTES) -SODIUM_EXPORT -size_t crypto_secretbox_xchacha20poly1305_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_secretbox_xchacha20poly1305_easy(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_xchacha20poly1305_open_easy(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 -int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c, - unsigned char *mac, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull(1, 2, 5, 6))); - -SODIUM_EXPORT -int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m, - const unsigned char *c, - const unsigned char *mac, - unsigned long long clen, - const unsigned char *n, - const unsigned char *k) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6))); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_secretbox_xsalsa20poly1305.h b/win32/include/sodium/crypto_secretbox_xsalsa20poly1305.h deleted file mode 100644 index be0874cbaf..0000000000 --- a/win32/include/sodium/crypto_secretbox_xsalsa20poly1305.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef crypto_secretbox_xsalsa20poly1305_H -#define crypto_secretbox_xsalsa20poly1305_H - -#include -#include "crypto_stream_xsalsa20.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_secretbox_xsalsa20poly1305_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_keybytes(void); - -#define crypto_secretbox_xsalsa20poly1305_NONCEBYTES 24U -SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_noncebytes(void); - -#define crypto_secretbox_xsalsa20poly1305_MACBYTES 16U -SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_macbytes(void); - -/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ -#define crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX \ - (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_secretbox_xsalsa20poly1305_MACBYTES) -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)); - -/* -- NaCl compatibility interface ; Requires padding -- */ - -#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U -SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void); - -#define crypto_secretbox_xsalsa20poly1305_ZEROBYTES \ - (crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + \ - crypto_secretbox_xsalsa20poly1305_MACBYTES) -SODIUM_EXPORT -size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_secretstream_xchacha20poly1305.h b/win32/include/sodium/crypto_secretstream_xchacha20poly1305.h deleted file mode 100644 index b22e4e9313..0000000000 --- a/win32/include/sodium/crypto_secretstream_xchacha20poly1305.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef crypto_secretstream_xchacha20poly1305_H -#define crypto_secretstream_xchacha20poly1305_H - -#include - -#include "crypto_aead_xchacha20poly1305.h" -#include "crypto_stream_chacha20.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_secretstream_xchacha20poly1305_ABYTES \ - (1U + crypto_aead_xchacha20poly1305_ietf_ABYTES) -SODIUM_EXPORT -size_t crypto_secretstream_xchacha20poly1305_abytes(void); - -#define crypto_secretstream_xchacha20poly1305_HEADERBYTES \ - crypto_aead_xchacha20poly1305_ietf_NPUBBYTES -SODIUM_EXPORT -size_t crypto_secretstream_xchacha20poly1305_headerbytes(void); - -#define crypto_secretstream_xchacha20poly1305_KEYBYTES \ - crypto_aead_xchacha20poly1305_ietf_KEYBYTES -SODIUM_EXPORT -size_t crypto_secretstream_xchacha20poly1305_keybytes(void); - -#define crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX \ - SODIUM_MIN(SODIUM_SIZE_MAX - crypto_secretstream_xchacha20poly1305_ABYTES, \ - (64ULL * ((1ULL << 32) - 2ULL))) -SODIUM_EXPORT -size_t crypto_secretstream_xchacha20poly1305_messagebytes_max(void); - -#define crypto_secretstream_xchacha20poly1305_TAG_MESSAGE 0x00 -SODIUM_EXPORT -unsigned char crypto_secretstream_xchacha20poly1305_tag_message(void); - -#define crypto_secretstream_xchacha20poly1305_TAG_PUSH 0x01 -SODIUM_EXPORT -unsigned char crypto_secretstream_xchacha20poly1305_tag_push(void); - -#define crypto_secretstream_xchacha20poly1305_TAG_REKEY 0x02 -SODIUM_EXPORT -unsigned char crypto_secretstream_xchacha20poly1305_tag_rekey(void); - -#define crypto_secretstream_xchacha20poly1305_TAG_FINAL \ - (crypto_secretstream_xchacha20poly1305_TAG_PUSH | \ - crypto_secretstream_xchacha20poly1305_TAG_REKEY) -SODIUM_EXPORT -unsigned char crypto_secretstream_xchacha20poly1305_tag_final(void); - -typedef struct crypto_secretstream_xchacha20poly1305_state { - unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES]; - unsigned char nonce[crypto_stream_chacha20_ietf_NONCEBYTES]; - unsigned char _pad[8]; -} crypto_secretstream_xchacha20poly1305_state; - -SODIUM_EXPORT -size_t crypto_secretstream_xchacha20poly1305_statebytes(void); - -SODIUM_EXPORT -void crypto_secretstream_xchacha20poly1305_keygen - (unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_secretstream_xchacha20poly1305_init_push - (crypto_secretstream_xchacha20poly1305_state *state, - unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES], - const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_secretstream_xchacha20poly1305_push - (crypto_secretstream_xchacha20poly1305_state *state, - unsigned char *c, unsigned long long *clen_p, - const unsigned char *m, unsigned long long mlen, - const unsigned char *ad, unsigned long long adlen, unsigned char tag) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_secretstream_xchacha20poly1305_init_pull - (crypto_secretstream_xchacha20poly1305_state *state, - const unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES], - const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_secretstream_xchacha20poly1305_pull - (crypto_secretstream_xchacha20poly1305_state *state, - unsigned char *m, unsigned long long *mlen_p, unsigned char *tag_p, - const unsigned char *c, unsigned long long clen, - const unsigned char *ad, unsigned long long adlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -void crypto_secretstream_xchacha20poly1305_rekey - (crypto_secretstream_xchacha20poly1305_state *state); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_shorthash.h b/win32/include/sodium/crypto_shorthash.h deleted file mode 100644 index fecaa88bd8..0000000000 --- a/win32/include/sodium/crypto_shorthash.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef crypto_shorthash_H -#define crypto_shorthash_H - -#include - -#include "crypto_shorthash_siphash24.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_shorthash_BYTES crypto_shorthash_siphash24_BYTES -SODIUM_EXPORT -size_t crypto_shorthash_bytes(void); - -#define crypto_shorthash_KEYBYTES crypto_shorthash_siphash24_KEYBYTES -SODIUM_EXPORT -size_t crypto_shorthash_keybytes(void); - -#define crypto_shorthash_PRIMITIVE "siphash24" -SODIUM_EXPORT -const char *crypto_shorthash_primitive(void); - -SODIUM_EXPORT -int crypto_shorthash(unsigned char *out, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_shorthash_siphash24.h b/win32/include/sodium/crypto_shorthash_siphash24.h deleted file mode 100644 index 1e6f72a620..0000000000 --- a/win32/include/sodium/crypto_shorthash_siphash24.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef crypto_shorthash_siphash24_H -#define crypto_shorthash_siphash24_H - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -/* -- 64-bit output -- */ - -#define crypto_shorthash_siphash24_BYTES 8U -SODIUM_EXPORT -size_t crypto_shorthash_siphash24_bytes(void); - -#define crypto_shorthash_siphash24_KEYBYTES 16U -SODIUM_EXPORT -size_t crypto_shorthash_siphash24_keybytes(void); - -SODIUM_EXPORT -int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((nonnull(1, 4))); - -#ifndef SODIUM_LIBRARY_MINIMAL -/* -- 128-bit output -- */ - -#define crypto_shorthash_siphashx24_BYTES 16U -SODIUM_EXPORT -size_t crypto_shorthash_siphashx24_bytes(void); - -#define crypto_shorthash_siphashx24_KEYBYTES 16U -SODIUM_EXPORT -size_t crypto_shorthash_siphashx24_keybytes(void); - -SODIUM_EXPORT -int crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in, - unsigned long long inlen, const unsigned char *k) - __attribute__ ((nonnull(1, 4))); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_sign.h b/win32/include/sodium/crypto_sign.h deleted file mode 100644 index f5fafb123e..0000000000 --- a/win32/include/sodium/crypto_sign.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef crypto_sign_H -#define crypto_sign_H - -/* - * THREAD SAFETY: crypto_sign_keypair() is thread-safe, - * provided that sodium_init() was called before. - * - * Other functions, including crypto_sign_seed_keypair() are always thread-safe. - */ - -#include - -#include "crypto_sign_ed25519.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -typedef crypto_sign_ed25519ph_state crypto_sign_state; - -SODIUM_EXPORT -size_t crypto_sign_statebytes(void); - -#define crypto_sign_BYTES crypto_sign_ed25519_BYTES -SODIUM_EXPORT -size_t crypto_sign_bytes(void); - -#define crypto_sign_SEEDBYTES crypto_sign_ed25519_SEEDBYTES -SODIUM_EXPORT -size_t crypto_sign_seedbytes(void); - -#define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES -SODIUM_EXPORT -size_t crypto_sign_publickeybytes(void); - -#define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES -SODIUM_EXPORT -size_t crypto_sign_secretkeybytes(void); - -#define crypto_sign_MESSAGEBYTES_MAX crypto_sign_ed25519_MESSAGEBYTES_MAX -SODIUM_EXPORT -size_t crypto_sign_messagebytes_max(void); - -#define crypto_sign_PRIMITIVE "ed25519" -SODIUM_EXPORT -const char *crypto_sign_primitive(void); - -SODIUM_EXPORT -int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk, - const unsigned char *seed) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_keypair(unsigned char *pk, unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign(unsigned char *sm, unsigned long long *smlen_p, - const unsigned char *m, unsigned long long mlen, - const unsigned char *sk) __attribute__ ((nonnull(1, 5))); - -SODIUM_EXPORT -int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p, - const unsigned char *sm, unsigned long long smlen, - const unsigned char *pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5))); - -SODIUM_EXPORT -int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p, - const unsigned char *m, unsigned long long mlen, - const unsigned char *sk) __attribute__ ((nonnull(1, 5))); - -SODIUM_EXPORT -int crypto_sign_verify_detached(const unsigned char *sig, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_sign_init(crypto_sign_state *state); - -SODIUM_EXPORT -int crypto_sign_update(crypto_sign_state *state, - const unsigned char *m, unsigned long long mlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig, - unsigned long long *siglen_p, - const unsigned char *sk) - __attribute__ ((nonnull(1, 2, 4))); - -SODIUM_EXPORT -int crypto_sign_final_verify(crypto_sign_state *state, const unsigned char *sig, - const unsigned char *pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_sign_ed25519.h b/win32/include/sodium/crypto_sign_ed25519.h deleted file mode 100644 index 0fdac42d35..0000000000 --- a/win32/include/sodium/crypto_sign_ed25519.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef crypto_sign_ed25519_H -#define crypto_sign_ed25519_H - -#include -#include "crypto_hash_sha512.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -typedef struct crypto_sign_ed25519ph_state { - crypto_hash_sha512_state hs; -} crypto_sign_ed25519ph_state; - -SODIUM_EXPORT -size_t crypto_sign_ed25519ph_statebytes(void); - -#define crypto_sign_ed25519_BYTES 64U -SODIUM_EXPORT -size_t crypto_sign_ed25519_bytes(void); - -#define crypto_sign_ed25519_SEEDBYTES 32U -SODIUM_EXPORT -size_t crypto_sign_ed25519_seedbytes(void); - -#define crypto_sign_ed25519_PUBLICKEYBYTES 32U -SODIUM_EXPORT -size_t crypto_sign_ed25519_publickeybytes(void); - -#define crypto_sign_ed25519_SECRETKEYBYTES (32U + 32U) -SODIUM_EXPORT -size_t crypto_sign_ed25519_secretkeybytes(void); - -#define crypto_sign_ed25519_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES) -SODIUM_EXPORT -size_t crypto_sign_ed25519_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p, - const unsigned char *m, unsigned long long mlen, - const unsigned char *sk) - __attribute__ ((nonnull(1, 5))); - -SODIUM_EXPORT -int crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p, - const unsigned char *sm, unsigned long long smlen, - const unsigned char *pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5))); - -SODIUM_EXPORT -int crypto_sign_ed25519_detached(unsigned char *sig, - unsigned long long *siglen_p, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *sk) - __attribute__ ((nonnull(1, 5))); - -SODIUM_EXPORT -int crypto_sign_ed25519_verify_detached(const unsigned char *sig, - const unsigned char *m, - unsigned long long mlen, - const unsigned char *pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4))); - -SODIUM_EXPORT -int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519_seed_keypair(unsigned char *pk, unsigned char *sk, - const unsigned char *seed) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk, - const unsigned char *ed25519_pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk, - const unsigned char *ed25519_sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519_sk_to_seed(unsigned char *seed, - const unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_sign_ed25519ph_update(crypto_sign_ed25519ph_state *state, - const unsigned char *m, - unsigned long long mlen) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int crypto_sign_ed25519ph_final_create(crypto_sign_ed25519ph_state *state, - unsigned char *sig, - unsigned long long *siglen_p, - const unsigned char *sk) - __attribute__ ((nonnull(1, 2, 4))); - -SODIUM_EXPORT -int crypto_sign_ed25519ph_final_verify(crypto_sign_ed25519ph_state *state, - const unsigned char *sig, - const unsigned char *pk) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_sign_edwards25519sha512batch.h b/win32/include/sodium/crypto_sign_edwards25519sha512batch.h deleted file mode 100644 index eed158aa84..0000000000 --- a/win32/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/win32/include/sodium/crypto_stream.h b/win32/include/sodium/crypto_stream.h deleted file mode 100644 index 88dab5f611..0000000000 --- a/win32/include/sodium/crypto_stream.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef crypto_stream_H -#define crypto_stream_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include - -#include "crypto_stream_xsalsa20.h" -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_KEYBYTES crypto_stream_xsalsa20_KEYBYTES -SODIUM_EXPORT -size_t crypto_stream_keybytes(void); - -#define crypto_stream_NONCEBYTES crypto_stream_xsalsa20_NONCEBYTES -SODIUM_EXPORT -size_t crypto_stream_noncebytes(void); - -#define crypto_stream_MESSAGEBYTES_MAX crypto_stream_xsalsa20_MESSAGEBYTES_MAX -SODIUM_EXPORT -size_t crypto_stream_messagebytes_max(void); - -#define crypto_stream_PRIMITIVE "xsalsa20" -SODIUM_EXPORT -const char *crypto_stream_primitive(void); - -SODIUM_EXPORT -int crypto_stream(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_keygen(unsigned char k[crypto_stream_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_stream_chacha20.h b/win32/include/sodium/crypto_stream_chacha20.h deleted file mode 100644 index 408897558b..0000000000 --- a/win32/include/sodium/crypto_stream_chacha20.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef crypto_stream_chacha20_H -#define crypto_stream_chacha20_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_chacha20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_chacha20_keybytes(void); - -#define crypto_stream_chacha20_NONCEBYTES 8U -SODIUM_EXPORT -size_t crypto_stream_chacha20_noncebytes(void); - -#define crypto_stream_chacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX -SODIUM_EXPORT -size_t crypto_stream_chacha20_messagebytes_max(void); - -/* ChaCha20 with a 64-bit nonce and a 64-bit counter, as originally designed */ - -SODIUM_EXPORT -int crypto_stream_chacha20(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_chacha20_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_chacha20_xor_ic(unsigned char *c, const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, uint64_t ic, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_chacha20_keygen(unsigned char k[crypto_stream_chacha20_KEYBYTES]) - __attribute__ ((nonnull)); - -/* ChaCha20 with a 96-bit nonce and a 32-bit counter (IETF) */ - -#define crypto_stream_chacha20_ietf_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_chacha20_ietf_keybytes(void); - -#define crypto_stream_chacha20_ietf_NONCEBYTES 12U -SODIUM_EXPORT -size_t crypto_stream_chacha20_ietf_noncebytes(void); - -#define crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX \ - SODIUM_MIN(SODIUM_SIZE_MAX, 64ULL * (1ULL << 32)) -SODIUM_EXPORT -size_t crypto_stream_chacha20_ietf_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_chacha20_ietf_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_chacha20_ietf_xor_ic(unsigned char *c, const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, uint32_t ic, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_chacha20_ietf_keygen(unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES]) - __attribute__ ((nonnull)); - -/* Aliases */ - -#define crypto_stream_chacha20_IETF_KEYBYTES crypto_stream_chacha20_ietf_KEYBYTES -#define crypto_stream_chacha20_IETF_NONCEBYTES crypto_stream_chacha20_ietf_NONCEBYTES -#define crypto_stream_chacha20_IETF_MESSAGEBYTES_MAX crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_stream_salsa20.h b/win32/include/sodium/crypto_stream_salsa20.h deleted file mode 100644 index 45b3b3e34a..0000000000 --- a/win32/include/sodium/crypto_stream_salsa20.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef crypto_stream_salsa20_H -#define crypto_stream_salsa20_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_salsa20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_salsa20_keybytes(void); - -#define crypto_stream_salsa20_NONCEBYTES 8U -SODIUM_EXPORT -size_t crypto_stream_salsa20_noncebytes(void); - -#define crypto_stream_salsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX -SODIUM_EXPORT -size_t crypto_stream_salsa20_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_stream_salsa20(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, uint64_t ic, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_stream_salsa2012.h b/win32/include/sodium/crypto_stream_salsa2012.h deleted file mode 100644 index 6c5d303cac..0000000000 --- a/win32/include/sodium/crypto_stream_salsa2012.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef crypto_stream_salsa2012_H -#define crypto_stream_salsa2012_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_salsa2012_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_salsa2012_keybytes(void); - -#define crypto_stream_salsa2012_NONCEBYTES 8U -SODIUM_EXPORT -size_t crypto_stream_salsa2012_noncebytes(void); - -#define crypto_stream_salsa2012_MESSAGEBYTES_MAX SODIUM_SIZE_MAX -SODIUM_EXPORT -size_t crypto_stream_salsa2012_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_stream_salsa2012(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_salsa2012_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_salsa2012_keygen(unsigned char k[crypto_stream_salsa2012_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_stream_salsa208.h b/win32/include/sodium/crypto_stream_salsa208.h deleted file mode 100644 index d574f30478..0000000000 --- a/win32/include/sodium/crypto_stream_salsa208.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef crypto_stream_salsa208_H -#define crypto_stream_salsa208_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_salsa208_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_salsa208_keybytes(void) - __attribute__ ((deprecated)); - -#define crypto_stream_salsa208_NONCEBYTES 8U -SODIUM_EXPORT -size_t crypto_stream_salsa208_noncebytes(void) - __attribute__ ((deprecated)); - -#define crypto_stream_salsa208_MESSAGEBYTES_MAX SODIUM_SIZE_MAX - SODIUM_EXPORT -size_t crypto_stream_salsa208_messagebytes_max(void) - __attribute__ ((deprecated)); - -SODIUM_EXPORT -int crypto_stream_salsa208(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((deprecated)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_salsa208_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((deprecated)) __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_salsa208_keygen(unsigned char k[crypto_stream_salsa208_KEYBYTES]) - __attribute__ ((deprecated)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_stream_xchacha20.h b/win32/include/sodium/crypto_stream_xchacha20.h deleted file mode 100644 index c4002db00a..0000000000 --- a/win32/include/sodium/crypto_stream_xchacha20.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef crypto_stream_xchacha20_H -#define crypto_stream_xchacha20_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_xchacha20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_xchacha20_keybytes(void); - -#define crypto_stream_xchacha20_NONCEBYTES 24U -SODIUM_EXPORT -size_t crypto_stream_xchacha20_noncebytes(void); - -#define crypto_stream_xchacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX -SODIUM_EXPORT -size_t crypto_stream_xchacha20_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_xchacha20_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_xchacha20_xor_ic(unsigned char *c, const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, uint64_t ic, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_xchacha20_keygen(unsigned char k[crypto_stream_xchacha20_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_stream_xsalsa20.h b/win32/include/sodium/crypto_stream_xsalsa20.h deleted file mode 100644 index 20034e3462..0000000000 --- a/win32/include/sodium/crypto_stream_xsalsa20.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef crypto_stream_xsalsa20_H -#define crypto_stream_xsalsa20_H - -/* - * WARNING: This is just a stream cipher. It is NOT authenticated encryption. - * While it provides some protection against eavesdropping, it does NOT - * provide any security against active attacks. - * Unless you know what you're doing, what you are looking for is probably - * the crypto_box functions. - */ - -#include -#include -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -#define crypto_stream_xsalsa20_KEYBYTES 32U -SODIUM_EXPORT -size_t crypto_stream_xsalsa20_keybytes(void); - -#define crypto_stream_xsalsa20_NONCEBYTES 24U -SODIUM_EXPORT -size_t crypto_stream_xsalsa20_noncebytes(void); - -#define crypto_stream_xsalsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX -SODIUM_EXPORT -size_t crypto_stream_xsalsa20_messagebytes_max(void); - -SODIUM_EXPORT -int crypto_stream_xsalsa20(unsigned char *c, unsigned long long clen, - const unsigned char *n, const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_xsalsa20_xor(unsigned char *c, const unsigned char *m, - unsigned long long mlen, const unsigned char *n, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int crypto_stream_xsalsa20_xor_ic(unsigned char *c, const unsigned char *m, - unsigned long long mlen, - const unsigned char *n, uint64_t ic, - const unsigned char *k) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void crypto_stream_xsalsa20_keygen(unsigned char k[crypto_stream_xsalsa20_KEYBYTES]) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_verify_16.h b/win32/include/sodium/crypto_verify_16.h deleted file mode 100644 index 7b9c8077ad..0000000000 --- a/win32/include/sodium/crypto_verify_16.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef crypto_verify_16_H -#define crypto_verify_16_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_verify_16_BYTES 16U -SODIUM_EXPORT -size_t crypto_verify_16_bytes(void); - -SODIUM_EXPORT -int crypto_verify_16(const unsigned char *x, const unsigned char *y) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_verify_32.h b/win32/include/sodium/crypto_verify_32.h deleted file mode 100644 index 9b0f4529f6..0000000000 --- a/win32/include/sodium/crypto_verify_32.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef crypto_verify_32_H -#define crypto_verify_32_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_verify_32_BYTES 32U -SODIUM_EXPORT -size_t crypto_verify_32_bytes(void); - -SODIUM_EXPORT -int crypto_verify_32(const unsigned char *x, const unsigned char *y) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/crypto_verify_64.h b/win32/include/sodium/crypto_verify_64.h deleted file mode 100644 index c83b73025a..0000000000 --- a/win32/include/sodium/crypto_verify_64.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef crypto_verify_64_H -#define crypto_verify_64_H - -#include -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define crypto_verify_64_BYTES 64U -SODIUM_EXPORT -size_t crypto_verify_64_bytes(void); - -SODIUM_EXPORT -int crypto_verify_64(const unsigned char *x, const unsigned char *y) - __attribute__ ((warn_unused_result)) __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/export.h b/win32/include/sodium/export.h deleted file mode 100644 index a0074fc9cb..0000000000 --- a/win32/include/sodium/export.h +++ /dev/null @@ -1,57 +0,0 @@ - -#ifndef sodium_export_H -#define sodium_export_H - -#include -#include -#include - -#if !defined(__clang__) && !defined(__GNUC__) -# ifdef __attribute__ -# undef __attribute__ -# endif -# define __attribute__(a) -#endif - -#ifdef SODIUM_STATIC -# define SODIUM_EXPORT -# define SODIUM_EXPORT_WEAK -#else -# if defined(_MSC_VER) -# ifdef SODIUM_DLL_EXPORT -# define SODIUM_EXPORT __declspec(dllexport) -# else -# define SODIUM_EXPORT __declspec(dllimport) -# endif -# else -# if defined(__SUNPRO_C) -# ifndef __GNU_C__ -# define SODIUM_EXPORT __attribute__ (visibility(__global)) -# else -# define SODIUM_EXPORT __attribute__ __global -# endif -# elif defined(_MSG_VER) -# define SODIUM_EXPORT extern __declspec(dllexport) -# else -# define SODIUM_EXPORT __attribute__ ((visibility ("default"))) -# endif -# endif -# if defined(__ELF__) && !defined(SODIUM_DISABLE_WEAK_FUNCTIONS) -# define SODIUM_EXPORT_WEAK SODIUM_EXPORT __attribute__((weak)) -# else -# define SODIUM_EXPORT_WEAK SODIUM_EXPORT -# endif -#endif - -#ifndef CRYPTO_ALIGN -# if defined(__INTEL_COMPILER) || defined(_MSC_VER) -# define CRYPTO_ALIGN(x) __declspec(align(x)) -# else -# define CRYPTO_ALIGN(x) __attribute__ ((aligned(x))) -# endif -#endif - -#define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B)) -#define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX) - -#endif diff --git a/win32/include/sodium/randombytes.h b/win32/include/sodium/randombytes.h deleted file mode 100644 index a03cc65720..0000000000 --- a/win32/include/sodium/randombytes.h +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef randombytes_H -#define randombytes_H - -#include -#include - -#include - -#include "export.h" - -#ifdef __cplusplus -# ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wlong-long" -# endif -extern "C" { -#endif - -typedef struct randombytes_implementation { - const char *(*implementation_name)(void); /* required */ - uint32_t (*random)(void); /* required */ - void (*stir)(void); /* optional */ - uint32_t (*uniform)(const uint32_t upper_bound); /* optional, a default implementation will be used if NULL */ - void (*buf)(void * const buf, const size_t size); /* required */ - int (*close)(void); /* optional */ -} randombytes_implementation; - -#define randombytes_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 0xffffffffUL) - -#define randombytes_SEEDBYTES 32U -SODIUM_EXPORT -size_t randombytes_seedbytes(void); - -SODIUM_EXPORT -void randombytes_buf(void * const buf, const size_t size) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -void randombytes_buf_deterministic(void * const buf, const size_t size, - const unsigned char seed[randombytes_SEEDBYTES]) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -uint32_t randombytes_random(void); - -SODIUM_EXPORT -uint32_t randombytes_uniform(const uint32_t upper_bound); - -SODIUM_EXPORT -void randombytes_stir(void); - -SODIUM_EXPORT -int randombytes_close(void); - -SODIUM_EXPORT -int randombytes_set_implementation(randombytes_implementation *impl) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -const char *randombytes_implementation_name(void); - -/* -- NaCl compatibility interface -- */ - -SODIUM_EXPORT -void randombytes(unsigned char * const buf, const unsigned long long buf_len) - __attribute__ ((nonnull)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/randombytes_internal_random.h b/win32/include/sodium/randombytes_internal_random.h deleted file mode 100644 index 2b2b7d6edc..0000000000 --- a/win32/include/sodium/randombytes_internal_random.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef randombytes_internal_random_H -#define randombytes_internal_random_H - -#include "export.h" -#include "randombytes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -SODIUM_EXPORT -extern struct randombytes_implementation randombytes_internal_implementation; - -/* Backwards compatibility with libsodium < 1.0.18 */ -#define randombytes_salsa20_implementation randombytes_internal_implementation - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/randombytes_sysrandom.h b/win32/include/sodium/randombytes_sysrandom.h deleted file mode 100644 index 9e27b674c7..0000000000 --- a/win32/include/sodium/randombytes_sysrandom.h +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef randombytes_sysrandom_H -#define randombytes_sysrandom_H - -#include "export.h" -#include "randombytes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -SODIUM_EXPORT -extern struct randombytes_implementation randombytes_sysrandom_implementation; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/runtime.h b/win32/include/sodium/runtime.h deleted file mode 100644 index 7f15d58e7c..0000000000 --- a/win32/include/sodium/runtime.h +++ /dev/null @@ -1,52 +0,0 @@ - -#ifndef sodium_runtime_H -#define sodium_runtime_H - -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_neon(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_sse2(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_sse3(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_ssse3(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_sse41(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_avx(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_avx2(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_avx512f(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_pclmul(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_aesni(void); - -SODIUM_EXPORT_WEAK -int sodium_runtime_has_rdrand(void); - -/* ------------------------------------------------------------------------- */ - -int _sodium_runtime_get_cpu_features(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/utils.h b/win32/include/sodium/utils.h deleted file mode 100644 index ac80151291..0000000000 --- a/win32/include/sodium/utils.h +++ /dev/null @@ -1,179 +0,0 @@ - -#ifndef sodium_utils_H -#define sodium_utils_H - -#include - -#include "export.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef SODIUM_C99 -# if defined(__cplusplus) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L -# define SODIUM_C99(X) -# else -# define SODIUM_C99(X) X -# endif -#endif - -SODIUM_EXPORT -void sodium_memzero(void * const pnt, const size_t len); - -SODIUM_EXPORT -void sodium_stackzero(const size_t len); - -/* - * WARNING: sodium_memcmp() must be used to verify if two secret keys - * are equal, in constant time. - * It returns 0 if the keys are equal, and -1 if they differ. - * This function is not designed for lexicographical comparisons. - */ -SODIUM_EXPORT -int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len) - __attribute__ ((warn_unused_result)); - -/* - * sodium_compare() returns -1 if b1_ < b2_, 1 if b1_ > b2_ and 0 if b1_ == b2_ - * It is suitable for lexicographical comparisons, or to compare nonces - * and counters stored in little-endian format. - * However, it is slower than sodium_memcmp(). - */ -SODIUM_EXPORT -int sodium_compare(const unsigned char *b1_, const unsigned char *b2_, - size_t len) __attribute__ ((warn_unused_result)); - -SODIUM_EXPORT -int sodium_is_zero(const unsigned char *n, const size_t nlen); - -SODIUM_EXPORT -void sodium_increment(unsigned char *n, const size_t nlen); - -SODIUM_EXPORT -void sodium_add(unsigned char *a, const unsigned char *b, const size_t len); - -SODIUM_EXPORT -void sodium_sub(unsigned char *a, const unsigned char *b, const size_t len); - -SODIUM_EXPORT -char *sodium_bin2hex(char * const hex, const size_t hex_maxlen, - const unsigned char * const bin, const size_t bin_len) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen, - const char * const hex, const size_t hex_len, - const char * const ignore, size_t * const bin_len, - const char ** const hex_end) - __attribute__ ((nonnull(1))); - -#define sodium_base64_VARIANT_ORIGINAL 1 -#define sodium_base64_VARIANT_ORIGINAL_NO_PADDING 3 -#define sodium_base64_VARIANT_URLSAFE 5 -#define sodium_base64_VARIANT_URLSAFE_NO_PADDING 7 - -/* - * Computes the required length to encode BIN_LEN bytes as a base64 string - * using the given variant. The computed length includes a trailing \0. - */ -#define sodium_base64_ENCODED_LEN(BIN_LEN, VARIANT) \ - (((BIN_LEN) / 3U) * 4U + \ - ((((BIN_LEN) - ((BIN_LEN) / 3U) * 3U) | (((BIN_LEN) - ((BIN_LEN) / 3U) * 3U) >> 1)) & 1U) * \ - (4U - (~((((VARIANT) & 2U) >> 1) - 1U) & (3U - ((BIN_LEN) - ((BIN_LEN) / 3U) * 3U)))) + 1U) - -SODIUM_EXPORT -size_t sodium_base64_encoded_len(const size_t bin_len, const int variant); - -SODIUM_EXPORT -char *sodium_bin2base64(char * const b64, const size_t b64_maxlen, - const unsigned char * const bin, const size_t bin_len, - const int variant) __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int sodium_base642bin(unsigned char * const bin, const size_t bin_maxlen, - const char * const b64, const size_t b64_len, - const char * const ignore, size_t * const bin_len, - const char ** const b64_end, const int variant) - __attribute__ ((nonnull(1))); - -SODIUM_EXPORT -int sodium_mlock(void * const addr, const size_t len) - __attribute__ ((nonnull)); - -SODIUM_EXPORT -int sodium_munlock(void * const addr, const size_t len) - __attribute__ ((nonnull)); - -/* WARNING: sodium_malloc() and sodium_allocarray() are not general-purpose - * allocation functions. - * - * They return a pointer to a region filled with 0xd0 bytes, immediately - * followed by a guard page. - * As a result, accessing a single byte after the requested allocation size - * will intentionally trigger a segmentation fault. - * - * A canary and an additional guard page placed before the beginning of the - * region may also kill the process if a buffer underflow is detected. - * - * The memory layout is: - * [unprotected region size (read only)][guard page (no access)][unprotected pages (read/write)][guard page (no access)] - * With the layout of the unprotected pages being: - * [optional padding][16-bytes canary][user region] - * - * However: - * - These functions are significantly slower than standard functions - * - Each allocation requires 3 or 4 additional pages - * - The returned address will not be aligned if the allocation size is not - * a multiple of the required alignment. For this reason, these functions - * are designed to store data, such as secret keys and messages. - * - * sodium_malloc() can be used to allocate any libsodium data structure. - * - * The crypto_generichash_state structure is packed and its length is - * either 357 or 361 bytes. For this reason, when using sodium_malloc() to - * allocate a crypto_generichash_state structure, padding must be added in - * order to ensure proper alignment. crypto_generichash_statebytes() - * returns the rounded up structure size, and should be prefered to sizeof(): - * state = sodium_malloc(crypto_generichash_statebytes()); - */ - -SODIUM_EXPORT -void *sodium_malloc(const size_t size) - __attribute__ ((malloc)); - -SODIUM_EXPORT -void *sodium_allocarray(size_t count, size_t size) - __attribute__ ((malloc)); - -SODIUM_EXPORT -void sodium_free(void *ptr); - -SODIUM_EXPORT -int sodium_mprotect_noaccess(void *ptr) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int sodium_mprotect_readonly(void *ptr) __attribute__ ((nonnull)); - -SODIUM_EXPORT -int sodium_mprotect_readwrite(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) - __attribute__ ((nonnull(2))); - -SODIUM_EXPORT -int sodium_unpad(size_t *unpadded_buflen_p, const unsigned char *buf, - size_t padded_buflen, size_t blocksize) - __attribute__ ((nonnull(2))); - -/* -------- */ - -int _sodium_alloc_init(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/win32/include/sodium/version.h b/win32/include/sodium/version.h deleted file mode 100644 index 201a290e7d..0000000000 --- a/win32/include/sodium/version.h +++ /dev/null @@ -1,33 +0,0 @@ - -#ifndef sodium_version_H -#define sodium_version_H - -#include "export.h" - -#define SODIUM_VERSION_STRING "1.0.18" - -#define SODIUM_LIBRARY_VERSION_MAJOR 10 -#define SODIUM_LIBRARY_VERSION_MINOR 3 - - -#ifdef __cplusplus -extern "C" { -#endif - -SODIUM_EXPORT -const char *sodium_version_string(void); - -SODIUM_EXPORT -int sodium_library_version_major(void); - -SODIUM_EXPORT -int sodium_library_version_minor(void); - -SODIUM_EXPORT -int sodium_library_minimal(void); - -#ifdef __cplusplus -} -#endif - -#endif