From 080e1d53cef27d3ca3f41b3c209c67e7a2e6e236 Mon Sep 17 00:00:00 2001 From: M-AlNoaimi <26318936+M-AlNoaimi@users.noreply.github.com> Date: Sat, 24 May 2025 22:08:37 +0100 Subject: [PATCH] Add support for context string signing in signature algorithms Signed-off-by: M-AlNoaimi <26318936+M-AlNoaimi@users.noreply.github.com> --- src/sig/sig.c | 10 ++++++++++ src/sig/sig.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/sig/sig.c b/src/sig/sig.c index 35a84049b8..029931d7bd 100644 --- a/src/sig/sig.c +++ b/src/sig/sig.c @@ -1110,6 +1110,16 @@ OQS_API OQS_STATUS OQS_SIG_verify_with_ctx_str(const OQS_SIG *sig, const uint8_t } } +OQS_API bool OQS_SIG_supports_ctx_str(const char *alg_name) { + OQS_SIG *sig = OQS_SIG_new(alg_name); + if (sig == NULL) { + return false; + } + bool result = sig->sig_with_ctx_support; + OQS_SIG_free(sig); + return result; +} + OQS_API void OQS_SIG_free(OQS_SIG *sig) { OQS_MEM_insecure_free(sig); } diff --git a/src/sig/sig.h b/src/sig/sig.h index 1e76af0f8e..d77787fa9d 100644 --- a/src/sig/sig.h +++ b/src/sig/sig.h @@ -412,6 +412,14 @@ OQS_API OQS_STATUS OQS_SIG_verify_with_ctx_str(const OQS_SIG *sig, const uint8_t */ OQS_API void OQS_SIG_free(OQS_SIG *sig); +/** + * Indicates whether the specified signature algorithm supports signing with a context string. + * + * @param[in] alg_name Name of the desired algorithm; one of the names in `OQS_SIG_algs`. + * @return true if the algorithm supports context string signing, false otherwise. + */ +OQS_API bool OQS_SIG_supports_ctx_str(const char *alg_name); + ///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_INCLUDE_START #ifdef OQS_ENABLE_SIG_DILITHIUM #include