Skip to content

Commit

Permalink
Canonicalize CoseKey CBOR serialization.
Browse files Browse the repository at this point in the history
Change-Id: I9b4abf1662ffccef692258e979d7e3c23ddd52e2
  • Loading branch information
souravdasgupta committed Jun 6, 2024
1 parent f1716be commit f0e41c6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions enclave_apps/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions oak_dice/src/cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use alloc::{string::String, vec, vec::Vec};
use coset::{
cbor::value::Value,
cwt::{ClaimName, ClaimsSet, ClaimsSetBuilder},
iana, Algorithm, CborSerializable, CoseError, CoseKey, CoseSign1, KeyOperation, KeyType, Label,
RegisteredLabelWithPrivate,
iana, Algorithm, CborOrdering, CborSerializable, CoseError, CoseKey, CoseSign1, KeyOperation,
KeyType, Label, RegisteredLabelWithPrivate,
};
use hkdf::Hkdf;
use p256::{
Expand Down Expand Up @@ -228,7 +228,7 @@ pub fn cose_key_to_verifying_key(cose_key: &CoseKey) -> Result<VerifyingKey, &'s
/// Converts an ECDSA verifying key to a COSE_Key representation.
pub fn verifying_key_to_cose_key(public_key: &VerifyingKey) -> CoseKey {
let encoded_point = public_key.to_encoded_point(false);
CoseKey {
let mut ck = CoseKey {
kty: KeyType::Assigned(iana::KeyType::EC2),
key_id: Vec::from(derive_verifying_key_id(public_key)),
alg: Some(Algorithm::Assigned(iana::Algorithm::ES256)),
Expand All @@ -248,7 +248,9 @@ pub fn verifying_key_to_cose_key(public_key: &VerifyingKey) -> CoseKey {
),
],
..Default::default()
}
};
ck.canonicalize(CborOrdering::LengthFirstLexicographic);
ck
}

/// Generates a CWT certificate representing an ECDSA signing key, such as an
Expand Down
4 changes: 2 additions & 2 deletions oak_ml_transparency/runner/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions oak_restricted_kernel_bin/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions stage0_bin/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0e41c6

Please sign in to comment.