rasn_credssp/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#![doc = include_str!("../README.md")]
#![no_std]

use rasn::prelude::*;

/// Anonymous SEQUENCE OF member
#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
#[rasn(identifier = "SEQUENCE")]
pub struct AnonymousNegoData {
    #[rasn(tag(context, 0), identifier = "negoToken")]
    pub nego_token: OctetString,
}

impl AnonymousNegoData {
    pub fn new(nego_token: OctetString) -> Self {
        Self { nego_token }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
#[rasn(delegate)]
pub struct NegoData(pub SequenceOf<AnonymousNegoData>);

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSCredentials {
    #[rasn(tag(explicit(context, 0)), identifier = "credType")]
    pub cred_type: Integer,
    #[rasn(tag(explicit(context, 1)))]
    pub credentials: OctetString,
}

impl TSCredentials {
    pub fn new(cred_type: Integer, credentials: OctetString) -> Self {
        Self {
            cred_type,
            credentials,
        }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSCspDataDetail {
    #[rasn(tag(explicit(context, 0)), identifier = "keySpec")]
    pub key_spec: Integer,
    #[rasn(tag(explicit(context, 1)), identifier = "cardName")]
    pub card_name: Option<OctetString>,
    #[rasn(tag(explicit(context, 2)), identifier = "readerName")]
    pub reader_name: Option<OctetString>,
    #[rasn(tag(explicit(context, 3)), identifier = "containerName")]
    pub container_name: Option<OctetString>,
    #[rasn(tag(explicit(context, 4)), identifier = "cspName")]
    pub csp_name: Option<OctetString>,
}

impl TSCspDataDetail {
    pub fn new(
        key_spec: Integer,
        card_name: Option<OctetString>,
        reader_name: Option<OctetString>,
        container_name: Option<OctetString>,
        csp_name: Option<OctetString>,
    ) -> Self {
        Self {
            key_spec,
            card_name,
            reader_name,
            container_name,
            csp_name,
        }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSPasswordCreds {
    #[rasn(tag(explicit(context, 0)), identifier = "domainName")]
    pub domain_name: OctetString,
    #[rasn(tag(explicit(context, 1)), identifier = "userName")]
    pub user_name: OctetString,
    #[rasn(tag(explicit(context, 2)))]
    pub password: OctetString,
}

impl TSPasswordCreds {
    pub fn new(domain_name: OctetString, user_name: OctetString, password: OctetString) -> Self {
        Self {
            domain_name,
            user_name,
            password,
        }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSRemoteGuardCreds {
    #[rasn(tag(explicit(context, 0)), identifier = "logonCred")]
    pub logon_cred: TSRemoteGuardPackageCred,
    #[rasn(tag(explicit(context, 1)), identifier = "supplementalCreds")]
    pub supplemental_creds: Option<SequenceOf<TSRemoteGuardPackageCred>>,
}

impl TSRemoteGuardCreds {
    pub fn new(
        logon_cred: TSRemoteGuardPackageCred,
        supplemental_creds: Option<SequenceOf<TSRemoteGuardPackageCred>>,
    ) -> Self {
        Self {
            logon_cred,
            supplemental_creds,
        }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSRemoteGuardPackageCred {
    #[rasn(tag(explicit(context, 0)), identifier = "packageName")]
    pub package_name: OctetString,
    #[rasn(tag(explicit(context, 1)), identifier = "credBuffer")]
    pub cred_buffer: OctetString,
}

impl TSRemoteGuardPackageCred {
    pub fn new(package_name: OctetString, cred_buffer: OctetString) -> Self {
        Self {
            package_name,
            cred_buffer,
        }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSRequest {
    #[rasn(tag(explicit(context, 0)))]
    pub version: Integer,
    #[rasn(tag(explicit(context, 1)), identifier = "negoTokens")]
    pub nego_tokens: Option<NegoData>,
    #[rasn(tag(explicit(context, 2)), identifier = "authInfo")]
    pub auth_info: Option<OctetString>,
    #[rasn(tag(explicit(context, 3)), identifier = "pubKeyAuth")]
    pub pub_key_auth: Option<OctetString>,
    #[rasn(tag(explicit(context, 4)), identifier = "errorCode")]
    pub error_code: Option<Integer>,
    #[rasn(tag(explicit(context, 5)), identifier = "clientNonce")]
    pub client_nonce: Option<OctetString>,
}

impl TSRequest {
    pub fn new(
        version: Integer,
        nego_tokens: Option<NegoData>,
        auth_info: Option<OctetString>,
        pub_key_auth: Option<OctetString>,
        error_code: Option<Integer>,
        client_nonce: Option<OctetString>,
    ) -> Self {
        Self {
            version,
            nego_tokens,
            auth_info,
            pub_key_auth,
            error_code,
            client_nonce,
        }
    }
}

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
pub struct TSSmartCardCreds {
    #[rasn(tag(explicit(context, 0)))]
    pub pin: OctetString,
    #[rasn(tag(explicit(context, 1)), identifier = "cspData")]
    pub csp_data: TSCspDataDetail,
    #[rasn(tag(explicit(context, 2)), identifier = "userHint")]
    pub user_hint: Option<OctetString>,
    #[rasn(tag(explicit(context, 3)), identifier = "domainHint")]
    pub domain_hint: Option<OctetString>,
}

impl TSSmartCardCreds {
    pub fn new(
        pin: OctetString,
        csp_data: TSCspDataDetail,
        user_hint: Option<OctetString>,
        domain_hint: Option<OctetString>,
    ) -> Self {
        Self {
            pin,
            csp_data,
            user_hint,
            domain_hint,
        }
    }
}