Skip to content

Commit 7acf387

Browse files
authored
chore(rust-release): add Rust release directory (#709)
1 parent c133d77 commit 7acf387

File tree

1,559 files changed

+189926
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,559 files changed

+189926
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
To publish a new version of the aws-esdk for version N.N.N
2+
3+
1. Acquire the appropriate permissions
4+
1. Ensure git checkout of main is fresh and clean
5+
1. ./start_release.sh N.N.N
6+
1. `cd ../../../releases/rust/esdk`
7+
1. Create a PR with all changed or added files
8+
1. Within the PR, make sure you also:
9+
1. Update the `CHANGELOG.md` inside AwsEncryptionSDK/runtimes/rust/ with the changes
10+
1. If this is a major version bump, update the `SUPPORT_POLICY.rst` for Rust
11+
1. Get the PR reviewed by a teammate
12+
1. Before merging the PR, publish the new version of the `aws-esdk` crate and test the published crate (documented in next steps)
13+
1. Run `cargo publish`
14+
1. `cd ../../../AwsEncryptionSDK/runtimes/rust/` # i.e. return here
15+
1. ./test_published.sh N.N.N
16+
1. Ignore/stash the changes in `AwsEncryptionSDK/runtimes/rust/test_examples/Cargo.toml` which adds the `aws-esdk` crate
17+
1. Merge the release PR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash -eu
2+
3+
# Check if exactly one argument is provided
4+
if [ "$#" -ne 1 ]; then
5+
echo 1>&2 "USAGE: start_release.sh N.N.N"
6+
exit 1
7+
fi
8+
9+
# Go to the directory of this script
10+
cd $( dirname ${BASH_SOURCE[0]} )
11+
12+
# Check if the provided argument matches the version pattern
13+
REGEX_VERSION='^\d+\.\d+\.\d+$'
14+
MATCHES=$(echo "$1" | egrep $REGEX_VERSION | wc -l)
15+
if [ $MATCHES -eq 0 ]; then
16+
echo 1>&2 "Version \"$1\" must be N.N.N"
17+
exit 1
18+
fi
19+
20+
# Update the version in Cargo.toml
21+
perl -pe "s/^version = .*$/version = \"$1\"/" < Cargo.toml > new_Cargo.toml
22+
mv new_Cargo.toml Cargo.toml
23+
24+
# Remove all files and directories in src except for specified files
25+
find src -depth 1 | egrep -v '(lib.rs)' | xargs rm -rf
26+
27+
# Change to the parent directory and run make polymorph and transpile commands
28+
cd ../..
29+
make polymorph_rust transpile_rust test_rust
30+
31+
# Remove target directory
32+
cd runtimes/rust
33+
rm -rf target
34+
35+
# Remove existing release directory and copy current directory to releases
36+
rm -rf ../../../releases/rust/esdk
37+
cp -r . ../../../releases/rust/esdk
38+
39+
# Go to the release directory
40+
cd ../../../releases/rust/esdk
41+
42+
# Remove unnecessary files and directories
43+
rm -rf *~ copy_externs.sh start_release.sh test_published.sh test_examples *.pem RELEASE.md CHANGELOG.md
44+
45+
# Create .gitignore file with specified entries
46+
echo Cargo.lock > .gitignore
47+
echo target >> .gitignore
48+
49+
# Run cargo test and example tests
50+
cargo test
51+
cargo test --release --examples
52+
53+
# Remove Cargo.lock and .pem files after testing the examples
54+
rm -f Cargo.lock *.pem
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*~
2+
*.pem
3+
src
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "aws-esdk-examples"
3+
edition = "2021"
4+
rust-version = "1.80.0"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
aws-config = "1.5.10"
10+
aws-lc-rs = "1.11.1"
11+
aws-lc-sys = "0.23.1"
12+
aws-sdk-dynamodb = "1.55.0"
13+
aws-sdk-kms = "1.51.0"
14+
aws-smithy-runtime-api = {version = "1.7.3", features = ["client"] }
15+
aws-smithy-types = "1.2.9"
16+
chrono = "0.4.38"
17+
dafny-runtime = "0.1.1"
18+
dashmap = "6.1.0"
19+
pem = "3.0.4"
20+
rand = "0.8.5"
21+
tokio = {version = "1.42.0", features = ["full"] }
22+
uuid = { version = "1.11.0", features = ["v4"] }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash -eu
2+
3+
# Check if exactly one argument is provided
4+
if [ "$#" -ne 1 ]; then
5+
echo 1>&2 "USAGE: test_published.sh N.N.N"
6+
exit 1
7+
fi
8+
9+
# Go to the directory of this script
10+
cd $( dirname ${BASH_SOURCE[0]} )
11+
12+
# Check if the provided argument matches the version pattern
13+
REGEX_VERSION='^\d+\.\d+\.\d+$'
14+
echo "$1" | egrep -q $REGEX_VERSION
15+
if [ $? -ne 0 ]; then
16+
echo 1>&2 "Version \"$1\" must be N.N.N"
17+
exit 1
18+
fi
19+
20+
VERSION=$1
21+
22+
# Update examples in test_examples directory
23+
rm -rf test_examples/src
24+
cp -r examples test_examples/src/
25+
cd test_examples
26+
27+
# Add aws-esdk
28+
cargo add aws-esdk
29+
30+
# Check if the added version matches the provided version
31+
MATCH=$(fgrep "aws-esdk = \"$VERSION\"" Cargo.toml | wc -l)
32+
if [ $MATCH -eq "0" ]; then
33+
echo Version $VERSION of aws-esdk not the most recent
34+
egrep '^aws-esdk' Cargo.toml
35+
exit 1
36+
fi
37+
38+
# Run the cargo project
39+
cargo test --release

releases/rust/esdk/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cargo.lock
2+
target

releases/rust/esdk/Cargo.toml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[package]
2+
name = "aws-esdk"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.80.0"
6+
keywords = ["cryptography", "security", "dynamodb", "encryption", "client-side"]
7+
license = "ISC AND (Apache-2.0 OR ISC)"
8+
description = "aws-esdk is a library for implementing client side encryption."
9+
homepage = "https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html"
10+
repository = "https://github.com/aws/aws-encryption-sdk-dafny/releases/rust/esdk/"
11+
authors = ["AWS-CryptoTools"]
12+
documentation = "https://docs.rs/crate/aws-esdk"
13+
autoexamples = false
14+
readme = "README.md"
15+
16+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
17+
18+
[dependencies]
19+
aws-config = "1.5.10"
20+
aws-lc-rs = "1.11.1"
21+
aws-lc-sys = "0.23.1"
22+
aws-sdk-dynamodb = "1.55.0"
23+
aws-sdk-kms = "1.51.0"
24+
aws-smithy-runtime-api = {version = "1.7.3", features = ["client"] }
25+
aws-smithy-types = "1.2.9"
26+
chrono = "0.4.38"
27+
dafny-runtime = "0.1.1"
28+
dashmap = "6.1.0"
29+
pem = "3.0.4"
30+
rand = "0.8.5"
31+
tokio = {version = "1.42.0", features = ["full"] }
32+
uuid = { version = "1.11.0", features = ["v4"] }
33+
34+
[[example]]
35+
name = "main"

releases/rust/esdk/README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# AWS Encryption SDK for Rust
2+
3+
AWS Encryption SDK for Rust
4+
5+
## Using the AWS Encryption SDK for Rust
6+
7+
The AWS Encryption SDK is available on [Crates.io](https://www.crates.io/).
8+
9+
For more details about the design and architecture of the AWS Encryption SDK, see the [AWS Encryption SDK Developer Guide](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html).
10+
11+
## Building the AWS Encryption SDK for Rust
12+
13+
To build, the AWS Encryption SDK requires the most up to date version of [Dafny](https://github.com/dafny-lang/dafny) on your PATH.
14+
15+
You will also need to ensure that you fetch all submodules using either `git clone --recursive ...` when cloning the repository or `git submodule update --init` on an existing clone.
16+
17+
To setup your project to use the AWS Encryption SDK in Rust, run:
18+
19+
```
20+
cd AwsEncryptionSDK
21+
# Polymorph smithy to Rust
22+
make polymorph_rust
23+
# Transpile Dafny to Rust
24+
make transpile_rust
25+
```
26+
27+
### (Optional) Set up the AWS Encryption SDK to work with AWS KMS
28+
29+
If you set up the AWS Encryption SDK to use the AWS KMS Keyring,
30+
the AWS Encryption SDK will make calls to AWS KMS on your behalf,
31+
using the appropriate AWS SDK.
32+
33+
However, you must first set up AWS credentials for use with the AWS SDK.
34+
35+
## Testing the AWS Encryption SDK for Rust
36+
37+
### Configure AWS credentials
38+
39+
To run the test suite you must first set up AWS credentials for use with the AWS SDK.
40+
This is required in order to run the integration tests, which use a KMS Keyring against a publicly accessible KMS CMK.
41+
42+
### Run the tests
43+
44+
Run the test suite with:
45+
46+
```
47+
cd AwsEncryptionSDK
48+
make test_rust
49+
```
50+
51+
Run tests on examples, to ensure they are up to date:
52+
53+
```
54+
cd AwsEncryptionSDK/runtimes/rust/
55+
cargo test --examples
56+
```
57+
58+
Please look at the Examples on how to use the Encryption SDK in Rust [here](examples).
59+
60+
Please note that tests and test vectors require internet access and valid AWS credentials, since calls to KMS are made as part of the test workflow.
61+
62+
## License
63+
64+
This library is licensed under the Apache 2.0 License.

releases/rust/esdk/examples/README.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# AWS Encryption SDK for Rust Examples
2+
3+
This section features examples that show you
4+
how to use the AWS Encryption SDK.
5+
We demonstrate how to use the encryption and decryption APIs
6+
and how to set up some common configuration patterns.
7+
8+
## APIs
9+
10+
The AWS Encryption SDK provides two high-level APIs:
11+
one-step APIs that process the entire operation in memory
12+
and streaming APIs.
13+
14+
You can find examples that demonstrate these APIs
15+
in the [`examples/`](./) directory.
16+
17+
* [How to encrypt and decrypt](./keyring/aws_kms_keyring_example.rs)
18+
* [How to change the algorithm suite](./set_encryption_algorithm_suite_example.rs)
19+
* [How to set the commitment policy](./set_commitment_policy_example.rs)
20+
* [How to limit the number of encrypted data keys (EDKs)](./limit_encrypted_data_keys_example.rs)
21+
22+
## Configuration
23+
24+
To use the encryption and decryption APIs,
25+
you need to describe how you want the library to protect your data keys.
26+
You can do this by configuring
27+
[keyrings](#keyrings) or [cryptographic materials managers](#cryptographic-materials-managers).
28+
These examples will show you how to use the configuration tools that we include for you
29+
and how to create some of your own.
30+
We start with AWS KMS examples, then show how to use other wrapping keys.
31+
32+
* Using AWS Key Management Service (AWS KMS)
33+
* [How to use one AWS KMS key](./keyring/aws_kms_keyring_example.rs)
34+
* [How to use multiple AWS KMS keys in different regions](./keyring/aws_kms_mrk_discovery_multi_keyring_example.rs)
35+
* [How to decrypt when you don't know the AWS KMS key](./keyring/aws_kms_discovery_keyring_example.rs)
36+
* [How to limit decryption to a single region](./keyring/aws_kms_mrk_discovery_keyring_example.rs)
37+
* [How to decrypt with a preferred region but failover to others](./keyring/aws_kms_mrk_discovery_multi_keyring_example.rs)
38+
* [How to reproduce the behavior of an AWS KMS master key provider](./keyring/aws_kms_multi_keyring_example.rs)
39+
* Using raw wrapping keys
40+
* [How to use a raw AES wrapping key](./keyring/raw_aes_keyring_example.rs)
41+
* [How to use a raw RSA wrapping key](./keyring/raw_rsa_keyring_example.rs)
42+
* Combining wrapping keys
43+
* [How to combine AWS KMS with an offline escrow key](./keyring/multi_keyring_example.rs)
44+
* How to restrict algorithm suites
45+
* [with a custom cryptographic materials manager](./cryptographic_materials_manager/restrict_algorithm_suite/signing_suite_only_cmm.rs)
46+
47+
### Keyrings
48+
49+
Keyrings are the most common way for you to configure the AWS Encryption SDK.
50+
They determine how the AWS Encryption SDK protects your data.
51+
You can find these examples in [`examples/keyring`](./keyring).
52+
53+
### Cryptographic Materials Managers
54+
55+
Keyrings define how your data keys are protected,
56+
but there is more going on here than just protecting data keys.
57+
58+
Cryptographic materials managers give you higher-level controls
59+
over how the AWS Encryption SDK protects your data.
60+
This can include things like
61+
enforcing the use of certain algorithm suites or encryption context settings,
62+
reusing data keys across messages,
63+
or changing how you interact with keyrings.
64+
You can find these examples in
65+
[`examples/cryptographic_materials_manager`](./cryptographic_materials_manager).
66+
67+
### Client Supplier
68+
69+
The AWS Encryption SDK creates AWS KMS clients when interacting with AWS KMS.
70+
In case the default AWS KMS client configuration doesn't suit your needs,
71+
you can configure clients by defining a custom Client Supplier.
72+
For example, your Client Supplier could tune
73+
the retry and timeout settings on the client, or use different credentials
74+
based on which region is being called. In our
75+
[regional_role_client_supplier](./client_supplier/regional_role_client_supplier.rs)
76+
example, we show how you can build a custom Client Supplier which
77+
creates clients by assuming different IAM roles for different regions.
78+
79+
# Writing Examples
80+
81+
If you want to contribute a new example, that's awesome!
82+
To make sure that your example is tested in our CI,
83+
please make sure that it meets the following requirements:
84+
85+
1. The example MUST be a distinct subdirectory or file in the [`examples/`](./) directory.
86+
1. The example MAY be nested arbitrarily deeply. However, each example file MUST be added to the `mod.rs` files appropriately according to the directory structure. If the example is in the root directory [`examples/`](./), you MUST also add the module to the [`main.rs`](./main.rs) file. For instance, `pub mod set_commitment_policy_example;`.
87+
1. Each example file MUST contain exactly one example.
88+
1. Each example filename MUST be descriptive.
89+
1. Each example file MUST contain a testing function with the attribute `#[tokio::test(flavor = "multi_thread")]` just like the one at the end of the [KMS Keyring](./keyring/aws_kms_keyring_example.rs).
90+
1. Each example MUST also be called inside the `main` function of [main.rs](./main.rs).

0 commit comments

Comments
 (0)