-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add support to use KMS for signing EIF files when building them #20
base: main
Are you sure you want to change the base?
Conversation
We extend EIF building functionality with additional option of signing EIF files with KMS. sign_info parameter of EifBuilder now turned to a structure that contains enum for the signing key. This enum can be represented as local private key (previous functionality) or KMS signing key (implemented in COSE library). Also a couple of wrappers and helper methods are introduced to store initial information about signing keys and transform it to the keys itself. The information about KMS signing key is represented as unique KMS key id string and optional region string. In case region is missed it will be read from AWS_REGION environment variable as a standard way for SDK configuration. Signed-off-by: Eugene Koira <[email protected]>
Small part of reading and initializing key and certficate data is covered with tests. Signed-off-by: Eugene Koira <[email protected]>
Signed-off-by: Eugene Koira <[email protected]>
Update minimum supported rust version (MSRV) to 1.68.2. Signed-off-by: Eugene Koira <[email protected]>
aws-sdk-kms = "<=1.20" | ||
aws-config = "<=1.1" | ||
aws-types = "<=1.1" | ||
aws-smithy-runtime = { version = "<=1.2" } |
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.
What is the reason for enforcing a maximal version? Consider adding it as a comment or in the commit message.
}; | ||
|
||
let sign_key_data = sign_key_info.map(|key_info| { | ||
SignKeyData::new(&SignKeyDataInfo { | ||
cert_path: signing_certificate.unwrap().to_string(), |
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.
nit: unwrap
-> sign_key_info.zip(signing_certificate).map(|(key_info, certificate)| ...)
(None, Some(key_path)) => Some(SignKeyInfo::LocalPrivateKeyInfo { | ||
path: key_path.to_string(), | ||
}), | ||
_ => panic!("kms-key-id and private-key parameters are mutually exclusive"), |
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.
nit: panic!
-> unreachable!
pub private_key: Vec<u8>, | ||
pub struct SignKeyDataInfo { | ||
// Path to the certificate file | ||
pub cert_path: String, |
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.
nit: We should consider to use std::path::Path
for all the paths
.await | ||
.unwrap() | ||
}; | ||
let runtime = Runtime::new().unwrap(); |
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.
nit: consider to map the unwrap to an Err(String)
and use ?
signing_certificate, | ||
signature, | ||
signing_certificate: sign_info.cert.clone(), | ||
signature: cose_sign.unwrap().as_bytes(false).unwrap(), |
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.
nit: use expect and explain why it is safe to unwrap
Issue #, if available:
aws/aws-nitro-enclaves-cli#204
Description of changes:
This is a reworked version of #6 because it was abandoned
We extend EIF building functionality with additional option of signing EIF files with KMS.
sign_info
parameter of EifBuilder now turned to a structure that contains enum for the signing key.This enum can be represented as local private key (previous functionality)
or KMS signing key (implemented in COSE library).
Also a couple of wrappers and helper methods are introduced
to store initial information about signing keys and transform it to the keys itself.
The information about KMS signing key is represented as unique KMS key id string and optional
region string. In case region is missed it will be read from
AWS_REGION
environment variableas a standard way for SDK configuration.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.