(&self)
| 21 | |
| 22 | impl Command for VerifyDsse { |
| 23 | fn run(&self) -> CliResult<()> { |
| 24 | let key = |
| 25 | PublicKey::from_base32(&self.public_key).map_err(|e| CliError::InvalidArgument { |
| 26 | message: e.to_string(), |
| 27 | })?; |
| 28 | let reader: Box<dyn Read> = match &self.file { |
| 29 | Some(path) => Box::new(std::fs::File::open(path).map_err(CliError::Io)?), |
| 30 | None => Box::new(std::io::stdin()), |
| 31 | }; |
| 32 | let mut bytes = Vec::new(); |
| 33 | reader |
| 34 | .take(MAX_EXPORT_BYTES as u64 + 1) |
| 35 | .read_to_end(&mut bytes) |
| 36 | .map_err(CliError::Io)?; |
| 37 | let verified = |
| 38 | verify_provenance_export(&bytes, &key).map_err(|e| CliError::InvalidArgument { |
| 39 | message: e.to_string(), |
| 40 | })?; |
| 41 | // Deliberately write the authenticated bytes without reserialization, |
| 42 | // or a second decode of the original envelope. |
| 43 | std::io::stdout() |
| 44 | .lock() |
| 45 | .write_all(&verified.payload) |
| 46 | .map_err(CliError::Io) |
| 47 | } |
| 48 | } |
nothing calls this directly
no test coverage detected