Skip to content

Commit

Permalink
Add Verification Policy template
Browse files Browse the repository at this point in the history
Bug: 356629119

Change-Id: Iff766185dfefbf85c1f447a5df8de84d5d36abf9
  • Loading branch information
ipetr0v committed Sep 17, 2024
1 parent 931c256 commit 9b60b1f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions oak_attestation_verification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern crate alloc;

pub mod amd;
pub mod endorsement;
pub mod policy;
pub mod rekor;
pub mod util;
pub mod verifier;
44 changes: 44 additions & 0 deletions oak_attestation_verification/src/policy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Copyright 2024 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.
//

//! Contains code related to attestation verification policies.

use oak_proto_rust::oak::attestation::v1::{
AttestationResults, Endorsements, EventAttestationResults, EventLog,
};

/// Verification Policy that takes an EventLog and corresponding Event
/// Endorsements and performs attestation verification.
///
/// Verification Policy correspond to the "Appraisal Policy for Evidence"
/// provided by the RATS standard.
/// <https://datatracker.ietf.org/doc/html/rfc9334#section-8.5>
pub trait Policy {
fn verify(
event_log: &EventLog,
endorsements: &Endorsements,
) -> anyhow::Result<AttestationResults>;
}

/// Verification Policy that takes a serialized Event and a serialized Event
/// Endorsement and performs attestation verification for this specific Event.
pub trait EventPolicy {
fn verify(
&self,
serialized_event: &[u8],
serialized_event_endorsements: &[u8],
) -> anyhow::Result<EventAttestationResults>;
}
8 changes: 8 additions & 0 deletions oak_proto_rust/generated/oak.attestation.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ pub struct AttestationResults {
/// Contains the evidence values whenever the status indicates success.
#[prost(message, optional, tag = "5")]
pub extracted_evidence: ::core::option::Option<ExtractedEvidence>,
/// Detailed attestation verification results each event.
#[prost(message, repeated, tag = "6")]
pub event_attestation_results: ::prost::alloc::vec::Vec<EventAttestationResults>,
}
/// Nested message and enum types in `AttestationResults`.
pub mod attestation_results {
Expand Down Expand Up @@ -1014,6 +1017,11 @@ pub mod attestation_results {
}
}
}
/// Attestation verification results for an individual event.
/// TODO: b/366419879 - Implement descriptive per-event attestation results.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost_derive::Message)]
pub struct EventAttestationResults {}
/// Evidence values extracted from attestation evidence during verification.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost_derive::Message)]
Expand Down
7 changes: 7 additions & 0 deletions proto/attestation/verification.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ message AttestationResults {

// Contains the evidence values whenever the status indicates success.
ExtractedEvidence extracted_evidence = 5;

// Detailed attestation verification results each event.
repeated EventAttestationResults event_attestation_results = 6;
}

// Attestation verification results for an individual event.
// TODO: b/366419879 - Implement descriptive per-event attestation results.
message EventAttestationResults {}

// Evidence values extracted from attestation evidence during verification.
message ExtractedEvidence {
oneof evidence_values {
Expand Down

0 comments on commit 9b60b1f

Please sign in to comment.