Skip to content

Commit 6c76f47

Browse files
committed
fix: fix the bug of failed compilation
1 parent 3a40502 commit 6c76f47

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ pub struct CoreState {
6868
#[zeroize(skip)]
6969
pub system_view: Option<Arc<BarrierView>>,
7070
pub sealed: bool,
71-
pub unseal_key_shares: Vec<Vec<u8>>,
7271
pub hmac_key: Vec<u8>,
72+
unseal_key_shares: Vec<Vec<u8>>,
7373
}
7474

7575
pub struct Core {

src/http/sys.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::Arc;
33
use actix_web::{http::StatusCode, web, HttpRequest, HttpResponse};
44
use serde::{Deserialize, Serialize};
55
use serde_json::json;
6+
use zeroize::{Zeroize, Zeroizing};
67

78
use crate::{
89
core::{Core, SealConfig},
@@ -24,13 +25,15 @@ pub struct InitRequest {
2425
pub secret_threshold: u8,
2526
}
2627

27-
#[derive(Debug, Clone, Serialize, Deserialize)]
28+
#[derive(Debug, Clone, Serialize, Deserialize, Zeroize)]
29+
#[zeroize(drop)]
2830
pub struct InitResponse {
2931
pub keys: Vec<String>,
3032
pub root_token: String,
3133
}
3234

33-
#[derive(Debug, Clone, Serialize, Deserialize)]
35+
#[derive(Debug, Clone, Serialize, Deserialize, Zeroize)]
36+
#[zeroize(drop)]
3437
struct UnsealRequest {
3538
key: String,
3639
}
@@ -101,7 +104,7 @@ async fn sys_init_put_request_handler(
101104
let result = core.init(&seal_config)?;
102105

103106
let resp =
104-
InitResponse { keys: result.secret_shares.iter().map(hex::encode).collect(), root_token: result.root_token };
107+
InitResponse { keys: result.secret_shares.iter().map(hex::encode).collect(), root_token: result.root_token.clone() };
105108

106109
Ok(response_json_ok(None, resp))
107110
}
@@ -126,7 +129,7 @@ async fn sys_unseal_request_handler(
126129
// TODO
127130
let payload = serde_json::from_slice::<UnsealRequest>(&body)?;
128131
body.clear();
129-
let key = hex::decode(payload.key)?;
132+
let key: Zeroizing<Vec<u8>> = Zeroizing::new(hex::decode(payload.key.clone())?);
130133

131134
let _result = core.unseal(&key)?;
132135

src/storage/barrier_aes_gcm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct BarrierInit {
3939
}
4040

4141
#[derive(Debug, Clone, Default, Zeroize)]
42+
#[zeroize(drop)]
4243
struct BarrierInfo {
4344
#[default(true)]
4445
sealed: bool,

src/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl TestHttpServer {
113113

114114
assert!(unseal_test_rusty_vault_core(core.as_ref(), &k));
115115

116-
root_token = init_result.root_token;
116+
root_token = init_result.root_token.clone();
117117
println!("root_token: {:?}", root_token);
118118

119119
test_http_server.root_token = root_token;
@@ -1069,7 +1069,7 @@ pub fn new_unseal_test_rusty_vault(name: &str) -> (RustyVault, Arc<Core>, String
10691069

10701070
assert!(unseal_test_rusty_vault(&rvault, &k));
10711071

1072-
root_token = init_result.root_token;
1072+
root_token = init_result.root_token.clone();
10731073
println!("root_token: {:?}", root_token);
10741074

10751075
let core = rvault.core.load().clone();

tests/test_default_logical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ async fn test_default_logical() {
417417
unsealed = unseal.unwrap();
418418
}
419419

420-
root_token = init_result.root_token;
420+
root_token = init_result.root_token.clone();
421421

422422
assert!(unsealed);
423423

0 commit comments

Comments
 (0)