Skip to content
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

integration tests perform encryption manually #4770

Open
tiziano88 opened this issue Feb 8, 2024 · 1 comment
Open

integration tests perform encryption manually #4770

tiziano88 opened this issue Feb 8, 2024 · 1 comment

Comments

@tiziano88
Copy link
Collaborator

// Encrypt request.
let mut client_encryptor =
ClientEncryptor::create(&server_encryption_public_key).expect("couldn't create encryptor");
let encrypted_request = client_encryptor
.encrypt(&[1, 2, 3], EMPTY_ASSOCIATED_DATA)
.expect("couldn't encrypt request");

we should use a version of some OakClient library, also to make it easier for the tests to be maintained as we make changes to the protos and other parts of the encryption stack

@tiziano88
Copy link
Collaborator Author

cc @johnniechan

to add a bit more details: at the moment, in these tests we manually build the encryptor object based on the initial request, and then use that to encrypt the invocation request. All of this logic is already encapsulated in the oak_client crate:

pub async fn invoke(&mut self, request_body: &[u8]) -> anyhow::Result<Vec<u8>> {
// Encrypt request.
let mut client_encryptor = ClientEncryptor::create(&self.server_encryption_public_key)
.context("couldn't create encryptor")?;
let encrypted_request = client_encryptor
.encrypt(request_body, EMPTY_ASSOCIATED_DATA)
.context("couldn't encrypt request")?;
// Send request.
let encrypted_response = self
.transport
.invoke(&encrypted_request)
.await
.map_err(|error| anyhow!("couldn't send request: {:?}", error))?;
// Decrypt response.
// Currently we ignore the associated data.
let (response, _) = client_encryptor
.decrypt(&encrypted_response)
.context("client couldn't decrypt response")?;
Ok(response)
}

it may be necessary to adjust the underlying trait abstractions in order to support the tests, since there would not be an actual gRPC channel in tests, but the logic should be abstract enough to work in both cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant