-
Notifications
You must be signed in to change notification settings - Fork 71
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 capabilities discovery operations #426
Comments
Brain dump of this |
Also check ideas here |
I think this is fine to first go for For
The result would be the intersection of those two sets. A good test would be to make sure that all algorithms returned by |
Potential Design OverviewThis covers the code changes needed to implement MotivationThe reason this operation is needed is covered in detail in Hugues' post but concisely this will improve the stability of parsec by telling the clients what algorithms are supported rather than the client just trying algorithms that if the client is newer than the service could not be supported. Plan OverviewMy plan for parsec-bookAs
Additionally a line would need to be added to the Parsec Operations Coverage table to show that the operation is currently only supported on PKCS11 parsec-operationsAs
parsec-interface-rsoperations_protobufCreate Add Add requestsAdd the opcode for rust-cryptokiMake the new function which converts from parsecAdd Add Add TestingThe output of this operation should be a list of algorithms and each algorithm in the list should be able to be used as an input for the relevant operations so a test could be checking if they are all supported by either making a function to check or using them as inputs for the relevant operations and seeing if it produces an error. |
Thank you for the write-up! Some comments on my side:
We should discuss if we either make this operation a core operation, in which case it should always be directed to the core provider and would take as a parameter the provider ID to request the supported algorithms from (like ListOpcodes for example). Maybe that would make more sense as it's a similar kind of operation than the other
I think we can start with that but do some tests/checks to see if that wouldn't make the response too big. For example if you have to return the algorithms with all of the hashes they support it might be a lot. I think it should be ok.
You might also need to implement this operation in the
Good point! For our tests, we can manually find what the supported algorithms are in SoftHSM, which is the pkcs11 implementation we use for tests. edit: could be nice to have the command available in the Parsec Tool as well! Those kind of oeprations are very useful to have on the command line. |
Because of this I was wondering if it wouldn't make more sense to turn that query around: what if the client sent a list of fully-defined algorithms it wants to check for support and the service replies with a "filtered" list with only the supported ones. That way you avoid having to expand all the nested algorithms and the client gets what they want. Even with the current design you'll still have to do something similar - ask for the list from the service and then you as a client have your own list of supported algorithms and you compare and take the top one in your preferences. This also has the benefit of not having to implement the search for every client as well (though it's probably not that big of a deal in most languages). |
Yes I think that's a pretty valid idea as well! Clients could then only send the algorithm in an area they are just interested in (signing or encryption for example). |
PSA were looking at adding capability discovery stuff at one time, but it seems that there is no active work directly in this area right now. The closest thing that is being worked on is a structured data format for driver capabilities, but I'm not sure how directly relevant that is: https://github.com/ARMmbed/mbedtls/blob/development/docs/proposed/psa-driver-interface.md#driver-description-syntax There may be an opportunity to cross-pollinate what we are doing with PSA. Let's make sure we're thinking about what kind of client dev experiences we want to enable, rather than just design individual opcode contracts. How does this feed into smart defaulting, for instance? Are there going to be any kinds of preferential ordering semantics to the data being transacted over this API? It's absolutely fine to implement just in PKCS#11 for now, but let's make sure we have some kind of story (even if only on paper) for how these contracts would be back-ended to the other providers. |
Another idea of a capability discovery operation, linked with a proposal made on the PSA Crypto API. I am thinking of two general client use-cases for capability profiling. For any of the following:
clients want to:
This operation is based on the fact that the The operation contract is noted below. A possible improvement would make it take as input a vector of Notes:
CanDoCryptoCheck if the provider supports:
Parameters
CheckType typeA
ResultsNo values are returned by this operation. Specific response status codes
DescriptionThe meaning of the operation depends of the value of
|
An example for use case 1 with this new operation could be shown in our end-to-end tests. That would allow to remove the compile-time diff --git a/e2e_tests/tests/per_provider/normal_tests/import_key.rs b/e2e_tests/tests/per_provider/normal_tests/import_key.rs
index 8f0989a..2ae398b 100644
--- a/e2e_tests/tests/per_provider/normal_tests/import_key.rs
+++ b/e2e_tests/tests/per_provider/normal_tests/import_key.rs
@@ -99,12 +99,40 @@ fn import_rsa_key() -> Result<()> {
client.import_rsa_public_key(key_name, KEY_DATA.to_vec())
}
-#[cfg(not(feature = "tpm-provider"))]
#[test]
fn import_ecc_key() {
let mut client = TestClient::new();
let key_name = String::from("import_key_ecc");
- if !client.is_operation_supported(Opcode::PsaImportKey) {
+
+ let attributes = Attributes {
+ lifetime: Lifetime::Persistent,
+ key_type: Type::EccPublicKey {
+ curve_family: EccFamily::SecpR1,
+ },
+ bits: 256,
+ policy: Policy {
+ usage_flags: UsageFlags {
+ sign_hash: false,
+ verify_hash: true,
+ sign_message: false,
+ verify_message: true,
+ export: false,
+ encrypt: false,
+ decrypt: false,
+ cache: false,
+ copy: false,
+ derive: false,
+ },
+ permitted_algorithms: AsymmetricSignature::Ecdsa {
+ hash_alg: Hash::Sha256.into(),
+ }
+ .into(),
+ },
+ };
+
+ if !client.can_do(CheckType::Import, attributes)
+ || !client.is_operation_supported(Opcode::PsaVerifyHash)
+ {
return;
} |
Potential Design OverviewThis covers the code changes needed to implement the MotivationThe reason this operation is needed is covered in detail in Hugues' post but concisely this will improve the stability of parsec by telling the clients whether a certain set of Plan OverviewMy plan for parsec-bookAs parsec-operationsAs parsec-interface-rsoperations_protobufCreate Add Add requestsAdd the opcode for parsecAdd Add Add The ChecksTo check the I will check the I will check the TestingThis operation has no output but rather gives a status code depending on whether the I hope this covers everything. If I have missed anything then or just explained something badly then I apologise in advance and will try to give a more complete explaination. |
Thanks for the updated design!
I think you can put it in a new
Sounds good! If the
What do you mean? For the other checks than Use, you will have to check if the implementation allows to generate, import or derive a key of that type. For example for PKCS11, for RSA key pairs and for Generate, I think can be done by checking if the mechanism |
The mechanism info contains a set of flags which indicate whether the mechanism can be used for a given process so I was trying to say that I would check those but I shouldn't have listed Use as an example as I don't believe that any of the flags are relevant in this case. |
A few things that I noticed in https://github.com/parallaxsecond/parsec/pull/522/files :
|
Closing this issue as the initial work of adding the operations into the service has been done. Will open individual issues for the remaining work. |
See #388 for context.
The operations are described in this comment as GetSupportedAlgorithms and GetSupportedKeyAttributes.
When this issue is picked up, an initial refresher is needed to see if those two operations are still good as they are and still needed. Then the implementation can go through the Parsec stack.
These will allow clients to choose from a pool of allowed key parameters when generating/importing keys and a pool of algorithms when doing operations with the keys.
The text was updated successfully, but these errors were encountered: