Skip to content

Commit b0a796f

Browse files
sergio-correiaansasaki
authored andcommitted
push-model: implement continuous attestation with configurable intervals
After the first successful attestation, the agent now waits for a configurable interval before repeating the attestation process by returning to the Negotiating state, creating a continuous attestation loop. The interval between the attestations is currently fixed, but in the future, the verifier will provide this information in its response to the attestation, so we can parse it from there and use it instead. Currently, the interval between sending the measurements is defined as 60s, but can be configured with the --attestation-interval-seconds switch. Signed-off-by: Sergio Correia <[email protected]>
1 parent d7003ab commit b0a796f

File tree

3 files changed

+142
-64
lines changed

3 files changed

+142
-64
lines changed

keylime-push-model-agent/src/attestation.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ pub struct ResponseInformation {
1414
pub body: String,
1515
}
1616

17+
impl Default for ResponseInformation {
18+
fn default() -> Self {
19+
Self {
20+
status_code: StatusCode::OK,
21+
headers: HeaderMap::new(),
22+
body: String::new(),
23+
}
24+
}
25+
}
26+
1727
#[derive(Debug, Clone)]
1828
pub struct NegotiationConfig<'a> {
1929
pub avoid_tpm: bool,

keylime-push-model-agent/src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mod url_selector;
1515
const DEFAULT_TIMEOUT_MILLIS: &str = "5000";
1616
const DEFAULT_METHOD: &str = "POST";
1717
const DEFAULT_MESSAGE_TYPE_STR: &str = "Attestation";
18+
const DEFAULT_ATTESTATION_INTERVAL_SECONDS: u64 = 60;
1819

1920
pub enum MessageType {
2021
Attestation,
@@ -92,6 +93,10 @@ struct Args {
9293
/// Default: false
9394
#[arg(long, action, default_missing_value = "false")]
9495
avoid_tpm: Option<bool>,
96+
/// Interval in seconds between the attestations happening after the first successful attestation
97+
/// Default: 60
98+
#[arg(long, default_value_t = DEFAULT_ATTESTATION_INTERVAL_SECONDS)]
99+
attestation_interval_seconds: u64,
95100
}
96101

97102
fn get_avoid_tpm_from_args(args: &Args) -> bool {
@@ -101,7 +106,7 @@ fn get_avoid_tpm_from_args(args: &Args) -> bool {
101106
async fn run(args: &Args) -> Result<()> {
102107
match args.verifier_url {
103108
Some(ref url) if url.is_empty() => {
104-
info!("Verifier URL: {}", url);
109+
info!("Verifier URL: {url}");
105110
}
106111
_ => {}
107112
};
@@ -173,6 +178,7 @@ async fn run(args: &Args) -> Result<()> {
173178
attestation_client,
174179
neg_config,
175180
ctx_info,
181+
args.attestation_interval_seconds,
176182
);
177183
state_machine.run().await;
178184
Ok(())
@@ -208,6 +214,8 @@ mod tests {
208214
method: None,
209215
attestation_index: None,
210216
session_index: None,
217+
attestation_interval_seconds:
218+
DEFAULT_ATTESTATION_INTERVAL_SECONDS,
211219
};
212220
let res = run(&args);
213221
assert!(res.await.is_err());
@@ -233,6 +241,8 @@ mod tests {
233241
method: None,
234242
attestation_index: None,
235243
session_index: None,
244+
attestation_interval_seconds:
245+
DEFAULT_ATTESTATION_INTERVAL_SECONDS,
236246
};
237247
let avoid_tpm = get_avoid_tpm_from_args(&args);
238248
assert!(avoid_tpm);

0 commit comments

Comments
 (0)