1#[derive(Copy, Clone, Debug, Default)]
5#[repr(C)]
6pub struct Void {
7 _inner: [u8; 0],
8 _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
9}
10
11pub type INT8 = i8;
12pub type INT16 = i16;
13pub type INT32 = i32;
14pub type UINT8 = u8;
15pub type UINT16 = u16;
16pub type UINT32 = u32;
17pub type SHORT = INT16;
18pub type LONG = INT32;
19pub type UINT = INT32;
20pub type USHORT = UINT16;
21pub type ULONG = UINT32;
22
23pub type BOOL = UINT32;
24pub type BYTE = UINT8;
25pub type CHAR = UINT8;
26
27pub type WORD = UINT16;
28
29pub type DWORD = UINT32;
30pub type FLAGS = UINT32;
31
32pub type LPSTR = *const CHAR;
33pub type HANDLE = *const Void;
34
35pub const TRUE: BOOL = 0x00000001;
36pub const FALSE: BOOL = 0x00000000;
37
38pub const DEV_LOCK_FOREVER: ULONG = 0xffffffff;
39pub const ADMIN_TYPE: BYTE = 0x0;
40pub const USER_TYPE: BYTE = 0x1;
41
42pub const MAX_RSA_MODULUS_LEN: usize = 256;
43pub const MAX_RSA_EXPONENT_LEN: usize = 4;
44
45pub const ECC_MAX_X_COORDINATE_BITS_LEN: usize = 512;
46pub const ECC_MAX_Y_COORDINATE_BITS_LEN: usize = 512;
47pub const ECC_MAX_MODULUS_BITS_LEN: usize = 512;
48
49pub const MAX_IV_LEN: usize = 32;
50pub const MAX_FILE_NAME_LEN: usize = 32;
51pub const MAX_CONTAINER_NAME_LEN: usize = 128;
52pub const MIN_PIN_LEN: usize = 6;
53
54pub const SECURE_NEVER_ACCOUNT: UINT32 = 0x00000000;
55pub const SECURE_ADM_ACCOUNT: UINT32 = 0x00000001;
56pub const SECURE_USER_ACCOUNT: UINT32 = 0x00000010;
57pub const SECURE_EVERYONE_ACCOUNT: UINT32 = 0x000000FF;
58
59#[derive(Debug, Copy, Clone, Default)]
61#[repr(C, packed(1))]
62pub struct Version {
63 pub major: BYTE,
64 pub minor: BYTE,
65}
66
67#[derive(Debug, Copy, Clone)]
69#[repr(C, packed(1))]
70pub struct DeviceInfo {
71 pub version: Version,
72 pub manufacturer: [CHAR; 64],
73 pub issuer: [CHAR; 64],
74 pub label: [CHAR; 32],
75 pub serial_number: [CHAR; 32],
76 pub hw_version: Version,
77 pub firmware_version: Version,
78 pub alg_sym_cap: ULONG,
79 pub alg_asym_cap: ULONG,
80 pub alg_hash_cap: ULONG,
81 pub dev_auth_alg_id: ULONG,
82 pub total_space: ULONG,
83 pub free_space: ULONG,
84 pub max_ecc_buffer_size: ULONG,
85 pub max_buffer_size: ULONG,
86 pub reserved: [BYTE; 64],
87}
88
89#[derive(Debug, Copy, Clone)]
91#[repr(C, packed(1))]
92pub struct RSAPublicKeyBlob {
93 pub alg_id: ULONG,
94 pub bit_leb: ULONG,
95 pub version: Version,
96 pub modulus: [BYTE; MAX_RSA_MODULUS_LEN],
97 pub public_exponent: [BYTE; MAX_RSA_EXPONENT_LEN],
98}
99
100#[derive(Debug, Copy, Clone)]
102#[repr(C, packed(1))]
103pub struct RSAPrivateKeyBlob {
104 pub alg_id: ULONG,
105 pub bit_leb: ULONG,
106 pub modulus: [BYTE; MAX_RSA_MODULUS_LEN],
107 pub public_exponent: [BYTE; MAX_RSA_EXPONENT_LEN],
108 pub private_exponent: [BYTE; MAX_RSA_MODULUS_LEN],
109 pub prime1: [BYTE; MAX_RSA_MODULUS_LEN / 2],
110 pub prime2: [BYTE; MAX_RSA_MODULUS_LEN / 2],
111 pub prime1_exponent: [BYTE; MAX_RSA_MODULUS_LEN / 2],
112 pub prime2_exponent: [BYTE; MAX_RSA_MODULUS_LEN / 2],
113 pub coefficient: [BYTE; MAX_RSA_MODULUS_LEN / 2],
114}
115
116#[derive(Debug, Copy, Clone)]
118#[repr(C, packed(1))]
119pub struct ECCPublicKeyBlob {
120 pub bit_len: ULONG,
122 pub x_coordinate: [BYTE; ECC_MAX_X_COORDINATE_BITS_LEN / 8],
123 pub y_coordinate: [BYTE; ECC_MAX_Y_COORDINATE_BITS_LEN / 8],
124}
125
126#[derive(Debug, Copy, Clone)]
128#[repr(C, packed(1))]
129pub struct ECCPrivateKeyBlob {
130 pub bit_len: ULONG,
132 pub private_key: [BYTE; ECC_MAX_MODULUS_BITS_LEN / 8],
133}
134
135#[derive(Debug, Copy, Clone)]
137#[repr(C, packed(1))]
138pub struct ECCCipherBlob {
139 pub x_coordinate: [BYTE; ECC_MAX_X_COORDINATE_BITS_LEN / 8],
140 pub y_coordinate: [BYTE; ECC_MAX_Y_COORDINATE_BITS_LEN / 8],
141 pub hash: [BYTE; 32],
142 pub cipher_len: ULONG,
143 pub cipher: [BYTE; 1],
144}
145
146#[derive(Debug, Copy, Clone)]
148#[repr(C, packed(1))]
149pub struct ECCSignatureBlob {
150 pub r: [BYTE; ECC_MAX_X_COORDINATE_BITS_LEN / 8],
151 pub s: [BYTE; ECC_MAX_Y_COORDINATE_BITS_LEN / 8],
152}
153
154#[derive(Debug, Copy, Clone)]
156#[repr(C, packed(1))]
157pub struct EnvelopedKeyBlob {
158 pub version: ULONG,
159 pub sym_alg_id: ULONG,
160 pub bits: ULONG,
161 pub cb_encrypted_pri_key: [BYTE; 64],
162 pub pub_key: ECCPublicKeyBlob,
163 pub ecc_cipher_blob: ECCCipherBlob,
164}
165
166#[derive(Debug, Copy, Clone)]
168#[repr(C, packed(1))]
169pub struct BlockCipherParam {
170 pub iv: [BYTE; MAX_IV_LEN],
171 pub iv_len: ULONG,
172 pub padding_type: ULONG,
173 pub feed_bit_len: ULONG,
174}
175
176#[derive(Debug, Copy, Clone, Default)]
178#[repr(C, packed(1))]
179pub struct FileAttribute {
180 pub file_name: [CHAR; 32],
181 pub file_size: ULONG,
182 pub read_rights: ULONG,
183 pub write_rights: ULONG,
184}