Skip to content

Commit 1915a11

Browse files
authored
chore: add externs for os and language (#1149)
1 parent 5997919 commit 1915a11

File tree

37 files changed

+337
-19
lines changed

37 files changed

+337
-19
lines changed

AwsCryptographicMaterialProviders/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RUST_OTHER_FILES := \
2727
runtimes/rust/src/hmac.rs \
2828
runtimes/rust/src/kms.rs \
2929
runtimes/rust/src/local_cmc.rs \
30+
runtimes/rust/src/oslang.rs \
3031
runtimes/rust/src/random.rs \
3132
runtimes/rust/src/rsa.rs \
3233
runtimes/rust/src/sets.rs \

AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/test/Keyrings/TestMultiKeyring.dfy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
include "../../src/Index.dfy"
55
include "../TestUtils.dfy"
6+
include "../../../../../StandardLibrary/src/Time.dfy"
67

78
module TestMultiKeyring {
89
import opened Wrappers
@@ -12,6 +13,7 @@ module TestMultiKeyring {
1213
import AwsCryptographyPrimitivesTypes
1314
import MaterialProviders
1415
import Types = AwsCryptographyMaterialProvidersTypes
16+
import Time
1517

1618
method getInputEncryptionMaterials(encryptionContext: Types.EncryptionContext) returns (res: Types.EncryptionMaterials) {
1719

@@ -47,7 +49,7 @@ module TestMultiKeyring {
4749

4850
method {:test} TestHappyCase()
4951
{
50-
52+
var time := Time.GetAbsoluteTime();
5153
var mpl :- expect MaterialProviders.MaterialProviders();
5254

5355
var encryptionContext := TestUtils.SmallEncryptionContext(TestUtils.SmallEncryptionContextVariation.A);
@@ -99,6 +101,12 @@ module TestMultiKeyring {
99101
//# (structures.md#encryption-materials) returned by the last OnEncrypt
100102
//# call.
101103
expect |encryptionMaterialsOut.materials.encryptedDataKeys| == 2;
104+
105+
time := Time.PrintTimeSinceShortChained(time);
106+
for i := 0 to 100 {
107+
encryptionMaterialsOut :- expect multiKeyring.OnEncrypt(Types.OnEncryptInput(materials:=encryptionMaterials));
108+
}
109+
Time.PrintTimeSinceShort(time);
102110
}
103111

104112
method {:test} TestChildKeyringFailureEncrypt() {

AwsCryptographicMaterialProviders/runtimes/rust/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub mod ecdsa;
3939
pub mod hmac;
4040
pub mod kms;
4141
pub mod local_cmc;
42+
pub mod oslang;
4243
pub mod random;
4344
pub mod rsa;
4445
pub mod sets;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#![deny(warnings, unconditional_panic)]
5+
#![deny(nonstandard_style)]
6+
#![deny(clippy::all)]
7+
#![allow(dead_code)]
8+
#![allow(non_snake_case)]
9+
10+
impl crate::implementation_from_dafny::OsLang::_default {
11+
pub fn GetLanguageShort() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>
12+
{
13+
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string("Rust")
14+
}
15+
pub fn GetLanguageLong() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>
16+
{
17+
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string("Rust")
18+
}
19+
pub fn GetOsShort() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>
20+
{
21+
let os = match std::env::consts::OS {
22+
"macos" => "MacOS",
23+
"windows" => "Windows",
24+
"openbsd" => "Unix",
25+
"linux" => "Unix",
26+
"freebsd" => "Unix",
27+
"netbsd" => "Unix",
28+
_ => "Other"
29+
};
30+
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(os)
31+
}
32+
pub fn GetOsLong() -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>
33+
{
34+
let os = format!("{} {}", std::env::consts::OS, std::env::consts::ARCH);
35+
dafny_runtime::dafny_runtime_conversions::unicode_chars_false::string_to_dafny_string(&os)
36+
}
37+
38+
}

AwsCryptographyPrimitives/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RUST_OTHER_FILES := \
2121
runtimes/rust/src/ecdh.rs \
2222
runtimes/rust/src/ecdsa.rs \
2323
runtimes/rust/src/hmac.rs \
24+
runtimes/rust/src/oslang.rs \
2425
runtimes/rust/src/random.rs \
2526
runtimes/rust/src/rsa.rs \
2627
runtimes/rust/src/sets.rs \

AwsCryptographyPrimitives/runtimes/rust/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ src/digest.rs
2323
src/ecdh.rs
2424
src/ecdsa.rs
2525
src/hmac.rs
26+
src/oslang.rs
2627
src/random.rs
2728
src/rsa.rs
2829
src/sets.rs

AwsCryptographyPrimitives/runtimes/rust/copy_externs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cp $SRC/digest.rs src
1212
cp $SRC/ecdh.rs src
1313
cp $SRC/ecdsa.rs src
1414
cp $SRC/hmac.rs src
15+
cp $SRC/oslang.rs src
1516
cp $SRC/random.rs src
1617
cp $SRC/rsa.rs src
1718
cp $SRC/sets.rs src

AwsCryptographyPrimitives/runtimes/rust/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub mod digest;
2727
pub mod ecdh;
2828
pub mod ecdsa;
2929
pub mod hmac;
30+
pub mod oslang;
3031
pub mod random;
3132
pub mod rsa;
3233
pub mod sets;

ComAmazonawsDynamodb/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RUST_OTHER_FILES := \
1616
runtimes/rust/src/concurrent_call.rs \
1717
runtimes/rust/src/dafny_libraries.rs \
1818
runtimes/rust/src/ddb.rs \
19+
runtimes/rust/src/oslang.rs \
1920
runtimes/rust/src/sets.rs \
2021
runtimes/rust/src/time.rs \
2122
runtimes/rust/src/uuid.rs

ComAmazonawsDynamodb/runtimes/rust/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ src/dafny_libraries.rs
77
src/deps.rs
88
src/implementation_from_dafny.rs
99
src/sets.rs
10+
src/oslang.rs
1011
src/standard_library_conversions.rs
1112
src/standard_library_externs.rs
1213
src/time.rs

0 commit comments

Comments
 (0)