securedrop_protocol_minimal/setup.rs
1//! Setup module for FPF hardware operations
2//!
3//! This module contains implementations that run on FPF hardware.
4
5use crate::keys::FPFKeyPair;
6use crate::sign::{FpfOnNewsroom, Signature};
7use crate::wire::setup::{NewsroomSetupRequest, NewsroomSetupResponse};
8use anyhow::Error;
9
10impl NewsroomSetupRequest {
11 /// Setup a newsroom. This corresponds to step 2 in the spec.
12 ///
13 /// This runs on FPF hardware.
14 ///
15 /// The generated newsroom verifying key is sent to FPF,
16 /// which produces a signature over the newsroom verifying key using the
17 /// FPF signing key.
18 ///
19 /// # Security
20 ///
21 /// There is a manual verification step here: the caller should
22 /// instruct the user to stop, verify the fingerprint out of band, and
23 /// then proceed. The caller should also persist the fingerprint and signature
24 /// in its local data store.
25 ///
26 pub fn sign(self, fpf_keys: &FPFKeyPair) -> Result<NewsroomSetupResponse, Error> {
27 let newsroom_pk_bytes = self.newsroom_verifying_key.into_bytes();
28 let sig: Signature<FpfOnNewsroom> = fpf_keys.sign(&newsroom_pk_bytes);
29 Ok(NewsroomSetupResponse { sig })
30 }
31}