@@ -161,6 +161,7 @@ pub async fn execute(
161161 cert_dir,
162162 verify,
163163 push_model,
164+ tpm_policy,
164165 } => add_agent (
165166 AddAgentParams {
166167 agent_id : uuid,
@@ -173,6 +174,7 @@ pub async fn execute(
173174 cert_dir : cert_dir. as_deref ( ) ,
174175 verify : * verify,
175176 push_model : * push_model,
177+ tpm_policy : tpm_policy. as_deref ( ) ,
176178 } ,
177179 config,
178180 output,
@@ -258,6 +260,8 @@ struct AddAgentParams<'a> {
258260 verify : bool ,
259261 /// Whether to use push model (agent connects to verifier)
260262 push_model : bool ,
263+ /// Optional TPM policy in JSON format
264+ tpm_policy : Option < & ' a str > ,
261265}
262266
263267/// Add an agent to the verifier for continuous attestation monitoring
@@ -501,13 +505,17 @@ async fn add_agent(
501505 // Build the request payload
502506 let cv_agent_ip = params. verifier_ip . unwrap_or ( & agent_ip) ;
503507
508+ // Resolve TPM policy from CLI argument or default
509+ let tpm_policy = resolve_tpm_policy ( params. tpm_policy ) ;
510+
504511 let mut request_data = json ! ( {
505512 "cloudagent_ip" : cv_agent_ip,
506513 "cloudagent_port" : agent_port,
507514 "verifier_ip" : config. verifier. ip,
508515 "verifier_port" : config. verifier. port,
509516 "ak_tpm" : agent_data. get( "aik_tpm" ) ,
510517 "mtls_cert" : agent_data. get( "mtls_cert" ) ,
518+ "tpm_policy" : tpm_policy,
511519 } ) ;
512520
513521 // Add V key from attestation if available
@@ -824,6 +832,7 @@ async fn update_agent(
824832 cert_dir : None , // Use default cert handling
825833 verify : false , // Skip verification during update
826834 push_model : existing_push_model, // Preserve existing model
835+ tpm_policy : None , // Use default policy during update
827836 } ,
828837 config,
829838 output,
@@ -1367,10 +1376,19 @@ fn load_payload_file(path: &str) -> Result<String, CommandError> {
13671376 } )
13681377}
13691378
1379+ /// Resolve TPM policy from various sources with proper precedence
1380+ ///
1381+ /// Precedence order:
1382+ /// 1. Explicit CLI --tmp-policy argument
1383+ /// 2. Default empty policy "{}"
1384+ fn resolve_tpm_policy ( explicit_policy : Option < & str > ) -> String {
1385+ explicit_policy. unwrap_or ( "{}" ) . to_string ( )
1386+ }
1387+
13701388/// Generate a random string of the specified length
13711389///
13721390/// Uses system time as seed for a simple random string generator. This is a simple
1373- /// replacement for the missing tpm_util ::random_password function.
1391+ /// replacement for the missing tmp_util ::random_password function.
13741392fn generate_random_string ( length : usize ) -> String {
13751393 let charset: & [ u8 ] =
13761394 b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
0 commit comments