1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
5#[serde(rename_all = "lowercase")]
6pub enum KeyType {
7 Ed25519,
8 Rsa,
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct ExtensionRequest {
13 pub extension: String,
14 pub data: Vec<u8>,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct ExtensionResponse {
19 pub success: bool,
20 pub data: Vec<u8>,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct ManagedKey {
26 pub fp_sha256_hex: String,
27 #[serde(rename = "type")]
28 pub key_type: String,
29 pub format: String,
30 pub description: String,
31 pub source: String, pub loaded: bool,
33 pub has_disk: bool,
34 pub has_cert: bool,
35 pub password_protected: bool,
36 pub constraints: serde_json::Value,
37 #[serde(default, skip_serializing_if = "Option::is_none")]
38 pub default_constraints: Option<serde_json::Value>,
39 pub created: Option<String>,
40 pub updated: Option<String>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct ManageListResponse {
46 pub ok: bool,
47 pub keys: Vec<ManagedKey>,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct ManageOperationResponse {
53 pub ok: bool,
54 #[serde(skip_serializing_if = "Option::is_none")]
55 pub error: Option<String>,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct ManageCreateRequest {
61 pub key_type: String, #[serde(skip_serializing_if = "Option::is_none")]
63 pub bit_length: Option<u32>,
64 #[serde(skip_serializing_if = "Option::is_none")]
65 pub description: Option<String>,
66 #[serde(default = "default_load_to_ram")]
67 pub load_to_ram: bool,
68 #[serde(skip_serializing_if = "Option::is_none")]
69 pub confirm: Option<bool>,
70 #[serde(skip_serializing_if = "Option::is_none")]
71 pub notification: Option<bool>,
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub lifetime_seconds: Option<u32>,
74}
75
76fn default_load_to_ram() -> bool {
77 true
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct ManageCreateResponse {
83 pub ok: bool,
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub error: Option<String>,
86 #[serde(skip_serializing_if = "Option::is_none")]
87 pub fingerprint: Option<String>,
88 #[serde(skip_serializing_if = "Option::is_none")]
89 pub public_key: Option<String>,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94pub struct ManageDeleteRequest {
95 pub fp_sha256_hex: String,
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100pub struct ManageDeleteResponse {
101 pub ok: bool,
102 #[serde(skip_serializing_if = "Option::is_none")]
103 pub error: Option<String>,
104 #[serde(skip_serializing_if = "Option::is_none")]
105 pub fingerprint: Option<String>,
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct ManageSetPasswordRequest {
111 pub fp_sha256_hex: String,
112 pub set_password_protection: bool,
113 #[serde(skip_serializing_if = "Option::is_none")]
114 pub new_key_pass_b64: Option<String>,
115 #[serde(skip_serializing_if = "Option::is_none")]
116 pub current_key_pass_b64: Option<String>,
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121pub struct ManageSetPasswordResponse {
122 pub ok: bool,
123 #[serde(skip_serializing_if = "Option::is_none")]
124 pub error: Option<String>,
125 #[serde(skip_serializing_if = "Option::is_none")]
126 pub fingerprint: Option<String>,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct ManageSetDefaultConstraintsRequest {
132 pub fp_sha256_hex: String,
133 pub default_confirm: bool,
134 #[serde(default)]
135 pub default_notification: bool,
136 #[serde(skip_serializing_if = "Option::is_none")]
137 pub default_lifetime_seconds: Option<u64>,
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize)]
142pub struct ManageSetDefaultConstraintsResponse {
143 pub ok: bool,
144 #[serde(skip_serializing_if = "Option::is_none")]
145 pub error: Option<String>,
146 #[serde(skip_serializing_if = "Option::is_none")]
147 pub fingerprint: Option<String>,
148 #[serde(skip_serializing_if = "Option::is_none")]
149 pub default_confirm: Option<bool>,
150 #[serde(skip_serializing_if = "Option::is_none")]
151 pub default_lifetime_seconds: Option<u64>,
152}