Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ features that interact with a VBS enclave easier. To learn more about VBS enclav
| Language | Supported |
|-------------------|-----------|
| C++ (20 or later) | ✅ |
| Rust | ❌ |
| Rust | ✅ |

#### Operating System Support

Expand Down
5 changes: 5 additions & 0 deletions rust/edlcodegen/crates/libs/edlcodegen-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "edlcodegen-core"
version = "0.1.0"
edition = { workspace = true }
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-codegen", "enclave"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
categories = ["os", "no-std"]
description = "Internal core types and utilities shared by edlcodegen host and enclave support crates"

[lib]
crate-type = ["rlib"]
Expand Down
5 changes: 5 additions & 0 deletions rust/edlcodegen/crates/libs/edlcodegen-enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "edlcodegen-enclave"
version = "0.1.0"
edition = { workspace = true }
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-codegen", "enclave"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
categories = ["os", "no-std"]
description = "Enclave-side ABI and runtime support for Rust crates generated by edlcodegen"

[dependencies]
edlcodegen-core = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions rust/edlcodegen/crates/libs/edlcodegen-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "edlcodegen-host"
version = "0.1.0"
edition.workspace = true
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-codegen", "enclave"]
categories = ["os"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
description = "Host-side ABI and runtime support for Rust crates generated by edlcodegen"

[dependencies]
edlcodegen-core = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions rust/edlcodegen/crates/libs/edlcodegen-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "edlcodegen-macros"
version = "0.1.0"
edition.workspace = true
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-codegen", "enclave"]
categories = ["os"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
description = "Internal procedural macros used by edlcodegen-generated crates"

[lib]
proc-macro = true
Expand Down
5 changes: 5 additions & 0 deletions rust/edlcodegen/crates/libs/edlcodegen-tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "edlcodegen-tools"
version = "0.1.0"
edition = { workspace = true }
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-codegen", "enclave"]
categories = ["os"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
description = "Command-line tooling for generating Rust crates from EDL files, including the edlcodegen executable"

[dependencies]
winreg = "0.55.0"
3 changes: 3 additions & 0 deletions rust/edlcodegen/crates/tests/edlcodegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "edlcodegen"
version = "0.0.0"
edition.workspace = true
publish = false
license = "MIT"
repository = "https://github.com/microsoft/VbsEnclaveTooling"
description = "Internal test crate for edlcodegen tooling"

[lib]
doc = false
Expand Down
12 changes: 9 additions & 3 deletions rust/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@ resolver = "3"
members = [
"crates/libs/sdk-enclave",
"crates/libs/sdk-host",
"crates/libs/sdk-enclave/generated/sdk_gen",
"crates/libs/sdk-host/generated/sdk_gen",
"crates/libs/sdk-enclave/generated/vbsenclave_sdk_gen",
"crates/libs/sdk-host/generated/vbsenclave_sdk_gen",
"crates/libs/userboundkey-kcm",
"crates/tests/sdk",
"crates/libs/windows-enclave",
]

[workspace.package]
edition = "2024"
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-sdk", "enclave", "windows"]
categories = ["virtualization", "os"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"

[workspace.dependencies]
edlcodegen-tools = { git = "https://github.com/microsoft/VbsEnclaveTooling" }
edlcodegen-tools = { version = "0.1" }
regex = "1.11"
spin = "0.10.0"
tracelogging = { version ="1.2.4", default-features = false }
userboundkey-kcm = { version = "0.1.0", path = "crates/libs/userboundkey-kcm" }
uuid = {version = "1.19.0", default-features = false }
vbsenclave-sdk-enclave = { version = "0.1.0", path = "crates/libs/sdk-enclave" }
vbsenclave_sdk_enclave_gen = { version = "0.1.0", path = "crates/libs/sdk-enclave/generated/vbsenclave_sdk_gen" }
vbsenclave-sdk-host = { version = "0.1.0", path = "crates/libs/sdk-host" }
vbsenclave_sdk_host_gen = { version = "0.1.0", path = "crates/libs/sdk-host/generated/vbsenclave_sdk_gen" }
widestring = { version = "1.1", default-features = false, features = ["alloc"] }
windows = "0.62.2"
windows-bindgen = "0.66.0"
Expand Down
7 changes: 6 additions & 1 deletion rust/sdk/crates/libs/sdk-enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
name = "vbsenclave-sdk-enclave"
version = "0.1.0"
edition = { workspace = true }
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-sdk", "enclave"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
categories = ["os", "no-std"]
description = "Enclave-side Rust SDK for developing applications using Windows VBS enclaves"

[dependencies]
sdk_enclave_gen = { path = "./generated/sdk_gen" }
vbsenclave_sdk_enclave_gen = { workspace = true }
spin = { workspace = true }
tracelogging = { workspace = true, features = ["etw", "kernel_mode"] }
uuid = { workspace = true, default-features = false, features = [ "v4"] }
Expand Down
8 changes: 4 additions & 4 deletions rust/sdk/crates/libs/sdk-enclave/src/common/sdk_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

use crate::etw;
use crate::userboundkey;
use sdk_enclave_gen::AbiError;
use sdk_enclave_gen::implementation::trusted::Trusted;
use sdk_enclave_gen::implementation::types::attestationReportAndSessionInfo;
use sdk_enclave_gen::implementation::types::{EventFilterDescriptor, Guid};
use vbsenclave_sdk_enclave_gen::AbiError;
use vbsenclave_sdk_enclave_gen::implementation::trusted::Trusted;
use vbsenclave_sdk_enclave_gen::implementation::types::attestationReportAndSessionInfo;
use vbsenclave_sdk_enclave_gen::implementation::types::{EventFilterDescriptor, Guid};

/// SDK enclave implementation of the Trusted trait.
///
Expand Down
6 changes: 3 additions & 3 deletions rust/sdk/crates/libs/sdk-enclave/src/etw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use crate::common;
use alloc::{collections::BTreeMap, vec::Vec};
use core::marker::PhantomData;
use sdk_enclave_gen::AbiError;
use sdk_enclave_gen::implementation::types as edl_types;
use sdk_enclave_gen::stubs::untrusted::{self};
use spin::{Once, RwLock};
use tracelogging::{Channel, Level, Opcode, Provider};
use vbsenclave_sdk_enclave_gen::AbiError;
use vbsenclave_sdk_enclave_gen::implementation::types as edl_types;
use vbsenclave_sdk_enclave_gen::stubs::untrusted::{self};

/// Information about a registered ETW provider.
/// The registration_id is generated during registration
Expand Down
4 changes: 2 additions & 2 deletions rust/sdk/crates/libs/sdk-enclave/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub mod userboundkey;

// Re-export generated SDK enclave's export macro
// and println stub for use in this crate's macros.
pub use sdk_enclave_gen::export_enclave_functions;
pub use sdk_enclave_gen::stubs::untrusted::println;
pub use vbsenclave_sdk_enclave_gen::export_enclave_functions;
pub use vbsenclave_sdk_enclave_gen::stubs::untrusted::println;

/// Export all SDK enclave functions.
///
Expand Down
8 changes: 4 additions & 4 deletions rust/sdk/crates/libs/sdk-enclave/src/userboundkey/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ pub use crypto::{
pub use types::*;

// Re-export the cache config type for use by samples
pub use sdk_enclave_gen::implementation::types::keyCredentialCacheConfig;
pub use vbsenclave_sdk_enclave_gen::implementation::types::keyCredentialCacheConfig;

// Re-export widestring types for public API consumers
pub use widestring::U16Str;

use alloc::vec::Vec;

use sdk_enclave_gen::AbiError;
use sdk_enclave_gen::implementation::types::attestationReportAndSessionInfo;
use sdk_enclave_gen::stubs::untrusted;
use vbsenclave_sdk_enclave_gen::AbiError;
use vbsenclave_sdk_enclave_gen::implementation::types::attestationReportAndSessionInfo;
use vbsenclave_sdk_enclave_gen::stubs::untrusted;
use widestring::U16String;

use windows_enclave::veinterop::{
Expand Down
2 changes: 1 addition & 1 deletion rust/sdk/crates/libs/sdk-enclave/src/userboundkey/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use crate::common::{CryptoError, EnclaveUtilsError, ntstatus_to_hresult};
use alloc::string::String;
use sdk_enclave_gen::AbiError;
use vbsenclave_sdk_enclave_gen::AbiError;

/// Error type for user-bound key operations
#[derive(Debug)]
Expand Down
7 changes: 6 additions & 1 deletion rust/sdk/crates/libs/sdk-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "vbsenclave-sdk-host"
version = "0.1.0"
edition.workspace = true
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-sdk", "enclave"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
categories = ["os"]
description = "Host-side Rust SDK for interacting with Windows VBS enclaves"

[dependencies.windows]
workspace = true
Expand All @@ -18,7 +23,7 @@ features = [
]

[dependencies]
sdk_host_gen = { path = "./generated/sdk_gen" }
vbsenclave_sdk_host_gen = { workspace = true }
spin = { workspace = true }
userboundkey-kcm = { workspace = true }
uuid = {version = "1.19.0", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions rust/sdk/crates/libs/sdk-host/src/common/sdk_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

use crate::etw;
use crate::userboundkey;
use sdk_host_gen::AbiError;
use sdk_host_gen::implementation::types::{
use vbsenclave_sdk_host_gen::AbiError;
use vbsenclave_sdk_host_gen::implementation::types::{
EventDataDescriptor, EventDescriptor, Guid, credentialAndSessionInfo, keyCredentialCacheConfig,
};
use sdk_host_gen::implementation::untrusted::Untrusted;
use vbsenclave_sdk_host_gen::implementation::untrusted::Untrusted;
use widestring::{U16Str, U16String};

/// SDK host implementation of the Untrusted trait.
Expand Down
2 changes: 1 addition & 1 deletion rust/sdk/crates/libs/sdk-host/src/enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ impl EnclaveHandle {
impl Drop for EnclaveHandle {
fn drop(&mut self) {
if !self.enclave.is_null() {
let host = sdk_host_gen::SdkHost::new(self.enclave);
let host = vbsenclave_sdk_host_gen::SdkHost::new(self.enclave);
let _ = host.unregister_etw_providers();

// SAFETY: self.enclave is valid because it came from create()
Expand Down
6 changes: 3 additions & 3 deletions rust/sdk/crates/libs/sdk-host/src/etw.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use sdk_host_gen::AbiError;
use sdk_host_gen::SdkHost;
use sdk_host_gen::implementation::types as codegen_types;
use std::sync::{OnceLock, RwLock};
use vbsenclave_sdk_host_gen::AbiError;
use vbsenclave_sdk_host_gen::SdkHost;
use vbsenclave_sdk_host_gen::implementation::types as codegen_types;
use windows::Win32::System::Diagnostics::Etw;

#[repr(C)]
Expand Down
4 changes: 2 additions & 2 deletions rust/sdk/crates/libs/sdk-host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod etw;
pub mod userboundkey;

use common::HostImpl;
use sdk_host_gen::AbiError;
use vbsenclave_sdk_host_gen::AbiError;

// The userboundkey-kcm crate is not intended to be published as a standalone package.
// Long term, these KCM APIs should be consumed from the windows-rs crate.
Expand Down Expand Up @@ -42,7 +42,7 @@ pub use userboundkey_kcm::KeyCredentialManager;
/// ```
pub fn register_sdk_callbacks(enclave_ptr: *mut core::ffi::c_void) -> Result<(), AbiError> {
// Register SDK callbacks using the SdkHost interface and HostImpl
let sdk_wrapper = sdk_host_gen::SdkHost::new(enclave_ptr);
let sdk_wrapper = vbsenclave_sdk_host_gen::SdkHost::new(enclave_ptr);
sdk_wrapper.register_vtl0_callbacks::<HostImpl>()?;
sdk_wrapper.register_etw_providers()?;

Expand Down
6 changes: 3 additions & 3 deletions rust/sdk/crates/libs/sdk-host/src/userboundkey/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ macro_rules! debug_print {
};
}

use sdk_host_gen::AbiError;
pub use sdk_host_gen::SdkHost;
pub use sdk_host_gen::implementation::types::{
use vbsenclave_sdk_host_gen::AbiError;
pub use vbsenclave_sdk_host_gen::SdkHost;
pub use vbsenclave_sdk_host_gen::implementation::types::{
attestationReportAndSessionInfo, credentialAndSessionInfo, keyCredentialCacheConfig,
};

Expand Down
5 changes: 5 additions & 0 deletions rust/sdk/crates/libs/userboundkey-kcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "userboundkey-kcm"
version = "0.1.0"
edition.workspace = true
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-sdk", "enclave"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
categories = ["os"]
description = "Internal bindings and helpers for Windows KCM User-Bound Key APIs"

[build-dependencies]
windows-bindgen = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions rust/sdk/crates/libs/windows-enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
name = "windows-enclave"
version = "0.1.0"
edition.workspace = true
license = "MIT"
keywords = ["vbs", "vbs-enclave", "vbs-enclave-sdk", "enclave"]
repository = "https://github.com/microsoft/VbsEnclaveTooling"
categories = ["os"]
description = "Low-level FFI bindings for Windows APIs exposed to VBS enclaves"

[build-dependencies]
windows-bindgen = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions rust/sdk/crates/samples/userboundkey/enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "userboundkey-sample-enclave"
version = "0.1.0"
edition = { workspace = true }
publish = false

[lib]
# Make sure crate builds a dll and not a static lib
Expand Down
1 change: 1 addition & 0 deletions rust/sdk/crates/samples/userboundkey/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "userboundkey-sample-host"
version = "0.1.0"
edition = { workspace = true }
publish = false

[[bin]]
name = "userboundkey-sample"
Expand Down
2 changes: 1 addition & 1 deletion rust/sdk/generate_codegen_for_workspace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $sdkEdl = Join-Path $sdkImportDir "sdk.edl"
-HostAppOutDir "$hostSdkCrate\generated" `
-EnclaveOutDir "$enclaveSdkCrate\generated" `
-EdlPath $sdkEdl `
-Namespace "sdk" `
-Namespace "vbsenclave_sdk" `
-ImportDirectories $sdkImportDir `
-Vtl0ClassName "SdkHost"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[package]
name = "code_gen_test_enclave_gen"
version = "0.0.0"
version = "0.1.0"
edition = "2024"
publish = false
description = "Generated internal helper crate containing EDL-derived host bindings and marshaling code"
license = "MIT"

[lib]
doc = false
doctest = false
test = false

[build-dependencies]
edlcodegen-tools = { git = "https://github.com/microsoft/VbsEnclaveTooling" }
edlcodegen-tools = { version = "0.1" }

[dependencies]
edlcodegen-enclave = { git = "https://github.com/microsoft/VbsEnclaveTooling" }
edlcodegen-enclave = { version = "0.1" }
flatbuffers = { version = "25.9.23", default-features = false }
widestring = { version = "1.2.1", default-features = false, features = ["alloc"] }
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "code_gen_test_host_gen"
version = "0.0.0"
version = "0.1.0"
edition = "2024"
publish = false
description = "Generated internal helper crate containing EDL-derived host bindings and marshaling code"
license = "MIT"

[lib]
doc = false
doctest = false
test = false

[build-dependencies]
edlcodegen-tools = { git = "https://github.com/microsoft/VbsEnclaveTooling" }
edlcodegen-tools = { version = "0.1" }

[dependencies]
edlcodegen-host = { git = "https://github.com/microsoft/VbsEnclaveTooling" }
edlcodegen-host = { version = "0.1" }
windows-strings = "0.5"
flatbuffers = { version = "25.9.23", default-features = false }
widestring = { version = "1.2.1", default-features = false, features = ["alloc"] }
Loading