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

Cherry-Pick -- Always Finalize the PKCS11 FindObject Operation #1978

Merged
merged 1 commit into from
Oct 7, 2020
Merged

Cherry-Pick -- Always Finalize the PKCS11 FindObject Operation #1978

merged 1 commit into from
Oct 7, 2020

Conversation

lindluni
Copy link
Contributor

@lindluni lindluni commented Oct 7, 2020

There are 6 pkcs11 operations that require the session
handle to be finalized before a session can be reused.
These operations are: Encrypt, Decrypt, Sign, Verify,
Find, and Digest. The bccsp/pkcs11 package makes use
of three of these operations: sign, verify, and find.
Each of these operations has an init function, i.e.,
SignInit, VerifyInit and FindObjectInit, each are part
of the cryptoki implementation. If the Init functions
fail, the session handle is never initialized and
the finalize function do not need to be called.

For SignInit and VerifyInit, the next operation
we call are the Sign or Verify functions, which also
atomically finalized the session. For the FindObjectInit
operation however, we must explicitly call the FindObjectFinal
function to release the lock on the session handle.

The current implementation makes a call to FindObject in between
FindObjectInit and FindObjectFinal which has an error path.
In the current implementation FindObjectFinal is not called
on the error path, leaving the session in a state that it can't
be used again.

This change ensures FindObjectFinal is always called, even
on the error path.

Signed-off-by: Brett Logan [email protected]

There are 6 pkcs11 operations that require the session
handle to be finalized before a session can be reused.
These operations are: Encrypt, Decrypt, Sign, Verify,
Find, and Digest. The bccsp/pkcs11 package makes use
of three of these operations: sign, verify, and find.
Each of these operations has an init function, i.e.,
SignInit, VerifyInit and FindObjectInit, each are part
of the cryptoki implementation. If the Init functions
fail, the session handle is never initialized and
the finalize function do not need to be called.

For SignInit and VerifyInit, the next operation
we call are the Sign or Verify functions, which also
atomically finalized the session. For the FindObjectInit
operation however, we must explicitly call the FindObjectFinal
function to release the lock on the session handle.

The current implementation makes a call to FindObject in between
FindObjectInit and FindObjectFinal which has an error path.
In the current implementation FindObjectFinal is not called
on the error path, leaving the session in a state that it can't
be used again.

This change ensures FindObjectFinal is always called, even
on the error path.

Signed-off-by: Brett Logan <[email protected]>
@lindluni lindluni requested a review from a team as a code owner October 7, 2020 12:44
@lindluni lindluni changed the title Always Finalize the PKCS11 FindObject Operation Cherry-Pick -- Always Finalize the PKCS11 FindObject Operation Oct 7, 2020
@caod123 caod123 merged commit db1abf6 into hyperledger:release-1.4 Oct 7, 2020
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

Successfully merging this pull request may close these issues.

2 participants