1#![doc = include_str!("../README.md")]
2#![no_std]
3
4use rasn::prelude::*;
5
6#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
8#[rasn(identifier = "SEQUENCE")]
9pub struct AnonymousNegoData {
10 #[rasn(tag(context, 0), identifier = "negoToken")]
11 pub nego_token: OctetString,
12}
13
14impl AnonymousNegoData {
15 pub fn new(nego_token: OctetString) -> Self {
16 Self { nego_token }
17 }
18}
19
20#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
21#[rasn(delegate)]
22pub struct NegoData(pub SequenceOf<AnonymousNegoData>);
23
24#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
25pub struct TSCredentials {
26 #[rasn(tag(explicit(context, 0)), identifier = "credType")]
27 pub cred_type: Integer,
28 #[rasn(tag(explicit(context, 1)))]
29 pub credentials: OctetString,
30}
31
32impl TSCredentials {
33 pub fn new(cred_type: Integer, credentials: OctetString) -> Self {
34 Self {
35 cred_type,
36 credentials,
37 }
38 }
39}
40
41#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
42pub struct TSCspDataDetail {
43 #[rasn(tag(explicit(context, 0)), identifier = "keySpec")]
44 pub key_spec: Integer,
45 #[rasn(tag(explicit(context, 1)), identifier = "cardName")]
46 pub card_name: Option<OctetString>,
47 #[rasn(tag(explicit(context, 2)), identifier = "readerName")]
48 pub reader_name: Option<OctetString>,
49 #[rasn(tag(explicit(context, 3)), identifier = "containerName")]
50 pub container_name: Option<OctetString>,
51 #[rasn(tag(explicit(context, 4)), identifier = "cspName")]
52 pub csp_name: Option<OctetString>,
53}
54
55impl TSCspDataDetail {
56 pub fn new(
57 key_spec: Integer,
58 card_name: Option<OctetString>,
59 reader_name: Option<OctetString>,
60 container_name: Option<OctetString>,
61 csp_name: Option<OctetString>,
62 ) -> Self {
63 Self {
64 key_spec,
65 card_name,
66 reader_name,
67 container_name,
68 csp_name,
69 }
70 }
71}
72
73#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
74pub struct TSPasswordCreds {
75 #[rasn(tag(explicit(context, 0)), identifier = "domainName")]
76 pub domain_name: OctetString,
77 #[rasn(tag(explicit(context, 1)), identifier = "userName")]
78 pub user_name: OctetString,
79 #[rasn(tag(explicit(context, 2)))]
80 pub password: OctetString,
81}
82
83impl TSPasswordCreds {
84 pub fn new(domain_name: OctetString, user_name: OctetString, password: OctetString) -> Self {
85 Self {
86 domain_name,
87 user_name,
88 password,
89 }
90 }
91}
92
93#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
94pub struct TSRemoteGuardCreds {
95 #[rasn(tag(explicit(context, 0)), identifier = "logonCred")]
96 pub logon_cred: TSRemoteGuardPackageCred,
97 #[rasn(tag(explicit(context, 1)), identifier = "supplementalCreds")]
98 pub supplemental_creds: Option<SequenceOf<TSRemoteGuardPackageCred>>,
99}
100
101impl TSRemoteGuardCreds {
102 pub fn new(
103 logon_cred: TSRemoteGuardPackageCred,
104 supplemental_creds: Option<SequenceOf<TSRemoteGuardPackageCred>>,
105 ) -> Self {
106 Self {
107 logon_cred,
108 supplemental_creds,
109 }
110 }
111}
112
113#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
114pub struct TSRemoteGuardPackageCred {
115 #[rasn(tag(explicit(context, 0)), identifier = "packageName")]
116 pub package_name: OctetString,
117 #[rasn(tag(explicit(context, 1)), identifier = "credBuffer")]
118 pub cred_buffer: OctetString,
119}
120
121impl TSRemoteGuardPackageCred {
122 pub fn new(package_name: OctetString, cred_buffer: OctetString) -> Self {
123 Self {
124 package_name,
125 cred_buffer,
126 }
127 }
128}
129
130#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
131pub struct TSRequest {
132 #[rasn(tag(explicit(context, 0)))]
133 pub version: Integer,
134 #[rasn(tag(explicit(context, 1)), identifier = "negoTokens")]
135 pub nego_tokens: Option<NegoData>,
136 #[rasn(tag(explicit(context, 2)), identifier = "authInfo")]
137 pub auth_info: Option<OctetString>,
138 #[rasn(tag(explicit(context, 3)), identifier = "pubKeyAuth")]
139 pub pub_key_auth: Option<OctetString>,
140 #[rasn(tag(explicit(context, 4)), identifier = "errorCode")]
141 pub error_code: Option<Integer>,
142 #[rasn(tag(explicit(context, 5)), identifier = "clientNonce")]
143 pub client_nonce: Option<OctetString>,
144}
145
146impl TSRequest {
147 pub fn new(
148 version: Integer,
149 nego_tokens: Option<NegoData>,
150 auth_info: Option<OctetString>,
151 pub_key_auth: Option<OctetString>,
152 error_code: Option<Integer>,
153 client_nonce: Option<OctetString>,
154 ) -> Self {
155 Self {
156 version,
157 nego_tokens,
158 auth_info,
159 pub_key_auth,
160 error_code,
161 client_nonce,
162 }
163 }
164}
165
166#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
167pub struct TSSmartCardCreds {
168 #[rasn(tag(explicit(context, 0)))]
169 pub pin: OctetString,
170 #[rasn(tag(explicit(context, 1)), identifier = "cspData")]
171 pub csp_data: TSCspDataDetail,
172 #[rasn(tag(explicit(context, 2)), identifier = "userHint")]
173 pub user_hint: Option<OctetString>,
174 #[rasn(tag(explicit(context, 3)), identifier = "domainHint")]
175 pub domain_hint: Option<OctetString>,
176}
177
178impl TSSmartCardCreds {
179 pub fn new(
180 pin: OctetString,
181 csp_data: TSCspDataDetail,
182 user_hint: Option<OctetString>,
183 domain_hint: Option<OctetString>,
184 ) -> Self {
185 Self {
186 pin,
187 csp_data,
188 user_hint,
189 domain_hint,
190 }
191 }
192}