Remove cose_error
This isn't needed any more since the std feature of Coset (which is
now enabled) makes CoseError implement Error.
Test: atest hwtrust_tests
Change-Id: Ib03c9e0cbd0512647d9a042e9bc477ef95b9e967
diff --git a/remote_provisioning/hwtrust/src/cbor.rs b/remote_provisioning/hwtrust/src/cbor.rs
index 8092506..fe3fa88 100644
--- a/remote_provisioning/hwtrust/src/cbor.rs
+++ b/remote_provisioning/hwtrust/src/cbor.rs
@@ -8,10 +8,6 @@
use ciborium::{de::from_reader, value::Value};
use std::io::Read;
-fn cose_error(ce: coset::CoseError) -> anyhow::Error {
- anyhow::anyhow!("CoseError: {:?}", ce)
-}
-
type CiboriumError = ciborium::de::Error<std::io::Error>;
/// Decodes the provided binary CBOR-encoded value and returns a
diff --git a/remote_provisioning/hwtrust/src/cbor/dice.rs b/remote_provisioning/hwtrust/src/cbor/dice.rs
index 6336e25..59c82ce 100644
--- a/remote_provisioning/hwtrust/src/cbor/dice.rs
+++ b/remote_provisioning/hwtrust/src/cbor/dice.rs
@@ -1,6 +1,5 @@
//! Parsing and encoding DICE chain from and to CBOR.
-use crate::cbor::cose_error;
use anyhow::Result;
use ciborium::value::Value;
use coset::iana::{self, EnumI64};
@@ -28,12 +27,12 @@
// can handle it.
if let Value::Map(ref mut entries) = value {
for (label, value) in entries.iter_mut() {
- let label = Label::from_cbor_value(label.clone()).map_err(cose_error)?;
+ let label = Label::from_cbor_value(label.clone())?;
if label == Label::Int(iana::KeyParameter::KeyOps.to_i64()) && value.is_integer() {
*value = Value::Array(vec![value.clone()]);
}
}
}
}
- CoseKey::from_cbor_value(value).map_err(cose_error)
+ Ok(CoseKey::from_cbor_value(value)?)
}
diff --git a/remote_provisioning/hwtrust/src/cbor/dice/entry.rs b/remote_provisioning/hwtrust/src/cbor/dice/entry.rs
index fc4c374..07f7605 100644
--- a/remote_provisioning/hwtrust/src/cbor/dice/entry.rs
+++ b/remote_provisioning/hwtrust/src/cbor/dice/entry.rs
@@ -1,6 +1,6 @@
use super::cose_key_from_cbor_value;
use super::profile::{ComponentVersionType, ModeType, Profile};
-use crate::cbor::{cose_error, field_value::FieldValue, value_from_bytes};
+use crate::cbor::{field_value::FieldValue, value_from_bytes};
use crate::dice::{
ComponentVersion, ConfigDesc, ConfigDescBuilder, DiceMode, Payload, PayloadBuilder,
ProfileVersion,
@@ -42,7 +42,6 @@
impl Entry {
pub(super) fn verify_cbor_value(cbor: Value, key: &PublicKey) -> Result<Self> {
let sign1 = CoseSign1::from_cbor_value(cbor)
- .map_err(cose_error)
.context("Given CBOR does not appear to be a COSE_sign1")?;
key.verify_cose_sign1(&sign1, b"").context("cannot verify COSE_sign1")?;
match sign1.payload {
@@ -393,8 +392,7 @@
impl Payload {
pub(in super::super) fn to_cbor_value(&self) -> Result<Value> {
- let subject_public_key =
- self.subject_public_key().to_cose_key()?.to_vec().map_err(cose_error)?;
+ let subject_public_key = self.subject_public_key().to_cose_key()?.to_vec()?;
let config_desc = serialize(self.config_desc().to_cbor_value());
let mut map = vec![
(Value::from(ISS), Value::from(self.issuer())),