1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-04 02:33:33 +00:00

Fix build

This commit is contained in:
Bernd Schoolmann
2025-10-17 14:38:28 +02:00
parent 538bbc7567
commit 90bcfa4842
2 changed files with 5 additions and 4 deletions

View File

@@ -161,7 +161,7 @@ impl TryFrom<&[u8]> for SshSignRequest {
.map_err(|e| anyhow::anyhow!("Failed to read flags from sign request: {e}"))?;
Ok(SshSignRequest {
public_key: PublicKey::from_blob(public_key_blob),
public_key: PublicKey::try_from_blob(public_key_blob)?,
payload_to_sign: data.clone(),
parsed_sign_request: data.as_slice().try_into()?,
flags,

View File

@@ -360,11 +360,12 @@ impl PublicKey {
Ok(PublicKey { alg, blob })
}
pub fn from_blob(blob: Vec<u8>) -> Self {
pub fn try_from_blob(blob: Vec<u8>) -> Result<Self, anyhow::Error> {
// Parse the blob to extract the algorithm
let mut bytes = &blob[..];
let alg = String::from_utf8_lossy(read_bytes(&mut bytes).unwrap().as_slice()).to_string();
PublicKey { alg, blob }
let alg = String::from_utf8_lossy(read_bytes(&mut bytes)
.map_err(|e| anyhow::anyhow!("Failed to read algorithm from blob: {e}"))?.as_slice()).to_string();
Ok(PublicKey { alg, blob })
}
}