-
Notifications
You must be signed in to change notification settings - Fork 71
Use singleton to avoid multiple Context allocation #1029
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
Use singleton to avoid multiple Context allocation #1029
Conversation
e238449 to
688d094
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
22191a4 to
6011669
Compare
c8d06c4 to
7d9e8e4
Compare
|
/packit retest-failed |
7ee8e83 to
4320818
Compare
|
@ansasaki : Please, do not pay attention to the coverage reports. There seems to be errors with latest change. |
| tpm_encryption_alg: config.get_tpm_encryption_alg(), | ||
| tpm_hash_alg: config.get_tpm_hash_alg(), | ||
| tpm_signing_alg: config.get_tpm_signing_alg(), |
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.
I was trying to understand why these are fixed in the context. I think you do not need to follow the pull agent so much, in the sense that there we had a single set of algorithms to be configured, while in the push model the agent will negotiate the parameters.
For me, it would make more sense if the context held the supported algorithms obtained from the TPM capabilities.
Then, after negotiating the algorithms with the verifier, you should use this to decide which keys to generate/load and send the requested AK.
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.
When you create an AK, you need to specify a particular one:
let ak = self.tpm_context.create_ak(
self.ek_handle,
self.tpm_hash_alg,
key_alg_for_ak,
sign_alg,
)?;However, the amount of AKs that can be load is relatively small in TPM. That is the reason why I decided to follow this approach. Keeping the signing algorithm is just for BW compatibility. There is one AK generated for each RSA supported signing scheme.
So, if we change this ... how would you approach about this? A combination of all the options?
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.
OK, sorry for my last message, I think I was probably tired by the end of the day and could not understand the problem here. Now I see the problem.
I think the Agent should be configurable so that the user can decide which keys to offer, with the possibility of offering multiple keys if they want. So, in my mind, we should allow the user to configure a list of AK to offer, which can be:
- by setting the parameters to generate the key
- by setting the key handle, if it was persisted
- by setting a file path to load a previously generated key (maybe this will be part of the first option as usually we want to persist the generated keys somewhere)
We also should have a default option where it will offer a single key using a default set of algorithms. I think this is the easiest way for you to move forward (basically implement the default case, which is to offer a single AK key that is loaded from a default location or generated if the file is not there, like it is today in the pull agent).
I think we have to discuss with HPE guys and agree how this should work in the final form.
We could use JSON strings to specify the keys parameters or create a specific configuration language and write the parser for it.
PS.: The default behavior could also be similar to what you are doing, which is basically generate some keys with some combination of algorithms and offer them (probably one RSA and one ECC key would be sufficient), but I don't think it should be all the possible combinations
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.
@ansasaki : Do you think it would be feasible to have a first version that sends one RSA and one ECC, then create all the possible ones from config once config is groomed? This way, we can have something with multiple AKs and deliver proposed changes (persistence and configuration based AKs creation) in other PRs
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.
Yes, I think we can proceed like this and make the changes on a future PR
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.
Hello Anderson. After clarifying it, I understand original PR is not required. However, let me keep this open to have the Singleton to the Context Info maintained, as this will reduce allocating Context more than once. If you prefer me to open a newer PR, please, let me know.
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.
OK, let's repurpose it to implement the singleton for the Context
587373e to
b6a4c44
Compare
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
b6a4c44 to
6aad744
Compare
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.
LGTM
No description provided.