Skip to content

Commit

Permalink
Update sig_stfl.h document for #1650 (#1655)
Browse files Browse the repository at this point in the history
* update the stateful siganture header documentation

* catch the case when mutex is not set

* stress that only the Signing operation need to be locked/unlocked.

* make lock and unlock function to internal APIs.
  • Loading branch information
ducnguyen-sb authored and SWilson4 committed Apr 12, 2024
1 parent 2aa48d5 commit 36392cc
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 104 deletions.
15 changes: 13 additions & 2 deletions src/sig_stfl/sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,24 +1370,35 @@ OQS_API void OQS_SIG_STFL_SECRET_KEY_SET_mutex(OQS_SIG_STFL_SECRET_KEY *sk, void
}

/* OQS_SIG_STFL_SECRET_KEY_lock */
OQS_API OQS_STATUS OQS_SIG_STFL_SECRET_KEY_lock(OQS_SIG_STFL_SECRET_KEY *sk) {
OQS_STATUS OQS_SIG_STFL_SECRET_KEY_lock(OQS_SIG_STFL_SECRET_KEY *sk) {
if (sk == NULL) {
return OQS_ERROR;
}
if (sk->lock_key == NULL) {
return OQS_SUCCESS;
}

// Try to lock the private key but the mutex is unset.
if (sk->mutex == NULL) {
return OQS_ERROR;
}

return (sk->lock_key(sk->mutex));
}

/* OQS_SIG_STFL_SECRET_KEY_unlock */
OQS_API OQS_STATUS OQS_SIG_STFL_SECRET_KEY_unlock(OQS_SIG_STFL_SECRET_KEY *sk) {
OQS_STATUS OQS_SIG_STFL_SECRET_KEY_unlock(OQS_SIG_STFL_SECRET_KEY *sk) {
if (sk == NULL) {
return OQS_ERROR;
}
if (sk->unlock_key == NULL) {
return OQS_SUCCESS;
}

// Try to unlock the private key but the mutex is unset.
if (sk->mutex == NULL) {
return OQS_ERROR;
}

return (sk->unlock_key(sk->mutex));
}
Loading

0 comments on commit 36392cc

Please sign in to comment.