diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml new file mode 100644 index 000000000..f50864955 --- /dev/null +++ b/.github/workflows/build_linux.yml @@ -0,0 +1,41 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +name: Linux (GCC) CI +on: + push: + branches: [ "development" ] + pull_request: + branches: [ "development" ] + +jobs: + # Linux – Cached Debug Build + Ubuntu_x86_64_debug: + runs-on: ubuntu-24.04 + steps: + - name: Checkout Code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Cache Dependencies and Homebrew + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + ~/.cache/Homebrew + dependencies + key: linux-deps-${{ hashFiles('build_linux.sh') }} + restore-keys: linux-deps- + + - name: Cache Build Folder + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: build + key: linux-build-${{ hashFiles('CMakeLists.txt') }} + restore-keys: linux-build- + + - name: Run Linux Build Script + run: | + chmod +x ./build_linux.sh + ./build_linux.sh diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml new file mode 100644 index 000000000..ee071e63b --- /dev/null +++ b/.github/workflows/build_macos.yml @@ -0,0 +1,41 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +name: macOS (Clang) CI +on: + push: + branches: [ "development" ] + pull_request: + branches: [ "development" ] + +jobs: + # macOS – Cached Debug Build + Apple_Silicon_debug: + runs-on: macos-15 + steps: + - name: Checkout Code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Cache Dependencies and Homebrew + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + /Users/runner/Library/Caches/Homebrew + dependencies + key: macOS-deps-${{ hashFiles('build_macos.sh') }} + restore-keys: macOS-deps- + + - name: Cache Build Folder + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: build + key: macOS-build-${{ hashFiles('CMakeLists.txt') }} + restore-keys: macOS-build- + + - name: Run macOS Build Script + run: | + chmod +x ./build_macos.sh + ./build_macos.sh diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml new file mode 100644 index 000000000..504785b0c --- /dev/null +++ b/.github/workflows/build_windows.yml @@ -0,0 +1,75 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +name: Windows (MSVC) CI +on: + push: + branches: [ "development" ] + pull_request: + branches: [ "development" ] + +jobs: + # Windows – Cached Debug Build + x86_64_debug: + runs-on: windows-2025 + steps: + - name: Checkout Code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Cache installed dependencies + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + C:\boost + C:\botan + C:\flatbuffers + C:\mysql-connector-c++ + C:\pcre + C:\zlib + key: win-deps-${{ hashFiles('build_windows.ps1') }} + restore-keys: win-deps- + + - name: Cache Build Folder + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: build + key: win-build-${{ hashFiles('CMakeLists.txt') }} + restore-keys: win-build- + + - name: Run Windows Build Script + shell: pwsh + run: .\build_windows.ps1 + + # Windows ARM – Cached Debug Build + ARM64_debug: + runs-on: windows-11-arm + steps: + - name: Checkout Code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Cache installed dependencies + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + C:\boost + C:\botan + C:\flatbuffers + C:\mysql-connector-c++ + C:\pcre + C:\zlib + key: win_arm-deps-${{ hashFiles('build_windows.ps1') }} + restore-keys: win_arm-deps- + + - name: Cache Build Folder + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: build + key: win_arm-build-${{ hashFiles('CMakeLists.txt') }} + restore-keys: win_arm-build- + + - name: Run Windows Build Script + shell: pwsh + run: .\build_windows.ps1 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ff8f5824e..671d20377 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,3 +1,9 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + name: Docker Image CI on: @@ -8,8 +14,8 @@ on: jobs: - build: - runs-on: ubuntu-latest + Ubuntu_ARM64: + runs-on: ubuntu-24.04-arm steps: - name: Checkout Code uses: actions/checkout@v4.2.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 245d68a8a..e1c414cb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,19 +95,37 @@ set(version_file "${CMAKE_CURRENT_BINARY_DIR}/Version.cpp") ############################## # Botan # ############################## -find_package(Botan 2.14.0 REQUIRED) -include_directories(${BOTAN_INCLUDE_DIRS}) +find_package(Botan 3.6.1 REQUIRED) +# Check if the static target exists; otherwise fallback to the shared target. +if(TARGET Botan::Botan-static) + set(BOTAN_LIBRARY Botan::Botan-static) + message(STATUS "Using Botan static library") +elseif(TARGET Botan::Botan) + set(BOTAN_LIBRARY Botan::Botan) + message(STATUS "Using Botan shared library") +else() + message(FATAL_ERROR "No valid Botan target found") +endif() ############################## # MySQL Connector C++ # ############################## -find_package(MySQLConnectorCPP REQUIRED) -include_directories(${MYSQLCCPP_INCLUDE_DIRS}) +find_package(mysql-concpp REQUIRED) +# Check if the static JDBC target exists; otherwise fallback to the shared JDBC target. +if(TARGET mysql::concpp-jdbc-static) + set(MYSQLCCPP_LIBRARY mysql::concpp-jdbc-static) + message(STATUS "Using MySQL Connector/C++ JDBC static library") +elseif(TARGET mysql::concpp-jdbc) + set(MYSQLCCPP_LIBRARY mysql::concpp-jdbc) + message(STATUS "Using MySQL Connector/C++ JDBC shared library") +else() + message(FATAL_ERROR "No valid MySQL Connector/C++ JDBC target found") +endif() ############################## # FlatBuffers # ############################## -find_package(FlatBuffers 2.0.8 REQUIRED) +find_package(flatbuffers 2.0.8 REQUIRED) ############################## # zlib # @@ -143,6 +161,17 @@ include_directories(${CMAKE_SOURCE_DIR}/deps) include(BuildDBCLoaders) include(BuildSparkServices) +# For Apple: Amend homebrew installed libraries to cmake's search path +if(APPLE) + file(GLOB HOME_BREW_LIB_DIRS "/opt/homebrew/opt/*/lib") + set(HOMEBREW_LINKER_FLAGS_LIST "") + foreach(libdir ${HOME_BREW_LIB_DIRS}) + list(APPEND HOMEBREW_LINKER_FLAGS_LIST "-L${libdir}") + endforeach() + message(STATUS "Appending Homebrew linker flags: ${HOMEBREW_LINKER_FLAGS_LIST}") + add_link_options(${HOMEBREW_LINKER_FLAGS_LIST}) +endif() + add_subdirectory(schemas) set(cmake_ctest_arguments "CTEST_OUTPUT_ON_FAILURE") enable_testing() diff --git a/Dockerfile b/Dockerfile index c65783879..eb43d4afa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ LABEL description="Development build environment" # Update the distro and install our tools RUN apt-get -y update && apt-get -y upgrade \ && apt-get -y install software-properties-common \ - && apt-get -y install wget \ + && apt-get -y install wget tar \ # GCC stuff && apt-get -y install build-essential gcc-14 g++-14 \ # Clang stuff @@ -22,8 +22,9 @@ RUN apt-get -y update && apt-get -y upgrade \ && apt-get -y install cmake \ && apt-get -y install git \ # Install required library packages - && apt-get install -y libbotan-2-dev \ - && apt-get install -y libmysqlcppconn-dev \ + && apt-get install -y libbotan-3-dev \ + && apt-get install -y libmysqlclient-dev \ + && apt-get install -y libssl-dev \ && apt-get install -y zlib1g-dev \ && apt-get install -y libpcre3-dev \ && apt-get install -y libflatbuffers-dev \ @@ -33,6 +34,22 @@ RUN apt-get -y update && apt-get -y upgrade \ && ./bootstrap.sh --with-libraries=system,program_options,headers \ && ./b2 link=static install -d0 -j $(nproc) cxxflags="-std=c++23" +# Replace the apt-get install of libmysqlcppconn-dev with a custom installer +RUN arch=$(uname -m) && case "$arch" in \ + x86_64) url="https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-linux-glibc2.28-x86-64bit.tar.gz" ;; \ + aarch64) url="https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-linux-glibc2.28-aarch64.tar.gz" ;; \ + *) echo "Unsupported architecture: $arch" && exit 1 ;; esac && \ + echo "Downloading MySQL Connector/C++ from ${url}" && \ + wget "$url" -O /tmp/mysql-connector.tar.gz && \ + mkdir -p /usr/lib/cmake/mysql-concpp && \ + tar -zxf /tmp/mysql-connector.tar.gz -C /usr/lib/cmake/mysql-concpp --strip-components=1 && \ + echo "Installing headers and libraries..." && \ + mkdir -p /usr/include/mysql-cppconn && \ + cp -r /usr/lib/cmake/mysql-concpp/include/* /usr/include/mysql-cppconn/ && \ + cp -r /usr/lib/cmake/mysql-concpp/lib64/* /usr/local/lib/ && \ + ldconfig && \ + echo "MySQL Connector/C++ installed." + # Copy source ARG working_dir=/usr/src/ember COPY . ${working_dir} @@ -42,9 +59,15 @@ WORKDIR ${working_dir} # These can be overriden by passing them through to `docker build` ARG build_optional_tools=1 ARG disable_threads=0 -ARG build_type=Rel +ARG build_type=Debug ARG install_dir=/usr/local/bin +# Patch the Botan config file for header paths: (THIS IS FIXED IN BOTAN 3.8 - REMOVE WHEN apt-get HAS UPDATED) +RUN sh -c 'arch=$(dpkg-architecture -qDEB_HOST_MULTIARCH) && \ + BOTAN_CFG=$(find / -type f -iname "botan-config.cmake" 2>/dev/null | grep "/usr/lib/$arch" | head -n1) && \ + [ -n "$BOTAN_CFG" ] && \ + sed -i -e "s|\${_Botan_PREFIX}/include|/usr/include|g" -e "s|\${_Botan_PREFIX}/lib|/usr/lib/$arch|g" "$BOTAN_CFG"' + # Generate Makefile & compile RUN --mount=type=cache,target=build \ cmake -S . -B build \ @@ -52,8 +75,6 @@ RUN --mount=type=cache,target=build \ -DCMAKE_INSTALL_PREFIX=${install_dir} \ -DBUILD_OPT_TOOLS=${build_optional_tools} \ -DDISABLE_EMBER_THREADS=${disable_threads} \ - -DBOTAN_ROOT_DIR=/usr/include/botan-2/ \ - -DBOTAN_LIBRARY=/usr/lib/x86_64-linux-gnu/libbotan-2.so \ && cd build && make -j$(nproc) install \ && make test @@ -62,7 +83,7 @@ ARG install_dir=/usr/local/bin ARG working_dir=/usr/src/ember WORKDIR ${install_dir} RUN apt-get -y update \ - && apt-get install -y libbotan-2-19 \ + && apt-get install -y libbotan-3-7 \ && apt-get install -y libmysqlcppconn7v5 \ && apt-get install -y mysql-client COPY --from=builder ${install_dir} ${install_dir} diff --git a/build_linux.sh b/build_linux.sh new file mode 100644 index 000000000..353c6a5a2 --- /dev/null +++ b/build_linux.sh @@ -0,0 +1,101 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#!/bin/bash +set -e + +BUILD_DIR="build" +INSTALL_DIR="./build/bin" +BUILD_TYPE="Debug" + +BUILD_OPTIONAL_TOOLS=-1 +DISABLE_THREADS=0 + +##################################################################################################### +# Install build tools +# Already pre-installed: (software-properties-common, wget, gcc-14, g++-14, libstdc++-14-dev, git) +# GCC is already the default compiler and up-to-date +##################################################################################################### +echo "installing apt-get dependencies..." +sudo apt-get install -y build-essential cmake +sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 100 +sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 100 +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 +sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 + +# PCRE is wonky on linux with homebrew +sudo apt-get install -y procps curl file libpcre3-dev + +############################################################################################ +# Install homebrew and get dependencies through here since it's faster and more up-to-date +############################################################################################ +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >>~/.profile +eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + +brew update +brew upgrade +brew install boost +brew install botan +brew install mysql-client +brew install flatbuffers + +####################################### +# Install MySQL Connector/C++ +####################################### +CACHE_TARBALL="dependencies/mysql-connector.tar.gz" + +if [ -f "$CACHE_TARBALL" ]; then + echo "Cached MySQL Connector tarball found." +else + arch=$(uname -m) && case "$arch" in \ + x86_64) url="https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-linux-glibc2.28-x86-64bit.tar.gz" ;; \ + aarch64) url="https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-linux-glibc2.28-aarch64.tar.gz" ;; \ + *) echo "Unsupported architecture: $arch" && exit 1 ;; esac + echo "Downloading MySQL Connector/C++ from ${url}" + sudo mkdir -p dependencies + sudo wget "$url" -O "$CACHE_TARBALL" +fi + +echo "Extracting MySQL Connector tarball..." +sudo mkdir -p /usr/lib/cmake/mysql-concpp +sudo tar -zxf "$CACHE_TARBALL" -C /usr/lib/cmake/mysql-concpp --strip-components=1 + +echo "Installing headers and libraries..." +sudo mkdir -p /usr/include/mysql-cppconn +sudo cp -r /usr/lib/cmake/mysql-concpp/include/* /usr/include/mysql-cppconn/ +sudo cp -r /usr/lib/cmake/mysql-concpp/lib64/* /usr/local/lib/ +sudo ldconfig +echo "MySQL Connector/C++ installed." + +############################### +# Configure and Build Ember +############################### +echo "=== Configuring project with CMake ===" + +cmake -S . -B ${BUILD_DIR} \ + -DBUILD_OPT_TOOLS=${BUILD_OPTIONAL_TOOLS} \ + -DDISABLE_EMBER_THREADS=${DISABLE_THREADS} \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + +echo "Building and installing the project..." +cmake --build ${BUILD_DIR} --target install --config ${BUILD_TYPE} + +############################################### +# Run the unit_tests for regression control +############################################### +echo "=== Switching to installed directory and running tests ===" +cd ${INSTALL_DIR} +if [ -x "./unit_tests" ]; then + echo "Running installed test executable..." + ./unit_tests +else + echo "Error: Installed test executable not found in ${INSTALL_DIR}. Aborting." + exit 1 +fi + +echo "=== Build, install, and test complete ===" diff --git a/build_macos.sh b/build_macos.sh new file mode 100644 index 000000000..ea688379b --- /dev/null +++ b/build_macos.sh @@ -0,0 +1,114 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#!/bin/bash +set -e + +BUILD_DIR="build" +INSTALL_DIR="./build/bin" +BUILD_TYPE="Debug" + +BUILD_OPTIONAL_TOOLS=-1 +DISABLE_THREADS=0 + +# Force xcode 16.3 or it'll default to 16.0 +sudo xcode-select -s "/Applications/Xcode_16.3.app/Contents/Developer" + +############################################### +# Install build tools +# Already pre-installed: (git, cmake, ninja) +############################################### +brew update +brew upgrade +brew install llvm + +############################################################# +# Install dependencies through homebrew +# (Github macOS runner already come with openssl and zlib) +############################################################# +brew install boost +brew install botan +brew install mysql-client +brew install pcre +brew install flatbuffers + +####################################### +# Install MySQL Connector/C++ +####################################### +CACHE_TARBALL="dependencies/mysql-connector.tar.gz" + +if [ -f "$CACHE_TARBALL" ]; then + echo "Cached MySQL Connector tarball found." +else + echo "Downloading MySQL Connector/C++ Library from Oracle..." + sudo mkdir -p dependencies + sudo wget https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-macos15-arm64.tar.gz -O "$CACHE_TARBALL" +fi + +echo "Extracting MySQL Connector tarball..." +sudo mkdir -p /usr/local/lib/cmake/mysql-concpp +sudo tar -zxf "$CACHE_TARBALL" -C /usr/local/lib/cmake/mysql-concpp --strip-components=1 + +echo "Installing headers and libraries..." +sudo mkdir -p /usr/local/include/mysql-concpp +sudo cp -r /usr/local/lib/cmake/mysql-concpp/include/. /usr/local/include/mysql-concpp/ +sudo cp -r /usr/local/lib/cmake/mysql-concpp/lib64/. /usr/local/lib/ +echo "MySQL Connector/C++ installed." + +echo "Patching MySQL Connector dependencies to reference absolute OpenSSL paths..." +for libfile in /usr/local/lib/libmysqlcppconn*.dylib; do + if [ -f "$libfile" ]; then + sudo install_name_tool -change libssl.3.dylib /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib "$libfile" + sudo install_name_tool -change libcrypto.3.dylib /opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib "$libfile" + echo "Patched $libfile" + fi +done + +############################### +# Configure and Build Ember +############################### +echo "=== Configuring project with CMake ===" + +# Set the DYLD_LIBRARY_PATH for all subsequent build and runtime steps. +export DYLD_LIBRARY_PATH="$(brew --prefix openssl@3)/lib:$DYLD_LIBRARY_PATH" +echo "DYLD_LIBRARY_PATH set to: $DYLD_LIBRARY_PATH" + +C_COMPILER="/opt/homebrew/opt/llvm/bin/clang" +CXX_COMPILER="/opt/homebrew/opt/llvm/bin/clang++" + +CMAKE_C_FLAGS="-isystem /opt/homebrew/opt/llvm/include/c++/v1 -isysroot $(xcrun --show-sdk-path)" +CMAKE_CXX_FLAGS="-isystem /opt/homebrew/opt/llvm/include/c++/v1 -isysroot $(xcrun --show-sdk-path)" + +cmake -S . -B ${BUILD_DIR} \ + -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \ + -DCMAKE_C_COMPILER=${C_COMPILER} \ + -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ + -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" \ + -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \ + -DBUILD_OPT_TOOLS=${BUILD_OPTIONAL_TOOLS} \ + -DDISABLE_EMBER_THREADS=${DISABLE_THREADS} \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + +echo "Building and installing the project..." +cmake --build ${BUILD_DIR} --target install --config ${BUILD_TYPE} + +############################################### +# Run the unit_tests for regression control +############################################### +echo "=== Switching to installed directory and running tests ===" +cd ${INSTALL_DIR} +if [ -x "./unit_tests" ]; then + echo "Running installed test executable..." + # openssl is linked dynamically so we need to point the unit_tests to the library + sudo install_name_tool -change libssl.3.dylib "$(brew --prefix openssl@3)/lib/libssl.3.dylib" ./unit_tests + sudo install_name_tool -change libcrypto.3.dylib "$(brew --prefix openssl@3)/lib/libcrypto.3.dylib" ./unit_tests + sudo -E ./unit_tests +else + echo "Error: Installed test executable not found in ${INSTALL_DIR}. Aborting." + exit 1 +fi + +echo "=== Build, install, and test complete ===" diff --git a/build_windows.ps1 b/build_windows.ps1 new file mode 100644 index 000000000..cd931400e --- /dev/null +++ b/build_windows.ps1 @@ -0,0 +1,465 @@ +# Copyright (c) 2025 Ember +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +$buildDir = "build" +$installDir = ".\build\bin" +$buildType = "Debug" + +$buildOptionalTools = "-1" +$disableEmberThreads = "0" + +# Determine the required VC Tools based on architecture. +if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") { + $vcRequirement = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" + $cpuTarget = "x64" +} +elseif ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { + $vcRequirement = "Microsoft.VisualStudio.Component.VC.Tools.ARM64" + $cpuTarget = "arm64" +} +else { + Write-Error "Architecture not recognized: $env:PROCESSOR_ARCHITECTURE" + exit 1 +} + +# Locate the appropriate Visual Studio installation. +$vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" ` + -latest -products * -requires $vcRequirement -property installationPath + +if (-not $vsPath) { + Write-Error "Could not locate a Visual Studio installation with the required VC Tools: $vcRequirement" + exit 1 +} + +# Build the full path to VsDevCmd.bat. +$vsDevCmd = Join-Path $vsPath "Common7\Tools\VsDevCmd.bat" + +# Define a function to run a command with the freshly loaded VS environment. +function Invoke-WithDevEnv { + param( + [Parameter(Mandatory=$true)] + [string]$CommandToRun + ) + + switch ($env:PROCESSOR_ARCHITECTURE) { + "AMD64" { $archParam = "-arch=amd64" } + "ARM64" { $archParam = "-arch=arm64" } + default { Write-Warning "Unknown processor architecture: $env:PROCESSOR_ARCHITECTURE" } + } + + $fullCommand = "call `"$vsDevCmd`" $archParam && $CommandToRun" + Write-Host "Executing: $fullCommand" + cmd /c $fullCommand +} + +############################################################## +# WE NEED THE FOLLOWING DEPENDENCIES: +# Boost, Botan, Flatbuffers, mysql-connector-cpp, pcre, zlib +# We will install all of them from sources +############################################################## + +############################################################# +# Install Boost from source (version 1.88.0) - Minimal Build +############################################################# +$boostTargetDir = "C:\boost" +if (-not (Test-Path $boostTargetDir)) { + $zipFile = "boost_1_88_0.zip" + $url = "https://archives.boost.io/release/1.88.0/source/boost_1_88_0.zip" + + Write-Host "Downloading Boost 1.88.0 from $url" + if (Get-Command curl -ErrorAction SilentlyContinue) { + Write-Host "Downloading using curl..." + curl -L $url -o $zipFile + } + elseif (Get-Command wget -ErrorAction SilentlyContinue) { + Write-Host "Downloading using wget..." + wget $url -O $zipFile + } + else { + Write-Host "Downloading using Invoke-WebRequest..." + Invoke-WebRequest -Uri $url -OutFile $zipFile + } + + Write-Host "Extracting Boost..." + Expand-Archive -Path $zipFile -DestinationPath "boost_1_88_0" -Force + Write-Host "Boost extracted..." + # Use the expected source directory structure. + $sourceBase = "boost_1_88_0\boost_1_88_0" + if (-not (Test-Path $sourceBase)) { + # Fallback if the folder structure is different. + $sourceBase = "boost_1_88_0" + } + + Push-Location $sourceBase + + Write-Host "Running Boost bootstrap..." + & .\bootstrap.bat + + Write-Host "Building and installing minimal Boost to $boostTargetDir..." + & .\b2 install --prefix="$boostTargetDir" ` + --with-headers ` + --with-interprocess ` + --with-program_options ` + --with-system ` + --with-uuid ` + address-model=64 + + Pop-Location +} +else { + Write-Host "Boost is already installed at $boostTargetDir" +} + +$env:CMAKE_PREFIX_PATH = "$boostTargetDir;$env:CMAKE_PREFIX_PATH" +Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH" + +############################################################# +# Botan Installation from Source (Version 3.8.1) +############################################################# +$botanTargetDir = "C:\botan" +if (-not (Test-Path $botanTargetDir)) { + $zipFile = "botan-3.8.1.zip" + $url = "https://github.com/randombit/botan/archive/refs/tags/3.8.1.zip" + + Write-Host "Downloading Botan 3.8.1 from $url" + if (Get-Command curl -ErrorAction SilentlyContinue) { + Write-Host "Downloading using curl..." + curl -L $url -o $zipFile + } + elseif (Get-Command wget -ErrorAction SilentlyContinue) { + Write-Host "Downloading using wget..." + wget $url -O $zipFile + } + else { + Write-Host "Downloading using Invoke-WebRequest..." + Invoke-WebRequest -Uri $url -OutFile $zipFile + } + + Write-Host "Extracting Botan..." + Expand-Archive -Path $zipFile -DestinationPath "botan-3.8.1" -Force + + # Determine the source base folder. + $sourceBase = "botan-3.8.1\botan-3.8.1" + if (-not (Test-Path $sourceBase)) { + $sourceBase = "botan-3.8.1" + } + + Push-Location $sourceBase + + Write-Host "Configuring Botan build..." + python configure.py --cc=msvc --os=windows --cpu="$env:PROCESSOR_ARCHITECTURE" --prefix="$botanTargetDir" + + Write-Host "Building Botan..." + Invoke-WithDevEnv "nmake" + + Write-Host "Installing Botan..." + Invoke-WithDevEnv "nmake install" + + Pop-Location +} +else { + Write-Host "Botan is already installed at C:\botan" +} + +$env:CMAKE_PREFIX_PATH = "$botanTargetDir;$env:CMAKE_PREFIX_PATH" +Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH" + +############################################################# +# Install FlatBuffers from source (version 25.2.10) +############################################################# +$flatbuffersTargetDir = "C:\flatbuffers" +if (-not (Test-Path $flatbuffersTargetDir)) { + $zipFile = "flatbuffers-25.2.10.zip" + $url = "https://github.com/google/flatbuffers/archive/refs/tags/v25.2.10.zip" + + Write-Host "Downloading FlatBuffers v25.2.10 from $url" + if (Get-Command curl -ErrorAction SilentlyContinue) { + Write-Host "Downloading using curl..." + curl -L $url -o $zipFile + } + elseif (Get-Command wget -ErrorAction SilentlyContinue) { + Write-Host "Downloading using wget..." + wget $url -O $zipFile + } + else { + Write-Host "Downloading using Invoke-WebRequest..." + Invoke-WebRequest -Uri $url -OutFile $zipFile + } + + Write-Host "Extracting FlatBuffers..." + Expand-Archive -Path $zipFile -DestinationPath "flatbuffers-25.2.10" -Force + + # Use the expected source directory structure. + $sourceBase = "flatbuffers-25.2.10\flatbuffers-25.2.10" + if (-not (Test-Path $sourceBase)) { + # Fallback if folder structure is different. + $sourceBase = "flatbuffers-25.2.10" + } + + New-Item -ItemType Directory -Path "$sourceBase\build" -Force | Out-Null + + Push-Location "$sourceBase\build" + + Write-Host "Configuring FlatBuffers build..." + cmake .. -G "Visual Studio 17 2022" -A $cpuTarget ` + -DFLATBUFFERS_BUILD_TESTS=OFF ` + -DFLATBUFFERS_BUILD_FLATLIB=ON ` + -DCMAKE_INSTALL_PREFIX="$flatbuffersTargetDir" + + Write-Host "Building FlatBuffers..." + cmake --build . --config $buildType + + Write-Host "Installing FlatBuffers to $flatbuffersTargetDir..." + cmake --install . --config $buildType + + Pop-Location +} +else { + Write-Host "FlatBuffers is already installed at $flatbuffersTargetDir" +} + +$env:CMAKE_PREFIX_PATH = "$flatbuffersTargetDir;$env:CMAKE_PREFIX_PATH" +Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH" + +#################################################### +# Install MySQL Connector/C++ +# (Prebuilt for x86_64 / Source-compile for ARM64) +#################################################### +$mysqlconcppTargetDir = "C:\mysql-connector-c++" +if (-not (Test-Path $mysqlconcppTargetDir)) { + # Define the cache ZIP file path for MySQL Connector + $zipFile = "mysql-connector.zip" + + Write-Host "Downloading MySQL Connector/C++ source code." + $url = "https://github.com/mysql/mysql-connector-cpp/archive/refs/tags/9.3.0.zip" + $connectorSubDir = "mysql-connector-cpp-9.3.0" + + Write-Host "Downloading MySQL Connector/C++ from $url" + if (Get-Command curl -ErrorAction SilentlyContinue) { + Write-Host "Downloading using curl..." + curl -L $url -o $zipFile + } + elseif (Get-Command wget -ErrorAction SilentlyContinue) { + Write-Host "Downloading using wget..." + wget $url -O $zipFile + } + else { + Write-Host "Downloading using Invoke-WebRequest..." + Invoke-WebRequest -Uri $url -OutFile $zipFile + } + + $extractDir = "mysql-connector-c++" + New-Item -ItemType Directory -Path $extractDir | Out-Null + + Write-Host "Extracting MySQL Connector/C++..." + Expand-Archive -Path $zipFile -DestinationPath $extractDir + + # Determine source base directory (if the ZIP extract creates a subfolder) + $sourceBase = Join-Path $extractDir $connectorSubDir + if (-not (Test-Path $sourceBase)) { + $sourceBase = $extractDir + } + + New-Item -ItemType Directory -Path "$sourceBase\build" -Force | Out-Null + + Push-Location "$sourceBase\build" + + Write-Host "Configuring with CMake..." + cmake .. -G "Visual Studio 17 2022" -A $cpuTarget ` + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ` + -DBUILD_STATIC=ON ` + -DOPENSSL_USE_STATIC_LIBS=TRUE ` + -DWITH_JDBC=ON ` + -DWITH_MYSQL="C:\Program Files\MySQL\MySQL Server 8.0" ` + -DWITH_SSL="C:\Program Files\OpenSSL-Win64" ` + -DCMAKE_INSTALL_PREFIX="$mysqlconcppTargetDir" + + Write-Host "Building MySQL Connector/C++ Release..." + cmake --build . --config Release + + Write-Host "Installing MySQL Connector/C++ to $mysqlconcppTargetDir..." + cmake --install . --config Release + + # For some reason the config doesn't find the lib in the installed path... + New-Item -ItemType Directory -Path "$mysqlconcppTargetDir\lib" -Force | Out-Null + Copy-Item -Path (Join-Path "$mysqlconcppTargetDir\lib64\vs14" "*") ` + -Destination "$mysqlconcppTargetDir\lib" -Recurse -Force + + Write-Host "Building MySQL Connector/C++ Debug..." + cmake --build . --config Debug + + Write-Host "Installing MySQL Connector/C++ to $mysqlconcppTargetDir\lib\debug..." + cmake --install . --config Debug + + # For some reason the config doesn't find the lib in the installed path... + New-Item -ItemType Directory -Path "$mysqlconcppTargetDir\lib" -Force | Out-Null + Copy-Item -Path (Join-Path "$mysqlconcppTargetDir\lib64\debug\vs14" "*") ` + -Destination "$mysqlconcppTargetDir\lib\debug" -Recurse -Force + + Pop-Location + + Write-Host "MySQL Connector/C++ installed at: $mysqlconcppTargetDir" +} +else { + Write-Host "MySQL Connector/C++ is already installed at $mysqlconcppTargetDir" +} + +$env:CMAKE_PREFIX_PATH = "$mysqlconcppTargetDir;$env:CMAKE_PREFIX_PATH" +Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH" + +############################################################# +# PCRE 8.45 Installation from Source (Non-autotools Build) +############################################################# +$pcreTargetDir = "C:\pcre" +if (-not (Test-Path $pcreTargetDir)) { + $zipFile = "pcre-8.45.zip" + $url = "https://mirror.ihost.md/exim/pcre/pcre-8.45.zip" + + Write-Host "Downloading PCRE 8.45 from $url" + if (Get-Command curl -ErrorAction SilentlyContinue) { + Write-Host "Downloading using curl..." + curl -L $url -o $zipFile + } + elseif (Get-Command wget -ErrorAction SilentlyContinue) { + Write-Host "Downloading using wget..." + wget $url -O $zipFile + } + else { + Write-Host "Downloading using Invoke-WebRequest..." + Invoke-WebRequest -Uri $url -OutFile $zipFile + } + + Write-Host "Extracting PCRE 8.45..." + Expand-Archive -Path $zipFile -DestinationPath "pcre-8.45" -Force + + # Determine the source base folder. + $sourceBase = "pcre-8.45\pcre-8.45" + if (-not (Test-Path $sourceBase)) { + $sourceBase = "pcre-8.45" + } + + # Create a build directory within the source folder. + New-Item -ItemType Directory -Path "$sourceBase\build" -Force | Out-Null + + Push-Location "$sourceBase\build" + + Write-Host "Configuring PCRE build..." + cmake .. -G "Visual Studio 17 2022" -A $cpuTarget ` + -DCMAKE_INSTALL_PREFIX="$pcreTargetDir" + + # Release Build and Install + Write-Host "Building PCRE in Release Configuration..." + cmake --build . --config Release + + Write-Host "Installing PCRE (Release) to $pcreTargetDir..." + cmake --install . --config Release + + # Debug Build and Install + Write-Host "Building PCRE in Debug cConfiguration..." + cmake --build . --config Debug + + $debugDir = "$pcreTargetDir\lib\debug" + + Write-Host "Installing PCRE (Debug) to $debugDir" + cmake --install . --config Debug + + # Move the library from the lib folder to the newly-created debug folder and rename it + New-Item -ItemType Directory -Path $debugDir -Force | Out-Null + Write-Host "Created debug folder: $debugDir" + Move-Item "$pcreTargetDir\lib\pcred.lib" "$debugDir\pcre.lib" -Force + Write-Host "Moved 'pcred.lib' to '$debugDir\pcre.lib'" + + Pop-Location +} +else { + Write-Host "PCRE 8.45 is already installed at $pcreTargetDir" +} + +$env:CMAKE_PREFIX_PATH = "$pcreTargetDir;$env:CMAKE_PREFIX_PATH" +Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH" + +############################################################# +# ZLIB 1.3.1 Installation from Source (CMake-Based Build) +############################################################# +$zlibTargetDir = "C:\zlib" +if (-not (Test-Path $zlibTargetDir)) { + $zipFile = "zlib131.zip" + $url = "https://zlib.net/zlib131.zip" + + Write-Host "Downloading ZLIB 1.3.1 from $url" + if (Get-Command curl -ErrorAction SilentlyContinue) { + Write-Host "Downloading using curl..." + curl -L $url -o $zipFile + } + elseif (Get-Command wget -ErrorAction SilentlyContinue) { + Write-Host "Downloading using wget..." + wget $url -O $zipFile + } + else { + Write-Host "Downloading using Invoke-WebRequest..." + Invoke-WebRequest -Uri $url -OutFile $zipFile + } + + Write-Host "Extracting ZLIB 1.3.1..." + Expand-Archive -Path $zipFile -DestinationPath "zlib-1.3.1" -Force + + # Determine the source base folder. + $sourceBase = "zlib-1.3.1\zlib-1.3.1" + if (-not (Test-Path $sourceBase)) { + $sourceBase = "zlib-1.3.1" + } + + # Create a build directory within the source folder. + New-Item -ItemType Directory -Path "$sourceBase\build" -Force | Out-Null + + Push-Location "$sourceBase\build" + + Write-Host "Configuring ZLIB build using CMake..." + cmake .. -G "Visual Studio 17 2022" -A $cpuTarget ` + -DCMAKE_INSTALL_PREFIX="$zlibTargetDir" + + Write-Host "Building ZLIB..." + cmake --build . --config $buildType + + Write-Host "Installing ZLIB to $zlibTargetDir" + cmake --install . --config $buildType + + Pop-Location +} +else { + Write-Host "ZLIB 1.3.1 is already installed at $zlibTargetDir" +} + +$env:CMAKE_PREFIX_PATH = "$zlibTargetDir;$env:CMAKE_PREFIX_PATH" +Write-Host "CMAKE_PREFIX_PATH set to: $env:CMAKE_PREFIX_PATH" + +#################################################### +# Configure and Build Ember +#################################################### +Write-Host "=== Configuring project with CMake ===" + +cmake -S . -B $buildDir -G "Visual Studio 17 2022" ` + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ` + -DBUILD_OPT_TOOLS="$buildOptionalTools" ` + -DDISABLE_EMBER_THREADS="$disableEmberThreads" ` + -DCMAKE_INSTALL_PREFIX="$installDir" + +Write-Host "Building and installing the project..." +cmake --build $buildDir --target install --config "$buildType" + +#################################################### +# Run the unit_tests for regression control +#################################################### +#Write-Host "=== Switching to installed directory and running tests ===" +#Set-Location $installDir +#if (Test-Path ".\unit_tests.exe") { +# .\unit_tests.exe +#} +#else { +# Write-Host "Warning: Installed test executable not found." +#} +# +#Write-Host "=== Build, install, and test complete ===" diff --git a/cmake/FindBotan.cmake b/cmake/FindBotan.cmake deleted file mode 100644 index ed1b583b4..000000000 --- a/cmake/FindBotan.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# Module for locating the Botan cryptographic library. -# -# Customizable variables: -# BOTAN_ROOT_DIR -# This variable points to the Botan root directory. On Windows the -# library location typically will have to be provided explicitly using the -# -D command-line option. -# -# Read-only variables: -# BOTAN_FOUND -# Indicates whether the library has been found. -# -# BOTAN_INCLUDE_DIRS -# Points to the Botan include directory. -# -# BOTAN_LIBRARIES -# Points to the Botan libraries that should be passed to -# target_link_libararies. -# -# -# Copyright (c) 2012 Sergiu Dotenco -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -INCLUDE (FindPackageHandleStandardArgs) - -SET (_BOTAN_POSSIBLE_LIB_SUFFIXES lib) - -FIND_PATH (BOTAN_ROOT_DIR - NAMES include/botan/botan.h - PATHS ENV BOTANROOT - DOC "Botan root directory") - -FIND_PATH (BOTAN_INCLUDE_DIR - NAMES botan/botan.h - HINTS ${BOTAN_ROOT_DIR} - PATH_SUFFIXES include - DOC "Botan include directory") - -FIND_LIBRARY (BOTAN_LIBRARY_DEBUG - NAMES botand - HINTS ${BOTAN_ROOT_DIR} - PATH_SUFFIXES ${_BOTAN_POSSIBLE_LIB_SUFFIXES} - DOC "Botan debug library") - -FIND_LIBRARY (BOTAN_LIBRARY_RELEASE - NAMES botan - HINTS ${BOTAN_ROOT_DIR} - PATH_SUFFIXES ${_BOTAN_POSSIBLE_LIB_SUFFIXES} - DOC "Botan release library") - -IF (BOTAN_LIBRARY_DEBUG AND BOTAN_LIBRARY_RELEASE) - SET (BOTAN_LIBRARY - optimized ${BOTAN_LIBRARY_RELEASE} - debug ${BOTAN_LIBRARY_DEBUG} CACHE DOC "Botan library") -ELSEIF (BOTAN_LIBRARY_RELEASE) - SET (BOTAN_LIBRARY ${BOTAN_LIBRARY_RELEASE} CACHE STRING "Botan library") -ENDIF (BOTAN_LIBRARY_DEBUG AND BOTAN_LIBRARY_RELEASE) - -IF (BOTAN_INCLUDE_DIR) - SET (_BOTAN_VERSION_HEADER ${BOTAN_INCLUDE_DIR}/botan/build.h) - - IF (EXISTS ${_BOTAN_VERSION_HEADER}) - FILE (STRINGS ${_BOTAN_VERSION_HEADER} _BOTAN_VERSION_TMP REGEX - "#define BOTAN_VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+") - - STRING (REGEX REPLACE - ".*#define BOTAN_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" BOTAN_VERSION_MAJOR - ${_BOTAN_VERSION_TMP}) - STRING (REGEX REPLACE - ".*#define BOTAN_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" BOTAN_VERSION_MINOR - ${_BOTAN_VERSION_TMP}) - STRING (REGEX REPLACE - ".*#define BOTAN_VERSION_PATCH[ \t]+([0-9]+).*" "\\1" BOTAN_VERSION_PATCH - ${_BOTAN_VERSION_TMP}) - - SET (BOTAN_VERSION_COUNT 3) - SET (BOTAN_VERSION - ${BOTAN_VERSION_MAJOR}.${BOTAN_VERSION_MINOR}.${BOTAN_VERSION_PATCH}) - ENDIF (EXISTS ${_BOTAN_VERSION_HEADER}) -ENDIF (BOTAN_INCLUDE_DIR) - -SET (BOTAN_INCLUDE_DIRS ${BOTAN_INCLUDE_DIR}) -SET (BOTAN_LIBRARIES ${BOTAN_LIBRARY}) - -MARK_AS_ADVANCED (BOTAN_ROOT_DIR BOTAN_INCLUDE_DIR BOTAN_LIBRARY - BOTAN_LIBRARY_DEBUG BOTAN_LIBRARY_RELEASE) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS (Botan REQUIRED_VARS BOTAN_ROOT_DIR - BOTAN_INCLUDE_DIR BOTAN_LIBRARY VERSION_VAR BOTAN_VERSION) \ No newline at end of file diff --git a/cmake/FindMySQLConnectorCPP.cmake b/cmake/FindMySQLConnectorCPP.cmake deleted file mode 100644 index dd108997a..000000000 --- a/cmake/FindMySQLConnectorCPP.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# Module for locating the MySQL Connector/C++ library -# Based on Sergiu Dotenco's FindBotan module - -include(FindPackageHandleStandardArgs) - -set(MYSQLCCPP_ROOT_HINTS - include/mysql_connection.h # Docker - include/jdbc/mysql_connection.h) # vcpkg -set(MYSQLCCPP_INCLUDE_PATH - include # Docker - include/jdbc) # vcpkg - -set(MYSQLCCPP_LIBRARY_NAMES - mysqlcppconn # Docker - libmysqlcppconn-static.a) # vcpkg -set(_MYSQLCCPP_POSSIBLE_LIB_SUFFIXES lib) - -set(MYSQLCCPP_LIBRARYD_NAMES - mysqlcppconnd # Docker - libmysqlcppconn-static.a) # vcpkg -set(_MYSQLCCPP_POSSIBLE_LIBD_SUFFIXES - debug/lib # vcpkg - lib) # Docker - -find_path(MYSQLCCPP_ROOT_DIR - NAMES ${MYSQLCCPP_ROOT_HINTS} - PATHS ENV MYSQLCCPPROOT - DOC "MySQL Connector/C++ root directory") - -find_path(MYSQLCCPP_INCLUDE_DIR - NAMES mysql_connection.h - HINTS ${MYSQLCCPP_ROOT_DIR} - PATH_SUFFIXES ${MYSQLCCPP_INCLUDE_PATH} - DOC "MySQL Connector/C++ include directory") - -find_library(MYSQLCCPP_LIBRARY_RELEASE - NAMES ${MYSQLCCPP_LIBRARY_NAMES} - HINTS ${MYSQLCCPP_ROOT_DIR} - PATH_SUFFIXES ${_MYSQLCCPP_POSSIBLE_LIB_SUFFIXES} - DOC "MySQL Connector/C++ release library") - -find_library(MYSQLCCPP_LIBRARY_DEBUG - NAMES ${MYSQLCCPP_LIBRARYD_NAMES} - HINTS ${MYSQLCCPP_ROOT_DIR} - PATH_SUFFIXES ${_MYSQLCCPP_POSSIBLE_LIBD_SUFFIXES} - DOC "MySQL Connector/C++ debug library") - -if(MYSQLCCPP_LIBRARY_DEBUG AND MYSQLCCPP_LIBRARY_RELEASE) - set(MYSQLCCPP_LIBRARY - optimized ${MYSQLCCPP_LIBRARY_RELEASE} - debug ${MYSQLCCPP_LIBRARY_DEBUG} CACHE DOC "MySQL Connector/C++ library") -elseif(MYSQLCCPP_LIBRARY_RELEASE) - set(MYSQLCCPP_LIBRARY ${MYSQLCCPP_LIBRARY_RELEASE} CACHE STRING "MySQL Connector/C++ library") -endif(MYSQLCCPP_LIBRARY_DEBUG AND MYSQLCCPP_LIBRARY_RELEASE) - -set(MYSQLCCPP_INCLUDE_DIRS ${MYSQLCCPP_INCLUDE_DIR}) -set(MYSQLCCPP_LIBRARIES ${MYSQLCCPP_LIBRARY}) - -mark_as_advanced(MYSQLCCPP_ROOT_DIR MYSQLCCPP_INCLUDE_DIR MYSQLCCPP_LIBRARY - MYSQLCCPP_LIBRARY_DEBUG MYSQLCCPP_LIBRARY_RELEASE) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQLConnectorCPP REQUIRED_VARS MYSQLCCPP_ROOT_DIR - MYSQLCCPP_INCLUDE_DIR MYSQLCCPP_LIBRARY) \ No newline at end of file diff --git a/schemas/CMakeLists.txt b/schemas/CMakeLists.txt index 09d6ffd39..dfb4052b7 100644 --- a/schemas/CMakeLists.txt +++ b/schemas/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2016 - 2024 Ember +# Copyright (c) 2016 - 2025 Ember # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this @@ -6,6 +6,8 @@ set(FB_SCHEMA_TARGET_NAME FB_SCHEMA_COMPILE) +set(BINARY_SCHEMAS_DIR ${CMAKE_BINARY_DIR}/schemas/FB_SCHEMA_COMPILE) + set(SERVICE_SCHEMAS ${CMAKE_CURRENT_SOURCE_DIR}/spark/services/Account.fbs ${CMAKE_CURRENT_SOURCE_DIR}/spark/services/Character.fbs @@ -25,10 +27,16 @@ flatbuffers_generate_headers( TARGET ${FB_SCHEMA_TARGET_NAME} SCHEMAS ${FB_SCHEMAS} INCLUDE ${CMAKE_CURRENT_SOURCE_DIR} - BINARY_SCHEMAS_DIR ${CMAKE_BINARY_DIR} + BINARY_SCHEMAS_DIR ${BINARY_SCHEMAS_DIR} FLAGS ${FLATC_ARGS} + BYPRODUCTS ${BINARY_SCHEMAS_DIR}/Spark_generated.h ) -target_include_directories(${FB_SCHEMA_TARGET_NAME} INTERFACE ${CMAKE_BINARY_DIR}/schemas/FB_SCHEMA_COMPILE) +target_link_libraries(${FB_SCHEMA_TARGET_NAME} INTERFACE flatbuffers::flatbuffers) +target_include_directories(${FB_SCHEMA_TARGET_NAME} INTERFACE ${BINARY_SCHEMAS_DIR}) + +# MSVC requires a post-compile target to depend upon or it will not respsect build order +add_custom_target(GenerateSparkHeaders ALL DEPENDS ${BINARY_SCHEMAS_DIR}/Spark_generated.h) + set(TEMPLATE_DIR ${CMAKE_SOURCE_DIR}/src/tools/rpcgen/templates/) -build_spark_services("${SERVICE_SCHEMAS}" ${TEMPLATE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}) \ No newline at end of file +build_spark_services("${SERVICE_SCHEMAS}" ${TEMPLATE_DIR} ${BINARY_SCHEMAS_DIR} ${BINARY_SCHEMAS_DIR}) diff --git a/src/account/AccountService.cpp b/src/account/AccountService.cpp index 1e18a7225..4dfded35c 100644 --- a/src/account/AccountService.cpp +++ b/src/account/AccountService.cpp @@ -46,7 +46,8 @@ AccountService::handle_session_fetch(const SessionLookup& msg, const Link& link, return response; } - auto key = Botan::BigInt::encode(*session); + std::vector key((*session).bytes()); + (*session).serialize_to(std::span(key.data(), key.size())); response.status = Status::OK; response.account_id = msg.account_id(); diff --git a/src/account/CMakeLists.txt b/src/account/CMakeLists.txt index 3ed35c445..95bd6ff89 100644 --- a/src/account/CMakeLists.txt +++ b/src/account/CMakeLists.txt @@ -25,9 +25,8 @@ set(LIBRARY_SRC include_directories(${SPARK_INCLUDES_DIR}) add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC}) -target_link_libraries(${LIBRARY_NAME} PRIVATE spark conpool logger shared ${MYSQLCCPP_LIBRARY} - ${BOTAN_LIBRARY} ${Boost_LIBRARIES} Threads::Threads FB_SCHEMA_COMPILE) -target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR}) +target_link_libraries(${LIBRARY_NAME} spark conpool logger shared ${Boost_LIBRARIES} + ${BOTAN_LIBRARY} ${MYSQLCCPP_LIBRARY} Threads::Threads) add_executable(${EXECUTABLE_NAME} main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared ${Boost_LIBRARIES} Threads::Threads) diff --git a/src/character/CMakeLists.txt b/src/character/CMakeLists.txt index 8be169a5c..81f686b99 100644 --- a/src/character/CMakeLists.txt +++ b/src/character/CMakeLists.txt @@ -24,13 +24,12 @@ set(LIBRARY_SRC include_directories(${CMAKE_SOURCE_DIR}/deps/utf8cpp) add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC}) -target_link_libraries(${LIBRARY_NAME} dbcreader spark logger protocol shared ${BOTAN_LIBRARY} - ${Boost_LIBRARIES} Threads::Threads FB_SCHEMA_COMPILE) -target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR}) +target_link_libraries(${LIBRARY_NAME} logger shared dbcreader spark protocol ${Boost_LIBRARIES} + ${BOTAN_LIBRARY} ${MYSQLCCPP_LIBRARY} Threads::Threads) add_executable(${EXECUTABLE_NAME} main.cpp) -target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} protocol dbcreader spark conpool logger shared - ${MYSQLCCPP_LIBRARY} ${Boost_LIBRARIES} Threads::Threads) +target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared protocol dbcreader spark conpool + ${Boost_LIBRARIES} Threads::Threads) INSTALL(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) set_target_properties(character PROPERTIES FOLDER "Services/Applications") diff --git a/src/fusion/CMakeLists.txt b/src/fusion/CMakeLists.txt index 8ec4aaacd..d401774be 100644 --- a/src/fusion/CMakeLists.txt +++ b/src/fusion/CMakeLists.txt @@ -17,7 +17,7 @@ set(SERVICE_LIBRARIES libcharacter ) -target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared ${SERVICE_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(${EXECUTABLE_NAME} logger shared ${SERVICE_LIBRARIES} ${Boost_LIBRARIES}) target_include_directories(${EXECUTABLE_NAME} PRIVATE ../) INSTALL(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/src/gateway/AccountClient.cpp b/src/gateway/AccountClient.cpp index cfa5aeb4b..3e6996d19 100644 --- a/src/gateway/AccountClient.cpp +++ b/src/gateway/AccountClient.cpp @@ -87,7 +87,7 @@ void AccountClient::handle_locate_response(std::expectedkey()->data(), msg->key()->size()); + auto key = Botan::BigInt::from_bytes(std::span(msg->key()->data(), msg->key()->size())); cb(msg->status(), std::move(key)); } diff --git a/src/gateway/CMakeLists.txt b/src/gateway/CMakeLists.txt index f9c3033e7..93ba8ba90 100644 --- a/src/gateway/CMakeLists.txt +++ b/src/gateway/CMakeLists.txt @@ -85,9 +85,8 @@ set(LIBRARY_SRC add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC}) add_dependencies(${LIBRARY_NAME} FB_SCHEMA_COMPILE) -target_link_libraries(${LIBRARY_NAME} PRIVATE ${Boost_LIBRARIES} PRIVATE nsd conpool stun ports dbcreader protocol spark - logger shared ${ZLIB_LIBRARY} ${BOTAN_LIBRARY} Threads::Threads) -target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR}) +target_link_libraries(${LIBRARY_NAME} logger shared nsd conpool stun ports dbcreader protocol spark + ${Boost_LIBRARIES} ${BOTAN_LIBRARY} ${MYSQLCCPP_LIBRARY} Threads::Threads) add_executable(${EXECUTABLE_NAME} main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared ${Boost_LIBRARIES} Threads::Threads) diff --git a/src/gateway/PacketCrypto.h b/src/gateway/PacketCrypto.h index 15fb0c1dd..5b473313b 100644 --- a/src/gateway/PacketCrypto.h +++ b/src/gateway/PacketCrypto.h @@ -44,7 +44,7 @@ class PacketCrypto final { ); key_.resize(key.bytes(), boost::container::default_init); - key.binary_encode(key_.data(), key_.size()); + key.serialize_to(std::span( key_.data() + (key_.size() - key.bytes()), key.bytes() )); } inline void encrypt(auto& data) { diff --git a/src/gateway/states/Authentication.cpp b/src/gateway/states/Authentication.cpp index f6b167f5b..59a6c5d6a 100644 --- a/src/gateway/states/Authentication.cpp +++ b/src/gateway/states/Authentication.cpp @@ -164,7 +164,7 @@ void prove_session(ClientContext& ctx, const Botan::BigInt& key) { key.bytes(), boost::container::default_init ); - key.binary_encode(k_bytes.data(), k_bytes.size()); + key.serialize_to(std::span(k_bytes.data() + (k_bytes.size() - key.bytes()), key.bytes())); const std::uint32_t protocol_id = 0; // best guess, this is hardcoded to zero in the client auto& auth_ctx = std::get(ctx.state_ctx); diff --git a/src/libs/conpool/src/MySQL/Driver.cpp b/src/libs/conpool/src/MySQL/Driver.cpp index 30458411d..bd6b5cfa9 100644 --- a/src/libs/conpool/src/MySQL/Driver.cpp +++ b/src/libs/conpool/src/MySQL/Driver.cpp @@ -7,13 +7,13 @@ */ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/libs/mpq/CMakeLists.txt b/src/libs/mpq/CMakeLists.txt index f754752c4..3864bc919 100644 --- a/src/libs/mpq/CMakeLists.txt +++ b/src/libs/mpq/CMakeLists.txt @@ -54,8 +54,7 @@ add_library(${LIBRARY_NAME} src/Utility.cpp ) -target_link_libraries(${LIBRARY_NAME} shared storm_pklib - bzip2 lzma storm_adpcm storm_sparse storm_huffman - ${Boost_LIBRARIES} ${ZLIB_LIBRARY}) +target_link_libraries(${LIBRARY_NAME} shared bzip2 lzma storm_pklib storm_adpcm storm_sparse + storm_huffman ${Boost_LIBRARIES} ZLIB::ZLIB) target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") diff --git a/src/libs/protocol/CMakeLists.txt b/src/libs/protocol/CMakeLists.txt index bb2709bde..fd32ea76e 100644 --- a/src/libs/protocol/CMakeLists.txt +++ b/src/libs/protocol/CMakeLists.txt @@ -52,6 +52,6 @@ source_group("Core Headers" FILES ${CORE_HEADERS}) add_library(${LIBRARY_NAME} INTERFACE) target_sources(${LIBRARY_NAME} INTERFACE ${HEADERS}) -target_link_libraries(${LIBRARY_NAME} INTERFACE shared spark ${Boost_LIBRARIES}) +target_link_libraries(${LIBRARY_NAME} INTERFACE shared spark ${Boost_LIBRARIES} ZLIB::ZLIB) target_include_directories(${LIBRARY_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") diff --git a/src/libs/shared/CMakeLists.txt b/src/libs/shared/CMakeLists.txt index 955a8b380..16dbf1420 100644 --- a/src/libs/shared/CMakeLists.txt +++ b/src/libs/shared/CMakeLists.txt @@ -89,6 +89,7 @@ set(UTIL_SRC shared/utility/polyfill/inplace_vector shared/utility/polyfill/ranged_iota shared/utility/polyfill/atomic_shared_ptr + shared/utility/polyfill/toUpper shared/utility/Timing.h shared/utility/Timing.cpp shared/utility/Exception.h @@ -136,6 +137,6 @@ source_group("Metrics" FILES ${METRICS_SRC}) include_directories(${CMAKE_SOURCE_DIR}/deps/utf8cpp ${PROJECT_BINARY_DIR}/src) add_library(${LIBRARY_NAME} ${LIBRARY_SRC}) +target_link_libraries(${LIBRARY_NAME} PUBLIC logger conpool ${BOTAN_LIBRARY} ${PCRE_LIBRARY}) target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/) -target_link_libraries(${LIBRARY_NAME} PUBLIC logger conpool ${PCRE_LIBRARY}) -set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") \ No newline at end of file +set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") diff --git a/src/libs/shared/shared/database/daos/mysql/CharacterDAO.h b/src/libs/shared/shared/database/daos/mysql/CharacterDAO.h index def761094..e6b160d3a 100644 --- a/src/libs/shared/shared/database/daos/mysql/CharacterDAO.h +++ b/src/libs/shared/shared/database/daos/mysql/CharacterDAO.h @@ -10,10 +10,10 @@ #include #include -#include -#include #include -#include +#include +#include +#include #include #include #include diff --git a/src/libs/shared/shared/database/daos/mysql/IPBanDAO.h b/src/libs/shared/shared/database/daos/mysql/IPBanDAO.h index 59ef027f7..4f7d69d4f 100644 --- a/src/libs/shared/shared/database/daos/mysql/IPBanDAO.h +++ b/src/libs/shared/shared/database/daos/mysql/IPBanDAO.h @@ -10,10 +10,10 @@ #include #include -#include -#include #include -#include +#include +#include +#include #include #include diff --git a/src/libs/shared/shared/database/daos/mysql/PatchDAO.h b/src/libs/shared/shared/database/daos/mysql/PatchDAO.h index 880cae936..e73dbb7b0 100644 --- a/src/libs/shared/shared/database/daos/mysql/PatchDAO.h +++ b/src/libs/shared/shared/database/daos/mysql/PatchDAO.h @@ -11,10 +11,10 @@ #include #include #include -#include -#include #include -#include +#include +#include +#include #include #include #include @@ -64,7 +64,8 @@ class MySQLPatchDAO final : public PatchDAO { const auto md5 = res->getString("md5"); Botan::BigInt md5_int(md5.asStdString()); - Botan::BigInt::encode_1363(meta.file_meta.md5.data(), meta.file_meta.md5.size(), md5_int); + std::fill(meta.file_meta.md5.begin(), meta.file_meta.md5.end(), 0); // 1363 style padding + md5_int.serialize_to({ meta.file_meta.md5.data() + meta.file_meta.md5.size() - md5_int.bytes(), md5_int.bytes() }); patches.emplace_back(std::move(meta)); } @@ -87,8 +88,8 @@ class MySQLPatchDAO final : public PatchDAO { stmt->setBoolean(3, meta.mpq); stmt->setString(4, meta.file_meta.name); stmt->setUInt64(5, meta.file_meta.size); - auto md5 = Botan::BigInt::decode(reinterpret_cast(meta.file_meta.md5.data()), - meta.file_meta.md5.size()); + auto md5 = Botan::BigInt::from_bytes(std::span(reinterpret_cast( + meta.file_meta.md5.data()), meta.file_meta.md5.size())); stmt->setString(6, md5.to_hex_string()); stmt->setUInt(7, meta.locale_id); diff --git a/src/libs/shared/shared/database/daos/mysql/RealmDAO.h b/src/libs/shared/shared/database/daos/mysql/RealmDAO.h index 61905906b..b6c3be7d3 100644 --- a/src/libs/shared/shared/database/daos/mysql/RealmDAO.h +++ b/src/libs/shared/shared/database/daos/mysql/RealmDAO.h @@ -10,10 +10,10 @@ #include #include -#include -#include #include -#include +#include +#include +#include #include #include #include diff --git a/src/libs/shared/shared/database/daos/mysql/UserDAO.h b/src/libs/shared/shared/database/daos/mysql/UserDAO.h index d947bbc2b..0e9eafaf6 100644 --- a/src/libs/shared/shared/database/daos/mysql/UserDAO.h +++ b/src/libs/shared/shared/database/daos/mysql/UserDAO.h @@ -10,10 +10,10 @@ #include #include -#include -#include #include -#include +#include +#include +#include #include #include #include diff --git a/src/libs/shared/shared/threading/Spinlock.h b/src/libs/shared/shared/threading/Spinlock.h index c2b401c62..173f8c40f 100644 --- a/src/libs/shared/shared/threading/Spinlock.h +++ b/src/libs/shared/shared/threading/Spinlock.h @@ -14,9 +14,11 @@ #if defined(__x86_64__) || defined(_M_X64) || defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86) #define YIELD_INSTRUCTION _mm_pause() #define ember_x86_or_x64 -#elif defined(__APPLE__) && defined(__aarch64__) +#elif defined(__clang__) && defined(__aarch64__) #define YIELD_INSTRUCTION __builtin_arm_yield() -#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__aarch64__) +#elif defined(__aarch64__) +#define YIELD_INSTRUCTION __asm__ volatile("yield" ::: "memory") +#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) #define YIELD_INSTRUCTION __yield() #endif diff --git a/src/libs/shared/shared/utility/UTF8.cpp b/src/libs/shared/shared/utility/UTF8.cpp index 8ae98f947..9cee1b6c9 100644 --- a/src/libs/shared/shared/utility/UTF8.cpp +++ b/src/libs/shared/shared/utility/UTF8.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace ember::util::utf8 { diff --git a/src/libs/shared/shared/utility/polyfill/toUpper b/src/libs/shared/shared/utility/polyfill/toUpper new file mode 100644 index 000000000..2122479d3 --- /dev/null +++ b/src/libs/shared/shared/utility/polyfill/toUpper @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 Ember + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +// Until libc++ maybe provides this functionality... +#if defined(_LIBCPP_VERSION) + +#include +#include +#include +#include + +inline void toUpper(std::string &str, const std::string &localeStr) +{ + std::locale loc(localeStr); + // Decode the UTF‑8 string into Unicode code points. + std::vector codepoints; + using unchecked_iterator = utf8::unchecked::iterator; + unchecked_iterator it(str.begin()); + unchecked_iterator it_end(str.end()); + + for (; it != it_end; ++it) + { + char32_t cp = *it; + wchar_t buf[1] = {static_cast(cp)}; + std::use_facet>(loc).toupper(buf, buf + 1); + cp = static_cast(buf[0]); + codepoints.push_back(cp); + } + + // Re-encode the code points back into a UTF‑8 string. + std::string out; + utf8::utf32to8(codepoints.begin(), codepoints.end(), std::back_inserter(out)); + str = std::move(out); +} + +namespace std { + // Convert a code point to a wide character, apply the locale's + // toupper (via the ctype facet), and convert it back. + inline char32_t toupper(char32_t c, const locale &loc) { + wchar_t buf[1] = {static_cast(c)}; + std::use_facet>(loc).toupper(buf, buf + 1); + return static_cast(buf[0]); + } + + // Convert a char32_t code point to lowercase + // using the locale's ctype facet. + inline char32_t tolower(char32_t c, const locale &loc) { + wchar_t buf[1] = {static_cast(c)}; + std::use_facet>(loc).tolower(buf, buf + 1); + return static_cast(buf[0]); + } + + // Overload for per‑codepoint isalpha for char32_t. + inline bool isalpha(char32_t c, const locale &loc) { + auto &facet = std::use_facet>(loc); + return facet.is(std::ctype_base::alpha, static_cast(c)) != 0; + } +} + +#endif // defined(_LIBCPP_VERSION) diff --git a/src/libs/spark/CMakeLists.txt b/src/libs/spark/CMakeLists.txt index 89ba15c86..550c8e9c1 100644 --- a/src/libs/spark/CMakeLists.txt +++ b/src/libs/spark/CMakeLists.txt @@ -38,7 +38,7 @@ set(IO_SRC include/spark/buffers/BufferSequence.h include/spark/buffers/BinaryStream.h include/spark/buffers/StaticBuffer.h - include/spark/buffers/Concepts.h + include/spark/buffers/Concepts.h include/spark/buffers/detail/IntrusiveStorage.h include/spark/buffers/FileBuffer.h include/spark/buffers/Endian.h @@ -71,7 +71,7 @@ add_library( ${CORE} ${IO_SRC} ${IO_PMR_SRC} - ${IO_ALLOC_SRC} + ${IO_ALLOC_SRC} ) source_group("Core" FILES ${CORE}) @@ -80,5 +80,6 @@ source_group("IO\\Polymorphic" FILES ${IO_PMR_SRC}) source_group("IO\\Allocators" FILES ${IO_ALLOC_SRC}) target_link_libraries(${LIBRARY_NAME} shared ${Boost_LIBRARIES} FB_SCHEMA_COMPILE) +add_dependencies(${LIBRARY_NAME} GenerateSparkHeaders) target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) -set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") \ No newline at end of file +set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") diff --git a/src/libs/srp6/CMakeLists.txt b/src/libs/srp6/CMakeLists.txt index 4722e9965..6c4756124 100644 --- a/src/libs/srp6/CMakeLists.txt +++ b/src/libs/srp6/CMakeLists.txt @@ -19,6 +19,6 @@ add_library(${LIBRARY_NAME} include/srp6/detail/Primes.h ) -target_link_libraries(${LIBRARY_NAME} PRIVATE ${Boost_LIBRARIES}) +target_link_libraries(${LIBRARY_NAME} PRIVATE ${Boost_LIBRARIES} ${BOTAN_LIBRARY}) target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) set_target_properties(${LIBRARY_NAME} PROPERTIES FOLDER "Common Libraries") diff --git a/src/libs/srp6/src/Client.cpp b/src/libs/srp6/src/Client.cpp index edc9af153..880669613 100644 --- a/src/libs/srp6/src/Client.cpp +++ b/src/libs/srp6/src/Client.cpp @@ -23,7 +23,7 @@ Client::Client(std::string identifier, std::string password, Generator gen, std: : Client(std::move(identifier), std::move(password), gen, - BigInt::decode((AutoSeeded_RNG()).random_vec(key_size)) % gen.prime(), + BigInt::from_bytes(std::span{ (AutoSeeded_RNG().random_vec(key_size)).data(), key_size }) % gen.prime(), srp6a) { } Client::Client(std::string identifier, std::string password, Generator gen, BigInt a, bool srp6a) @@ -64,7 +64,7 @@ SessionKey Client::session_key(const BigInt& B, std::span sa return SessionKey(detail::interleaved_hash(detail::encode_flip_1363(S, N.bytes()))); } else { KeyType key(S.bytes(), boost::container::default_init); - S.binary_encode(key.data(), key.size()); + S.serialize_to(std::span(key.data(), key.size())); return SessionKey(key); } } diff --git a/src/libs/srp6/src/Server.cpp b/src/libs/srp6/src/Server.cpp index 08cbb3db8..cfdd5b5d3 100644 --- a/src/libs/srp6/src/Server.cpp +++ b/src/libs/srp6/src/Server.cpp @@ -48,7 +48,7 @@ SessionKey Server::session_key(const BigInt& A, Compliance mode, bool interleave return SessionKey(detail::interleaved_hash(detail::encode_flip_1363(S, N_.bytes()))); } else { KeyType key(N_.bytes(), boost::container::default_init); - S.binary_encode(key.data(), key.size()); + S.serialize_to(std::span(key.data(), key.size())); return SessionKey(key); } } diff --git a/src/libs/srp6/src/Util.cpp b/src/libs/srp6/src/Util.cpp index 9962bd440..1a8c27465 100644 --- a/src/libs/srp6/src/Util.cpp +++ b/src/libs/srp6/src/Util.cpp @@ -21,19 +21,20 @@ namespace detail { Botan::BigInt decode_flip(std::span val) { std::ranges::reverse(val); - return Botan::BigInt::decode(val.data(), val.size()); + return Botan::BigInt::from_bytes(std::span(val.data(), val.size())); } SmallVec encode_flip(const Botan::BigInt& val) { SmallVec res(val.bytes(), boost::container::default_init); - val.binary_encode(res.data(), res.size()); + val.serialize_to(std::span(res.data(), res.size())); std::ranges::reverse(res); return res; } SmallVec encode_flip_1363(const Botan::BigInt& val, std::size_t padding) { SmallVec res(padding, boost::container::default_init); - Botan::BigInt::encode_1363(res.data(), res.size(), val); + std::fill(res.begin(), res.end(), 0); // 1363 style padding + val.serialize_to({ res.data() + res.size() - val.bytes(), val.bytes() }); std::ranges::reverse(res); return res; } @@ -69,15 +70,15 @@ Botan::BigInt scrambler(const Botan::BigInt& A, const Botan::BigInt& B, std::siz auto hasher = Botan::HashFunction::create_or_throw("SHA-1"); BOOST_ASSERT_MSG(SHA1_LEN == hasher->output_length(), "Bad hash length"); std::array hash_out; - SmallVec vec(padding, boost::container::default_init); + SmallVec vec(padding, 0); // 1363 style padding if(mode == Compliance::RFC5054) { - Botan::BigInt::encode_1363(vec.data(), vec.size(), A); + A.serialize_to(std::span(vec.data(), vec.size())); hasher->update(vec.data(), vec.size()); - Botan::BigInt::encode_1363(vec.data(), vec.size(), B); + B.serialize_to(std::span(vec.data(), vec.size())); hasher->update(vec.data(), vec.size()); hasher->final(hash_out.data()); - return Botan::BigInt::decode(hash_out.data(), hash_out.size()); + return Botan::BigInt::from_bytes(std::span(hash_out.data(), hash_out.size())); } else { const auto& a_enc = encode_flip_1363(A, padding); const auto& b_enc = encode_flip_1363(B, padding); @@ -93,10 +94,14 @@ Botan::BigInt compute_k(const Botan::BigInt& g, const Botan::BigInt& N) { std::array hash; auto hasher = Botan::HashFunction::create_or_throw("SHA-1"); BOOST_ASSERT_MSG(SHA1_LEN == hasher->output_length(), "Bad hash length"); - hasher->update(Botan::BigInt::encode(N)); - hasher->update(Botan::BigInt::encode_1363(g, N.bytes())); + std::vector n_buf(N.bytes(), 0); // 1363 style padding + N.serialize_to({ n_buf.data() + n_buf.size() - N.bytes(), N.bytes() }); + std::vector g_buf(N.bytes(), 0); // 1363 style padding + g.serialize_to({ g_buf.data() + g_buf.size() - g.bytes(), g.bytes() }); + hasher->update(n_buf.data(), n_buf.size()); + hasher->update(g_buf.data(), g_buf.size()); hasher->final(hash.data()); - return Botan::BigInt::decode(hash.data(), hash.size()); + return Botan::BigInt::from_bytes(std::span(hash.data(), hash.size())); } Botan::BigInt compute_x(std::string_view identifier, std::string_view password, @@ -123,7 +128,7 @@ Botan::BigInt compute_x(std::string_view identifier, std::string_view password, hasher->final(hash.data()); if(mode == Compliance::RFC5054) { - return Botan::BigInt::decode(hash.data(), hash.size()); + return Botan::BigInt::from_bytes(std::span(hash.data(), hash.size())); } else { return detail::decode_flip(hash); } diff --git a/src/login/AccountClient.cpp b/src/login/AccountClient.cpp index 3f16ca8df..2c0db25dd 100644 --- a/src/login/AccountClient.cpp +++ b/src/login/AccountClient.cpp @@ -90,7 +90,7 @@ void AccountClient::handle_locate_response(std::expectedkey()->data(), msg->key()->size()); + auto key = Botan::BigInt::from_bytes(std::span(msg->key()->data(), msg->key()->size())); cb(msg->status(), std::move(key)); } diff --git a/src/login/Authenticator.cpp b/src/login/Authenticator.cpp index ffb382831..a0465b1ef 100644 --- a/src/login/Authenticator.cpp +++ b/src/login/Authenticator.cpp @@ -53,7 +53,7 @@ ReconnectAuthenticator::ReconnectAuthenticator(utf8_string username, : username_(std::move(username)) { std::ranges::copy(salt, salt_.data()); sess_key_.t.resize(session_key.bytes()); - session_key.binary_encode(sess_key_.t.data(), sess_key_.t.size()); + session_key.serialize_to(std::span(sess_key_.t.data() + (sess_key_.t.size() - session_key.bytes()), session_key.bytes())); } bool ReconnectAuthenticator::proof_check(std::span salt, diff --git a/src/login/CMakeLists.txt b/src/login/CMakeLists.txt index 7af4de9d1..04d320d83 100644 --- a/src/login/CMakeLists.txt +++ b/src/login/CMakeLists.txt @@ -87,9 +87,8 @@ set(LIBRARY_SRC source_group("Grunt Protocol" FILES ${GRUNT_SRC}) add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC} ${GRUNT_SRC}) -target_link_libraries(${LIBRARY_NAME} dbcreader spark srp6 logger stun ports shared ${ZLIB_LIBRARY} - ${BOTAN_LIBRARY} ${Boost_LIBRARIES} Threads::Threads FB_SCHEMA_COMPILE) -target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR}) +target_link_libraries(${LIBRARY_NAME} logger shared dbcreader spark srp6 stun ports ${Boost_LIBRARIES} + ${BOTAN_LIBRARY} ${MYSQLCCPP_LIBRARY} ZLIB::ZLIB Threads::Threads) add_executable(${EXECUTABLE_NAME} main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared ${Boost_LIBRARIES} Threads::Threads) diff --git a/src/login/LoginHandler.cpp b/src/login/LoginHandler.cpp index 6399cefb7..dd65dfaf1 100644 --- a/src/login/LoginHandler.cpp +++ b/src/login/LoginHandler.cpp @@ -360,7 +360,7 @@ bool LoginHandler::validate_client_integrity(std::span hash, salt.bytes(), boost::container::default_init ); - salt.binary_encode(bytes.data(), bytes.size()); + salt.serialize_to(std::span(bytes.data(), salt.bytes())); std::ranges::reverse(bytes); return validate_client_integrity(hash, bytes, reconnect); } diff --git a/src/login/grunt/client/LoginProof.h b/src/login/grunt/client/LoginProof.h index 8a7919434..7713c2cf0 100644 --- a/src/login/grunt/client/LoginProof.h +++ b/src/login/grunt/client/LoginProof.h @@ -166,11 +166,13 @@ class LoginProof final : public Packet { stream << opcode; std::array a_bytes; - Botan::BigInt::encode_1363(a_bytes.data(), a_bytes.size(), A); + std::fill(a_bytes.begin(), a_bytes.end(), 0); // 1363 style padding + A.serialize_to({ a_bytes.data() + a_bytes.size() - A.bytes(), A.bytes() }); stream.put(a_bytes.rbegin(), a_bytes.rend()); std::array m1_bytes; - Botan::BigInt::encode_1363(m1_bytes.data(), m1_bytes.size(), M1); + std::fill(m1_bytes.begin(), m1_bytes.end(), 0); // 1363 style padding + M1.serialize_to({ m1_bytes.data() + m1_bytes.size() - M1.bytes(), M1.bytes() }); stream.put(m1_bytes.rbegin(), m1_bytes.rend()); stream.put(client_checksum.data(), client_checksum.size()); diff --git a/src/login/grunt/server/LoginChallenge.h b/src/login/grunt/server/LoginChallenge.h index 524852151..6cc86fe88 100644 --- a/src/login/grunt/server/LoginChallenge.h +++ b/src/login/grunt/server/LoginChallenge.h @@ -132,7 +132,8 @@ class LoginChallenge final : public Packet { } std::array bytes{}; - Botan::BigInt::encode_1363(bytes.data(), bytes.size(), B); + std::fill(bytes.begin(), bytes.end(), 0); // 1363 style padding + B.serialize_to({ bytes.data() + (bytes.size() - B.bytes()), B.bytes() }); stream.put(bytes.rbegin(), bytes.rend()); stream << g_len; @@ -140,11 +141,13 @@ class LoginChallenge final : public Packet { stream << n_len; static_assert(bytes.size() == PRIME_LENGTH); - Botan::BigInt::encode_1363(bytes.data(), bytes.size(), N); + std::fill(bytes.begin(), bytes.end(), 0); // 1363 style padding + N.serialize_to({ bytes.data() + (bytes.size() - N.bytes()), N.bytes() }); stream.put(bytes.rbegin(), bytes.rend()); static_assert(bytes.size() == SALT_LENGTH); - Botan::BigInt::encode_1363(bytes.data(), bytes.size(), s); + std::fill(bytes.begin(), bytes.end(), 0); // 1363 style padding + s.serialize_to({ bytes.data() + (bytes.size() - s.bytes()), s.bytes() }); stream.put(bytes.rbegin(), bytes.rend()); stream.put(checksum_salt.data(), checksum_salt.size()); diff --git a/src/login/grunt/server/LoginProof.h b/src/login/grunt/server/LoginProof.h index a061bafb1..0f955ad90 100644 --- a/src/login/grunt/server/LoginProof.h +++ b/src/login/grunt/server/LoginProof.h @@ -93,7 +93,8 @@ class LoginProof final : public Packet { } std::array bytes{}; - Botan::BigInt::encode_1363(bytes.data(), bytes.size(), M2); + std::fill(bytes.begin(), bytes.end(), 0); // 1363 style padding + M2.serialize_to({ bytes.data() + (bytes.size() - M2.bytes()), M2.bytes() }); stream.put(bytes.rbegin(), bytes.rend()); stream << survey_id; diff --git a/src/mdns/CMakeLists.txt b/src/mdns/CMakeLists.txt index 3e5c6043c..543a6ca23 100644 --- a/src/mdns/CMakeLists.txt +++ b/src/mdns/CMakeLists.txt @@ -33,8 +33,7 @@ set(LIBRARY_SRC ) add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC}) -target_link_libraries(${LIBRARY_NAME} PRIVATE logger shared spark ${Boost_LIBRARIES} Threads::Threads FB_SCHEMA_COMPILE) -target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_BINARY_DIR}) +target_link_libraries(${LIBRARY_NAME} PRIVATE logger shared spark ${Boost_LIBRARIES} Threads::Threads) add_executable(${EXECUTABLE_NAME} main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared ${Boost_LIBRARIES} Threads::Threads) diff --git a/src/social/CMakeLists.txt b/src/social/CMakeLists.txt index a7082770e..9e28b0dd3 100644 --- a/src/social/CMakeLists.txt +++ b/src/social/CMakeLists.txt @@ -17,7 +17,7 @@ set(LIBRARY_SRC ) add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC}) -target_link_libraries(${LIBRARY_NAME} logger shared ${Boost_LIBRARIES} FB_SCHEMA_COMPILE) +target_link_libraries(${LIBRARY_NAME} logger shared ${Boost_LIBRARIES}) add_executable(${EXECUTABLE_NAME} main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} spark logger shared ${Boost_LIBRARIES} Threads::Threads) diff --git a/src/tools/dbutils/mysql/MySQLQueryExecutor.cpp b/src/tools/dbutils/mysql/MySQLQueryExecutor.cpp index 3301d3f4b..29e0f652f 100644 --- a/src/tools/dbutils/mysql/MySQLQueryExecutor.cpp +++ b/src/tools/dbutils/mysql/MySQLQueryExecutor.cpp @@ -8,8 +8,8 @@ #include "MySQLQueryExecutor.h" #include -#include -#include +#include +#include #include #include diff --git a/src/tools/dbutils/mysql/MySQLQueryExecutor.h b/src/tools/dbutils/mysql/MySQLQueryExecutor.h index 1e35c6b07..4b3a3e96f 100644 --- a/src/tools/dbutils/mysql/MySQLQueryExecutor.h +++ b/src/tools/dbutils/mysql/MySQLQueryExecutor.h @@ -9,7 +9,7 @@ #pragma once #include "../QueryExecutor.h" -#include +#include #include class MySQLQueryExecutor final : public QueryExecutor { diff --git a/src/tools/rpcgen/CMakeLists.txt b/src/tools/rpcgen/CMakeLists.txt index c3532d52b..604934c12 100644 --- a/src/tools/rpcgen/CMakeLists.txt +++ b/src/tools/rpcgen/CMakeLists.txt @@ -10,12 +10,13 @@ set(EXECUTABLE_SRC main.cpp SchemaParser.h SchemaParser.cpp - Utility.h - Utility.cpp - ) + Utility.h + Utility.cpp +) include_directories(${CMAKE_SOURCE_DIR}/deps/nlohmann) add_executable(${EXECUTABLE_NAME} ${EXECUTABLE_SRC}) target_link_libraries(${EXECUTABLE_NAME} logger shared ${Boost_LIBRARIES} FB_SCHEMA_COMPILE) +add_dependencies(${EXECUTABLE_NAME} GenerateSparkHeaders) INSTALL(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/tools) -set_target_properties(${EXECUTABLE_NAME} PROPERTIES FOLDER "Tools") \ No newline at end of file +set_target_properties(${EXECUTABLE_NAME} PROPERTIES FOLDER "Tools") diff --git a/src/tools/srpgen/main.cpp b/src/tools/srpgen/main.cpp index 880b5cbe9..0a853d5b7 100644 --- a/src/tools/srpgen/main.cpp +++ b/src/tools/srpgen/main.cpp @@ -84,7 +84,7 @@ void launch(const po::variables_map& args) { void plaintext_output(std::string_view username, const Botan::BigInt& verifier, std::span salt) { std::cout << "Username: " << username << "\n"; - std::cout << "Verifier: " << "0x" << std::hex << verifier << "\n"; + std::cout << "Verifier: " << "0x" << verifier.to_hex_string() << "\n"; std::cout << "Salt: "; for(auto byte : salt) { @@ -94,7 +94,7 @@ void plaintext_output(std::string_view username, const Botan::BigInt& verifier, void json_output(std::string_view username, const Botan::BigInt& verifier, std::span salt) { const auto vstr = std::format("0x{}", verifier.to_hex_string()); - const auto saltdec = Botan::BigInt::decode(salt.data(), salt.size()); + const auto saltdec = Botan::BigInt::from_bytes(std::span(salt.data(), salt.size())); const auto sstr = std::format("0x{}", saltdec.to_hex_string()); json data; diff --git a/src/world/CMakeLists.txt b/src/world/CMakeLists.txt index a2cd92d7e..1dbe4de2b 100644 --- a/src/world/CMakeLists.txt +++ b/src/world/CMakeLists.txt @@ -24,7 +24,7 @@ set(LIBRARY_SRC ) add_library(${LIBRARY_NAME} ${LIBRARY_HDR} ${LIBRARY_SRC}) -target_link_libraries(${LIBRARY_NAME} dbcreader spark logger shared ${Boost_LIBRARIES}) +target_link_libraries(${LIBRARY_NAME} logger shared dbcreader spark ${Boost_LIBRARIES}) add_executable(${EXECUTABLE_NAME} main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${LIBRARY_NAME} logger shared ${Boost_LIBRARIES}) diff --git a/tests/MPQ.cpp b/tests/MPQ.cpp index a8411f9e1..722e5c63f 100644 --- a/tests/MPQ.cpp +++ b/tests/MPQ.cpp @@ -122,7 +122,7 @@ TEST(MPQ, Extract_WAV) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("owl.wav", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0x3a66b4b718686cb4d5aa143895290d84"); ASSERT_EQ(md5, expected); } @@ -137,7 +137,7 @@ TEST(MPQ, Extract_MP3) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("owl.mp3", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0x2f7b030648e1f7ec77109c659bbea3ce"); ASSERT_EQ(md5, expected); } @@ -152,7 +152,7 @@ TEST(MPQ, Extract_Binary) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("elevated_1920_1080.ex_", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0xf3b82b404a36a9714bb266007cacd489"); ASSERT_EQ(md5, expected); } @@ -167,7 +167,7 @@ TEST(MPQ, Extract_JPG) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("ember.jpg", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0x8a623acdf09f9388719010d76a5c7a52"); ASSERT_EQ(md5, expected); } @@ -182,7 +182,7 @@ TEST(MPQ, Extract_PNG) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("ember.png", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0xb29a1ad8ebeef28de68fa9bb0325b893"); ASSERT_EQ(md5, expected); } @@ -196,7 +196,7 @@ TEST(MPQ, Extract_Listfile) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("(listfile)", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0xc4185e8d87a01ac3057a6498deccab1e"); ASSERT_EQ(md5, expected); } @@ -210,7 +210,7 @@ TEST(MPQ, Extract_Attributes) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("(attributes)", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0x44fd6bad334ea24d8901e80ab20c07ba"); ASSERT_EQ(md5, expected); } @@ -224,7 +224,7 @@ TEST(MPQ, Extract_Text) { mpq::DynamicMemorySink sink; ASSERT_NO_THROW(archive->extract_file("compressed.txt", sink)); const auto md5_buf = util::generate_md5(sink.data()); - const auto md5 = Botan::BigInt::decode(md5_buf.data(), md5_buf.size()); + const auto md5 = Botan::BigInt::from_bytes(std::span(md5_buf.data(), md5_buf.size())); Botan::BigInt expected("0xf13fad545731a0b71b2cc17e1acd48f4"); ASSERT_EQ(md5, expected); } diff --git a/tests/SRP6.cpp b/tests/SRP6.cpp index bf40469d2..20d1a7720 100644 --- a/tests/SRP6.cpp +++ b/tests/SRP6.cpp @@ -43,7 +43,7 @@ class srp6SessionTest : public ::testing::Test { TEST(srp6a, RFC5054_TestVectors) { std::string identifier { "alice" }; std::string password { "password123" }; - const auto salt = Botan::BigInt::encode(Botan::BigInt(("0xBEB25379D1A8581EB5A727673A2441EE"))); + const auto salt = Botan::BigInt("0xBEB25379D1A8581EB5A727673A2441EE").serialize(); srp6::Generator gen(srp6::Generator::Group::_1024_BIT); Botan::BigInt expected_k("0x7556AA045AEF2CDD07ABAF0F665C3E818913186F"); @@ -97,9 +97,9 @@ TEST(srp6a, RFC5054_TestVectors) { const auto& c_sess_key = client.session_key(expected_B, salt, srp6::Compliance::RFC5054).t; const auto& s_sess_key = server.session_key(expected_A, srp6::Compliance::RFC5054).t; - EXPECT_EQ(expected_key, Botan::BigInt::decode(c_sess_key.data(), c_sess_key.size())) + EXPECT_EQ(expected_key, Botan::BigInt::from_bytes(std::span(c_sess_key.data(), c_sess_key.size()))) << "Client key did not match expected value!"; - EXPECT_EQ(expected_key, Botan::BigInt::decode(s_sess_key.data(), s_sess_key.size())) + EXPECT_EQ(expected_key, Botan::BigInt::from_bytes(std::span(s_sess_key.data(), s_sess_key.size()))) << "Server key did not match expected value!"; } @@ -142,7 +142,7 @@ TEST_F(srp6SessionTest, GameAuthentication) { srp6::SessionKey key = server.session_key(A); Botan::BigInt M1_S = srp6::generate_client_proof("CHAOSVEX", key, gen.prime(), gen.generator(), A, - server.public_ephemeral(), Botan::BigInt::encode(salt)); + server.public_ephemeral(), salt.serialize()); Botan::BigInt M2_S = server.generate_proof(key, A, M1); EXPECT_EQ(M1, M1_S) << "Server's calculated client proof did not match the replayed proof!"; @@ -176,7 +176,7 @@ TEST(srp6Regressions, SaltZeroPad_ComputeX) { srp6::Generator gen(srp6::Generator::Group::_1024_BIT); Botan::BigInt expected_x("0x7E5250F2CB894FD9703611318C387A773FD52C09"); - Botan::BigInt x = srp6::detail::compute_x(username, password, Botan::BigInt::encode(salt), srp6::Compliance::GAME); + Botan::BigInt x = srp6::detail::compute_x(username, password, salt.serialize(), srp6::Compliance::GAME); ASSERT_EQ(expected_x, x) << "x was calculated incorrectly!"; } @@ -186,7 +186,7 @@ TEST(srp6Regressions, SaltZeroPad_GenerateUser) { Botan::BigInt salt("0xBEB25379D1A8581EB5A727673A2441EE"); auto gen = srp6::Generator(srp6::Generator::Group::_256_BIT); - auto verifier = srp6::generate_verifier(username, password, gen, Botan::BigInt::encode(salt), srp6::Compliance::GAME); + auto verifier = srp6::generate_verifier(username, password, gen, salt.serialize(), srp6::Compliance::GAME); Botan::BigInt expected_v("0x399CF53C149F220F4AA88F7F2F6CA9CB6E4C44EA5240AC0F65601F392F32A16A"); ASSERT_EQ(expected_v, verifier) << "Verifier was calculated incorrectly!"; @@ -199,7 +199,7 @@ TEST(srp6Regressions, NPad_GenerateClientProof) { const Botan::BigInt b("0x809C1BC78BDB3873D286FDADF38D1524348C9CA5AB63E7793EF6A7944C5A8D"); Botan::BigInt session_val("0x42C6518D6F338C050717427B18F7C6B6131C968B0CFC20C43AAAD61625F286DA55E24BF6A2CBDC79"); srp6::KeyType kt(session_val.bytes(), boost::container::default_init); - session_val.binary_encode(kt.data(), kt.size()); + session_val.serialize_to({ kt.data() + (kt.size() - session_val.bytes()), session_val.bytes() }); const srp6::SessionKey key(std::move(kt)); const std::array salt {