Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(support Rust): Add Rust Encryption SDK #682

Closed
wants to merge 15 commits into from
Closed
22 changes: 22 additions & 0 deletions AwsEncryptionSDK/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ DIR_STRUCTURE_V2=V2
PROJECT_SERVICES := \
AwsEncryptionSdk \

MAIN_SERVICE_FOR_RUST := AwsEncryptionSdk

RUST_OTHER_FILES := \
runtimes/rust/src/aes_gcm.rs \
runtimes/rust/src/aes_kdf_ctr.rs \
runtimes/rust/src/ddb.rs \
runtimes/rust/src/concurrent_call.rs \
runtimes/rust/src/dafny_libraries.rs \
runtimes/rust/src/digest.rs \
runtimes/rust/src/ecdh.rs \
runtimes/rust/src/ecdsa.rs \
runtimes/rust/src/hmac.rs \
runtimes/rust/src/kms.rs \
runtimes/rust/src/local_cmc.rs \
runtimes/rust/src/random.rs \
runtimes/rust/src/rsa.rs \
runtimes/rust/src/sets.rs \
runtimes/rust/src/software_externs.rs \
runtimes/rust/src/storm_tracker.rs \
runtimes/rust/src/time.rs \
runtimes/rust/src/uuid.rs

SERVICE_NAMESPACE_AwsEncryptionSdk=aws.cryptography.encryptionSdk
MAX_RESOURCE_COUNT=90000000
# Order is important
Expand Down
2 changes: 2 additions & 0 deletions AwsEncryptionSDK/runtimes/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
Cargo.lock
37 changes: 37 additions & 0 deletions AwsEncryptionSDK/runtimes/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "aws-esdk"
version = "0.1.0"
edition = "2021"
rust-version = "1.80.0"
keywords = ["crypto", "cryptography", "security", "dynamodb", "ddb", "encryption", "client-side", "clientside"]
license = "ISC AND (Apache-2.0 OR ISC)"
description = "aws-esdk is a library for implementing client side encryption."
homepage = "https://github.com/aws/aws-encryption-sdk-dafny"
repository = "https://github.com/aws/aws-encryption-sdk-dafny"
authors = ["AWS-CryptoTools"]
documentation = "https://docs.rs/crate/aws-esdk"
autoexamples = false
readme = "README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-config = "1.5.6"
aws-lc-rs = "1.9.0"
aws-lc-sys = "0.21.2"
aws-sdk-dynamodb = "1.47.0"
aws-sdk-kms = "1.44.0"
aws-smithy-runtime-api = {version = "1.7.2", features = ["client"] }
aws-smithy-types = "1.2.6"
chrono = "0.4.38"
dafny_runtime = { path = "dafny_runtime_rust"}
dashmap = "6.1.0"
pem = "3.0.4"
tokio = {version = "1.40.0", features = ["full"] }
uuid = { version = "1.10.0", features = ["v4"] }

[lib]
path = "src/implementation_from_dafny.rs"

[[example]]
name = "main"
3 changes: 3 additions & 0 deletions AwsEncryptionSDK/runtimes/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is NOT ready for production

# Use at your own risk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "dafny_runtime"
version = "0.1.0"
edition = "2021"

[dependencies]
once_cell = "1.18.0"
num = "0.4"
itertools = "0.11.0"
22 changes: 22 additions & 0 deletions AwsEncryptionSDK/runtimes/rust/dafny_runtime_rust/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# Invoking the CLI this way just to stay platform-independent
DAFNY = dotnet run --project ../../Dafny --no-build --

GENERATED_SYSTEM_MODULE_SOURCE=../obj/systemModulePopulator-rust/src/systemModulePopulator.rs
GENERATED_SYSTEM_MODULE_TARGET=src/system/mod.rs

all: check-system-module test

build-system-module:
$(DAFNY) translate rs --no-verify --use-basename-for-filename --optimize-erasable-datatype-wrapper:false --system-module:OmitAllOtherModules ../systemModulePopulator.dfy --output:../obj/systemModulePopulator
python -c "import sys; data = sys.stdin.read(); sys.stdout.write(data.replace('::dafny_runtime', 'crate'))" < $(GENERATED_SYSTEM_MODULE_SOURCE) > $(GENERATED_SYSTEM_MODULE_SOURCE).tmp && mv $(GENERATED_SYSTEM_MODULE_SOURCE).tmp $(GENERATED_SYSTEM_MODULE_SOURCE)

check-system-module: build-system-module
diff $(GENERATED_SYSTEM_MODULE_SOURCE) $(GENERATED_SYSTEM_MODULE_TARGET)

update-system-module: build-system-module
cp $(GENERATED_SYSTEM_MODULE_SOURCE) $(GENERATED_SYSTEM_MODULE_TARGET)

test:
cargo test
(cd ../../DafnyRuntime.Tests/DafnyRuntimeRustTest; cargo test)
Loading
Loading