vaultrs/api/transit/
responses.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
use super::KeyType;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Response from executing
/// [ReadKeyRequest][crate::api::transit::requests::ReadKeyRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct ReadKeyResponse {
    #[serde(rename = "type")]
    pub key_type: KeyType,
    pub deletion_allowed: bool,
    pub derived: bool,
    pub exportable: bool,
    pub allow_plaintext_backup: bool,
    /// If the key is asymmetric, the API returns the public keys
    pub keys: ReadKeyData,
    pub min_decryption_version: u64,
    pub min_encryption_version: u64,
    pub name: String,
    pub supports_encryption: bool,
    pub supports_decryption: bool,
    pub supports_derivation: bool,
    pub supports_signing: bool,
    pub imported: Option<bool>,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReadKeyData {
    /// A key ID integer (string) to unix timestamp.
    Symmetric(HashMap<String, u64>),
    /// A key ID integer (string) to public key mapping.
    Asymmetric(HashMap<String, ReadPublicKeyEntry>),
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct ReadPublicKeyEntry {
    /// An ISO8601 timestamp
    pub creation_time: String,
    pub name: String,
    pub public_key: String,
}

/// Response from executing
/// [ListKeysRequest][crate::api::transit::requests::ListKeysRequest]
#[derive(Deserialize, Debug, Serialize)]
pub struct ListKeysResponse {
    pub keys: Vec<String>,
}

/// Response from executing
/// [ExportKeyRequest][crate::api::transit::requests::ExportKeyRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct ExportKeyResponse {
    pub name: String,
    pub keys: HashMap<String, String>,
}

/// Response from executing
/// [EncryptDataRequest][crate::api::transit::requests::EncryptDataRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct EncryptDataResponse {
    pub ciphertext: String,
}

/// Response from executing
/// [DecryptDataRequest][crate::api::transit::requests::DecryptDataRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct DecryptDataResponse {
    pub plaintext: String,
}

/// Response from executing
/// [RewrapDataRequest][crate::api::transit::requests::RewrapDataRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct RewrapDataResponse {
    pub ciphertext: String,
}

/// Response from executing
/// [GenerateDataKeyRequest][crate::api::transit::requests::GenerateDataKeyRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct GenerateDataKeyResponse {
    pub plaintext: Option<String>,
    pub ciphertext: String,
}

/// Response from executing
/// [GenerateRandomBytesRequest][crate::api::transit::requests::GenerateRandomBytesRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct GenerateRandomBytesResponse {
    pub random_bytes: String,
}

/// Response from executing
/// [HashDataRequest][crate::api::transit::requests::HashDataRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct HashDataResponse {
    pub sum: String,
}

/// Response from executing
/// [GenerateHmacRequest][crate::api::transit::requests::GenerateHmacRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct GenerateHmacResponse {
    pub hmac: String,
}

/// Response from executing
/// [SignDataRequest][crate::api::transit::requests::SignDataRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct SignDataResponse {
    pub signature: String,
}

/// Response from executing
/// [VerifySignedDataRequest][crate::api::transit::requests::VerifySignedDataRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct VerifySignedDataResponse {
    pub valid: bool,
}

/// Response from executing
/// [BackupKeyRequest][crate::api::transit::requests::BackupKeyRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct BackupKeyResponse {
    pub backup: String,
}

/// Response from executing
/// [ReadTransitCacheConfigurationRequest][crate::api::transit::requests::ReadTransitCacheConfigurationRequest]
#[derive(Debug, Serialize, Deserialize)]
pub struct ReadTransitCacheConfigurationResponse {
    pub size: u64,
}