Skip to content

Commit

Permalink
fix Makefile; update externs
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikKapila committed Oct 1, 2024
1 parent 1c4b133 commit 983bff1
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 97 deletions.
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
38 changes: 28 additions & 10 deletions AwsEncryptionSDK/runtimes/rust/src/ddb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
#![deny(clippy::all)]

use aws_config::Region;
use std::sync::LazyLock;

static DAFNY_TOKIO_RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
});

#[allow(non_snake_case)]
impl crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::_default {
Expand All @@ -19,11 +27,16 @@ impl crate::r#software::amazon::cryptography::services::dynamodb::internaldafny:
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(
region,
);
let shared_config = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
});
let shared_config = match tokio::runtime::Handle::try_current() {
Ok(curr) => tokio::task::block_in_place(|| {
curr.block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
}),
Err(_) => DAFNY_TOKIO_RUNTIME.block_on(aws_config::load_defaults(
aws_config::BehaviorVersion::v2024_03_28(),
)),
};
let shared_config = shared_config
.to_builder()
.region(Region::new(region))
Expand All @@ -42,11 +55,16 @@ impl crate::r#software::amazon::cryptography::services::dynamodb::internaldafny:
::std::rc::Rc<crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::Error>
>
>{
let shared_config = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
});
let shared_config = match tokio::runtime::Handle::try_current() {
Ok(curr) => tokio::task::block_in_place(|| {
curr.block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
}),
Err(_) => DAFNY_TOKIO_RUNTIME.block_on(aws_config::load_defaults(
aws_config::BehaviorVersion::v2024_03_28(),
)),
};
let inner = aws_sdk_dynamodb::Client::new(&shared_config);
let client = crate::deps::com_amazonaws_dynamodb::client::Client { inner };
let dafny_client = ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(client));
Expand Down
40 changes: 30 additions & 10 deletions AwsEncryptionSDK/runtimes/rust/src/kms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
#![deny(clippy::all)]

use aws_config::Region;
use std::sync::LazyLock;

static DAFNY_TOKIO_RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
});

impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_default {
#[allow(non_snake_case)]
Expand All @@ -14,11 +22,17 @@ impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_def
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::dafny_string_to_string(
region,
);
let shared_config = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
});

let shared_config = match tokio::runtime::Handle::try_current() {
Ok(curr) => tokio::task::block_in_place(|| {
curr.block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
}),
Err(_) => DAFNY_TOKIO_RUNTIME.block_on(aws_config::load_defaults(
aws_config::BehaviorVersion::v2024_03_28(),
)),
};

let shared_config = shared_config
.to_builder()
Expand All @@ -34,11 +48,17 @@ impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_def

#[allow(non_snake_case)]
pub fn KMSClient() -> ::std::rc::Rc<crate::r#_Wrappers_Compile::Result<::dafny_runtime::Object<dyn crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient>, ::std::rc::Rc<crate::software::amazon::cryptography::services::kms::internaldafny::types::Error>>>{
let shared_config = tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
});
let shared_config = match tokio::runtime::Handle::try_current() {
Ok(curr) => tokio::task::block_in_place(|| {
curr.block_on(async {
aws_config::load_defaults(aws_config::BehaviorVersion::v2024_03_28()).await
})
}),
Err(_) => DAFNY_TOKIO_RUNTIME.block_on(aws_config::load_defaults(
aws_config::BehaviorVersion::v2024_03_28(),
)),
};

let inner = aws_sdk_kms::Client::new(&shared_config);
let client = crate::deps::com_amazonaws_kms::client::Client { inner };
let dafny_client = ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(client));
Expand Down
77 changes: 0 additions & 77 deletions AwsEncryptionSDK/runtimes/rust/src/software_externs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,83 +17,6 @@ pub mod software {
pub use crate::local_cmc::internal_SynchronizedLocalCMC::*;
}
}
pub mod dbencryptionsdk {
pub mod dynamodb {
pub mod itemencryptor {
pub mod internaldafny {
pub mod legacy {
use crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::Error as DafnyError;
use crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::internaldafny::types::LegacyPolicy;
use ::std::rc::Rc;
type Legacy = ::dafny_runtime::Object<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::legacy::InternalLegacyOverride>;

fn error(s: &str) -> Rc<DafnyError> {
Rc::new(DafnyError::DynamoDbItemEncryptorException {
message:
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(s),
})
}
pub struct InternalLegacyOverride {
pub r#__i_policy: Rc<LegacyPolicy>,
}
fn fail_override() -> Rc<
crate::_Wrappers_Compile::Result<
Rc<crate::_Wrappers_Compile::Option<Legacy>>,
Rc<DafnyError>,
>,
> {
Rc::new(crate::_Wrappers_Compile::Result::Failure {
error: error("Legacy configuration unsupported."),
})
}
fn success_override() -> Rc<
crate::_Wrappers_Compile::Result<
Rc<crate::_Wrappers_Compile::Option<Legacy>>,
Rc<DafnyError>,
>,
> {
Rc::new(crate::_Wrappers_Compile::Result::Success {
value: Rc::new(crate::_Wrappers_Compile::Option::None {}),
})
}

impl InternalLegacyOverride {
pub fn Build(
config: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DynamoDbItemEncryptorConfig>,
) -> Rc<
crate::_Wrappers_Compile::Result<
Rc<crate::_Wrappers_Compile::Option<Legacy>>,
Rc<DafnyError>,
>,
> {
match &**config.legacyOverride() {
crate::_Wrappers_Compile::Option::Some{value} => {
match &**value.policy() {
LegacyPolicy::FORBID_LEGACY_ENCRYPT_FORBID_LEGACY_DECRYPT{} => success_override(),
_ => fail_override()
}
}
crate::_Wrappers_Compile::Option::None{} => success_override()
}
}
pub fn EncryptItem(&mut self, _input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::EncryptItemInput>) -> Rc<crate::_Wrappers_Compile::Result<Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::EncryptItemOutput>, Rc<DafnyError>>>{
todo!("InternalLLegacyOverride::EncryptItem")
}
pub fn DecryptItem(&mut self, _input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemInput>) -> Rc<crate::_Wrappers_Compile::Result<Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemOutput>, Rc<DafnyError>>>{
todo!("InternalLLegacyOverride::DecryptItem")
}
pub fn IsLegacyInput(
&self,
_input: &Rc<crate::software::amazon::cryptography::dbencryptionsdk::dynamodb::itemencryptor::internaldafny::types::DecryptItemInput>,
) -> bool {
false
}
}
}
}
}
}
}
}
}
}

0 comments on commit 983bff1

Please sign in to comment.