diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9676e456..dc8e9c884 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -165,7 +165,7 @@ jobs: ##### KOTLIN BUILD ##### build_kotlin: needs: setup_config - runs-on: "ubuntu-latest" + runs-on: "ubuntu-22.04" steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/native/native-build-linux/action.yml b/.github/workflows/native/native-build-linux/action.yml index 4446b49f5..299a64e1a 100644 --- a/.github/workflows/native/native-build-linux/action.yml +++ b/.github/workflows/native/native-build-linux/action.yml @@ -9,10 +9,6 @@ runs: name: config.txt path: ./wrappers/csharp - - uses: actions/setup-python@v5 - with: - python-version: "3.7" - - name: Installing dependencies shell: bash run: | @@ -44,7 +40,19 @@ runs: - name: Building Linux working-directory: ./wrappers/csharp shell: bash - run: python GeneratePackage.py -p linux + run: | + cargo build -p devolutions-crypto-ffi --release --target=i686-unknown-linux-gnu + cargo build -p devolutions-crypto-ffi --release --target=x86_64-unknown-linux-gnu + cargo build -p devolutions-crypto-ffi --release --target=aarch64-unknown-linux-gnu + + - name: Copy Linux Natives + shell: bash + run: | + mkdir ./wrappers/csharp/linux + + cp ./target/i686-unknown-linux-gnu/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/linux/libDevolutionsCrypto-x86.so + cp ./target/x86_64-unknown-linux-gnu/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/linux/libDevolutionsCrypto-x64.so + cp ./target/aarch64-unknown-linux-gnu/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/linux/libDevolutionsCrypto-arm64.so - name: Configure Android NDK shell: bash @@ -72,7 +80,8 @@ runs: ar = \"$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-ar\" linker = \"$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang\"" >> ./.cargo/config.toml - - name: Build Android package + + - name: Building Android working-directory: ./wrappers/csharp shell: bash run: | @@ -80,8 +89,26 @@ runs: export ANDROID_SDK_ROOT="${ANDROID_ROOT}/sdk" export ANDROID_NDK=$ANDROID_SDK_ROOT/ndk-bundle ln -sfn $ANDROID_SDK_ROOT/ndk/27.2.12479018 $ANDROID_NDK + + cargo build -p devolutions-crypto-ffi --release --target=aarch64-linux-android + cargo build -p devolutions-crypto-ffi --release --target=armv7-linux-androideabi + cargo build -p devolutions-crypto-ffi --release --target=i686-linux-android + cargo build -p devolutions-crypto-ffi --release --target=x86_64-linux-android + + - name: Copy Android Natives + shell: bash + run: | + mkdir ./wrappers/csharp/android + mkdir ./wrappers/csharp/android/aarch64 + mkdir ./wrappers/csharp/android/armv7 + mkdir ./wrappers/csharp/android/i686 + mkdir ./wrappers/csharp/android/x86_64 + + cp ./target/aarch64-linux-android/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/android/aarch64/libDevolutionsCrypto.so + cp ./target/armv7-linux-androideabi/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/android/armv7/libDevolutionsCrypto.so + cp ./target/i686-linux-android/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/android/i686/libDevolutionsCrypto.so + cp ./target/x86_64-linux-android/release/libdevolutions_crypto_ffi.so ./wrappers/csharp/android/x86_64/libDevolutionsCrypto.so - python GeneratePackage.py -p android - uses: actions/upload-artifact@v4.3.6 with: diff --git a/.github/workflows/native/native-build-macos/action.yml b/.github/workflows/native/native-build-macos/action.yml index 9f75689c1..38c3a8646 100644 --- a/.github/workflows/native/native-build-macos/action.yml +++ b/.github/workflows/native/native-build-macos/action.yml @@ -42,23 +42,33 @@ runs: source $HOME/.cargo/env cargo test - - name: Building Mac Modern + - name: Build macOS Natives working-directory: ./wrappers/csharp shell: bash run: | - source $HOME/.cargo/env - python3 GeneratePackage.py -p mac-modern + cargo build -p devolutions-crypto-ffi --release --target=x86_64-apple-darwin + cargo build -p devolutions-crypto-ffi --release --target=aarch64-apple-darwin + + - name: Copy macOS Natives + shell: bash + run: | + mkdir ./wrappers/csharp/macos + mkdir ./wrappers/csharp/macos/x86_64 + mkdir ./wrappers/csharp/macos/aarch64 + + cp ./target/x86_64-apple-darwin/release/libdevolutions_crypto_ffi.dylib ./wrappers/csharp/macos/x86_64/libDevolutionsCrypto.dylib + cp ./target/aarch64-apple-darwin/release/libdevolutions_crypto_ffi.dylib ./wrappers/csharp/macos/aarch64/libDevolutionsCrypto.dylib - name: Prepare folder structure working-directory: ./ shell: bash run: | - mv wrappers/csharp/macos-modern wrappers/csharp/macos-modern-temp - mkdir -p wrappers/csharp/macos-modern/macos-modern - mv wrappers/csharp/macos-modern-temp/* wrappers/csharp/macos-modern/macos-modern/ - rmdir wrappers/csharp/macos-modern-temp + mv wrappers/csharp/macos wrappers/csharp/macos-temp + mkdir -p wrappers/csharp/macos/macos + mv wrappers/csharp/macos-temp/* wrappers/csharp/macos/macos/ + rmdir wrappers/csharp/macos-temp - uses: actions/upload-artifact@v4.3.6 with: name: native-macos - path: wrappers/csharp/macos-modern/ + path: wrappers/csharp/macos/ diff --git a/.github/workflows/native/native-build-windows/action.yml b/.github/workflows/native/native-build-windows/action.yml index a69cea091..05bf20890 100644 --- a/.github/workflows/native/native-build-windows/action.yml +++ b/.github/workflows/native/native-build-windows/action.yml @@ -9,16 +9,6 @@ runs: name: config.txt path: ./wrappers/csharp - - uses: actions/setup-python@v5 - with: - python-version: "3.7" - - - name: Setting up PATH environment variable - shell: bash - run: | - ls "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Roslyn" - echo "c:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Roslyn" >> $GITHUB_PATH - - name: Installing rust targets shell: bash run: | @@ -33,17 +23,33 @@ runs: run: | cargo test - - name: Building WIN + - name: Build Windows Natives working-directory: ./wrappers/csharp shell: bash run: | - python GeneratePackage.py -p windows + cargo build -p devolutions-crypto-ffi --release --target=x86_64-pc-windows-msvc + cargo build -p devolutions-crypto-ffi --release --target=i686-pc-windows-msvc + cargo build -p devolutions-crypto-ffi --release --target=aarch64-pc-windows-msvc + + - name: Copy Windows Natives + shell: bash + run: | + mkdir ./wrappers/csharp/windows + + cp ./target/x86_64-pc-windows-msvc/release/devolutions_crypto_ffi.dll ./wrappers/csharp/windows/DevolutionsCrypto-x64.dll + cp ./target/i686-pc-windows-msvc/release/devolutions_crypto_ffi.dll ./wrappers/csharp/windows/DevolutionsCrypto-x86.dll + cp ./target/aarch64-pc-windows-msvc/release/devolutions_crypto_ffi.dll ./wrappers/csharp/windows/DevolutionsCrypto-arm64.dll - name: Building DOTNET CORE working-directory: ./wrappers/csharp shell: bash run: | - python GeneratePackage.py -p dotnet-core + VERSION_MANAGED=$(grep 'version' config.txt | cut -d '=' -f2 | tr -d ' "') + VERSION_NATIVE=$(grep 'package.version = "' ../../Cargo.toml | cut -d '"' -f2) + + sed -i -e "s/||MANAGED_VERSION||/${VERSION_MANAGED}/g" -e "s/||NATIVE_VERSION||/${VERSION_NATIVE}/g" ./src/Native.cs + + dotnet build ./src/devolutions-crypto.csproj -p:Version="$VERSION_MANAGED" --configuration Release --output ./dotnet-core/bin - uses: actions/upload-artifact@v4.3.6 with: diff --git a/.github/workflows/python/build/linux/action.yml b/.github/workflows/python/build/linux/action.yml index 94149a355..f0db43d78 100644 --- a/.github/workflows/python/build/linux/action.yml +++ b/.github/workflows/python/build/linux/action.yml @@ -4,19 +4,22 @@ runs: steps: - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.13" - name: Installing dependencies shell: bash run: | sudo apt-get update sudo apt-get install nuget gcc-multilib software-properties-common + sudo apt-get install -y gcc-aarch64-linux-gnu - name: Install rust shell: bash run: | rustup update rustup target add x86_64-unknown-linux-gnu + rustup target add i686-unknown-linux-gnu + rustup target add aarch64-unknown-linux-gnu - name: Install Maturin working-directory: ./python @@ -28,50 +31,61 @@ runs: working-directory: "./python" shell: bash + - name: Building 3.13 wheel + working-directory: ./python + shell: bash + run: | + maturin build -i 3.13 --release --target=x86_64-unknown-linux-gnu + maturin build -i 3.13 --release --target=i686-unknown-linux-gnu + maturin build -i 3.13 --release --target=aarch64-unknown-linux-gnu + - uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Building x86_64 3.12 Wheel + - name: Building 3.12 wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-unknown-linux-gnu + run: | + maturin build -i 3.12 --release --target=x86_64-unknown-linux-gnu + maturin build -i 3.12 --release --target=i686-unknown-linux-gnu + maturin build -i 3.12 --release --target=aarch64-unknown-linux-gnu - uses: actions/setup-python@v5 with: python-version: "3.11" - - name: Building x86_64 3.11 Wheel + - name: Building 3.11 Wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-unknown-linux-gnu + run: | + maturin build -i 3.11 --release --target=x86_64-unknown-linux-gnu + maturin build -i 3.11 --release --target=i686-unknown-linux-gnu + maturin build -i 3.11 --release --target=aarch64-unknown-linux-gnu - uses: actions/setup-python@v5 with: python-version: "3.10" - - name: Building x86_64 3.10 Wheel + - name: Building 3.10 Wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-unknown-linux-gnu + run: | + maturin build -i 3.10 --release --target=x86_64-unknown-linux-gnu + maturin build -i 3.10 --release --target=i686-unknown-linux-gnu + maturin build -i 3.10 --release --target=aarch64-unknown-linux-gnu - uses: actions/setup-python@v5 with: python-version: "3.9" - - name: Building x86_64 3.9 Wheel + - name: Building 3.9 Wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-unknown-linux-gnu - - - uses: actions/setup-python@v5 - with: - python-version: "3.8" - - - name: Building x86_64 3.8 Wheel - working-directory: ./python - shell: bash - run: maturin build -i python --release --target=x86_64-unknown-linux-gnu + run: | + maturin build -i 3.9 --release --target=x86_64-unknown-linux-gnu + maturin build -i 3.9 --release --target=i686-unknown-linux-gnu + maturin build -i 3.9 --release --target=aarch64-unknown-linux-gnu - name: Place Artifacts shell: bash diff --git a/.github/workflows/python/build/macos/action.yml b/.github/workflows/python/build/macos/action.yml index 3c33b5180..4d3d1ff26 100644 --- a/.github/workflows/python/build/macos/action.yml +++ b/.github/workflows/python/build/macos/action.yml @@ -4,7 +4,7 @@ runs: steps: - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.13" - name: Install rust shell: bash @@ -15,79 +15,73 @@ runs: source $HOME/.cargo/env rustup target add x86_64-apple-darwin + rustup target add aarch64-apple-darwin - name: Install maturin working-directory: ./python shell: bash - run: pip install maturin - - - uses: actions/setup-python@v5 - with: - python-version: "3.12" + run: pip install maturin --disable-pip-version-check - - name: Building aarch64 3.12 Wheel + - name: Building 3.13 Wheel working-directory: ./python shell: bash run: | source $HOME/.cargo/env - maturin build --release -i python --target=aarch64-apple-darwin - - - name: Building x86_64 3.12 Wheel - working-directory: ./python - shell: bash - run: | - source $HOME/.cargo/env - - maturin build --release -i python --target=x86_64-apple-darwin + maturin build --release -i 3.13 --target=x86_64-apple-darwin + maturin build --release -i 3.13 --target=aarch64-apple-darwin - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - - name: Building x86_64 3.11 Wheel + - name: Building 3.12 Wheel working-directory: ./python shell: bash run: | source $HOME/.cargo/env - maturin build --release -i python --target=x86_64-apple-darwin + maturin build --release -i 3.12 --target=x86_64-apple-darwin + maturin build --release -i 3.12 --target=aarch64-apple-darwin - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - - name: Building x86_64 3.10 Wheel + - name: Building 3.11 Wheel working-directory: ./python shell: bash - run: + run: | source $HOME/.cargo/env - maturin build --release -i python --target=x86_64-apple-darwin + maturin build --release -i 3.11 --target=x86_64-apple-darwin + maturin build --release -i 3.11 --target=aarch64-apple-darwin - uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.10" - - name: Building x86_64 3.9 Wheel + - name: Building 3.10 Wheel working-directory: ./python shell: bash run: | source $HOME/.cargo/env - maturin build --release -i python --target=x86_64-apple-darwin + maturin build --release -i 3.10 --target=x86_64-apple-darwin + maturin build --release -i 3.10 --target=aarch64-apple-darwin - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.9" - - name: Building x86_64 3.8 Wheel + - name: Building 3.9 Wheel working-directory: ./python shell: bash run: | source $HOME/.cargo/env - maturin build --release -i python --target=x86_64-apple-darwin + maturin build --release -i 3.9 --target=x86_64-apple-darwin + maturin build --release -i 3.9 --target=aarch64-apple-darwin - name: Place Artifacts shell: bash diff --git a/.github/workflows/python/build/windows/action.yml b/.github/workflows/python/build/windows/action.yml index e086dbfce..06e20dfa1 100644 --- a/.github/workflows/python/build/windows/action.yml +++ b/.github/workflows/python/build/windows/action.yml @@ -4,7 +4,7 @@ runs: steps: - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.13" - name: Setting up PATH environment variable shell: bash @@ -12,64 +12,131 @@ runs: - name: Installing rust targets shell: bash - run: rustup target add x86_64-pc-windows-msvc + run: | + rustup target add i686-pc-windows-msvc + rustup target add aarch64-pc-windows-msvc + rustup target add x86_64-pc-windows-msvc - name: Install maturin working-directory: ./python shell: bash run: pip install maturin + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + architecture: "x86" + + - name: Building i686 3.13 wheel + working-directory: ./python + shell: bash + run: maturin build -i 3.13 --release --target=i686-pc-windows-msvc + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + architecture: "x64" + + - name: Building x86_64, aarch64 3.13 wheel + working-directory: ./python + shell: bash + run: | + maturin build -i 3.13 --release --target=x86_64-pc-windows-msvc + maturin build -i 3.13 --release --target=aarch64-pc-windows-msvc + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + architecture: "x86" + + - name: Building i686 3.12 wheel + working-directory: ./python + shell: bash + run: maturin build -i 3.12 --release --target=i686-pc-windows-msvc + - uses: actions/setup-python@v5 with: python-version: "3.12" + architecture: "x64" - - name: Building x86_64 3.12 + - name: Building x86_64, aarch64 3.12 wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-pc-windows-msvc + run: | + maturin build -i 3.12 --release --target=x86_64-pc-windows-msvc + maturin build -i 3.12 --release --target=aarch64-pc-windows-msvc - uses: actions/setup-python@v5 with: python-version: "3.11" + architecture: "x86" - - name: Building x86_64 3.11 + - name: Building i686 3.11 wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-pc-windows-msvc + run: maturin build -i 3.11 --release --target=i686-pc-windows-msvc + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + architecture: "x64" + + - name: Building x86_64, aarch64 3.11 wheel + working-directory: ./python + shell: bash + run: | + maturin build -i 3.11 --release --target=x86_64-pc-windows-msvc + maturin build -i 3.11 --release --target=aarch64-pc-windows-msvc - uses: actions/setup-python@v5 with: python-version: "3.10" + architecture: "x86" - - name: Building x86_64 3.10 + - name: Building i686 3.10 wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-pc-windows-msvc + run: maturin build -i 3.10 --release --target=i686-pc-windows-msvc + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + architecture: "x64" + + - name: Building x86_64, aarch64 3.10 wheel + working-directory: ./python + shell: bash + run: | + maturin build -i 3.10 --release --target=x86_64-pc-windows-msvc + maturin build -i 3.10 --release --target=aarch64-pc-windows-msvc - uses: actions/setup-python@v5 with: python-version: "3.9" + architecture: "x86" - - name: Building x86_64 3.9 + - name: Building i686 3.9 wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-pc-windows-msvc + run: maturin build -i 3.9 --release --target=i686-pc-windows-msvc - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.9" + architecture: "x64" - - name: Building x86_64 3.8 + - name: Building x86_64, aarch64 3.9 wheel working-directory: ./python shell: bash - run: maturin build -i python --release --target=x86_64-pc-windows-msvc + run: | + maturin build -i 3.9 --release --target=x86_64-pc-windows-msvc + maturin build -i 3.9 --release --target=aarch64-pc-windows-msvc - name: Place Artifacts shell: bash - run: | - mv target/wheels/*.whl . + run: mv target/wheels/*.whl . - - uses: actions/upload-artifact@v4.3.6 + - uses: actions/upload-artifact@v4 with: name: python-wheels-windows path: ./*.whl diff --git a/.gitignore b/.gitignore index faa94f2e4..b3c0c3323 100644 --- a/.gitignore +++ b/.gitignore @@ -11,13 +11,13 @@ wrappers/csharp/nuget/dotnet/package/* wrappers/csharp/nuget/Android/Devolutions.Crypto.Android/package/* wrappers/csharp/nuget/iOS/Devolutions.Crypto.iOS/package/* wrappers/csharp/nuget/macOS/Devolutions.Crypto.Mac/package/* -wrappers/csharp/windows/bin -wrappers/csharp/ios/bin -wrappers/csharp/android/bin -wrappers/csharp/linux/bin -wrappers/csharp/macos-full/bin -wrappers/csharp/macos-modern/bin -wrappers/csharp/dotnet-core/bin +wrappers/csharp/windows/ +wrappers/csharp/ios/ +wrappers/csharp/android/ +wrappers/csharp/linux/ +wrappers/csharp/macos-full/ +wrappers/csharp/macos/ +wrappers/csharp/dotnet-core/ wrappers/csharp/tests/unit-tests/manual/dotnet-framework/bin/ wrappers/csharp/tests/unit-tests/manual/dotnet-core/bin/ target/ @@ -30,3 +30,4 @@ node_modules __pycache__ config.txt .github/hooks +TestResults diff --git a/Cargo.lock b/Cargo.lock index 97e47fd6c..29640f56e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aead" @@ -194,12 +194,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - [[package]] name = "blahaj" version = "0.6.0" @@ -377,7 +371,7 @@ version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.89", @@ -686,12 +680,6 @@ dependencies = [ "foldhash", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -770,16 +758,6 @@ dependencies = [ "cc", ] -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.22" @@ -876,29 +854,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "paste" version = "1.0.15" @@ -977,15 +932,15 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "57fe09249128b3173d092de9523eaa75136bf7ba85e0d69eca241c7939c933cc" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -995,19 +950,20 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "1cd3927b5a78757a0d71aa9dff669f903b1eb64b54142a9bd9f757f8fde65fd7" dependencies = [ "once_cell", + "python3-dll-a", "target-lexicon", ] [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d" dependencies = [ "libc", "pyo3-build-config", @@ -1015,9 +971,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "91871864b353fd5ffcb3f91f2f703a22a9797c91b9ab497b1acac7b07ae509c7" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -1027,17 +983,26 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "43abc3b80bc20f3facd86cd3c60beed58c3e2aa26213f3cda368de39c60a27e4" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "pyo3-build-config", "quote", "syn 2.0.89", ] +[[package]] +name = "python3-dll-a" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b66f9171950e674e64bad3456e11bb3cca108e5c34844383cfe277f45c8a7a8" +dependencies = [ + "cc", +] + [[package]] name = "quote" version = "1.0.37" @@ -1077,15 +1042,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" -dependencies = [ - "bitflags", -] - [[package]] name = "rust-argon2" version = "1.0.1" @@ -1143,12 +1099,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "scroll" version = "0.12.0" @@ -1264,12 +1214,6 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - [[package]] name = "smawk" version = "0.3.2" @@ -1313,7 +1257,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -1491,7 +1435,7 @@ dependencies = [ "fs-err", "glob", "goblin", - "heck 0.5.0", + "heck", "once_cell", "paste", "serde", diff --git a/python/Cargo.toml b/python/Cargo.toml index 66f92e104..edacc6a48 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -13,4 +13,4 @@ crate-type = ["cdylib"] devolutions-crypto = { path = "../" } zeroize = "1" base64 = "0.21" -pyo3 = { version = "0.20", features = ["extension-module"] } +pyo3 = { version = "0.23", features = ["extension-module", "generate-import-lib"] } diff --git a/python/src/lib.rs b/python/src/lib.rs index e9794befd..9a193aeb7 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -42,7 +42,7 @@ type Result = std::result::Result; #[pymodule] #[pyo3(name = "devolutions_crypto")] -fn devolutions_crypto_module(py: Python, m: &PyModule) -> PyResult<()> { +fn devolutions_crypto_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { #[pyfn(m)] #[pyo3(name = "encrypt")] #[pyo3(signature = (data, key, aad=None, version=0))] @@ -125,7 +125,9 @@ fn devolutions_crypto_module(py: Python, m: &PyModule) -> PyResult<()> { fn verify_password(py: Python, password: &[u8], hash: &[u8]) -> Result> { let res = devolutions_crypto::password_hash::PasswordHash::try_from(hash)?; - Ok(PyBool::new(py, res.verify_password(password)).into()) + Ok(PyBool::new(py, res.verify_password(password)) + .to_owned() + .into()) } #[pyfn(m)] @@ -214,7 +216,9 @@ fn devolutions_crypto_module(py: Python, m: &PyModule) -> PyResult<()> { let public_key = SigningPublicKey::try_from(public_key)?; let signature = Signature::try_from(signature)?; - Ok(PyBool::new(py, signature.verify(data, &public_key)).into()) + Ok(PyBool::new(py, signature.verify(data, &public_key)) + .to_owned() + .into()) } #[pyfn(m)] diff --git a/wrappers/csharp/GeneratePackage.py b/wrappers/csharp/GeneratePackage.py deleted file mode 100644 index afe8035dd..000000000 --- a/wrappers/csharp/GeneratePackage.py +++ /dev/null @@ -1,394 +0,0 @@ -import argparse -import platform -import sys -import subprocess -import os -import datetime -import time -import shutil -import shlex - -# Assembly manifest template -assembly_manifest_template = """ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - - -[assembly: AssemblyTitle("DevolutionsCrypto")] -[assembly: AssemblyCompany("Devolutions Inc.")] -[assembly: AssemblyCopyright("Copyright © ||YEAR||")] - -[assembly: AssemblyVersion("||VERSION||")] -""" -config_path = "./config.txt" - -def exec_command(command, cwd="."): - args = shlex.split(command) - process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8", cwd=cwd) - - output = "" - - if(process.stdout != None): - output = process.stdout + "\r\n" - - if(process.stderr != None): - output = output + process.stderr - - return output - -def generate_manifest(): - print("Generating assembly manifest...") - # Generate assembly manifest with the right version - with open(config_path, 'r') as file: - data=file.read() - version_managed = data.split("version = \"")[1].split("\"", 1)[0] - - assembly_manifest = assembly_manifest_template.replace("||YEAR||", str(datetime.datetime.now().year)) - assembly_manifest = assembly_manifest.replace("||VERSION||", version_managed) - return (assembly_manifest, version_managed) - -def version_live_change(): - print("Changing version manifest...") - # Generate assembly manifest with the right version - with open(config_path, 'r') as file: - data=file.read() - print(data) - version_managed = data.split("version = \"")[1].split("\"", 1)[0] - - with open('../../Cargo.toml', 'r') as file: - data=file.read() - version_native = data.split("version = \"")[1].split("\"", 1)[0] - - with open('./src/Native.cs', 'r+') as file: - data=file.read() - file.seek(0) - data = data.replace("||MANAGED_VERSION||", version_managed) - data = data.replace("||NATIVE_VERSION||", version_native) - file.write(data) - file.truncate() - -def build_native(architectures, target_folder, manifest=None, clean=True): - - if clean: - try: - shutil.rmtree(target_folder) - except: - pass - - try: - os.mkdir(target_folder) - except: - pass - - try: - os.mkdir(target_folder + "/bin") - except: - pass - - - if manifest: - with open(target_folder + "/bin/AssemblyInfo.cs","w+") as file: - file.write(manifest) - - for arch in architectures: - print("Starting build for " + arch["name"]) - - try: - shutil.rmtree("../../target/" + arch["value"] + "/release") - except: - pass - - - print("Building Native Libraries...") - - command = "cargo build --release --target " + arch["value"] - if arch.get("manifest_path"): - command = command + " --manifest-path " + arch.get("manifest_path") - - output = exec_command(command, "../../ffi/") - print(output) - - os.mkdir(target_folder + "/bin/" + arch["name"]) - - shutil.copy(arch["cargo_output"], target_folder + "/bin/" + arch["filename"]) - -def ensure_config(): - if(not os.path.exists(config_path)): - with open(config_path, "w") as file: - today = datetime.datetime.today() - file.write("version = \"" + today.strftime("%Y.%m.%d") + "\"") - -def main(): - platforms = { - "windows": build_windows, - "dotnet-core": build_dotnet_core, - "linux": build_linux, - "mac-modern": build_mac_modern, - "android": build_android, - } - - parser = argparse.ArgumentParser() - - parser.add_argument("-p", "--platform", default=platform.system().lower(), - choices=platforms.keys(), - help="The platform to build for.") - - parser.add_argument("-o", "--output", default=None, help="Output folder") - - parser.add_argument("--no-64", action="store_true", default=False, help="Don't build the 64 bit version of the library") - parser.add_argument("--no-32", action="store_true", default=False, help="Don't build the 32 bit version of the library") - - args = parser.parse_args() - - if(args.platform == "darwin"): - args.platform = "mac-modern" - - - script_dir = os.path.dirname(os.path.abspath(__file__)) - print("script directory :") - print(script_dir) - - os.chdir(script_dir) - - ensure_config() - - (assembly_manifest, version) = generate_manifest() - version_live_change() - - platforms.get(args.platform)(assembly_manifest, version, args) - print("Done") - -def build_windows(assembly_manifest, version, args): - output = exec_command("csc") - print("output") - - if("is not recognized as an internal or external command" in output): - print("error : make sure you have csc (c# compiler) configured in your path") - exit(1) - - - architectures = [] - - if not args.no_32: - architectures.append({"name" : "x86", "value" : "i686-pc-windows-msvc"}) - - if not args.no_64: - architectures.append({"name" : "x64", "value" : "x86_64-pc-windows-msvc"}) - architectures.append({"name" : "arm64", "value" : "aarch64-pc-windows-msvc"}) - - folder = "windows" - - # Loop because permission issues on windows - print("Detecting if " +folder +" directory is present...") - while(os.path.isdir("./" + folder)): - print("Deleting " + folder + " directory...") - try: - shutil.rmtree("./" + folder) - except: - print("Access denied...Retrying") - time.sleep(1) - - - while(not os.path.isdir("./" + folder)): - try: - print("Creating " + folder + " directory...") - os.mkdir("./" + folder) - os.mkdir("./" + folder + "/bin") - except: - print("Access denied...Retrying") - time.sleep(1) - - with open("./" + folder + "/bin/AssemblyInfo.cs","wb+") as filee: - filee.write(assembly_manifest.encode("utf-8")) - - for arch in architectures: - print("Starting build for " + arch["name"]) - - try: - shutil.rmtree("../../target/" + arch["value"] + "/release") - except: - pass - - - print("Building Native Libraries...") - - output = exec_command("cargo build --release --target " + arch["value"], "../../ffi") - print(output) - - dllpath = "./" + folder + "/bin/DevolutionsCrypto-" + arch["name"] + ".dll" - - shutil.copy("../../target/" + arch["value"] + "/release/devolutions_crypto_ffi.dll", dllpath) - - output = exec_command("./tools/rcedit-x64.exe " + dllpath + " --set-file-version " + version) - print(output) - - print("Building Managed Library...") - - define = "-define:WIN" - - output = exec_command("csc -out:./" + folder + "/bin/Devolutions.Crypto.dll -debug:pdbonly -pdb:./" + folder + "/bin/Devolutions.Crypto.pdb -target:library -platform:anycpu " + define + " src/*.cs ./" + folder + "/bin/AssemblyInfo.cs -optimize") - print(output) - - if("error" in output): - exit(1) - - os.remove("./" + folder + "/bin/AssemblyInfo.cs") - - -def build_dotnet_core(assembly_manifest, version, args): - output = exec_command("csc") - print("output") - - if("is not recognized as an internal or external command" in output): - print("error : make sure you have csc (c# compiler) configured in your path") - exit(1) - - folder = "dotnet-core" - - # Loop because permission issues on windows - print("Detecting if " +folder +" directory is present...") - while(os.path.isdir("./" + folder)): - print("Deleting " + folder + " directory...") - try: - shutil.rmtree("./" + folder) - except: - print("Access denied...Retrying") - time.sleep(1) - - - while(not os.path.isdir("./" + folder)): - try: - print("Creating " + folder + " directory...") - os.mkdir("./" + folder) - os.mkdir("./" + folder + "/bin") - except: - print("Access denied...Retrying") - time.sleep(1) - - with open("./" + folder + "/bin/AssemblyInfo.cs","wb+") as filee: - filee.write(assembly_manifest.encode("utf-8")) - - print("Building Native Libraries...") - - print("Skipping for .NET Core") - - print("Building Managed Library...") - - define = "-define:DOTNET_CORE" - - output = exec_command("csc -out:./" + folder + "/bin/Devolutions.Crypto.dll -debug:pdbonly -pdb:./" + folder + "/bin/Devolutions.Crypto.pdb -target:library -platform:anycpu " + define + " src/*.cs ./" + folder + "/bin/AssemblyInfo.cs -optimize") - print(output) - - if("error" in output): - exit(1) - - os.remove("./" + folder + "/bin/AssemblyInfo.cs") - - -def build_linux(assembly_manifest, version, args): - architectures = [] - - if not args.no_32: - architectures.append({"name" : "i686", - "value" : "i686-unknown-linux-gnu", - "cargo_output": "../../target/i686-unknown-linux-gnu/release/libdevolutions_crypto_ffi.so", - "filename" : "libDevolutionsCrypto-x86.so"}) - - if not args.no_64: - architectures.append({"name" : "x86_64", - "value" : "x86_64-unknown-linux-gnu", - "cargo_output": "../../target/x86_64-unknown-linux-gnu/release/libdevolutions_crypto_ffi.so", - "filename" : "libDevolutionsCrypto-x64.so"}) - - architectures.append({"name" : "aarch64", - "value" : "aarch64-unknown-linux-gnu", - "cargo_output": "../../target/aarch64-unknown-linux-gnu/release/libdevolutions_crypto_ffi.so", - "filename" : "libDevolutionsCrypto-arm64.so"}) - - target_folder = "./linux" - if args.output: - target_folder = args.output - - build_native(architectures, target_folder, manifest=assembly_manifest) - - print("Building Managed Library...") - - output = exec_command("csc -out:./linux/bin/Devolutions.Crypto.dll -debug:pdbonly -pdb:./linux/bin/Devolutions.Crypto.pdb -target:library -platform:anycpu -define:LINUX src/*.cs ./linux/bin/AssemblyInfo.cs -optimize") - print(output) - - if("error" in output): - exit(1) - - os.remove("./linux/bin/AssemblyInfo.cs") - -def build_mac_modern(assembly_manifest, version, args): - architectures = [ - #{"name" : "i686", "value" : "i686-apple-darwin"}, # no longer supported in stable (Tier 3) - { - "name" : "x86_64", - "value" : "x86_64-apple-darwin", - "cargo_output": "../../target/x86_64-apple-darwin/release/libdevolutions_crypto_ffi.dylib", - "filename" : "x86_64/libDevolutionsCrypto.dylib" - }, - { - "name" : "aarch64", - "value" : "aarch64-apple-darwin", - "cargo_output": "../../target/aarch64-apple-darwin/release/libdevolutions_crypto_ffi.dylib", - "filename" : "aarch64/libDevolutionsCrypto.dylib" - } - ] - - target_folder = "./macos-modern" - if args.output: - target_folder = args.output - - build_native(architectures, target_folder, clean=False) - - print("Making universal binary...") - - os.mkdir("./macos-modern/bin/universal") - - libs = " " - - for arch in architectures: - libs = libs + " ./macos-modern/bin/" + arch["name"] + "/" + "libDevolutionsCrypto.dylib" - - args = "lipo -create" - args = args + libs - args = args + " -output ./macos-modern/bin/universal/libDevolutionsCrypto.dylib" - - output = exec_command(args) - print(output) - - if("error" in output): - exit(1) - -def build_android(assembly_manifest, version, args): - architectures = [ - {"name" : "aarch64", - "value" : "aarch64-linux-android", - "cargo_output": "../../target/aarch64-linux-android/release/libdevolutions_crypto_ffi.so", - "filename" : "aarch64/libDevolutionsCrypto.so"}, - {"name" : "armv7", - "value" : "armv7-linux-androideabi", - "cargo_output": "../../target/armv7-linux-androideabi/release/libdevolutions_crypto_ffi.so", - "filename" : "armv7/libDevolutionsCrypto.so"}, - {"name" : "i686", - "value" : "i686-linux-android", - "cargo_output": "../../target/i686-linux-android/release/libdevolutions_crypto_ffi.so", - "filename" : "i686/libDevolutionsCrypto.so"}, - {"name" : "x86_64", - "value" : "x86_64-linux-android", - "cargo_output": "../../target/x86_64-linux-android/release/libdevolutions_crypto_ffi.so", - "filename" : "x86_64/libDevolutionsCrypto.so"} - ] - - target_folder = "./android" - if args.output: - target_folder = args.output - - build_native(architectures, target_folder) - -if __name__=="__main__": - main() diff --git a/wrappers/csharp/SetupAndBuild.py b/wrappers/csharp/SetupAndBuild.py deleted file mode 100644 index 7309d6267..000000000 --- a/wrappers/csharp/SetupAndBuild.py +++ /dev/null @@ -1,71 +0,0 @@ -import subprocess -import sys -import shutil -import os -import stat -import time - -script_dir = os.path.dirname(os.path.abspath(__file__)) -print("script directory :") -print(script_dir) - -os.chdir(script_dir) - -def get_output(args, cwd=None): - try: - result = subprocess.check_output(args, cwd=cwd, stderr=subprocess.STDOUT).decode(sys.stdout.encoding).strip() - return result - except subprocess.CalledProcessError as exc: - result = exc.output.decode(sys.stdout.encoding).strip() - return result - -version = "" - -with open('../../Cargo.toml', 'r') as filee: - data=filee.read() - version = data.split("version = \"")[1].split("\"", 1)[0] - -platform = sys.platform - -if(platform == "win32" or platform == "win64"): - print("Building native and managed library") - print("===================================") - output = get_output(["python", "./GeneratePackage.py", "-p", "windows"]) - print(output) - - if("Access is denied" in output or "error : make sure you have csc (c# compiler) configured in your path" in output): - exit(1) - - print("Generating nuget package") - print("========================") - output = get_output(["python", "./GenerateNuget.py", "WIN"], cwd="./nuget") - print(output) - - # Loop because permission issues on windows - print("Detecting if Nugets directory is present...") - while(os.path.isdir("./unit-tests/Nugets")): - print("Deleting Nugets directory...") - try: - shutil.rmtree("./unit-tests/Nugets") - except: - print("Access denied...Retrying") - time.sleep(1) - - while(not os.path.isdir("./unit-tests/Nugets")): - try: - print("Creating Nugets directory...") - os.mkdir("./unit-tests/Nugets") - except: - print("Access denied...Retrying") - time.sleep(1) - - shutil.copyfile("./nuget/Windows/package/Devolutions.Crypto.Windows." + version + ".nupkg", "./unit-tests/nugets/Nugets/Devolutions.Crypto.Windows." + version + ".nupkg") - - output = get_output(["python", "./Test.py", "DOTNET-FRAMEWORK"], cwd="./unit-tests") - print(output) - -else: - print("this is only available on windows for now.") - exit(1) - - \ No newline at end of file diff --git a/wrappers/csharp/nuget/dotnet-core/Devolutions.Crypto.Core.nuspec b/wrappers/csharp/nuget/dotnet-core/Devolutions.Crypto.Core.nuspec index 3824477e6..aec67643c 100644 --- a/wrappers/csharp/nuget/dotnet-core/Devolutions.Crypto.Core.nuspec +++ b/wrappers/csharp/nuget/dotnet-core/Devolutions.Crypto.Core.nuspec @@ -16,27 +16,23 @@ - - - - - - - + + + - - - + + + - - + + @@ -47,10 +43,10 @@ - - - - + + + + diff --git a/wrappers/csharp/src/Native.Core.cs b/wrappers/csharp/src/Native.Core.cs index 449101c9e..903e8e631 100644 --- a/wrappers/csharp/src/Native.Core.cs +++ b/wrappers/csharp/src/Native.Core.cs @@ -1,6 +1,6 @@ // Xamarin and .NET Core bindings -#if ANDROID || IOS || MACOS || DOTNET_CORE +#if ANDROID || IOS || MACOS || NETCOREAPP || NETSTANDARD namespace Devolutions.Cryptography { using System; @@ -114,7 +114,7 @@ public static partial class Native internal static extern long VersionSizeNative(); [DllImport(LibName, EntryPoint = "ScryptSimple", CallingConvention = CallingConvention.Cdecl)] - internal static extern long ScryptSimple(byte[] password, UIntPtr passwordLength, byte[] salt, UIntPtr saltLength, byte logN, uint r, uint p, byte[] output, UIntPtr outputLength); + internal static extern long ScryptSimple(byte[] password, UIntPtr passwordLength, byte[] salt, UIntPtr saltLength, byte logN, uint r, uint p, byte[] output, UIntPtr outputLength); [DllImport(LibName, EntryPoint = "ScryptSimpleSize", CallingConvention = CallingConvention.Cdecl)] internal static extern long ScryptSimpleSize(); diff --git a/wrappers/csharp/src/Native.cs b/wrappers/csharp/src/Native.cs index bfcbac916..14dc016c1 100644 --- a/wrappers/csharp/src/Native.cs +++ b/wrappers/csharp/src/Native.cs @@ -24,7 +24,7 @@ public static partial class Native private const string LibName86 = "DevolutionsCrypto"; #endif -#if !ANDROID && !IOS && !MACOS && !WIN && !DOTNET_CORE +#if !ANDROID && !IOS && !MACOS && !WIN && !NETCOREAPP && !NETSTANDARD private const string LibName64 = "DevolutionsCrypto-x64"; private const string LibName86 = "DevolutionsCrypto-x86"; @@ -125,7 +125,7 @@ public static bool VerifyPassword(byte[] password, byte[] hash) return Managed.VerifyPassword(password, hash); } -#if !ANDROID && !IOS && !MACOS && !DOTNET_CORE +#if !ANDROID && !IOS && !MACOS && !NETCOREAPP && !NETSTANDARD internal static long GenerateSharedKeyNative(UIntPtr nbShares, UIntPtr threshold, UIntPtr size, IntPtr[] shares) { if (Environment.Is64BitProcess) diff --git a/wrappers/csharp/src/devolutions-crypto.csproj b/wrappers/csharp/src/devolutions-crypto.csproj index 7abd70389..ca0995b3b 100644 --- a/wrappers/csharp/src/devolutions-crypto.csproj +++ b/wrappers/csharp/src/devolutions-crypto.csproj @@ -1,43 +1,25 @@ - - - netstandard2.0 - devolutions_crypto - ../stylecop.ruleset - Devolutions.Crypto - - - - - DevolutionsCrypto-x86.dll - Always - - - - DevolutionsCrypto-x64.dll - Always - - - - libDevolutionsCrypto-x86.so - Always - - - - libDevolutionsCrypto-x64.so - Always - - - - libDevolutionsCrypto.dylib - Always - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + netstandard2.0 + devolutions_crypto + Devolutions.Crypto + + + + DevolutionsCrypto.dll + Always + + + libDevolutionsCrypto.so + Always + + + libDevolutionsCrypto.dylib + Always + + + + \ No newline at end of file diff --git a/wrappers/csharp/tests/unit-tests/TestArgon2Parameters.cs b/wrappers/csharp/tests/unit-tests/TestArgon2Parameters.cs index 83ba5826b..3082af3f5 100644 --- a/wrappers/csharp/tests/unit-tests/TestArgon2Parameters.cs +++ b/wrappers/csharp/tests/unit-tests/TestArgon2Parameters.cs @@ -6,7 +6,7 @@ namespace Devolutions.Crypto.Tests using System.IO; using Devolutions.Cryptography.Argon2; - + using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] diff --git a/wrappers/csharp/tests/unit-tests/TestLegacy.cs b/wrappers/csharp/tests/unit-tests/TestLegacy.cs index a62f996ac..c537346e4 100644 --- a/wrappers/csharp/tests/unit-tests/TestLegacy.cs +++ b/wrappers/csharp/tests/unit-tests/TestLegacy.cs @@ -1,4 +1,4 @@ -#pragma warning disable SA1600 // Elements should be documented +#pragma warning disable SA1600, SYSLIB0021, SYSLIB0041 namespace Devolutions.Crypto.Tests { @@ -146,4 +146,4 @@ public bool VerifyPassword(byte[] password, byte[] hash) } } } -#pragma warning restore SA1600 // Elements should be documented \ No newline at end of file +#pragma warning restore SA1600, SYSLIB0021, SYSLIB0041 \ No newline at end of file diff --git a/wrappers/csharp/tests/unit-tests/TestManaged.cs b/wrappers/csharp/tests/unit-tests/TestManaged.cs index a9fd4c089..6a1dcff62 100644 --- a/wrappers/csharp/tests/unit-tests/TestManaged.cs +++ b/wrappers/csharp/tests/unit-tests/TestManaged.cs @@ -76,13 +76,13 @@ public void DecryptWithPassword2_5() { try { - string encrytedDataAsBase64 = "DQwCAAAAAgDutPWBLPHG0+ocNw+Yzs6xygGOeOlNPOAjbYDdbJKjPRnEP8HuDN7Y3h3dCoH81Szf3tCf3mNf"; - string password = "testPa$$"; - byte[] decryptResult = Managed.DecryptWithPassword(encrytedDataAsBase64, password); - string decryptResultString = Utils.ByteArrayToUtf8String(decryptResult); - Assert.AreEqual(decryptResultString, "test Ciph3rtext"); + string encrytedDataAsBase64 = "DQwCAAAAAgDutPWBLPHG0+ocNw+Yzs6xygGOeOlNPOAjbYDdbJKjPRnEP8HuDN7Y3h3dCoH81Szf3tCf3mNf"; + string password = "testPa$$"; + byte[] decryptResult = Managed.DecryptWithPassword(encrytedDataAsBase64, password); + string decryptResultString = Utils.ByteArrayToUtf8String(decryptResult); + Assert.AreEqual(decryptResultString, "test Ciph3rtext"); } - catch(Exception ex) + catch (Exception ex) { Console.WriteLine(ex.InnerException?.Message); Console.WriteLine(ex.InnerException?.StackTrace); diff --git a/wrappers/csharp/tests/unit-tests/local/README.md b/wrappers/csharp/tests/unit-tests/local/README.md new file mode 100644 index 000000000..6c279c0be --- /dev/null +++ b/wrappers/csharp/tests/unit-tests/local/README.md @@ -0,0 +1,7 @@ +## To run tests locally + +``` +cargo build -p devolutions-crypto-ffi + +dotnet test ./wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.sln +``` \ No newline at end of file diff --git a/wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.csproj b/wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.csproj new file mode 100644 index 000000000..074546b9e --- /dev/null +++ b/wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.csproj @@ -0,0 +1,20 @@ + + + net9.0 + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.sln b/wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.sln new file mode 100644 index 000000000..f2250871b --- /dev/null +++ b/wrappers/csharp/tests/unit-tests/local/devolutions-crypto-tests/devolutions-crypto-tests.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "devolutions-crypto-tests", "devolutions-crypto-tests.csproj", "{2572533D-1305-403B-9FC5-351A86A3765A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "devolutions-crypto", "..\..\..\..\src\devolutions-crypto.csproj", "{D95FF36A-9165-4CD1-9618-F2733AD8B70D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2572533D-1305-403B-9FC5-351A86A3765A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2572533D-1305-403B-9FC5-351A86A3765A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2572533D-1305-403B-9FC5-351A86A3765A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2572533D-1305-403B-9FC5-351A86A3765A}.Release|Any CPU.Build.0 = Release|Any CPU + {D95FF36A-9165-4CD1-9618-F2733AD8B70D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D95FF36A-9165-4CD1-9618-F2733AD8B70D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D95FF36A-9165-4CD1-9618-F2733AD8B70D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D95FF36A-9165-4CD1-9618-F2733AD8B70D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/wrappers/csharp/tests/unit-tests/nugets/dotnet-core/dotnet-core.csproj b/wrappers/csharp/tests/unit-tests/nugets/dotnet-core/dotnet-core.csproj index 8e4ac284d..3d0ead7ba 100644 --- a/wrappers/csharp/tests/unit-tests/nugets/dotnet-core/dotnet-core.csproj +++ b/wrappers/csharp/tests/unit-tests/nugets/dotnet-core/dotnet-core.csproj @@ -8,7 +8,7 @@ - TRACE;DOTNET_CORE + TRACE