MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / decrypt_env_vars

Method decrypt_env_vars

dstack-util/src/system_setup.rs:1437–1457  ·  view source on GitHub ↗
(
        &self,
        key: &[u8],
        ciphertext: &[u8],
        allowed: &BTreeSet<String>,
    )

Source from the content-addressed store, hash-verified

1435
1436impl Stage1<'_> {
1437 fn decrypt_env_vars(
1438 &self,
1439 key: &[u8],
1440 ciphertext: &[u8],
1441 allowed: &BTreeSet<String>,
1442 ) -> Result<BTreeMap<String, String>> {
1443 let vars = if !key.is_empty() && !ciphertext.is_empty() {
1444 info!("Processing encrypted env");
1445 let env_crypt_key: [u8; 32] = key
1446 .try_into()
1447 .ok()
1448 .context("Invalid env crypt key length")?;
1449 let decrypted_json =
1450 dh_decrypt(env_crypt_key, ciphertext).context("Failed to decrypt env file")?;
1451 crate::parse_env_file::parse_env(&decrypted_json, allowed)?
1452 } else {
1453 info!("No encrypted env, using default");
1454 Default::default()
1455 };
1456 Ok(vars)
1457 }
1458
1459 fn write_env_file(&self, env_vars: &BTreeMap<String, String>) -> Result<()> {
1460 info!("Writing env");

Callers 1

unseal_env_varsMethod · 0.80

Calls 3

dh_decryptFunction · 0.85
parse_envFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected