Parses message headers to find out which Secure-Join step the message represents. Returns `None` if the message is not a Secure-Join message.
(mime_message: &MimeMessage)
| 374 | /// |
| 375 | /// Returns `None` if the message is not a Secure-Join message. |
| 376 | pub(crate) fn get_secure_join_step(mime_message: &MimeMessage) -> Option<SecureJoinStep> { |
| 377 | if let Some(invitenumber) = mime_message.get_header(HeaderDef::SecureJoinInvitenumber) { |
| 378 | // We do not care about presence of `Secure-Join: vc-request` or `Secure-Join: vg-request` header. |
| 379 | // This allows us to always treat `Secure-Join` header as protected and ignore it |
| 380 | // in the unencrypted part even though it is sent there for backwards compatibility. |
| 381 | Some(SecureJoinStep::Request { |
| 382 | invitenumber: invitenumber.to_string(), |
| 383 | }) |
| 384 | } else if let Some(step) = mime_message.get_header(HeaderDef::SecureJoin) { |
| 385 | match step { |
| 386 | "vc-request-pubkey" => Some(SecureJoinStep::RequestPubkey), |
| 387 | "vc-pubkey" => Some(SecureJoinStep::Pubkey), |
| 388 | "vg-auth-required" | "vc-auth-required" => Some(SecureJoinStep::AuthRequired), |
| 389 | "vg-request-with-auth" | "vc-request-with-auth" => { |
| 390 | Some(SecureJoinStep::RequestWithAuth) |
| 391 | } |
| 392 | "vc-contact-confirm" => Some(SecureJoinStep::ContactConfirm), |
| 393 | "vg-member-added" => Some(SecureJoinStep::MemberAdded), |
| 394 | "vg-member-added-received" | "vc-contact-confirm-received" => { |
| 395 | Some(SecureJoinStep::Deprecated) |
| 396 | } |
| 397 | step => Some(SecureJoinStep::Unknown { |
| 398 | step: step.to_string(), |
| 399 | }), |
| 400 | } |
| 401 | } else { |
| 402 | None |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | /// Handle incoming secure-join handshake. |
| 407 | /// |
no test coverage detected