From 5a5bcd9f6e16a3da39cb370bbb4a8f335d8d22cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Corella?=
<39066999+josecorella@users.noreply.github.com>
Date: Tue, 21 Nov 2023 16:04:12 -0800
Subject: [PATCH] fix(ESDK): Head Auth logic and HKDF's info parameter (#621)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The ESDK-NET’s Message Header AAD
incorrectly appended two empty bytes
when using the DefaultCMM.
The HKDF invocation of non-committing algorithm suites
failed to include the Message ID in the info parameter.
Neither of these issues
effect the security of messages
written by the 4.0.0 release.
However,
these messages diverge
from the Encryption SDK Message Specification.
Thus:
* ESDK-NET v4.0.0 writes messages that only ESDK-NET v4.0.0 and greater can read.
* ESDK-NET v4.0.0 is ONLY able to read messages that are written by ESDK-NET v4.0.0
These issues are fixed in 4.0.1,
which writes messages according to the Encryption SDK Message Specification,
and are interoperable with other implementations of this library.
The option NetV4_RetryPolicy can be use to decrypt v4.0.0 messages.
See AwsEncryptionSDK/runtimes/net/Examples/NetV4_0_0Example.cs on how to use the NetV4_RetryPolicy
and details on distributed applications.
---
.github/CODEOWNERS | 5 -
.github/workflows/ci_static-analysis.yaml | 2 +-
.github/workflows/duvet.yaml | 2 +-
.../workflows/library_dafny_verification.yml | 2 +-
.github/workflows/library_java_tests.yml | 2 +-
.github/workflows/library_net_tests.yml | 234 +-
.gitmodules | 3 -
.../codebuild/release/release-staging.yml | 49 +
.../codebuild/release/test-prod.yml | 58 +
.../AwsCryptographyEncryptionSdkTypes.dfy | 620 ++--
.../dafny/AwsEncryptionSdk/Model/esdk.smithy | 19 +
.../src/AwsEncryptionSdkOperations.dfy | 88 +-
.../AwsEncryptionSdk/src/EncryptDecrypt.dfy | 2 +-
.../dafny/AwsEncryptionSdk/src/Index.dfy | 9 +-
.../AwsEncryptionSdk/src/KeyDerivation.dfy | 29 +-
.../src/Serialize/EncryptionContext.dfy | 42 +-
.../test/TestCreateEsdkClient.dfy | 93 +-
.../runtimes/net/Benchmarks/.gitignore | 3 -
.../AWSEncryptionSDKBenchmarks.csproj | 21 -
.../runtimes/net/Benchmarks/Benchmarks.cs | 158 -
.../runtimes/net/Benchmarks/README.md | 55 -
AwsEncryptionSDK/runtimes/net/CHANGELOG.md | 31 +
AwsEncryptionSDK/runtimes/net/ESDK.csproj | 2 +-
.../net/Examples/DiscoveryFilterExample.cs | 33 -
.../net/Examples/ExampleUtils/ExampleUtils.cs | 34 +
.../runtimes/net/Examples/NetV4_0_0Example.cs | 180 ++
.../resources/defaultRegionKmsKey.bin | Bin 797 -> 797 bytes
.../resources/defaultRegionMrkKey.bin | Bin 814 -> 814 bytes
.../resources/v4DefaultRegionKmsKey.bin | Bin 0 -> 797 bytes
.../resources/v4DefaultRegionMrkKey.bin | Bin 0 -> 814 bytes
.../AwsEncryptionSdkConfig.cs | 8 +
.../AwsEncryptionSdk/NetV4_0_0_RetryPolicy.cs | 17 +
.../Generated/AwsEncryptionSdk/OpaqueError.cs | 2 +-
.../AwsEncryptionSdk/TypeConversion.cs | 1364 ++++++--
AwsEncryptionSDK/runtimes/net/README.md | 40 +-
...AWSEncryptionSDKTestVectorGenerator.csproj | 9 +-
.../TestVectorGenerator/Generator.cs | 90 +-
.../TestVectorGenerator/README.md | 0
.../resources/0002-keys.v3.json | 0
...wses-message-decryption-generation.v2.json | 0
.../resources/net4x-generate-manifest.json | 2850 +++++++++++++++++
.../resources/net4x-keys.json | 44 +
.../resources/python-2.3.0_keys.json | 0
.../AWSEncryptionSDKTestVectorLib.csproj | 15 +
.../TestVectorLib/MaterialProviderFactory.cs | 91 +-
.../TestVectorLib/TestVectorTypes.cs | 99 +-
.../TestVectorLib/Utils.cs | 29 +
.../AWSEncryptionSDKTestVectors.csproj | 4 +-
.../TestVectors/README.md | 0
.../TestVectors/TestVectors.cs | 280 ++
.../resources/invalid-Net-4.0.0.zip | Bin 0 -> 328285 bytes
.../TestVectors/resources/valid-Net-4.0.0.zip | Bin 0 -> 68110 bytes
.../Test/AWSEncryptionSDKTests.csproj | 84 -
.../TestVectorsV3/Test/Extern/TestUtils.cs | 33 -
.../NativeWrappers/OutputValidationTests.cs | 142 -
.../TypeConversionToDafnyWrapperTest.cs | 52 -
.../AWSEncryptionSDKTestVectorLib.csproj | 13 -
.../TestVectorsV3/TestVectors/TestVectors.cs | 159 -
.../resources/aws-encryption-sdk-test-vectors | 1 -
SharedMakefileV2.mk | 9 +-
60 files changed, 5579 insertions(+), 1632 deletions(-)
delete mode 100644 .github/CODEOWNERS
delete mode 100644 AwsEncryptionSDK/runtimes/net/Benchmarks/.gitignore
delete mode 100644 AwsEncryptionSDK/runtimes/net/Benchmarks/AWSEncryptionSDKBenchmarks.csproj
delete mode 100644 AwsEncryptionSDK/runtimes/net/Benchmarks/Benchmarks.cs
delete mode 100644 AwsEncryptionSDK/runtimes/net/Benchmarks/README.md
create mode 100644 AwsEncryptionSDK/runtimes/net/Examples/NetV4_0_0Example.cs
create mode 100644 AwsEncryptionSDK/runtimes/net/Examples/resources/v4DefaultRegionKmsKey.bin
create mode 100644 AwsEncryptionSDK/runtimes/net/Examples/resources/v4DefaultRegionMrkKey.bin
create mode 100644 AwsEncryptionSDK/runtimes/net/Generated/AwsEncryptionSdk/NetV4_0_0_RetryPolicy.cs
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorGenerator/AWSEncryptionSDKTestVectorGenerator.csproj (66%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorGenerator/Generator.cs (67%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorGenerator/README.md (100%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorGenerator/resources/0002-keys.v3.json (100%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorGenerator/resources/0006-awses-message-decryption-generation.v2.json (100%)
create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorGenerator/resources/net4x-generate-manifest.json
create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorGenerator/resources/net4x-keys.json
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorGenerator/resources/python-2.3.0_keys.json (100%)
create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorLib/MaterialProviderFactory.cs (73%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorLib/TestVectorTypes.cs (62%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectorLib/Utils.cs (81%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectors/AWSEncryptionSDKTestVectors.csproj (93%)
rename AwsEncryptionSDK/runtimes/net/{TestVectorsV3 => TestVectorsNative}/TestVectors/README.md (100%)
create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs
create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/invalid-Net-4.0.0.zip
create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/valid-Net-4.0.0.zip
delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsV3/Test/AWSEncryptionSDKTests.csproj
delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsV3/Test/Extern/TestUtils.cs
delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsV3/Test/NativeWrappers/OutputValidationTests.cs
delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsV3/Test/NativeWrappers/TypeConversionToDafnyWrapperTest.cs
delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsV3/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj
delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsV3/TestVectors/TestVectors.cs
delete mode 160000 AwsEncryptionSDK/runtimes/net/TestVectorsV3/TestVectors/resources/aws-encryption-sdk-test-vectors
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
deleted file mode 100644
index 806891736..000000000
--- a/.github/CODEOWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-# Each line is a file pattern followed by one or more owners.
-# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
-
-# Default code owner for everything is our aws-crypto-tools group
-* @aws/aws-crypto-tools
diff --git a/.github/workflows/ci_static-analysis.yaml b/.github/workflows/ci_static-analysis.yaml
index 139c158cb..d08c5ea5b 100644
--- a/.github/workflows/ci_static-analysis.yaml
+++ b/.github/workflows/ci_static-analysis.yaml
@@ -1,7 +1,7 @@
# This workflow performs static analysis checks.
name: static analysis
-on: ["pull_request", "push"]
+on: ["pull_request"]
jobs:
not-grep:
diff --git a/.github/workflows/duvet.yaml b/.github/workflows/duvet.yaml
index bf278775b..db9513192 100644
--- a/.github/workflows/duvet.yaml
+++ b/.github/workflows/duvet.yaml
@@ -7,7 +7,7 @@ on:
pull_request:
push:
branches:
- - main
+ - public-v4
jobs:
duvet:
diff --git a/.github/workflows/library_dafny_verification.yml b/.github/workflows/library_dafny_verification.yml
index 33b734f23..33dc497c0 100644
--- a/.github/workflows/library_dafny_verification.yml
+++ b/.github/workflows/library_dafny_verification.yml
@@ -5,7 +5,7 @@ on:
pull_request:
push:
branches:
- - main
+ - public-v4
workflow_dispatch:
# Manual trigger for this workflow, either the normal version
# or the nightly build that uses the latest Dafny prerelease
diff --git a/.github/workflows/library_java_tests.yml b/.github/workflows/library_java_tests.yml
index 4c7e09f52..bba8a6723 100644
--- a/.github/workflows/library_java_tests.yml
+++ b/.github/workflows/library_java_tests.yml
@@ -5,7 +5,7 @@ on:
pull_request:
push:
branches:
- - main
+ - public-v4
schedule:
# Nightly build against Dafny's nightly prereleases,
# for early warning of verification issues or regressions.
diff --git a/.github/workflows/library_net_tests.yml b/.github/workflows/library_net_tests.yml
index 2f335f924..5f3c9fcb0 100644
--- a/.github/workflows/library_net_tests.yml
+++ b/.github/workflows/library_net_tests.yml
@@ -5,7 +5,7 @@ on:
pull_request:
push:
branches:
- - main
+ - public-v4
schedule:
# Nightly build against Dafny's nightly prereleases,
# for early warning of verification issues or regressions.
@@ -22,6 +22,8 @@ env:
AWS_ENCRYPTION_SDK_EXAMPLE_KMS_MRK_KEY_ID_2: arn:aws:kms:eu-west-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
AWS_ENCRYPTION_SDK_EXAMPLE_LIMITED_ROLE_ARN_US_EAST_1: arn:aws:iam::370957321024:role/GitHub-CI-ESDK-Dafny-Role-us-west-2
AWS_ENCRYPTION_SDK_EXAMPLE_LIMITED_ROLE_ARN_EU_WEST_1: arn:aws:iam::370957321024:role/GitHub-CI-ESDK-Dafny-Role-us-west-2
+ # Used for Test Vectors
+ VECTORS_URL: https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-2.3.0.zip
jobs:
testDotNet:
@@ -29,11 +31,6 @@ jobs:
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
strategy:
matrix:
- library: [
- AwsEncryptionSDK
- ]
- dotnet-version: [ '6.0.x' ]
- frameworks: [net6.0, net48]
os: [
windows-latest,
ubuntu-latest,
@@ -57,18 +54,18 @@ jobs:
run: |
git submodule update --init libraries
git submodule update --init --recursive mpl
-
+
- name: Configure AWS Credentials
- uses: aws-actions/configure-aws-credentials@v1
+ uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
- role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
+ role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-ESDK-Dafny-Role-us-west-2
role-session-name: NetTests
-
- - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
+
+ - name: Setup .NET Core SDK 6
uses: actions/setup-dotnet@v3
with:
- dotnet-version: ${{ matrix.dotnet-version }}
+ dotnet-version: '6.0.x'
- name: Setup Dafny
uses: dafny-lang/setup-dafny-action@v1.6.1
@@ -77,53 +74,208 @@ jobs:
dafny-version: ${{ (github.event_name == 'schedule' || inputs.nightly) && 'nightly-latest' || '4.2.0' }}
- name: Download Dependencies
- working-directory: ./${{ matrix.library }}
+ working-directory: ./AwsEncryptionSDK
run: make setup_net
- - name: Compile ${{ matrix.library }} implementation
+ - name: Compile AwsEncryptionSDK implementation
shell: bash
- working-directory: ./${{ matrix.library }}
+ working-directory: ./AwsEncryptionSDK
run: |
# This works because `node` is installed by default on GHA runners
CORES=$(node -e 'console.log(os.cpus().length)')
make transpile_net CORES=$CORES
- - name: Test ${{ matrix.library }} .NET Framework net48
- working-directory: ./${{ matrix.library }}
+ - name: Test .NET Framework net48
+ working-directory: ./AwsEncryptionSDK
+ shell: bash
+ run: |
+ make test_net FRAMEWORK=net48
+
+ - name: Test .NET net6.0
+ working-directory: ./AwsEncryptionSDK
+ shell: bash
+ run: |
+ if [ "$RUNNER_OS" == "macOS" ]; then
+ make test_net_mac_intel FRAMEWORK=net6.0
+ else
+ make test_net FRAMEWORK=net6.0
+ fi
+
+ - name: Test Examples on .NET Framework net48
+ working-directory: ./AwsEncryptionSDK
+ shell: bash
+ run: |
+ dotnet test \
+ runtimes/net/Examples \
+ --framework net48
+
+ - name: Test Examples on .NET net6.0
+ working-directory: ./AwsEncryptionSDK
shell: bash
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
- DYLD_LIBRARY_PATH="/usr/local/opt/openssl@1.1/lib"
- dotnet run \
- --project runtimes/net/tests/ \
- --framework net48
- else
- dotnet run \
- --project runtimes/net/tests/ \
- --framework net48
- fi
+ DYLD_LIBRARY_PATH="/usr/local/opt/openssl@1.1/lib"
+ dotnet test \
+ runtimes/net/Examples \
+ --framework net6.0
+ else
+ dotnet test \
+ runtimes/net/Examples \
+ --framework net6.0
+ fi
+
+ - name: Fetch awses-decrypt/python-2.3.0.zip
+ working-directory: ./
+ shell: bash
+ run: |
+ PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors
+ mkdir -p $PYTHON_23_VECTOR_PATH
+ DOWNLOAD_NAME=python23.zip
+ curl --no-progress-meter --output $DOWNLOAD_NAME --location $VECTORS_URL
+ unzip -o -qq $DOWNLOAD_NAME -d $PYTHON_23_VECTOR_PATH
+ rm $DOWNLOAD_NAME
- - name: Test ${{ matrix.library }}
- working-directory: ./${{ matrix.library }}
+ - name: Run Test Vectors on .NET Framework net48
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
shell: bash
run: |
+ PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \
+ dotnet test --framework net48
+
+ - name: Run Decrypt Test Vectors on .NET net6.0
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ shell: bash
+ run: |
+ PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors
if [ "$RUNNER_OS" == "macOS" ]; then
- make test_net_mac_intel
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \
+ DYLD_LIBRARY_PATH="/usr/local/opt/openssl@1.1/lib" \
+ dotnet test --framework net6.0
else
- make test_net
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \
+ dotnet test --framework net6.0
fi
- - name: Test Examples on ${{ matrix.frameworks }}
+ - name: Generate Test Vectors with .NET Framework net6.0
+ # TODO Post-#619: Fix Zip file creation on Windows
+ if: matrix.os != 'windows-latest'
+ working-directory: ./AwsEncryptionSDK
+ shell: bash
+ run: |
+ NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors
+ mkdir -p $NET_41_VECTOR_PATH
+ GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator
+ dotnet run --project $GEN_PATH --framework net6.0 -- \
+ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \
+ --output-dir $NET_41_VECTOR_PATH
+
+ # TODO: Fix Zip file creation on Windows
+ # - name: Zip the Generated Test Vectors for ESDK-JS on Windows
+ # if: matrix.os == 'windows-latest'
+ # shell: pwsh
+ # run: |
+ # # NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors
+ # Set-Location -Path "$env:GITHUB_WORKSPACE\net41\vectors"
+ # Compress-Archive -Path "$env:GITHUB_WORKSPACE\net41\vectors\*" -DestinationPath "$env:GITHUB_WORKSPACE\net41\vectors\net41.zip"
+
+ - name: Zip the Generated Test Vectors for ESDK-JS on Mac/Linux
+ if: matrix.os != 'windows-latest'
+ shell: bash
+ run: |
+ NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors
+ cd $NET_41_VECTOR_PATH
+ zip -qq net41.zip -r .
+
+ - name: Decrypt Generated Test Vectors with ESDK-JS
+ # TODO Post-#619: Fix Zip file creation on Windows
+ if: matrix.os != 'windows-latest'
+ shell: bash
+ run: |
+ NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors
+ cd $NET_41_VECTOR_PATH
+ npx -y @aws-crypto/integration-node decrypt -v $NET_41_VECTOR_PATH/net41.zip -c cpu
+
+ - name: Unzip ESDK-NET @ v4.0.0 Valid Vectors
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources
+ shell: bash
+ run: |
+ NET_400_VALID_VECTORS=$GITHUB_WORKSPACE/v4Net400Valid/vectors
+ mkdir -p $NET_400_VALID_VECTORS
+ DOWNLOAD_NAME=valid-Net-4.0.0.zip
+ unzip -o -qq $DOWNLOAD_NAME -d $NET_400_VALID_VECTORS
+
+ - name: Run ESDK-NET @ v4.0.0 Valid Vectors expect success
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ continue-on-error: true
+ shell: bash
+ run: |
+ NET_400_VALID_VECTORS=$GITHUB_WORKSPACE/v4Net400Valid/vectors
+ ESDK_NET_V400_POLICY="forbid" \
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_VALID_VECTORS/manifest.json" \
+ dotnet test --framework net48
+ ESDK_NET_V400_POLICY="forbid" \
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_VALID_VECTORS/manifest.json" \
+ dotnet test --framework net6.0 --logger "console;verbosity=quiet"
+
+ - name: Unzip ESDK-NET @ v4.0.0 Invalid Vectors
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources
shell: bash
- working-directory: ./${{ matrix.library }}
run: |
+ NET_400_INVALID_VECTORS=$GITHUB_WORKSPACE/v4Net400Invalid/vectors
+ mkdir -p $NET_400_INVALID_VECTORS
+ DOWNLOAD_NAME=invalid-Net-4.0.0.zip
+ unzip -o -qq $DOWNLOAD_NAME -d $NET_400_INVALID_VECTORS
+
+ - name: Run ESDK-NET @ v4.0.0 Invalid Vectors .NET 48 expect failure
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ continue-on-error: true
+ shell: bash
+ run: |
+ NET_400_INVALID_VECTORS=$GITHUB_WORKSPACE/v4Net400Invalid/vectors
+ ESDK_NET_V400_POLICY="forbid" \
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_INVALID_VECTORS/manifest.json" \
+ dotnet test --framework net48
+ # Dotnet test returns 1 for failure.
+ TEMP=$?; if [[ "$TEMP" -eq 1 ]]; then true; else false; fi;
+ # We want this to fail, so if it returned 1, step passes, else it fails
+ # TODO Post-#619: Refactor Test Vectors to expect failure,
+ # as I doubt this true false logic works
+
+ - name: Run ESDK-NET @ v4.0.0 Invalid Vectors .NET 6.0 expect failure
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ continue-on-error: true
+ shell: bash
+ run: |
+ NET_400_INVALID_VECTORS=$GITHUB_WORKSPACE/v4Net400Invalid/vectors
if [ "$RUNNER_OS" == "macOS" ]; then
- DYLD_LIBRARY_PATH="/usr/local/opt/openssl@1.1/lib"
- dotnet test \
- runtimes/net/Examples \
- --framework ${{ matrix.frameworks }}
- else
- dotnet test \
- runtimes/net/Examples \
- --framework ${{ matrix.frameworks }}
- fi
+ ESDK_NET_V400_POLICY="forbid" \
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_INVALID_VECTORS/manifest.json" \
+ DYLD_LIBRARY_PATH="/usr/local/opt/openssl@1.1/lib" \
+ dotnet test --framework net6.0
+ else
+ ESDK_NET_V400_POLICY="forbid" \
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_INVALID_VECTORS/manifest.json" \
+ dotnet test --framework net6.0
+ fi
+ # Dotnet test returns 1 for failure.
+ TEMP=$?; if [[ "$TEMP" -eq 1 ]]; then true; else false; fi;
+ # We want this to fail, so if it returned 1, step passes, else it fails
+ # TODO Post-#619: Refactor Test Vectors to expect failure,
+ # as I doubt this true false logic works
+
+ - name: Run ESDK-NET @ v4.0.0 Invalid Vectors .NET expect Success
+ working-directory: ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ shell: bash
+ run: |
+ NET_400_INVALID_VECTORS=$GITHUB_WORKSPACE/v4Net400Invalid/vectors
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_INVALID_VECTORS/manifest.json" \
+ dotnet test --framework net48 --logger "console;verbosity=quiet"
+ if [ "$RUNNER_OS" == "macOS" ]; then
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_INVALID_VECTORS/manifest.json" \
+ DYLD_LIBRARY_PATH="/usr/local/opt/openssl@1.1/lib" \
+ dotnet test --framework net6.0 --logger "console;verbosity=quiet"
+ else
+ DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$NET_400_INVALID_VECTORS/manifest.json" \
+ dotnet test --framework net6.0 --logger "console;verbosity=quiet"
+ fi
diff --git a/.gitmodules b/.gitmodules
index b36b1ceca..f2f326da7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -8,6 +8,3 @@
[submodule "mpl"]
path = mpl
url = https://github.com/aws/aws-cryptographic-material-providers-library-dafny.git
-[submodule "AwsEncryptionSDK/runtimes/net/TestVectorsV3/TestVectors/resources/aws-encryption-sdk-test-vectors"]
- path = AwsEncryptionSDK/runtimes/net/TestVectorsV3/TestVectors/resources/aws-encryption-sdk-test-vectors
- url = https://github.com/awslabs/aws-encryption-sdk-test-vectors.git
diff --git a/AwsEncryptionSDK/codebuild/release/release-staging.yml b/AwsEncryptionSDK/codebuild/release/release-staging.yml
index e81f75383..e6170ddc1 100644
--- a/AwsEncryptionSDK/codebuild/release/release-staging.yml
+++ b/AwsEncryptionSDK/codebuild/release/release-staging.yml
@@ -14,6 +14,9 @@ env:
arn:aws:iam::587316601012:role/GitHub-DotNet-KMS-US-East-1-Only
AWS_ENCRYPTION_SDK_EXAMPLE_LIMITED_ROLE_ARN_EU_WEST_1: >-
arn:aws:iam::587316601012:role/GitHub-DotNet-KMS-EU-West-1-Only
+ VECTORS_URL: >-
+ https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-2.3.0.zip
+
phases:
install:
@@ -26,6 +29,13 @@ phases:
- curl https://github.com/dafny-lang/dafny/releases/download/v4.2.0/dafny-4.2.0-x64-ubuntu-20.04.zip -L -o dafny.zip
- unzip -qq dafny.zip && rm dafny.zip
- export PATH="$PWD/dafny:$PATH"
+ # install mono to run net48 copied from
+ # https://www.mono-project.com/download/stable/#download-lin
+ - sudo apt install ca-certificates gnupg
+ - sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+ - echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
+ - sudo apt update
+ - sudo apt-get install mono-devel -y
# Switch back to the main directory
- cd private-aws-encryption-sdk-dafny-staging/AwsEncryptionSDK
pre_build:
@@ -72,3 +82,42 @@ phases:
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
- aws sts get-caller-identity
- make test_net
+
+ # add staged artifact to testvectors
+ - sed -i.backup "/\/d" runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj
+ - dotnet add runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj package AWS.Cryptography.EncryptionSDK --version $VERSION
+
+ # Fetch awses-decrypt/python-2.3.0.zip
+ - cd ../
+ - pwd
+ - export PYTHON_23_VECTOR_PATH=$(pwd)/python23/vectors
+ - mkdir -p $PYTHON_23_VECTOR_PATH
+ - export DOWNLOAD_NAME=python23.zip
+ - curl --no-progress-meter --output $DOWNLOAD_NAME --location $VECTORS_URL
+ - unzip -o -qq $DOWNLOAD_NAME -d $PYTHON_23_VECTOR_PATH
+ - rm $DOWNLOAD_NAME
+
+ # Run Decrypt Test Vectors on .NET Framework net48
+ - cd ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ - export DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \
+ - dotnet test --framework net48
+
+ # Run Decrypt Test Vectors on .NET net6.0
+ - dotnet test --framework net6.0
+
+ # Generate Test Vectors with .NET Framework net6.0
+ - cd ../../../../
+ - export NET_41_VECTOR_PATH=$(pwd)/net41/vectors
+ - mkdir -p $NET_41_VECTOR_PATH
+ - GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator
+ - >-
+ dotnet run --project $GEN_PATH --framework net6.0 -- \
+ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \
+ --output-dir $NET_41_VECTOR_PATH
+
+ # Zip the Generated Test Vectors for ESDK-JS on Mac/Linux
+ - cd $NET_41_VECTOR_PATH
+ - zip -qq net41.zip -r .
+
+ # Decrypt Generated Test Vectors with ESDK-JS
+ - npx -y @aws-crypto/integration-node decrypt -v $NET_41_VECTOR_PATH/net41.zip -c cpu
diff --git a/AwsEncryptionSDK/codebuild/release/test-prod.yml b/AwsEncryptionSDK/codebuild/release/test-prod.yml
index f111190de..9fba593e1 100644
--- a/AwsEncryptionSDK/codebuild/release/test-prod.yml
+++ b/AwsEncryptionSDK/codebuild/release/test-prod.yml
@@ -1,5 +1,10 @@
version: 0.2
+env:
+ variables:
+ VECTORS_URL: >-
+ https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-2.3.0.zip
+
phases:
install:
runtime-versions:
@@ -11,6 +16,13 @@ phases:
- curl https://github.com/dafny-lang/dafny/releases/download/v4.2.0/dafny-4.2.0-x64-ubuntu-20.04.zip -L -o dafny.zip
- unzip -qq dafny.zip && rm dafny.zip
- export PATH="$PWD/dafny:$PATH"
+ # install mono to run net48 copied from
+ # https://www.mono-project.com/download/stable/#download-lin
+ - sudo apt install ca-certificates gnupg
+ - sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+ - echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
+ - sudo apt update
+ - sudo apt-get install mono-devel -y
# Switch back to the main directory
- cd private-aws-encryption-sdk-dafny-staging/AwsEncryptionSDK
pre_build:
@@ -30,3 +42,49 @@ phases:
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
- aws sts get-caller-identity
- make test_net
+
+ # add released artifact to testvectors
+ - sed -i.backup "/\/d" runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj
+ - dotnet add runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj package AWS.Cryptography.EncryptionSDK --version $VERSION
+
+ # Fetch awses-decrypt/python-2.3.0.zip
+ - cd ../
+ - pwd
+ - export PYTHON_23_VECTOR_PATH=$(pwd)/python23/vectors
+ - mkdir -p $PYTHON_23_VECTOR_PATH
+ - export DOWNLOAD_NAME=python23.zip
+ - curl --no-progress-meter --output $DOWNLOAD_NAME --location $VECTORS_URL
+ - unzip -o -qq $DOWNLOAD_NAME -d $PYTHON_23_VECTOR_PATH
+ - rm $DOWNLOAD_NAME
+
+ # Run Decrypt Test Vectors on .NET Framework net48
+ - cd ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors
+ - export DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \
+ - dotnet test --framework net48
+
+ # Run Decrypt Test Vectors on .NET net6.0
+ - dotnet test --framework net6.0
+
+ # Generate Test Vectors with .NET Framework net6.0
+ - cd ../../../../
+ - export NET_41_VECTOR_PATH=$(pwd)/net41/vectors
+ - mkdir -p $NET_41_VECTOR_PATH
+ - GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator
+ - >-
+ dotnet run --project $GEN_PATH --framework net6.0 -- \
+ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \
+ --output-dir $NET_41_VECTOR_PATH
+
+ # Zip the Generated Test Vectors for ESDK-JS on Mac/Linux
+ - cd $NET_41_VECTOR_PATH
+ - zip -qq net41.zip -r .
+
+ # Decrypt Generated Test Vectors with ESDK-JS
+ - npx -y @aws-crypto/integration-node decrypt -v $NET_41_VECTOR_PATH/net41.zip -c cpu
+
+ # Unzip ESDK-NET @ v4.0.0 Valid Vectors
+ - cd runtimes/net/TestVectorsNative/TestVectors/resources
+ - NET_400_VALID_VECTORS=$(pwd)/v4Net400Valid/vectors
+ - mkdir -p $NET_400_VALID_VECTORS
+ - DOWNLOAD_NAME=valid-Net-4.0.0.zip
+ - unzip -o -qq $DOWNLOAD_NAME -d $NET_400_VALID_VECTORS
diff --git a/AwsEncryptionSDK/dafny/AwsEncryptionSdk/Model/AwsCryptographyEncryptionSdkTypes.dfy b/AwsEncryptionSDK/dafny/AwsEncryptionSdk/Model/AwsCryptographyEncryptionSdkTypes.dfy
index c80ce7bc6..2cf7013f2 100644
--- a/AwsEncryptionSDK/dafny/AwsEncryptionSdk/Model/AwsCryptographyEncryptionSdkTypes.dfy
+++ b/AwsEncryptionSDK/dafny/AwsEncryptionSdk/Model/AwsCryptographyEncryptionSdkTypes.dfy
@@ -2,322 +2,326 @@
// SPDX-License-Identifier: Apache-2.0
// Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
include "../../../../mpl/StandardLibrary/src/Index.dfy"
- include "../../../../mpl/AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/src/Index.dfy"
- include "../../../../mpl/AwsCryptographyPrimitives/src/Index.dfy"
- module {:extern "software.amazon.cryptography.encryptionsdk.internaldafny.types" } AwsCryptographyEncryptionSdkTypes
- {
- import opened Wrappers
- import opened StandardLibrary.UInt
- import opened UTF8
- import AwsCryptographyMaterialProvidersTypes
- import AwsCryptographyPrimitivesTypes
- // Generic helpers for verification of mock/unit tests.
- datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O)
-
- // Begin Generated Types
-
- class IAwsEncryptionSdkClientCallHistory {
- ghost constructor() {
- Encrypt := [];
- Decrypt := [];
-}
- ghost var Encrypt: seq>>
- ghost var Decrypt: seq>>
-}
- trait {:termination false} IAwsEncryptionSdkClient
- {
- // Helper to define any additional modifies/reads clauses.
- // If your operations need to mutate state,
- // add it in your constructor function:
- // Modifies := {your, fields, here, History};
- // If you do not need to mutate anything:
-// Modifies := {History};
+include "../../../../mpl/AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/src/Index.dfy"
+include "../../../../mpl/AwsCryptographyPrimitives/src/Index.dfy"
+module {:extern "software.amazon.cryptography.encryptionsdk.internaldafny.types" } AwsCryptographyEncryptionSdkTypes
+{
+ import opened Wrappers
+ import opened StandardLibrary.UInt
+ import opened UTF8
+ import AwsCryptographyMaterialProvidersTypes
+ import AwsCryptographyPrimitivesTypes
+ // Generic helpers for verification of mock/unit tests.
+ datatype DafnyCallEvent = DafnyCallEvent(input: I, output: O)
- ghost const Modifies: set