-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Policy is not implemented yes, since we need to decide on how we are going to integrate the session binding key into the authentication scheme. Bug: 368030563 Bug: 399885537 Change-Id: I96f1308b8fba1ee4886bf6d8eea7597155e77c92
- Loading branch information
Showing
9 changed files
with
224 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
oak_attestation_verification/src/policy/application_keys.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// Copyright 2025 The Project Oak Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
use alloc::{ | ||
collections::BTreeMap, | ||
string::{String, ToString}, | ||
vec::Vec, | ||
}; | ||
|
||
use oak_attestation_verification_types::policy::Policy; | ||
use oak_proto_rust::oak::{ | ||
attestation::v1::{ | ||
ApplicationKeysData, ApplicationKeysReferenceValues, EventAttestationResults, | ||
}, | ||
Variant, | ||
}; | ||
|
||
use crate::{ | ||
policy::{ | ||
HYBRID_ENCRYPTION_PUBLIC_KEY_ID, SESSION_BINDING_PUBLIC_KEY_ID, SIGNING_PUBLIC_KEY_ID, | ||
}, | ||
util::decode_event_proto, | ||
}; | ||
|
||
pub struct ApplicationKeysPolicy { | ||
_reference_values: ApplicationKeysReferenceValues, | ||
} | ||
|
||
impl ApplicationKeysPolicy { | ||
pub fn new(reference_values: &ApplicationKeysReferenceValues) -> Self { | ||
Self { _reference_values: reference_values.clone() } | ||
} | ||
} | ||
|
||
// We have to use [`Policy<[u8]>`] instead of [`EventPolicy`], because | ||
// Rust doesn't yet support implementing trait aliases. | ||
// <https://github.com/rust-lang/rfcs/blob/master/text/1733-trait-alias.md> | ||
impl Policy<[u8]> for ApplicationKeysPolicy { | ||
fn verify( | ||
&self, | ||
encoded_event: &[u8], | ||
_encoded_endorsement: &Variant, | ||
_milliseconds_since_epoch: i64, | ||
) -> anyhow::Result<EventAttestationResults> { | ||
let event = decode_event_proto::<ApplicationKeysData>( | ||
"type.googleapis.com/oak.attestation.v1.ApplicationKeysData", | ||
encoded_event, | ||
)?; | ||
|
||
// TODO: b/399885537 - Verify that the key is signed by the CA. | ||
|
||
let mut artifacts = BTreeMap::<String, Vec<u8>>::new(); | ||
if !event.session_binding_public_key.is_empty() { | ||
artifacts.insert( | ||
SESSION_BINDING_PUBLIC_KEY_ID.to_string(), | ||
event.session_binding_public_key.to_vec(), | ||
); | ||
} | ||
if !event.hybrid_encryption_public_key.is_empty() { | ||
artifacts.insert( | ||
HYBRID_ENCRYPTION_PUBLIC_KEY_ID.to_string(), | ||
event.hybrid_encryption_public_key, | ||
); | ||
} | ||
if !event.signing_public_key.is_empty() { | ||
artifacts.insert(SIGNING_PUBLIC_KEY_ID.to_string(), event.signing_public_key); | ||
} | ||
|
||
// TODO: b/356631062 - Return detailed attestation results. | ||
Ok(EventAttestationResults { artifacts }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters