tss_sapi/
errors.rs

1pub mod tcti {
2    error_chain! {
3        errors {
4            GenFail {
5                description("general failure")
6                display("general failure")
7            }
8            IoError {
9                description("I/O failure")
10                display("I/O failure")
11            }
12            NotWrapped(e: u32) {
13                description("an unwrapped TCTI error")
14                display("an unwrapped TCTI error: 0x{:08X}", e)
15            }
16        }
17    }
18}
19
20pub mod tpm {
21    error_chain! {
22        errors {
23            Asymmetric {
24                description("asymmetric algorithm not supported or not correct")
25                display("asymmetric algorithm not supported or not correct")
26            }
27            Attributes {
28                description("inconsistent attributes")
29                display("inconsistent attributes")
30            }
31            AuthFail {
32                description("the authorization HMAC check failed and DA counter incremented")
33                display("the authorization HMAC check failed and DA counter incremented")
34            }
35            BadAuth {
36                description("authorization failure without DA implications")
37                display("authorization failure without DA implications")
38            }
39            Disabled {
40                description("TPM is disabled")
41                display("TPM is disabled")
42            }
43            Failure {
44                description("commands not accepted because of a TPM failure")
45                display("commands not accepted because of a TPM failure")
46            }
47            Exclusive {
48                description("command failed because audit sequence required exclusivity")
49                display("command failed because audit sequence required exclusivity")
50            }
51            FormatOne(e: u32) {
52                description("an unwrapped TPM format one error")
53                display("an unwrapped TPM format one error: 0x{:02X}", e)
54            }
55            FormatZero(e: u32) {
56                description("an unwrapped TPM format zero error")
57                display("an unwrapped TPM format zero error: 0x{:02X}", e)
58            }
59            Handle {
60                description("the handle is not correct for the use")
61                display("the handle is not correct for the use")
62            }
63            Hash {
64                description("hash algorithm not supported or not appropriate")
65                display("hash algorithm not supported or not appropriate")
66            }
67            Hierarchy {
68                description("hierarchy is not enabled or is not correct for the use")
69                display("hierarchy is not enabled or is not correct for the use")
70            }
71            Initialize {
72                description("TPM not initialized")
73                display("TPM not initialized")
74            }
75            Insufficient {
76                description("the TPM was unable to unmarshal a value\
77                    because there were not enough objects in the input")
78                display("the TPM was unable to unmarshal a value\
79                    because there were not enough objects in the input")
80            }
81            Kdf {
82                description(r#"unsupported key derivation function or
83                    function not appropriate for use"#)
84                display("unsupported key derivation function or function not appropriate for use")
85            }
86            Key {
87                description("key fields are not compatible with the selected use")
88                display("key fields are not compatible with the selected use")
89            }
90            KeySize {
91                description("key size is not supported")
92                display("key size is not supported")
93            }
94            Mgf {
95                description("mask generation function not supported")
96                display("mask generation function not supported")
97            }
98            Mode {
99                description("mode of operation not supported")
100                display("mode of operation not supported")
101            }
102            Nonce {
103                description("invalid nonce size")
104                display("invalid nonce size")
105            }
106            NvAuthorization {
107                description("NV access authorization fails in command actions")
108                display("NV access authorization fails in command actions")
109            }
110            NvDefined {
111                description("NV Index or persistend object already defined")
112                display("NV Index or persistend object already defined")
113            }
114            NvLocked {
115                description("NV access is locked")
116                display("NV access is locked")
117            }
118            NvSpace {
119                description("insufficient space for NV allocation")
120                display("insufficient space for NV allocation")
121            }
122            NvUnavailable {
123                description("command requires writing of NV and NV is not accessible")
124                display("command requires writing of NV and NV is not accessible")
125            }
126            PhysicalPresence {
127                description("auth requires assertion of physical presense")
128                display("auth requires assertion of physical presense")
129            }
130            PolicyFail {
131                description("a policy check failed")
132                display("a policy check failed")
133            }
134            Range {
135                description("value was out of allowed range")
136                display("value was out of allowed range")
137            }
138            Reboot {
139                description("TPM init and startup(clear) is required for TPM to resume operation")
140                display("TPM init and startup(clear) is required for TPM to resume operation")
141            }
142            Scheme {
143                description("unsupported or incompatible scheme")
144                display("unsupported or incompatible scheme")
145            }
146            Selector {
147                description("union selector is incorrect")
148                display("union selector is incorrect")
149            }
150            Signature {
151                description("the signature is not valid")
152                display("the signature is not valid")
153            }
154            Size {
155                description("structure is the wrong size")
156                display("structure is the wrong size")
157            }
158            Symmetric {
159                description("unsupported symmetric algorithm or key size")
160                display("unsupported symmetric algorithm or key size")
161            }
162            Tag {
163                description("incorrect structure tag")
164                display("incorrect structure tag")
165            }
166            Type {
167                description("the type of the value is not appropriate for the use")
168                display("the type of the value is not appropriate for the use")
169            }
170            Value {
171                description("value is out of range or is not correct for the context")
172                display("value is out of range or is not correct for the context")
173            }
174        }
175    }
176}
177
178error_chain! {
179     foreign_links {
180         Io(::std::io::Error);
181         Null(::std::ffi::NulError);
182     }
183    links {
184        Tpm(tpm::Error, tpm::ErrorKind);
185        Tcti(tcti::Error, tcti::ErrorKind);
186    }
187    errors {
188        AppError(e: u32) {
189            description("unknown app level error")
190            display("unknown app level error: 0x{:08X}", e)
191        }
192        BadSize(e: String) {
193            description("invalid size provided")
194            display("invalid size provided: {}", e)
195        }
196        FeatureError(e: u32) {
197            description("unknown feature error")
198            display("unknown app level error: 0x{:08X}", e)
199        }
200        EsapiError(e: u32) {
201            description("unknown ESAPI error")
202            display("unknown ESAPI error: 0x{:08X}", e)
203        }
204        ResMgrTpmError(e: u32) {
205            description("unknown resource manager TPM error")
206            display("unknown resource manager TPM error: 0x{:08X}", e)
207        }
208        ResMgrError(e: u32) {
209            description("unknown resource manager error")
210            display("unknown resource manager error: 0x{:08X}", e)
211        }
212        DriverError(e: u32) {
213            description("unknown driver error")
214            display("unknown driver error: 0x{:08X}", e)
215        }
216        Unknown(e: u32) {
217            description("unknown error")
218            display("unknown error: 0x{:08X}", e)
219        }
220    }
221}