Skip to main content

windows_enclave/manual_bindings/
veinterop.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use crate::vertdll::*;
5
6// The following types in VEINTEROP.DLL should be generated but are not currently included in the Win32 metadata.
7// We manually define them here based on the content of veinterop_kcm.h.
8
9pub type USER_BOUND_KEY_SESSION_HANDLE = *mut core::ffi::c_void;
10pub type USER_BOUND_KEY_AUTH_CONTEXT_HANDLE = *mut core::ffi::c_void;
11
12#[repr(i32)]
13#[derive(Copy, Clone)]
14pub enum USER_BOUND_KEY_AUTH_CONTEXT_PROPERTY_NAME {
15    UserBoundKeyAuthContextPropertyCacheConfig = 0,
16}
17
18#[repr(C)]
19#[derive(Copy, Clone)]
20pub struct USER_BOUND_KEY_AUTH_CONTEXT_PROPERTY {
21    pub name: USER_BOUND_KEY_AUTH_CONTEXT_PROPERTY_NAME,
22    pub size: u32,
23    pub value: *mut core::ffi::c_void,
24}
25
26windows_link::link!("veinterop.dll" "system" fn InitializeUserBoundKeySession(
27    challenge: *const core::ffi::c_void,
28    challengeSize: u32,
29    report: *mut *mut core::ffi::c_void,
30    reportSize: *mut u32,
31    sessionHandle: *mut USER_BOUND_KEY_SESSION_HANDLE
32) -> HRESULT);
33
34windows_link::link!("veinterop.dll" "system" fn CreateUserBoundKeyRequestForRetrieveAuthorizationContext(
35    sessionHandle: USER_BOUND_KEY_SESSION_HANDLE,
36    keyName: PCWSTR,
37    nonce: *mut u64,
38    encryptedRequest: *mut *mut core::ffi::c_void,
39    encryptedRequestSize: *mut u32
40) -> HRESULT);
41
42windows_link::link!("veinterop.dll" "system" fn GetUserBoundKeyAuthContext(
43    sessionHandle: USER_BOUND_KEY_SESSION_HANDLE,
44    authContextBlob: *const core::ffi::c_void,
45    authContextBlobSize: u32,
46    nonce: u64,
47    authContextHandle: *mut USER_BOUND_KEY_AUTH_CONTEXT_HANDLE
48) -> HRESULT);
49
50windows_link::link!("veinterop.dll" "system" fn ValidateUserBoundKeyAuthContext(
51    keyName: PCWSTR,
52    authContextHandle: USER_BOUND_KEY_AUTH_CONTEXT_HANDLE,
53    count: u32,
54    values: *const USER_BOUND_KEY_AUTH_CONTEXT_PROPERTY
55) -> HRESULT);
56
57windows_link::link!("veinterop.dll" "system" fn ProtectUserBoundKey(
58    authContext: USER_BOUND_KEY_AUTH_CONTEXT_HANDLE,
59    userKey: *const core::ffi::c_void,
60    userKeySize: u32,
61    boundKey: *mut *mut core::ffi::c_void,
62    boundKeySize: *mut u32
63) -> HRESULT);
64
65windows_link::link!("veinterop.dll" "system" fn CloseUserBoundKeyAuthContext(
66    handle: USER_BOUND_KEY_AUTH_CONTEXT_HANDLE
67) -> HRESULT);
68
69windows_link::link!("veinterop.dll" "system" fn CloseUserBoundKeySession(
70    sessionHandle: USER_BOUND_KEY_SESSION_HANDLE
71) -> HRESULT);
72
73windows_link::link!("veinterop.dll" "system" fn CreateUserBoundKeyRequestForDeriveSharedSecret(
74    sessionHandle: USER_BOUND_KEY_SESSION_HANDLE,
75    keyName: PCWSTR,
76    publicKeyBytes: *const core::ffi::c_void,
77    publicKeyBytesSize: u32,
78    nonce: *mut u64,
79    encryptedRequest: *mut *mut core::ffi::c_void,
80    encryptedRequestSize: *mut u32
81) -> HRESULT);
82
83windows_link::link!("veinterop.dll" "system" fn UnprotectUserBoundKey(
84    sessionHandle: USER_BOUND_KEY_SESSION_HANDLE,
85    authContext: USER_BOUND_KEY_AUTH_CONTEXT_HANDLE,
86    sessionEncryptedDerivedSecret: *const core::ffi::c_void,
87    sessionEncryptedDerivedSecretSize: u32,
88    encryptedUserBoundKey: *const core::ffi::c_void,
89    encryptedUserBoundKeySize: u32,
90    nonce: u64,
91    userKey: *mut *mut core::ffi::c_void,
92    userKeySize: *mut u32
93) -> HRESULT);