Add interruptible Crypto API operations - #375
Conversation
gilles-peskine-arm
left a comment
There was a problem hiding this comment.
I've reviewed the document with the partial implementation in TF-PSA-Crypto in mind. We know that we'll need to update our implementation since it followed a now outdated beta.
Many of my comments apply to multiple operation types. I only noted the first place where I noticed something.
My biggest concern is the verify flow. For verify-message, I don't think providing the signature before the message works out in practice.
Quick response on this:
A algorithm-agnostic flow requires the signature before the message parts. |
|
Following discussion - we need to support use cases where the signature is only provided after the message content (required for some streaming protocols), as well as use cases where the signature is provided before the message (which is required for some algorithms). For Using the current For the new flow, three additional APIs are provided:
This design, providing a distinct setup function, enables the implementation to detect the application intent explicitly and immediately, and respond with an error if not supported. With a more generic, single setup function without a signature; the application intent can only be inferred when |
|
I think I've managed to address all of the substanive issues raised in the feedback so far. I would appreciate a re-review of the resulting updated PR. |
gilles-peskine-arm
left a comment
There was a problem hiding this comment.
Thanks for the updates. I only have a couple of minor nits now, except maybe for one point. I want to think further about verification with and without deferred signature.
|
I had another thought about the verification and deferred signatures. For both the multi-part and interruptible verification operations, the operation object wil have to copy some or all of the signature data if it is passed during setup. For PQC signatures, this can be a very sizeable buffer and will be challenging for constrained implementations with no dynamic allocation. However, although it might work (from a memory management point of view) to have the application deal with the signature memory issue, and pass the signature to both the setup and the finishing phases for an algorithm that requires the signature before the message - is there a security/cryptographic risk in having the application pass what is meant to be the same signature data twice to the implementation? |
I think that for interruptible operations, this memory has to exist anyway between For multipart operations, it's a different matter: with most algorithms, the signature only needs to exist during the verify-finish phase, which is a single function call.
It's definitely more error prone. I can't think of a direct security risk however, since the inputs of verification are generally not confidential and the output is a single boolean. If the application makes a mistake and passes a different signature, the worst that can happen is that it will get a passing verification without a correct signature. But the application is only harming itself. The surface against glitch attacks is likely much higher, though. |
|
Another inconsistency has come to light after implementing #381. The behaviour of the interruptible operation functions when the operation is not in a valid state for the chosen algorithm is to report a These are scenarios where the function being called is incorrect for the operation state (including algorithm-specific state) irrespective of the arguments passed to the function. In other multi-part operations, similar scenarios result in a
I suspect the behaviour (using There are some scenarios in the new interruptible operations (and possibly in the multi-part sign/verify operations?) which might be better served by using |
|
Another unusual aspect to the sign and verify iop API is that the permission check for the keys is deferred until the application calls the This is not ideal, both from an application error discovery point of view, or from an implementation point of view (which often combines key lookup with policy verification). I propose to check for the appropriate SIGN_MESSAGE/VERIFY_MESSAGE usage when the operation is set up - noting that SIGN_HASH usage always implies SIGN_MESSAGE permission as well. Then there is a second permission check if the applicaiton uses the Although this still defers part of the permission check in some uses, it provides a better compromise without introducing separate setup APIs for hash and message interruptible signature operations. |
|
I have added a few more commits to regularise the following:
|
gilles-peskine-arm
left a comment
There was a problem hiding this comment.
Mostly LGTM, but there are still a few kinks in the verify flow.
gilles-peskine-arm
left a comment
There was a problem hiding this comment.
LGTM for the overall design.
I've done a detailed review of most of the content, but I haven't verified that the last commit 84ad096 is complete.
Signed-off-by: Andrew Thoelke <andrew.thoelke@arm.com>
Signed-off-by: Andrew Thoelke <andrew.thoelke@arm.com>
Signed-off-by: Andrew Thoelke <andrew.thoelke@arm.com>
Signed-off-by: Andrew Thoelke <andrew.thoelke@arm.com>
f1fa64f to
8cdff16
Compare
|
Rebased to resolve conflict in history.rst with upstream main branch. |
This is a rebased version of #107 and #199, targetting version 1.6 of the specification.
Apart from adding the previously drafted APIs, this incorporates other changes to the documentation since the original PRs. The introductory text for interruptible signatures has also been updated to reflect the presence of both multi-part signatures and interruptibel signature APIs.