Skip to content

Commit adc17f0

Browse files
committed
pr feedback
1 parent 3a26afc commit adc17f0

29 files changed

+180
-120
lines changed

DynamoDbEncryption/README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ Within `runtimes/java`:
3333
- `ImplementationFromDafny.cs` contains all Dafny to .NET transpiled code.
3434
- `Generated/` contains all Smithy to .NET generated code.
3535

36+
#### Rust
37+
38+
`runtimes/rust` contains the Rust related code and build instructions for this project.
39+
40+
- `src/` contains all hand written Dotnet code, including externs, and also all Smithy to Rust generated code.
41+
- `src/implementation_from_dafny.cs` contains all Dafny to .NET transpiled code.
42+
3643
### Development
3744

3845
Common Makefile targets are:
@@ -74,10 +81,12 @@ Common Makefile targets are:
7481
that end up adding or removing dafny-generated files.
7582
- The above command takes a while to complete.
7683
- `make test_net_mac_intel` builds and tests the transpiled code in .NET in an Intel-MacOS environment.
84+
- `make transpile_rust` transpiles all of the Dafny code into runtimes/rust/src/implementation_from_dafny.
85+
- `make polymorph_rust` transpiles the smithy files into untimes/rust/src/*.rs
7786

7887
### Development Requirements
7988

80-
- Dafny 4.1.0: https://github.com/dafny-lang/dafny
89+
- Dafny 4.9.0: https://github.com/dafny-lang/dafny
8190
- A Java 8 or newer development environment
8291

8392
#### (Optional) Dafny Report Generator Requirements
+41-54
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,66 @@
11
# AWS Database Encryption SDK for DynamoDB
22

3-
📣 Note: This repository contains the source code and related files for all
4-
language implementations of the AWS Database Encryption SDK for DynamoDB.
5-
See our [supported languages](#supported-languages) section for more information.
3+
AWS Database Encryption SDK for DynamoDB
64

7-
The AWS Database Encryption SDK (DB-ESDK) for DynamoDB is a client-side encryption
8-
library that allows you to perform attribute-level encryption, enabling you to encrypt specific
9-
attribute values within items before storing them in your DynamoDB table. All encryption and
10-
decryption are performed within your application. This lets you protect sensitive data in-transit
11-
and at-rest, as data cannot be exposed unless decrypted by your application.
5+
## Using the AWS Database Encryption SDK for DynamoDB for Rust
126

13-
For more details about the design and architecture of the DB-ESDK for DynamoDB,
14-
see the [AWS Database Encryption SDK Developer Guide](https://docs.aws.amazon.com/database-encryption-sdk/latest/devguide/).
7+
The AWS Database Encryption SDK for DynamoDB is available on [Crates.io](https://www.crates.io/).
158

16-
# Security
9+
## Building the AWS Database Encryption SDK for DynamoDB
1710

18-
If you discover a potential security issue in this project
19-
we ask that you notify AWS/Amazon Security via our
20-
[vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/).
21-
Please **do not** create a public GitHub issue.
11+
To build, the AWS Database Encryption SDK for DynamoDB requires the most up to date version of [Dafny](https://github.com/dafny-lang/dafny) on your PATH.
2212

23-
# Support Policy
13+
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.
2414

25-
See [Support Policy](./SUPPORT_POLICY.rst) for details
26-
on the current support status of all major versions of this library.
15+
To setup your project to use the AWS Database Encryption SDK for DynamoDB in Rust, run:
2716

28-
## Giving Feedback
17+
```
18+
cd DynamoDbEncryption
19+
# Polymorph smithy to Rust
20+
make polymorph_rust
21+
# Transpile Dafny to Rust
22+
make transpile_rust
23+
# Build Project
24+
cd runtimes/rust
25+
cargo build
26+
```
2927

30-
We need your help in making this SDK great.
31-
Please participate in the community and contribute to this effort by
32-
submitting issues,
33-
participating in discussion forums and
34-
submitting pull requests through the following channels:
28+
### (Optional) Set up the AWS Database Encryption SDK for DynamoDB to work with AWS KMS
3529

36-
- Submit [issues](https://github.com/aws/aws-database-encryption-sdk-dynamodb-java/issues)
37-
\- this is the **preferred** channel to interact with our team
38-
- Articulate your
39-
[feature request](https://github.com/aws/aws-database-encryption-sdk-dynamodb-java/issues?q=is%3Aopen+is%3Aissue+label%3A%22feature-request%22)
40-
or upvote existing ones
41-
- Ask [questions](https://repost.aws/tags/TAc3VKZnkNQyimpHnCHetNOQ/aws-crypto-tools) on AWS re:Post under AWS Crypto Tools tag
30+
If you set up the AWS Database Encryption SDK for DynamoDB to use the AWS KMS Keyring,
31+
the AWS Database Encryption SDK for DynamoDB will make calls to AWS KMS on your behalf,
32+
using the appropriate AWS SDK.
4233

43-
# Getting Started
34+
However, you must first set up AWS credentials for use with the AWS SDK.
4435

45-
### Repository structure
36+
## Testing the AWS Database Encryption SDK for DynamoDB for Rust
4637

47-
This repository is a top level repository which houses all source code in order to compile this library into
48-
different runtimes.
38+
### Configure AWS credentials
4939

50-
This library is written in Dafny, a formally verifiable programming language that can be compiled into
51-
different runtimes. This library is currently **ONLY** supported in Java and .NET
40+
To run the test suite you must first set up AWS credentials for use with the AWS SDK.
41+
This is required in order to run the integration tests, which use a KMS Keyring against a publicly accessible KMS CMK.
5242

53-
### AWS Integration
43+
### Run the tests
5444

55-
You need an Amazon Web Services (AWS) account to use the DB-ESDK for DynamoDB as it's specifically designed to work with Amazon DynamoDB. Optionally, you can use AWS Key Management Service (AWS KMS) as your main keyring provider.
45+
Run the test suite with:
5646

57-
- **To create an AWS account**, go to
58-
[Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html)
59-
and then choose **I am a new user.**
60-
Follow the instructions to create an AWS account.
47+
```
48+
cd AwsEncryptionSDK
49+
make test_rust
50+
```
6151

62-
- **(Optional) To create a key in AWS KMS**, see
63-
[Creating Keys](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html).
52+
Run tests on examples, to ensure they are up to date:
6453

65-
## Supported Languages
54+
```
55+
cd AwsEncryptionSDK/runtimes/rust/
56+
cargo test --examples
57+
```
6658

67-
- Java
68-
- .NET
69-
- Dafny
59+
Please look at the Examples on how to use the Encryption SDK in Rust [here](examples).
7060

71-
# Contributing
61+
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.
7262

73-
See [CONTRIBUTING](CONTRIBUTING.md) for more information.
63+
## License
7464

75-
# License
65+
This library is licensed under the Apache 2.0 License.
7666

77-
This project is licensed under the Apache-2.0 License.
78-
79-
[ddbenhanced]: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/dynamodb-enhanced-client.html
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# AWS Database Encryption SDK for DynamoDb Java Examples
2+
3+
This project contains examples for using the AWS Database Encryption SDK for DynamoDb in Rust.
4+
5+
Overview:
6+
7+
```
8+
├── ..
9+
├── examples: Examples source
10+
│ ├── basic_get_put_example.rs: Example using AWS DB ESDK to Put and Get an encrypted item from DynamoDB
11+
│ ├── create_keystore_key.rs: Example creating a branch key in a Keystore DynamoDB table
12+
│ ├── clientsupplier/: Examples using a custom KMS ClientSupplier
13+
│ ├── itemencryptor/: Examples using the DynamoDbItemEncryptor
14+
│ ├── keyring/: Examples creating and using different keyrings
15+
│ └── searchableencryption/: Examples demonstrating searchable encryption configuration and usage
16+
└── src: Source code including tests
17+
```
18+
19+
## Getting Started
20+
21+
### Development Requirements
22+
23+
- A Rust 1.80 or newer development environment
24+
25+
### Building and Running
26+
27+
All of the examples are called from the `main` method.
28+
To run a given example, inspect its particular setup requirements,
29+
create and/or grant access to any required AWS resources,
30+
and run the example.
31+
32+
## Security
33+
34+
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
35+
36+
## License
37+
38+
This project is licensed under the Apache-2.0 License.

DynamoDbEncryption/runtimes/rust/examples/clientsupplier/client_supplier_example.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use super::regional_role_client_supplier::RegionalRoleClientSupplier;
25
use crate::test_utils;
36
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::DynamoDbTableEncryptionConfig;
47
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_structuredEncryption::types::CryptoAction;
58
use aws_db_esdk::aws_cryptography_materialProviders::client as mpl_client;
6-
//use aws_db_esdk::aws_cryptography_materialProviders::types::client_supplier::ClientSupplierRef;
79
use aws_db_esdk::aws_cryptography_materialProviders::types::material_providers_config::MaterialProvidersConfig;
810
use aws_db_esdk::aws_cryptography_materialProviders::types::DiscoveryFilter;
911
use aws_db_esdk::intercept::DbEsdkInterceptor;
@@ -54,9 +56,6 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
5456
// defined in the RegionalRoleClientSupplier class in this directory.
5557
// Note: RegionalRoleClientSupplier will internally use the key_arn's region
5658
// to retrieve the correct IAM role.
57-
// let supplier_ref = ClientSupplierRef {
58-
// inner: std::rc::Rc::new(std::cell::RefCell::new(RegionalRoleClientSupplier {})),
59-
// };
6059

6160
let mrk_keyring_with_client_supplier = mpl
6261
.create_aws_kms_mrk_multi_keyring()
@@ -176,7 +175,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
176175
AttributeValue::S("encrypt and sign me!".to_string())
177176
);
178177

179-
// 7. Create a MRK discovery multi-keyring with a custom client supplier.
178+
// 8. Create a MRK discovery multi-keyring with a custom client supplier.
180179
// A discovery MRK multi-keyring will be composed of
181180
// multiple discovery MRK keyrings, one for each region.
182181
// Each component keyring has its own KMS client in a particular region.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
pub mod client_supplier_example;
25
pub mod regional_role_client_supplier;
36
pub mod regional_role_client_supplier_config;

DynamoDbEncryption/runtimes/rust/examples/clientsupplier/regional_role_client_supplier.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use aws_config::Region;
25
use aws_db_esdk::aws_cryptography_materialProviders::operation::get_client::GetClientInput;
36
use aws_db_esdk::aws_cryptography_materialProviders::types::error::Error;

DynamoDbEncryption/runtimes/rust/examples/clientsupplier/regional_role_client_supplier_config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
use std::collections::HashMap;
25

36
/*

DynamoDbEncryption/runtimes/rust/examples/keyring/hierarchical_keyring.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use aws_db_esdk::aws_cryptography_keyStore::types::key_store_config::KeyStoreCon
1010
use aws_db_esdk::aws_cryptography_keyStore::types::KmsConfiguration;
1111
use aws_db_esdk::aws_cryptography_materialProviders::client as mpl_client;
1212
use aws_db_esdk::aws_cryptography_materialProviders::types::material_providers_config::MaterialProvidersConfig;
13-
//use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::dynamo_db_key_branch_key_id_supplier::DynamoDbKeyBranchKeyIdSupplierRef;
1413
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_dynamoDb::types::DynamoDbTableEncryptionConfig;
1514
use aws_db_esdk::aws_cryptography_dbEncryptionSdk_structuredEncryption::types::CryptoAction;
1615
use aws_db_esdk::intercept::DbEsdkInterceptor;
@@ -94,9 +93,7 @@ pub async fn put_item_get_item(
9493
let dbesdk_config = DynamoDbEncryptionConfig::builder().build()?;
9594
let dbesdk = dbesdk_client::Client::from_conf(dbesdk_config)?;
9695
let supplier = ExampleBranchKeyIdSupplier::new(tenant1_branch_key_id, tenant2_branch_key_id);
97-
// let supplier_ref = DynamoDbKeyBranchKeyIdSupplierRef {
98-
// inner: ::std::rc::Rc::new(std::cell::RefCell::new(supplier)),
99-
// };
96+
10097
let branch_key_id_supplier = dbesdk
10198
.create_dynamo_db_encryption_branch_key_id_supplier()
10299
.ddb_key_branch_key_id_supplier(supplier)
@@ -212,7 +209,7 @@ pub async fn put_item_get_item(
212209
.send()
213210
.await?;
214211

215-
// 10. Get the item back from our table using the same client.
212+
// 9. Get the item back from our table using the same client.
216213
// The client will decrypt the item client-side, and return
217214
// back the original item.
218215
// Because the returned item's partition value is "tenantId1",

DynamoDbEncryption/runtimes/rust/examples/keyring/kms_rsa_keyring.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
176176
.send()
177177
.await?;
178178

179-
// 9. Get the item back from our table using the client.
179+
// 8. Get the item back from our table using the client.
180180
// The client will decrypt the item client-side using the RSA keyring
181181
// and return the original item.
182182
let key_to_get = HashMap::from([

DynamoDbEncryption/runtimes/rust/examples/keyring/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
pub mod branch_key_id_supplier;
25
pub mod hierarchical_keyring;
36
pub mod kms_rsa_keyring;

DynamoDbEncryption/runtimes/rust/examples/keyring/mrk_discovery_multi_keyring.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
119119
.build();
120120
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);
121121

122-
// 7. Put an item into our table using the above client.
122+
// 6. Put an item into our table using the above client.
123123
// Before the item gets sent to DynamoDb, it will be encrypted
124124
// client-side using the MRK multi-keyring.
125125
let item = HashMap::from([
@@ -140,7 +140,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
140140
.send()
141141
.await?;
142142

143-
// 8. Construct a discovery filter.
143+
// 7. Construct a discovery filter.
144144
// A discovery filter limits the set of encrypted data keys
145145
// the keyring can use to decrypt data.
146146
// We will only let the keyring use keys in the selected AWS accounts
@@ -152,7 +152,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
152152
.account_ids(account_ids)
153153
.build()?;
154154

155-
// 9. Construct a discovery keyring.
155+
// 8. Construct a discovery keyring.
156156
// Note that we choose to use the MRK discovery multi-keyring, even though
157157
// our original keyring used a single KMS key.
158158

@@ -163,7 +163,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
163163
.send()
164164
.await?;
165165

166-
// 10. Create new DDB config and client using the decrypt discovery keyring.
166+
// 9. Create new DDB config and client using the decrypt discovery keyring.
167167
// This is the same as the above config, except we pass in the decrypt keyring.
168168
let table_config_for_decrypt = DynamoDbTableEncryptionConfig::builder()
169169
.logical_table_name(ddb_table_name)
@@ -186,7 +186,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
186186
.build();
187187
let ddb_for_decrypt = aws_sdk_dynamodb::Client::from_conf(dynamo_config_for_decrypt);
188188

189-
// 11. Get the item back from our table using the client.
189+
// 10. Get the item back from our table using the client.
190190
// The client will retrieve encrypted items from the DDB table, then
191191
// detect the KMS key that was used to encrypt their data keys.
192192
// The client will make a request to KMS to decrypt with the encrypting KMS key.

DynamoDbEncryption/runtimes/rust/examples/keyring/multi_keyring.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
152152
.build();
153153
let ddb = aws_sdk_dynamodb::Client::from_conf(dynamo_config);
154154

155-
// 9. Put an item into our table using the above client.
155+
// 8. Put an item into our table using the above client.
156156
// Before the item gets sent to DynamoDb, it will be encrypted
157157
// client-side using the multi-keyring.
158158
// The item will be encrypted with all wrapping keys in the keyring,
@@ -175,7 +175,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
175175
.send()
176176
.await?;
177177

178-
// 10. Get the item back from our table using the above client.
178+
// 9. Get the item back from our table using the above client.
179179
// The client will decrypt the item client-side using the AWS KMS
180180
// keyring, and return back the original item.
181181
// Since the generator key is the first available key in the keyring,
@@ -198,7 +198,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
198198

199199
assert_eq!(resp.item, Some(item.clone()));
200200

201-
// 11. Create a new config and client with only the raw AES keyring to GET the item
201+
// 10. Create a new config and client with only the raw AES keyring to GET the item
202202
// This is the same setup as above, except the config uses the `rawAesKeyring`.
203203
let only_aes_table_config = DynamoDbTableEncryptionConfig::builder()
204204
.logical_table_name(ddb_table_name)
@@ -221,7 +221,7 @@ pub async fn put_item_get_item() -> Result<(), crate::BoxError> {
221221
.build();
222222
let only_aes_ddb = aws_sdk_dynamodb::Client::from_conf(only_aes_dynamo_config);
223223

224-
// 12. Get the item back from our table using the client
224+
// 11. Get the item back from our table using the client
225225
// configured with only the raw AES keyring.
226226
// The client will decrypt the item client-side using the raw
227227
// AES keyring, and return back the original item.

0 commit comments

Comments
 (0)