kmip_protocol/types/
common.rs

1//! Rust types common to both serialization of KMIP requests and deserialization KMIP responses.
2use serde_derive::Deserialize;
3use serde_derive::Serialize;
4
5use enum_display_derive::Display;
6use enum_flags::EnumFlags;
7use std::fmt::Display;
8
9///  See KMIP 1.0 section 2.1.1 [Attribute](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581155).
10#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
11#[serde(rename = "Transparent:0x42000A")]
12pub struct AttributeName(pub String);
13
14impl std::cmp::PartialEq<str> for AttributeName {
15    fn eq(&self, other: &str) -> bool {
16        self.0 == other
17    }
18}
19
20///  See KMIP 1.0 section 2.1.1 [Attribute](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581155).
21#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
22#[serde(rename = "Transparent:0x420009")]
23pub struct AttributeIndex(pub i32);
24
25impl std::cmp::PartialEq<i32> for AttributeIndex {
26    fn eq(&self, other: &i32) -> bool {
27        &self.0 == other
28    }
29}
30
31///  See KMIP 1.0 section 2.1.1 [Attribute](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581155).
32#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
33#[serde(rename(serialize = "Override:0x42000B"))]
34#[non_exhaustive]
35pub enum AttributeValue {
36    // ///  See KMIP 1.0 section 3.1 Unique Identifier.
37    // Not implemented
38
39    // ///  See KMIP 1.0 section 3.2 Name.
40    #[serde(rename(deserialize = "if 0x42000A==Name"))]
41    Name(NameValue, NameType),
42
43    // ///  See KMIP 1.0 section 3.3 Object Type.
44    #[serde(rename(deserialize = "if 0x42000A==Object Type"))]
45    #[serde(rename(serialize = "Transparent"))]
46    ObjectType(ObjectType),
47
48    // ///  See KMIP 1.0 section 3.4 Cryptographic Algorithm.
49    #[serde(rename(deserialize = "if 0x42000A==Cryptographic Algorithm"))]
50    #[serde(rename(serialize = "Transparent"))]
51    CryptographicAlgorithm(CryptographicAlgorithm),
52
53    // ///  See KMIP 1.0 section 3.5 Cryptographic Length.
54    // Not implemented
55
56    // ///  See KMIP 1.0 section 3.6 Cryptographic Parameters.
57    #[serde(rename(deserialize = "if 0x42000A==Cryptographic Parameters"))]
58    CryptographicParameters(
59        #[serde(skip_serializing_if = "Option::is_none")] Option<BlockCipherMode>,
60        #[serde(skip_serializing_if = "Option::is_none")] Option<PaddingMethod>,
61        #[serde(skip_serializing_if = "Option::is_none")] Option<HashingAlgorithm>,
62        #[serde(skip_serializing_if = "Option::is_none")] Option<KeyRoleType>,
63        #[serde(skip_serializing_if = "Option::is_none")] Option<DigitalSignatureAlgorithm>, // KMIP 1.2
64        #[serde(skip_serializing_if = "Option::is_none")] Option<CryptographicAlgorithm>,    // KMIP 1.2
65        #[serde(skip_serializing_if = "Option::is_none")] Option<RandomIV>,                  // KMIP 1.2
66        #[serde(skip_serializing_if = "Option::is_none")] Option<IVLength>,                  // KMIP 1.2
67        #[serde(skip_serializing_if = "Option::is_none")] Option<TagLength>,                 // KMIP 1.2
68        #[serde(skip_serializing_if = "Option::is_none")] Option<FixedFieldLength>,          // KMIP 1.2
69        #[serde(skip_serializing_if = "Option::is_none")] Option<InvocationFieldLength>,     // KMIP 1.2
70        #[serde(skip_serializing_if = "Option::is_none")] Option<CounterLength>,             // KMIP 1.2
71        #[serde(skip_serializing_if = "Option::is_none")] Option<InitialCounterValue>,       // KMIP 1.2
72    ),
73
74    // ///  See KMIP 1.0 section 3.7 Cryptographic Domain Parameters.
75    // Not implemented
76
77    // ///  See KMIP 1.0 section 3.8 Certificate Type.
78    // Not implemented
79
80    // ///  See KMIP 1.0 section 3.9 Certificate Identifier.
81    // Not implemented
82
83    // ///  See KMIP 1.0 section 3.10 Certificate Subject.
84    // Not implemented
85
86    // ///  See KMIP 1.0 section 3.11 Certificate Issuer.
87    // Not implemented
88
89    // ///  See KMIP 1.0 section 3.12 Digest.
90    // Not implemented
91
92    // ///  See KMIP 1.0 section 3.13 Operation Policy Name.
93    // Not implemented
94
95    // ///  See KMIP 1.0 section 3.14 Cryptographic Usage Mask.
96    // Not implemented
97
98    // ///  See KMIP 1.0 section 3.15 Lease Time.
99    // Not implemented
100
101    // ///  See KMIP 1.0 section 3.16 Usage Limits.
102    // Not implemented
103
104    // ///  See KMIP 1.0 section 3.17 State.
105    #[serde(rename(deserialize = "if 0x42000A==State"))]
106    #[serde(rename(serialize = "Transparent"))]
107    State(State),
108
109    // ///  See KMIP 1.0 section 3.18 Initial Date.
110    // Not implemented
111
112    // ///  See KMIP 1.0 section 3.19 Activation Date.
113    // Not implemented
114
115    // ///  See KMIP 1.0 section 3.20 Process Start Date.
116    // Not implemented
117
118    // ///  See KMIP 1.0 section 3.21 Protect Stop Date.
119    // Not implemented
120
121    // ///  See KMIP 1.0 section 3.22 Deactivation Date.
122    // Not implemented
123
124    // ///  See KMIP 1.0 section 3.23 Destroy Date.
125    // Not implemented
126
127    // ///  See KMIP 1.0 section 3.24 Compromise Occurence Date.
128    // Not implemented
129
130    // ///  See KMIP 1.0 section 3.25 Compromise Date.
131    // Not implemented
132
133    // ///  See KMIP 1.0 section 3.26 Revocation Reason.
134    // Not implemented
135
136    // ///  See KMIP 1.0 section 3.27 Archive Date.
137    // Not implemented
138
139    // ///  See KMIP 1.0 section 3.28 Object Group.
140    #[serde(rename(deserialize = "if 0x42000A==Object Group"))]
141    ObjectGroup(String),
142
143    // ///  See KMIP 1.0 section 3.29 Link.
144    #[serde(rename(deserialize = "if 0x42000A==Linked Object Identifier"))]
145    Link(LinkType, LinkedObjectIdentifier),
146
147    // ///  See KMIP 1.0 section 3.30 Application Specific Information.
148    #[serde(rename(deserialize = "if 0x42000A==Application Specific Information"))]
149    ApplicationSpecificInformation(ApplicationNamespace, ApplicationData),
150
151    // ///  See KMIP 1.0 section 3.31 Contact Information.
152    #[serde(rename(deserialize = "if 0x42000A==Contact Information"))]
153    #[serde(rename(serialize = "Transparent"))]
154    ContactInformation(String),
155
156    // ///  See KMIP 1.0 section 3.32 Last Change Date.
157    // Not implemented
158
159    // ///  See KMIP 1.0 section 3.33 Custom Attribute:.
160    //   "Any data type or structure. If a structure, then the structure SHALL NOT include sub structures"
161    // See: https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581207
162
163    // TODO: Will this support arbitrary structures?
164    #[serde(rename(deserialize = "if type==Structure"))]
165    Structure(Vec<AttributeValue>),
166
167    #[serde(rename(deserialize = "if type==Integer"))]
168    #[serde(rename(serialize = "Transparent"))]
169    Integer(i32),
170
171    #[serde(rename(deserialize = "if type==LongInteger"))]
172    LongInteger(i64),
173
174    // TODO
175    // #[serde(rename = "if type==BigInteger")]
176    // BigInteger(??)
177    #[serde(rename(deserialize = "if type==Enumeration"))]
178    #[serde(rename(serialize = "Transparent"))]
179    Enumeration(u32),
180
181    #[serde(rename(deserialize = "if type==Boolean"))]
182    #[serde(rename(serialize = "Transparent"))]
183    Boolean(bool),
184
185    #[serde(rename(deserialize = "if type==TextString"))]
186    #[serde(rename(serialize = "Transparent"))]
187    TextString(String),
188
189    #[serde(rename(deserialize = "if type==ByteString"))]
190    #[serde(with = "serde_bytes")]
191    ByteString(Vec<u8>),
192
193    #[serde(rename(deserialize = "if type==DateTime"))]
194    #[serde(rename(serialize = "Transparent"))]
195    DateTime(u64),
196    // TODO
197    // #[serde(rename = "if type==Interval")]
198    // Interval(??),
199}
200
201///  See KMIP 1.0 section 2.1.4 [Key Value](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581158).
202#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
203#[serde(rename = "0x420043")]
204pub enum KeyMaterial {
205    #[serde(rename(deserialize = "if 0x420042 in [0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000006]"))] // Raw, Opaque, PKCS1, PKCS8 or ECPrivateKey
206    #[serde(rename(serialize = "Transparent"))]
207    Bytes(#[serde(with = "serde_bytes")] Vec<u8>),
208
209    #[serde(rename(deserialize = "if 0x420042 == 0x00000007"))]
210    TransparentSymmetricKey(TransparentSymmetricKey),
211
212    #[serde(rename(deserialize = "if 0x420042 == 0x00000008"))]
213    TransparentDSAPrivateKey(TransparentDSAPrivateKey),
214
215    #[serde(rename(deserialize = "if 0x420042 == 0x00000009"))]
216    TransparentDSAPublicKey(TransparentDSAPublicKey),
217
218    #[serde(rename(deserialize = "if 0x420042 == 0x0000000A"))]
219    TransparentRSAPrivateKey(TransparentRSAPrivateKey),
220
221    #[serde(rename(deserialize = "if 0x420042 == 0x0000000B"))]
222    TransparentRSAPublicKey(TransparentRSAPublicKey),
223
224    #[serde(rename(deserialize = "if 0x420042 == 0x0000000C"))]
225    TransparentDHPrivateKey(TransparentDHPrivateKey),
226
227    #[serde(rename(deserialize = "if 0x420042 == 0x0000000D"))]
228    TransparentDHPublicKey(TransparentDHPublicKey),
229
230    #[serde(rename(deserialize = "if 0x420042 >= 0x0000000E"))]
231    Structure(#[serde(with = "serde_bytes")] Vec<u8>), // All other transparent key types which we don't support yet
232}
233
234///  See KMIP 1.0 section 2.1.7.1 [Transparent Symmetric Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
235#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
236#[serde(rename = "0x420043")]
237pub struct TransparentSymmetricKey {
238    #[serde(with = "serde_bytes")]
239    pub key: Vec<u8>,
240}
241
242///  See KMIP 1.0 section 2.1.7.2 [Transparent DSA Private Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
243#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
244#[serde(rename = "0x420043")]
245pub struct TransparentDSAPrivateKey {
246    #[serde(with = "serde_bytes")]
247    pub p: Vec<u8>,
248    #[serde(with = "serde_bytes")]
249    pub q: Vec<u8>,
250    #[serde(with = "serde_bytes")]
251    pub g: Vec<u8>,
252    #[serde(with = "serde_bytes")]
253    pub x: Vec<u8>,
254}
255
256///  See KMIP 1.0 section 2.1.7.3 [Transparent DSA Public Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
257#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
258#[serde(rename = "0x420043")]
259pub struct TransparentDSAPublicKey {
260    #[serde(with = "serde_bytes")]
261    pub p: Vec<u8>,
262    #[serde(with = "serde_bytes")]
263    pub q: Vec<u8>,
264    #[serde(with = "serde_bytes")]
265    pub g: Vec<u8>,
266    #[serde(with = "serde_bytes")]
267    pub x: Vec<u8>,
268}
269
270///  See KMIP 1.0 section 2.1.7.4 [Transparent RSA Private Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
271#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
272#[serde(rename = "0x420043")]
273pub struct TransparentRSAPrivateKey {
274    #[serde(with = "serde_bytes")]
275    pub modulus: Vec<u8>,
276    #[serde(with = "serde_bytes")]
277    pub private_exponent: Option<Vec<u8>>,
278    #[serde(with = "serde_bytes")]
279    pub public_exponent: Option<Vec<u8>>,
280    #[serde(with = "serde_bytes")]
281    pub p: Option<Vec<u8>>,
282    #[serde(with = "serde_bytes")]
283    pub q: Option<Vec<u8>>,
284    #[serde(with = "serde_bytes")]
285    pub prime_exponent_p: Option<Vec<u8>>,
286    #[serde(with = "serde_bytes")]
287    pub prime_exponent_q: Option<Vec<u8>>,
288    #[serde(with = "serde_bytes")]
289    pub crt_coefficient: Option<Vec<u8>>,
290}
291
292///  See KMIP 1.0 section 2.1.7.5 [Transparent RSA Public Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
293#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
294#[serde(rename = "0x420043")]
295pub struct TransparentRSAPublicKey {
296    #[serde(with = "serde_bytes")]
297    pub modulus: Vec<u8>,
298    #[serde(with = "serde_bytes")]
299    pub public_exponent: Vec<u8>,
300}
301
302///  See KMIP 1.0 section 2.1.7.6 [Transparent DH Private Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
303#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
304#[serde(rename = "0x420043")]
305pub struct TransparentDHPrivateKey {
306    #[serde(with = "serde_bytes")]
307    pub p: Vec<u8>,
308    #[serde(with = "serde_bytes")]
309    pub q: Option<Vec<u8>>,
310    #[serde(with = "serde_bytes")]
311    pub g: Vec<u8>,
312    #[serde(with = "serde_bytes")]
313    pub j: Option<Vec<u8>>,
314    #[serde(with = "serde_bytes")]
315    pub x: Vec<u8>,
316}
317
318///  See KMIP 1.0 section 2.1.7.7 [Transparent DH Public Key](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581161).
319#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
320#[serde(rename = "0x420043")]
321pub struct TransparentDHPublicKey {
322    #[serde(with = "serde_bytes")]
323    pub p: Vec<u8>,
324    #[serde(with = "serde_bytes")]
325    pub q: Option<Vec<u8>>,
326    #[serde(with = "serde_bytes")]
327    pub g: Vec<u8>,
328    #[serde(with = "serde_bytes")]
329    pub j: Option<Vec<u8>>,
330    #[serde(with = "serde_bytes")]
331    pub y: Vec<u8>,
332}
333
334///  See KMIP 1.2 section 2.1.10 [Data](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc395776391).
335#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
336#[serde(rename(deserialize = "0x4200C2"))]
337#[serde(rename(serialize = "Transparent:0x4200C2"))]
338pub struct Data(#[serde(with = "serde_bytes")] pub Vec<u8>);
339
340///  See KMIP 1.2 section 2.1.11 [Data Length](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613467).
341#[derive(Clone, Copy, Debug, Serialize, PartialEq, Eq)]
342#[serde(rename = "Transparent:0x4200C4")]
343pub struct DataLength(pub i32);
344
345///  See KMIP 1.0 section 3.1 [Unique Identifier](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613482).
346#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
347#[serde(rename = "Transparent:0x420094")]
348pub struct UniqueIdentifier(pub String);
349
350impl std::ops::Deref for UniqueIdentifier {
351    type Target = String;
352
353    fn deref(&self) -> &Self::Target {
354        &self.0
355    }
356}
357
358impl std::cmp::PartialEq<str> for UniqueIdentifier {
359    fn eq(&self, other: &str) -> bool {
360        self.0 == other
361    }
362}
363
364///  See KMIP 1.0 section 3.2 [Name](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581174).
365#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
366#[serde(rename = "Transparent:0x420055")]
367pub struct NameValue(pub String);
368
369impl std::fmt::Display for NameValue {
370    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
371        f.write_str(&self.0)
372    }
373}
374
375///  See KMIP 1.0 section 3.3 [Object Type](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581175).
376#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
377#[serde(rename = "0x420057")]
378#[non_exhaustive]
379pub enum ObjectType {
380    // KMIP 1.0 and 1.1 variants
381    #[serde(rename = "0x00000001")]
382    Certificate,
383
384    #[serde(rename = "0x00000002")]
385    SymmetricKey,
386
387    #[serde(rename = "0x00000003")]
388    PublicKey,
389
390    #[serde(rename = "0x00000004")]
391    PrivateKey,
392
393    #[serde(rename = "0x00000005")]
394    SplitKey,
395
396    #[serde(rename = "0x00000006")]
397    Template,
398
399    #[serde(rename = "0x00000007")]
400    SecretData,
401
402    #[serde(rename = "0x00000008")]
403    OpaqueObject,
404
405    // KMIP 1.2 variants
406    #[serde(rename = "0x00000009")]
407    PGPKey,
408}
409
410///  See KMIP 1.0 section 3.4 [Cryptographic Algorithm Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581176).
411#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
412#[serde(rename = "0x420028")]
413#[non_exhaustive]
414#[allow(non_camel_case_types)]
415pub enum CryptographicAlgorithm {
416    #[serde(rename = "0x00000001")]
417    DES,
418
419    #[serde(rename = "0x00000002")]
420    TRIPLE_DES,
421
422    #[serde(rename = "0x00000003")]
423    AES,
424
425    #[serde(rename = "0x00000004")]
426    RSA,
427}
428
429///  See KMIP 1.0 section 3.5 [Cryptographic Length](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581177).
430#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
431#[serde(rename = "Transparent:0x42002A")]
432pub struct CryptographicLength(pub i32);
433
434///  See KMIP 1.0 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
435#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
436#[serde(rename = "0x42002B")]
437#[rustfmt::skip]
438pub struct CryptographicParameters {
439    #[serde(skip_serializing_if = "Option::is_none")] pub block_cipher_mode: Option<BlockCipherMode>,
440    #[serde(skip_serializing_if = "Option::is_none")] pub padding_method: Option<PaddingMethod>,
441    #[serde(skip_serializing_if = "Option::is_none")] pub hashing_algorithm: Option<HashingAlgorithm>,
442    #[serde(skip_serializing_if = "Option::is_none")] pub key_role_type: Option<KeyRoleType>,
443    #[serde(skip_serializing_if = "Option::is_none")] pub digital_signature_algorithm: Option<DigitalSignatureAlgorithm>, // KMIP 1.2
444    #[serde(skip_serializing_if = "Option::is_none")] pub cryptographic_algorithm: Option<CryptographicAlgorithm>, // KMIP 1.2
445    #[serde(skip_serializing_if = "Option::is_none")] pub random_iv: Option<RandomIV>, // KMIP 1.2
446    #[serde(skip_serializing_if = "Option::is_none")] pub iv_length: Option<IVLength>, // KMIP 1.2
447    #[serde(skip_serializing_if = "Option::is_none")] pub tag_length: Option<TagLength>, // KMIP 1.2
448    #[serde(skip_serializing_if = "Option::is_none")] pub fixed_field_length: Option<FixedFieldLength>, // KMIP 1.2
449    #[serde(skip_serializing_if = "Option::is_none")] pub invocation_field_length: Option<InvocationFieldLength>, // KMIP 1.2
450    #[serde(skip_serializing_if = "Option::is_none")] pub counter_length: Option<CounterLength>, // KMIP 1.2
451    #[serde(skip_serializing_if = "Option::is_none")] pub initial_counter_value: Option<InitialCounterValue>, // KMIP 1.2
452}
453
454impl CryptographicParameters {
455    pub fn with_block_cipher_mode(self, value: BlockCipherMode) -> Self {
456        Self {
457            block_cipher_mode: Some(value),
458            ..self
459        }
460    }
461
462    pub fn with_padding_method(self, value: PaddingMethod) -> Self {
463        Self {
464            padding_method: Some(value),
465            ..self
466        }
467    }
468
469    pub fn with_hashing_algorithm(self, value: HashingAlgorithm) -> Self {
470        Self {
471            hashing_algorithm: Some(value),
472            ..self
473        }
474    }
475
476    pub fn with_key_role_type(self, value: KeyRoleType) -> Self {
477        Self {
478            key_role_type: Some(value),
479            ..self
480        }
481    }
482
483    pub fn with_digital_signature_algorithm(self, value: DigitalSignatureAlgorithm) -> Self {
484        Self {
485            digital_signature_algorithm: Some(value),
486            ..self
487        }
488    }
489
490    pub fn with_cryptographic_algorithm(self, value: CryptographicAlgorithm) -> Self {
491        Self {
492            cryptographic_algorithm: Some(value),
493            ..self
494        }
495    }
496
497    pub fn with_random_iv(self, value: RandomIV) -> Self {
498        Self {
499            random_iv: Some(value),
500            ..self
501        }
502    }
503
504    pub fn with_iv_length(self, value: IVLength) -> Self {
505        Self {
506            iv_length: Some(value),
507            ..self
508        }
509    }
510
511    pub fn with_tag_length(self, value: TagLength) -> Self {
512        Self {
513            tag_length: Some(value),
514            ..self
515        }
516    }
517
518    pub fn with_fixed_field_length(self, value: FixedFieldLength) -> Self {
519        Self {
520            fixed_field_length: Some(value),
521            ..self
522        }
523    }
524
525    pub fn with_invocation_field_length(self, value: InvocationFieldLength) -> Self {
526        Self {
527            invocation_field_length: Some(value),
528            ..self
529        }
530    }
531
532    pub fn with_counter_length(self, value: CounterLength) -> Self {
533        Self {
534            counter_length: Some(value),
535            ..self
536        }
537    }
538
539    pub fn with_initial_counter_value(self, value: InitialCounterValue) -> Self {
540        Self {
541            initial_counter_value: Some(value),
542            ..self
543        }
544    }
545}
546
547impl From<CryptographicParameters> for AttributeValue {
548    fn from(params: CryptographicParameters) -> Self {
549        AttributeValue::CryptographicParameters(
550            params.block_cipher_mode,
551            params.padding_method,
552            params.hashing_algorithm,
553            params.key_role_type,
554            params.digital_signature_algorithm,
555            params.cryptographic_algorithm,
556            params.random_iv,
557            params.iv_length,
558            params.tag_length,
559            params.fixed_field_length,
560            params.invocation_field_length,
561            params.counter_length,
562            params.initial_counter_value,
563        )
564    }
565}
566
567///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
568#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
569#[serde(rename = "Transparent:0x4200C5")]
570pub struct RandomIV(pub bool);
571
572///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
573#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
574#[serde(rename = "Transparent:0x4200CD")]
575pub struct IVLength(pub i32);
576
577///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
578#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
579#[serde(rename = "Transparent:0x4200CE")]
580pub struct TagLength(pub i32);
581
582///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
583#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
584#[serde(rename = "Transparent:0x4200CF")]
585pub struct FixedFieldLength(pub i32);
586
587///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
588#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
589#[serde(rename = "Transparent:0x4200D2")]
590pub struct InvocationFieldLength(pub i32);
591
592///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
593#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
594#[serde(rename = "Transparent:0x4200D0")]
595pub struct CounterLength(pub i32);
596
597///  See KMIP 1.2 section 3.6 [Cryptographic Parameters](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Toc409613487).
598#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
599#[serde(rename = "Transparent:0x4200D1")]
600pub struct InitialCounterValue(pub i32);
601
602///  See KMIP 1.0 section 3.14 [Cryptographic Usage Mask](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581188).
603// Note: This enum value is stored in a u32 but is serialized as an i32.
604#[repr(u32)]
605#[derive(EnumFlags, Clone, Copy, Deserialize, Serialize, Display, PartialEq, Eq)]
606#[rustfmt::skip]
607#[non_exhaustive]
608pub enum CryptographicUsageMask {
609    Sign                            = 0x00000001,
610    Verify                          = 0x00000002,
611    Encrypt                         = 0x00000004,
612    Decrypt                         = 0x00000008,
613    WrapKey                         = 0x00000010,
614    UnwrapKey                       = 0x00000020,
615    Export                          = 0x00000040,
616    MacGenerate                     = 0x00000080,
617    MacVerify                       = 0x00000100,
618    DeriveKey                       = 0x00000200,
619    ContentCommitmentNonRepudiation = 0x00000400,
620    KeyAgreement                    = 0x00000800,
621    CertificateSign                 = 0x00001000,
622    CrlSign                         = 0x00002000,
623    GenerateCryptogram              = 0x00004000,
624    ValidateCryptogram              = 0x00008000,
625    TranslateEncrypt                = 0x00010000,
626    TranslateDecrypt                = 0x00020000,
627    TranslateWrap                   = 0x00040000,
628    TranslateUnwrap                 = 0x00080000,
629}
630
631///  See KMIP 1.0 section 3.24 [Compromise Occurrence Date](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581198).
632#[derive(Clone, Copy, Debug, Serialize, PartialEq, Eq)]
633#[serde(rename = "Transparent:0x420021")]
634pub struct CompromiseOccurrenceDate(pub u64);
635
636///  See KMIP 1.0 section 3.26 [Revocation Reason](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581200).
637#[derive(Clone, Debug, Serialize, PartialEq, Eq)]
638#[serde(rename = "Transparent:0x420080")]
639pub struct RevocationMessage(pub String);
640
641///  See KMIP 1.0 section 3.29 [Linked Object Identifier](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581203).
642#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
643#[serde(rename = "Transparent:0x42004C")]
644pub struct LinkedObjectIdentifier(pub String);
645
646///  See KMIP 1.0 section 3.30 [Application Namespace](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581204).
647#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
648#[serde(rename = "Transparent:0x420003")]
649pub struct ApplicationNamespace(pub String);
650
651///  See KMIP 1.0 section 3.30 [Application Data](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581204).
652#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
653#[serde(rename = "Transparent:0x420002")]
654pub struct ApplicationData(pub String);
655
656///  See KMIP 1.0 section 6.4 [Unique Batch Item ID](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262581242).
657#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
658#[serde(rename(serialize = "Transparent:0x420093"))]
659pub struct UniqueBatchItemID(#[serde(with = "serde_bytes")] pub Vec<u8>);
660
661impl PartialEq<Vec<u8>> for &UniqueBatchItemID {
662    fn eq(&self, other: &Vec<u8>) -> bool {
663        &self.0 == other
664    }
665}
666
667///  See KMIP 1.0 section 9.1.3.2.2 [Key Compression Type Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Ref241603856).
668#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
669#[serde(rename = "0x420041")]
670#[non_exhaustive]
671pub enum KeyCompressionType {
672    #[serde(rename = "0x00000001")]
673    ECPUblicKeyTypeUncompressed,
674
675    #[serde(rename = "0x00000002")]
676    ECPUblicKeyTypeX962CompressedPrime,
677
678    #[serde(rename = "0x00000003")]
679    ECPUblicKeyTypeX962CompressedChar2,
680
681    #[serde(rename = "0x00000004")]
682    ECPUblicKeyTypeX962Hybrid,
683}
684
685///  See KMIP 1.0 section 9.1.3.2.3 [Key Format Type Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Ref241992670).
686#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
687#[serde(rename = "0x420042")]
688#[non_exhaustive]
689pub enum KeyFormatType {
690    #[serde(rename = "0x00000001")]
691    Raw,
692
693    #[serde(rename = "0x00000002")]
694    Opaque,
695
696    #[serde(rename = "0x00000003")]
697    PKCS1,
698
699    #[serde(rename = "0x00000004")]
700    PKCS8,
701
702    #[serde(rename = "0x00000005")]
703    X509,
704
705    #[serde(rename = "0x00000006")]
706    ECPrivateKey,
707
708    #[serde(rename = "0x00000007")]
709    TransparentSymmetricKey,
710
711    #[serde(rename = "0x00000008")]
712    TransparentDSAPrivateKey,
713
714    #[serde(rename = "0x00000009")]
715    TransparentDSAPublicKey,
716
717    #[serde(rename = "0x0000000A")]
718    TransparentRSAPrivateKey,
719
720    #[serde(rename = "0x0000000B")]
721    TransparentRSAPublicKey,
722
723    #[serde(rename = "0x0000000C")]
724    TransparentDHPrivateKey,
725
726    #[serde(rename = "0x0000000D")]
727    TransparentDHPublicKey,
728
729    #[serde(rename = "0x0000000E")]
730    TransparentECDSAPrivateKey,
731
732    #[serde(rename = "0x0000000F")]
733    TransparentECDSAPublicKey,
734
735    #[serde(rename = "0x00000010")]
736    TransparentECHDPrivateKey,
737
738    #[serde(rename = "0x00000011")]
739    TransparentECDHPublicKey,
740
741    #[serde(rename = "0x00000012")]
742    TransparentECMQVPrivateKey,
743
744    #[serde(rename = "0x00000013")]
745    TransparentECMQVPublicKey,
746}
747
748///  See KMIP 1.0 section 9.1.3.2.6 [Certificate Type Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Ref241994296).
749#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
750#[serde(rename = "0x42001D")]
751#[non_exhaustive]
752pub enum CertificateType {
753    #[serde(rename = "0x00000001")]
754    X509,
755
756    #[serde(rename = "0x00000002")]
757    PGP,
758}
759
760///  See KMIP 1.2 section 9.1.3.2.7 [Digital Signature Algorithm Enumeration](https://docs.oasis-open.org/kmip/spec/v1.2/os/kmip-spec-v1.2-os.html#_Ref306812211).
761#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
762#[serde(rename = "0x4200AE")]
763#[non_exhaustive]
764#[allow(non_camel_case_types)]
765pub enum DigitalSignatureAlgorithm {
766    #[serde(rename = "0x00000001")]
767    MD2WithRSAEncryption_PKCS1_v1_5,
768
769    #[serde(rename = "0x00000002")]
770    MD5WithRSAEncryption_PKCS1_v1_5,
771
772    #[serde(rename = "0x00000003")]
773    SHA1WithRSAEncryption_PKCS1_v1_5,
774
775    #[serde(rename = "0x00000004")]
776    SHA224WithRSAEncryption_PKCS1_v1_5,
777
778    #[serde(rename = "0x00000005")]
779    SHA256WithRSAEncryption_PKCS1_v1_5,
780
781    #[serde(rename = "0x00000006")]
782    SHA384WithRSAEncryption_PKCS1_v1_5,
783
784    #[serde(rename = "0x00000007")]
785    SHA512WithRSAEncryption_PKCS1_v1_5,
786
787    #[serde(rename = "0x00000008")]
788    RSASSA_PSS_PKCS1_v1_5,
789
790    #[serde(rename = "0x00000009")]
791    DSAWithSHA1,
792
793    #[serde(rename = "0x0000000A")]
794    DSAWithSHA224,
795
796    #[serde(rename = "0x0000000B")]
797    DSAWithSHA256,
798
799    #[serde(rename = "0x0000000C")]
800    ECDSAWithSHA1,
801
802    #[serde(rename = "0x0000000D")]
803    ECDSAWithSHA224,
804
805    #[serde(rename = "0x0000000E")]
806    ECDSAWithSHA256,
807
808    #[serde(rename = "0x0000000F")]
809    ECDSAWithSHA384,
810
811    #[serde(rename = "0x00000010")]
812    ECDSAWithSHA512,
813}
814
815///  See KMIP 1.0 section 9.1.3.2.10 [Name Type Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262582060).
816#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
817#[serde(rename = "0x420054")]
818#[non_exhaustive]
819pub enum NameType {
820    #[serde(rename = "0x00000001")]
821    UninterpretedTextString,
822
823    #[serde(rename = "0x00000002")]
824    URI,
825}
826
827///  See KMIP 1.0 section 9.1.3.2.13 [Block Cipher Mode Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc236497881).
828#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
829#[serde(rename = "0x420011")]
830#[non_exhaustive]
831#[allow(non_camel_case_types)]
832pub enum BlockCipherMode {
833    #[serde(rename = "0x00000001")]
834    CBC,
835
836    #[serde(rename = "0x00000002")]
837    ECB,
838
839    #[serde(rename = "0x00000003")]
840    PCBC,
841
842    #[serde(rename = "0x00000004")]
843    CFB,
844
845    #[serde(rename = "0x00000005")]
846    OFB,
847
848    #[serde(rename = "0x00000006")]
849    CTR,
850
851    #[serde(rename = "0x00000007")]
852    CMAC,
853
854    #[serde(rename = "0x00000008")]
855    CCM,
856
857    #[serde(rename = "0x00000009")]
858    GCM,
859
860    #[serde(rename = "0x0000000A")]
861    CBC_MAC,
862
863    #[serde(rename = "0x0000000B")]
864    XTS,
865
866    #[serde(rename = "0x0000000C")]
867    AESKeyWrapPadding,
868
869    #[serde(rename = "0x0000000D")]
870    NISTKeyWrap,
871
872    #[serde(rename = "0x0000000E")]
873    X9_102_AESKW,
874
875    #[serde(rename = "0x0000000F")]
876    X9_102_TDKW,
877
878    #[serde(rename = "0x00000010")]
879    X9_102_AKW1,
880
881    #[serde(rename = "0x00000011")]
882    X9_102_AKW2,
883}
884
885///  See KMIP 1.0 section 9.1.3.2.14 [Padding Method Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc236497882).
886#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
887#[serde(rename = "0x42005F")]
888#[non_exhaustive]
889#[allow(non_camel_case_types)]
890pub enum PaddingMethod {
891    #[serde(rename = "0x00000001")]
892    None,
893
894    #[serde(rename = "0x00000002")]
895    OAEP,
896
897    #[serde(rename = "0x00000003")]
898    PKCS5,
899
900    #[serde(rename = "0x00000004")]
901    SSL3,
902
903    #[serde(rename = "0x00000005")]
904    Zeros,
905
906    #[serde(rename = "0x00000006")]
907    ANSI_X9_23,
908
909    #[serde(rename = "0x00000007")]
910    ISO_10126,
911
912    #[serde(rename = "0x00000008")]
913    PKCS1_v1_5,
914
915    #[serde(rename = "0x00000009")]
916    X9_31,
917
918    #[serde(rename = "0x0000000A")]
919    PSS,
920}
921
922///  See KMIP 1.0 section 9.1.3.2.15 [Hashing Algorithm Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc236497883).
923#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
924#[serde(rename = "0x420038")]
925#[non_exhaustive]
926#[allow(non_camel_case_types)]
927pub enum HashingAlgorithm {
928    #[serde(rename = "0x00000001")]
929    MD2,
930
931    #[serde(rename = "0x00000002")]
932    MD4,
933
934    #[serde(rename = "0x00000003")]
935    MD5,
936
937    #[serde(rename = "0x00000004")]
938    SHA1,
939
940    #[serde(rename = "0x00000005")]
941    SHA224,
942
943    #[serde(rename = "0x00000006")]
944    SHA256,
945
946    #[serde(rename = "0x00000007")]
947    SHA384,
948
949    #[serde(rename = "0x00000008")]
950    SHA512,
951
952    #[serde(rename = "0x00000009")]
953    RIPEMD160,
954
955    #[serde(rename = "0x0000000A")]
956    Tiger,
957
958    #[serde(rename = "0x0000000B")]
959    Whirlpool,
960}
961
962///  See KMIP 1.0 section 9.1.3.2.15 [Key Role Type Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc236497884).
963#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
964#[serde(rename = "0x420083")]
965#[non_exhaustive]
966#[allow(non_camel_case_types)]
967pub enum KeyRoleType {
968    #[serde(rename = "0x00000001")]
969    BDK,
970
971    #[serde(rename = "0x00000002")]
972    CVK,
973
974    #[serde(rename = "0x00000003")]
975    DEK,
976
977    #[serde(rename = "0x00000004")]
978    MKAC,
979
980    #[serde(rename = "0x00000005")]
981    MKSMC,
982
983    #[serde(rename = "0x00000006")]
984    MKSMI,
985
986    #[serde(rename = "0x00000007")]
987    MKDAC,
988
989    #[serde(rename = "0x00000008")]
990    MKDN,
991
992    #[serde(rename = "0x00000009")]
993    MKCP,
994
995    #[serde(rename = "0x0000000A")]
996    MKOTH,
997
998    #[serde(rename = "0x0000000B")]
999    KEK,
1000
1001    #[serde(rename = "0x0000000C")]
1002    MAC16609,
1003
1004    #[serde(rename = "0x0000000D")]
1005    MAC97971,
1006
1007    #[serde(rename = "0x0000000E")]
1008    MAC97972,
1009
1010    #[serde(rename = "0x0000000F")]
1011    MAC97973,
1012
1013    #[serde(rename = "0x00000010")]
1014    MAC97974,
1015
1016    #[serde(rename = "0x00000011")]
1017    MAC97975,
1018
1019    #[serde(rename = "0x00000012")]
1020    ZPK,
1021
1022    #[serde(rename = "0x00000013")]
1023    PVKIBM,
1024
1025    #[serde(rename = "0x00000014")]
1026    PVKPVV,
1027
1028    #[serde(rename = "0x00000015")]
1029    PVKOTH,
1030}
1031
1032///  See KMIP 1.0 section 9.1.3.2.17 [State Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262582066).
1033#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
1034#[serde(rename = "0x42008D")]
1035#[non_exhaustive]
1036pub enum State {
1037    #[serde(rename = "0x00000001")]
1038    PreActive,
1039
1040    #[serde(rename = "0x00000002")]
1041    Active,
1042
1043    #[serde(rename = "0x00000003")]
1044    Deactivated,
1045
1046    #[serde(rename = "0x00000004")]
1047    Compromised,
1048
1049    #[serde(rename = "0x00000005")]
1050    Destroyed,
1051
1052    #[serde(rename = "0x00000006")]
1053    DestroyedCompromised,
1054}
1055
1056///  See KMIP 1.0 section 9.1.3.2.18 [Revocation Reason Code Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Ref241996204).
1057#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
1058#[serde(rename = "0x420082")]
1059#[non_exhaustive]
1060pub enum RevocationReasonCode {
1061    #[serde(rename = "0x00000001")]
1062    Unspecified,
1063
1064    #[serde(rename = "0x00000002")]
1065    KeyCompromise,
1066
1067    #[serde(rename = "0x00000003")]
1068    CACompromise,
1069
1070    #[serde(rename = "0x00000004")]
1071    AffiliationChanged,
1072
1073    #[serde(rename = "0x00000005")]
1074    Superseded,
1075
1076    #[serde(rename = "0x00000006")]
1077    CessationOfOperation,
1078
1079    #[serde(rename = "0x00000007")]
1080    PrivilegeWithdrawn,
1081}
1082
1083///  See KMIP 1.0 section 9.1.3.2.19 [Link Type Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc262582069).
1084#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
1085#[serde(rename = "0x42004B")]
1086#[non_exhaustive]
1087pub enum LinkType {
1088    #[serde(rename = "0x00000101")]
1089    CertificateLink,
1090
1091    #[serde(rename = "0x00000102")]
1092    PublicKeyLink,
1093
1094    #[serde(rename = "0x00000103")]
1095    PrivateKeyLink,
1096
1097    #[serde(rename = "0x00000104")]
1098    DerivationBaseObjectLink,
1099
1100    #[serde(rename = "0x00000105")]
1101    DerivedKeyLink,
1102
1103    #[serde(rename = "0x00000106")]
1104    ReplacementObjectLink,
1105
1106    #[serde(rename = "0x00000107")]
1107    ReplacedObjectLink,
1108}
1109
1110///  See KMIP 1.0 section 9.1.3.2.26 [Operation Enumeration](https://docs.oasis-open.org/kmip/spec/v1.0/os/kmip-spec-1.0-os.html#_Toc236497894).
1111#[derive(Clone, Copy, Debug, Deserialize, Serialize, Display, PartialEq, Eq)]
1112#[serde(rename = "0x42005C")]
1113#[non_exhaustive]
1114pub enum Operation {
1115    // KMIP 1.0 operations
1116    #[serde(rename = "0x00000001")]
1117    Create = 1,
1118
1119    #[serde(rename = "0x00000002")]
1120    CreateKeyPair,
1121
1122    #[serde(rename = "0x00000003")]
1123    Register,
1124
1125    #[serde(rename = "0x00000004")]
1126    Rekey,
1127
1128    #[serde(rename = "0x00000005")]
1129    DeriveKey,
1130
1131    #[serde(rename = "0x00000006")]
1132    Certify,
1133
1134    #[serde(rename = "0x00000007")]
1135    Recertify,
1136
1137    #[serde(rename = "0x00000008")]
1138    Locate,
1139
1140    #[serde(rename = "0x00000009")]
1141    Check,
1142
1143    #[serde(rename = "0x0000000A")]
1144    Get,
1145
1146    #[serde(rename = "0x0000000B")]
1147    GetAttributes,
1148
1149    #[serde(rename = "0x0000000C")]
1150    GetAttributeList,
1151
1152    #[serde(rename = "0x0000000D")]
1153    AddAttribute,
1154
1155    #[serde(rename = "0x0000000E")]
1156    ModifyAttribute,
1157
1158    #[serde(rename = "0x0000000F")]
1159    DeleteAttribute,
1160
1161    #[serde(rename = "0x00000010")]
1162    ObtainLease,
1163
1164    #[serde(rename = "0x00000011")]
1165    GetUsageAllocation,
1166
1167    #[serde(rename = "0x00000012")]
1168    Activate,
1169
1170    #[serde(rename = "0x00000013")]
1171    Revoke,
1172
1173    #[serde(rename = "0x00000014")]
1174    Destroy,
1175
1176    #[serde(rename = "0x00000015")]
1177    Archive,
1178
1179    #[serde(rename = "0x00000016")]
1180    Recover,
1181
1182    #[serde(rename = "0x00000017")]
1183    Validate,
1184
1185    #[serde(rename = "0x00000018")]
1186    Query,
1187
1188    #[serde(rename = "0x00000019")]
1189    Cancel,
1190
1191    #[serde(rename = "0x0000001A")]
1192    Poll,
1193
1194    #[serde(rename = "0x0000001B")]
1195    Notify,
1196
1197    #[serde(rename = "0x0000001C")]
1198    Put,
1199
1200    // KMIP 1.1 operations
1201    #[serde(rename = "0x0000001D")]
1202    RekeyKeyPair,
1203
1204    #[serde(rename = "0x0000001E")]
1205    DiscoverVersions,
1206
1207    // KMIP 1.2 operations
1208    #[serde(rename = "0x0000001F")]
1209    Encrypt,
1210
1211    #[serde(rename = "0x00000020")]
1212    Decrypt,
1213
1214    #[serde(rename = "0x00000021")]
1215    Sign,
1216
1217    #[serde(rename = "0x00000022")]
1218    SignatureVerify,
1219
1220    #[serde(rename = "0x00000023")]
1221    MAC,
1222
1223    #[serde(rename = "0x00000024")]
1224    MACVerify,
1225
1226    #[serde(rename = "0x00000025")]
1227    RNGRetrieve,
1228
1229    #[serde(rename = "0x00000026")]
1230    RNGSeed,
1231
1232    #[serde(rename = "0x00000027")]
1233    Hash,
1234
1235    #[serde(rename = "0x00000028")]
1236    CreateSplitKey,
1237
1238    #[serde(rename = "0x00000029")]
1239    JoinSplitKey,
1240}
1241
1242#[cfg(test)]
1243mod test {
1244    use super::Operation;
1245
1246    #[test]
1247    fn test_operation_display() {
1248        assert_ne!("WrongName", &format!("{}", Operation::Create));
1249        assert_eq!("Create", &format!("{}", Operation::Create));
1250        assert_eq!("CreateKeyPair", &format!("{}", Operation::CreateKeyPair));
1251        assert_eq!("Register", &format!("{}", Operation::Register));
1252    }
1253}