MCPcopy Create free account
hub / github.com/chatmail/core / try_decrypt_with_bobstate

Function try_decrypt_with_bobstate

src/decrypt.rs:129–146  ·  view source on GitHub ↗
(
    esk: &SymKeyEncryptedSessionKey,
    conn: &mut rusqlite::Connection,
)

Source from the content-addressed store, hash-verified

127}
128
129fn try_decrypt_with_bobstate(
130 esk: &SymKeyEncryptedSessionKey,
131 conn: &mut rusqlite::Connection,
132) -> Result<Option<(PlainSessionKey, String)>> {
133 let mut stmt = conn.prepare("SELECT invite FROM bobstate")?;
134 let mut rows = stmt.query(())?;
135 while let Some(row) = rows.next()? {
136 let invite: crate::securejoin::QrInvite = row.get(0)?;
137 let authcode = invite.authcode().to_string();
138 let alice_fp = invite.fingerprint().hex();
139 let shared_secret = format!("securejoin/{alice_fp}/{authcode}");
140 if let Ok(psk) = decrypt_session_key_with_password(esk, &Password::from(shared_secret)) {
141 let fingerprint = invite.fingerprint().hex();
142 return Ok(Some((psk, fingerprint)));
143 }
144 }
145 Ok(None)
146}
147
148fn try_decrypt_with_broadcast_secret(
149 esk: &SymKeyEncryptedSessionKey,

Callers 1

Calls 6

authcodeMethod · 0.80
hexMethod · 0.80
prepareMethod · 0.45
nextMethod · 0.45
getMethod · 0.45
fingerprintMethod · 0.45

Tested by

no test coverage detected