]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Make public ml_dsa_mu_.. helpers
authorSimo Sorce <simo@redhat.com>
Fri, 11 Apr 2025 17:38:20 +0000 (13:38 -0400)
committerTomas Mraz <tomas@openssl.org>
Wed, 23 Apr 2025 11:35:03 +0000 (13:35 +0200)
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27342)

crypto/ml_dsa/ml_dsa_sign.c
include/crypto/ml_dsa.h

index bbeb95e2a351b7b7fa9e8277664fee6be06805d3..cb375f698c33838e80f44ec8ebf645f0608a10a8 100644 (file)
@@ -66,8 +66,8 @@ static void signature_init(ML_DSA_SIG *sig,
  * @returns an EVP_MD_CTX if the operation is successful, NULL otherwise.
  */
 
-static EVP_MD_CTX *ml_dsa_mu_init(const ML_DSA_KEY *key, int encode,
-                                  const uint8_t *ctx, size_t ctx_len)
+EVP_MD_CTX *ossl_ml_dsa_mu_init(const ML_DSA_KEY *key, int encode,
+                                const uint8_t *ctx, size_t ctx_len)
 {
     EVP_MD_CTX *md_ctx;
     uint8_t itb[2];
@@ -116,8 +116,7 @@ err:
  * @param msg_len: The length of the msg buffer to process
  * @returns 1 on success, 0 on error
  */
-static int ml_dsa_mu_update(EVP_MD_CTX *md_ctx,
-                            const uint8_t *msg, size_t msg_len)
+int ossl_ml_dsa_mu_update(EVP_MD_CTX *md_ctx, const uint8_t *msg, size_t msg_len)
 {
     return EVP_DigestUpdate(md_ctx, msg, msg_len);
 }
@@ -130,7 +129,7 @@ static int ml_dsa_mu_update(EVP_MD_CTX *md_ctx,
  * @param mu_len: The size of the output buffer
  * @returns 1 on success, 0 on error
  */
-static int ml_dsa_mu_finalize(EVP_MD_CTX *md_ctx, uint8_t *mu, size_t mu_len)
+int ossl_ml_dsa_mu_finalize(EVP_MD_CTX *md_ctx, uint8_t *mu, size_t mu_len)
 {
     if (!ossl_assert(mu_len == ML_DSA_MU_BYTES)) {
         ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH);
@@ -445,14 +444,14 @@ int ossl_ml_dsa_sign(const ML_DSA_KEY *priv, int msg_is_mu,
         mu_ptr = msg;
         mu_len = msg_len;
     } else {
-        md_ctx = ml_dsa_mu_init(priv, encode, context, context_len);
+        md_ctx = ossl_ml_dsa_mu_init(priv, encode, context, context_len);
         if (md_ctx == NULL)
             return 0;
 
-        if (!ml_dsa_mu_update(md_ctx, msg, msg_len))
+        if (!ossl_ml_dsa_mu_update(md_ctx, msg, msg_len))
             goto err;
 
-        if (!ml_dsa_mu_finalize(md_ctx, mu, mu_len))
+        if (!ossl_ml_dsa_mu_finalize(md_ctx, mu, mu_len))
             goto err;
     }
 
@@ -485,14 +484,14 @@ int ossl_ml_dsa_verify(const ML_DSA_KEY *pub, int msg_is_mu,
         mu_ptr = msg;
         mu_len = msg_len;
     } else {
-        md_ctx = ml_dsa_mu_init(pub, encode, context, context_len);
+        md_ctx = ossl_ml_dsa_mu_init(pub, encode, context, context_len);
         if (md_ctx == NULL)
             return 0;
 
-        if (!ml_dsa_mu_update(md_ctx, msg, msg_len))
+        if (!ossl_ml_dsa_mu_update(md_ctx, msg, msg_len))
             goto err;
 
-        if (!ml_dsa_mu_finalize(md_ctx, mu, mu_len))
+        if (!ossl_ml_dsa_mu_finalize(md_ctx, mu, mu_len))
             goto err;
     }
 
index 0df86dfb8c8c125bddd770b7d7189591a8446b85..e8054c6102766f2790e86145919ffa2e3e8fd7d0 100644 (file)
@@ -106,6 +106,11 @@ __owur int ossl_ml_dsa_key_public_from_private(ML_DSA_KEY *key);
 __owur int ossl_ml_dsa_pk_decode(ML_DSA_KEY *key, const uint8_t *in, size_t in_len);
 __owur int ossl_ml_dsa_sk_decode(ML_DSA_KEY *key, const uint8_t *in, size_t in_len);
 
+EVP_MD_CTX *ossl_ml_dsa_mu_init(const ML_DSA_KEY *key, int encode,
+                                const uint8_t *ctx, size_t ctx_len);
+__owur int ossl_ml_dsa_mu_update(EVP_MD_CTX *md_ctx, const uint8_t *msg, size_t msg_len);
+__owur int ossl_ml_dsa_mu_finalize(EVP_MD_CTX *md_ctx, uint8_t *mu, size_t mu_len);
+
 __owur int ossl_ml_dsa_sign(const ML_DSA_KEY *priv, int msg_is_mu,
                             const uint8_t *msg, size_t msg_len,
                             const uint8_t *context, size_t context_len,