-
Notifications
You must be signed in to change notification settings - Fork 128
Stop cloning additional_info into each ServerHandshaker #2574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
0789621
4963406
f6e6797
b761612
c490e31
238a1a9
3bb64bd
f626cf6
2e06b25
5523c4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ use anyhow::Context; | |
| use futures::{Stream, StreamExt}; | ||
| use oak_remote_attestation::handshaker::{AttestationBehavior, Encryptor, ServerHandshaker}; | ||
| use oak_utils::LogError; | ||
| use std::pin::Pin; | ||
| use std::{pin::Pin, sync::Arc}; | ||
| use tonic::{Request, Response, Status, Streaming}; | ||
|
|
||
| /// Handler for subsequent encrypted requests from the stream after the handshake is completed. | ||
|
|
@@ -93,7 +93,7 @@ pub struct AttestationServer<F, L: LogError> { | |
| /// Processes data from client requests and creates responses. | ||
| request_handler: F, | ||
| /// Configuration information to provide to the client for the attestation step. | ||
| additional_info: Vec<u8>, | ||
| additional_info: Arc<Vec<u8>>, | ||
| /// Error logging function that is required for logging attestation protocol errors. | ||
| /// Errors are only logged on server side and are not sent to clients. | ||
| error_logger: L, | ||
|
|
@@ -114,7 +114,7 @@ where | |
| Ok(Self { | ||
| tee_certificate, | ||
| request_handler, | ||
| additional_info, | ||
| additional_info: Arc::new(additional_info), | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we prefer a let declaration over instantiating the Arc in the struct instantiation? |
||
| error_logger, | ||
| }) | ||
| } | ||
|
|
@@ -136,8 +136,8 @@ where | |
| ) -> Result<Response<Self::StreamStream>, Status> { | ||
| let tee_certificate = self.tee_certificate.clone(); | ||
| let request_handler = self.request_handler.clone(); | ||
| let additional_info = self.additional_info.clone(); | ||
| let error_logger = self.error_logger.clone(); | ||
| let additional_info = self.additional_info.clone(); | ||
|
|
||
| let response_stream = async_stream::try_stream! { | ||
| let mut request_stream = request_stream.into_inner(); | ||
|
|
@@ -148,7 +148,7 @@ where | |
| error_logger.log_error(&format!("Couldn't create self attestation behavior: {:?}", error)); | ||
| Status::internal("") | ||
| })?, | ||
| additional_info, | ||
| additional_info | ||
| ); | ||
| while !handshaker.is_completed() { | ||
| let incoming_message = request_stream.next() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ pub fn into_server_identity_verifier( | |
| config_verifier: ConfigurationVerifier, | ||
| ) -> ServerIdentityVerifier { | ||
| let server_verifier = move |server_identity: ServerIdentity| -> anyhow::Result<()> { | ||
| let config = ConfigurationInfo::decode(server_identity.additional_info.as_ref())?; | ||
| let config = ConfigurationInfo::decode(&*server_identity.additional_info.as_slice())?; | ||
|
||
| // TODO(#2347): Check that ConfigurationInfo does not have additional/unknown fields. | ||
| config_verifier(config)?; | ||
| // TODO(#2316): Verify proof of inclusion in Rekor. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ use crate::{ | |
| MAXIMUM_MESSAGE_SIZE, REPLAY_PROTECTION_ARRAY_LENGTH, SERVER_IDENTITY_HEADER, | ||
| }, | ||
| }; | ||
| use alloc::{vec, vec::Vec}; | ||
| use alloc::{sync::Arc, vec, vec::Vec}; | ||
| use anyhow::{anyhow, Context}; | ||
| use assert_matches::assert_matches; | ||
| use quickcheck::{quickcheck, TestResult}; | ||
|
|
@@ -96,7 +96,7 @@ fn test_serialize_server_identity() { | |
| transcript_signature: Vec<u8>, | ||
| signing_public_key: Vec<u8>, | ||
| attestation_info: Vec<u8>, | ||
| additional_info: Vec<u8>, | ||
| additional_info: Arc<Vec<u8>>, | ||
| ) -> TestResult { | ||
| if ephemeral_public_key.len() > KEY_AGREEMENT_ALGORITHM_KEY_LENGTH | ||
| || random.len() > REPLAY_PROTECTION_ARRAY_LENGTH | ||
|
|
@@ -131,7 +131,9 @@ fn test_serialize_server_identity() { | |
| assert!(result.is_ok()); | ||
| TestResult::from_bool(result.unwrap()) | ||
| } | ||
| quickcheck(property as fn(Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>) -> TestResult); | ||
| quickcheck( | ||
| property as fn(Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>, Arc<Vec<u8>>) -> TestResult, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this test do? |
||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -202,7 +204,7 @@ fn test_deserialize_message() { | |
| default_array(), | ||
| default_array(), | ||
| vec![], | ||
| vec![], | ||
| Arc::new(vec![]), | ||
| ); | ||
| let deserialized_server_identity = deserialize_message(&server_identity.serialize().unwrap()); | ||
| assert_matches!(deserialized_server_identity, Ok(_)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we prefer a let declaration over instantiating the Arc in the struct instantiation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me.