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 cothan committed Apr 2, 2024
1 parent efdc461 commit bc579be
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 bc579be

Please sign in to comment.