Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ hex = { version = "0.4", features = ["serde"] }
thiserror = "1"
hex-literal = "0.4.1"
bitmask = "0.5.0"
serde_with = { version = "3.4.0", features = ["hex"] }
serde_with = { version = "3.14.0", features = ["hex"] }
jsonwebtoken = "9.1.0"
cose-rust = "0.1.7"
ear = "0.3.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ fn realm_tokens_decode() {
let files = vec!["testdata/realm-claims.cbor"];

for f in files {
let buf = fs::read(f).unwrap_or_else(|_| panic!("loading file {}", f));
let buf = fs::read(f).unwrap_or_else(|_| panic!("loading file {f}"));

let rc = Realm::decode(&buf).unwrap();

println!("{:#?}", rc);
println!("{rc:#?}");
}
}
2 changes: 1 addition & 1 deletion src/store/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Syntax(e) | Error::Sema(e) => {
write!(f, "{}", e)
write!(f, "{e}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/token/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl std::fmt::Debug for Error {
| Error::HashCalculateFail(e)
| Error::NoCoseAlgInHeader(e)
| Error::BadInternalState(e) => {
write!(f, "{}", e)
write!(f, "{e}")
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/token/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ impl CBORCollection {

if let Value::Tag(t, m) = v {
if t != CBOR_TAG {
return Err(Error::Syntax(format!(
"expecting tag {}, got {}",
CBOR_TAG, t
)));
return Err(Error::Syntax(format!("expecting tag {CBOR_TAG}, got {t}",)));
}

if let Value::Map(contents) = *m {
Expand Down Expand Up @@ -168,11 +165,11 @@ impl Evidence {

t.platform
.init_decoder(None)
.map_err(|e| Error::Syntax(format!("platform token: {:?}", e)))?;
.map_err(|e| Error::Syntax(format!("platform token: {e:?}")))?;

t.realm
.init_decoder(None)
.map_err(|e| Error::Syntax(format!("realm token: {:?}", e)))?;
.map_err(|e| Error::Syntax(format!("realm token: {e:?}")))?;

t.platform_claims = Platform::decode(&t.platform.payload)?;
t.realm_claims = Realm::decode(&t.realm.payload)?;
Expand Down
11 changes: 4 additions & 7 deletions src/token/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ impl Platform {

if x_len != 32 {
return Err(Error::Sema(format!(
"implementation-id: expecting 32 bytes, got {}",
x_len
"implementation-id: expecting 32 bytes, got {x_len}"
)));
}

Expand All @@ -363,8 +362,7 @@ impl Platform {

if x_len != 33 {
return Err(Error::Sema(format!(
"instance-id: expecting 33 bytes, got {}",
x_len
"instance-id: expecting 33 bytes, got {x_len}"
)));
}

Expand Down Expand Up @@ -477,8 +475,7 @@ impl Platform {

if _xi.is_none() {
return Err(Error::TypeMismatch(format!(
"sw-component[{}] MUST be map",
i
"sw-component[{i}] MUST be map"
)));
}

Expand All @@ -505,7 +502,7 @@ mod tests {

let _p = Platform::decode(&buf).unwrap();

println!("{:#?}", _p);
println!("{_p:#?}");
}

#[test]
Expand Down
11 changes: 4 additions & 7 deletions src/token/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ impl Realm {
if self.profile.is_empty() {
if x_len != 97 {
return Err(Error::Sema(format!(
"public-key: expecting 97 bytes, got {}",
x_len
"public-key: expecting 97 bytes, got {x_len}"
)));
}
self.raw_rak[..].clone_from_slice(&x);
Expand Down Expand Up @@ -289,13 +288,12 @@ impl Realm {

if x_len != 4 {
return Err(Error::Sema(format!(
"extensible-measurements: expecting 4 slots, got {}",
x_len
"extensible-measurements: expecting 4 slots, got {x_len}"
)));
}

for (i, xi) in x.iter().enumerate() {
self.rem[i] = to_measurement(xi, format!("extensible-measurement[{}]", i).as_str())?;
self.rem[i] = to_measurement(xi, format!("extensible-measurement[{i}]").as_str())?;
}

self.claims_set.set(Claims::Rem);
Expand All @@ -321,8 +319,7 @@ impl Realm {

if x_len != 64 {
return Err(Error::Sema(format!(
"personalization value: expecting 64 bytes, got {}",
x_len
"personalization value: expecting 64 bytes, got {x_len}"
)));
}

Expand Down