]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ml-dsa: add more to internal header
authorPauli <ppzgs1@gmail.com>
Wed, 22 Jan 2025 02:08:33 +0000 (13:08 +1100)
committerTomas Mraz <tomas@openssl.org>
Fri, 14 Feb 2025 09:46:04 +0000 (10:46 +0100)
The ossl_ml_dsa_key_get0_libctx() and the various size macros are better in the intneral header

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26548)

crypto/ml_dsa/ml_dsa_key.c
crypto/ml_dsa/ml_dsa_params.c
include/crypto/ml_dsa.h
providers/implementations/signature/ml_dsa_sig.c

index 5feb2eb3da416d0f2571c3da0fdb2284dfa60135..e34f22cef75f9c0b6d912831e09b2bb62c33c872 100644 (file)
@@ -500,6 +500,11 @@ size_t ossl_ml_dsa_key_get_sig_len(const ML_DSA_KEY *key)
     return key->params->sig_len;
 }
 
+OSSL_LIB_CTX *ossl_ml_dsa_key_get0_libctx(const ML_DSA_KEY *key)
+{
+    return key != NULL ? key->libctx : NULL;
+}
+
 const char *ossl_ml_dsa_key_get_name(const ML_DSA_KEY *key)
 {
     return key->params->alg;
index fa56fbb7a3000c0fa98f3fed3dab2384679a04e2..3057f491d48b8cdf055e5a4faeb21e4a20028406 100644 (file)
@@ -20,9 +20,6 @@
 #define ML_DSA_44_BETA 78
 #define ML_DSA_44_OMEGA 80
 #define ML_DSA_44_SECURITY_CATEGORY 2
-#define ML_DSA_44_PRIV_LEN 2560
-#define ML_DSA_44_PUB_LEN 1312
-#define ML_DSA_44_SIG_LEN 2420
 
 /* See FIPS 204 Section 4 Table 1 & Table 2 */
 #define ML_DSA_65_TAU 49
@@ -33,9 +30,6 @@
 #define ML_DSA_65_BETA 196
 #define ML_DSA_65_OMEGA 55
 #define ML_DSA_65_SECURITY_CATEGORY 3
-#define ML_DSA_65_PRIV_LEN 4032
-#define ML_DSA_65_PUB_LEN 1952
-#define ML_DSA_65_SIG_LEN 3309
 
 /* See FIPS 204 Section 4 Table 1 & Table 2 */
 #define ML_DSA_87_TAU 60
@@ -46,9 +40,6 @@
 #define ML_DSA_87_BETA 120
 #define ML_DSA_87_OMEGA 75
 #define ML_DSA_87_SECURITY_CATEGORY 5
-#define ML_DSA_87_PRIV_LEN 4896
-#define ML_DSA_87_PUB_LEN 2592
-#define ML_DSA_87_SIG_LEN 4627
 
 static const ML_DSA_PARAMS ml_dsa_params[] = {
     { "ML-DSA-44",
index 7cf446d7d22579e78ba9bcbde9d5684b7e4243ce..709dad9d70b48c439f6a4ab1a8c6adef066faf0a 100644 (file)
 
 # define ML_DSA_MAX_CONTEXT_STRING_LEN 255
 
+# define ML_DSA_ENTROPY_LEN 32
+
+/* See FIPS 204 Section 4 Table 1 & Table 2 */
+# define ML_DSA_44_PRIV_LEN 2560
+# define ML_DSA_44_PUB_LEN 1312
+# define ML_DSA_44_SIG_LEN 2420
+
+/* See FIPS 204 Section 4 Table 1 & Table 2 */
+# define ML_DSA_65_PRIV_LEN 4032
+# define ML_DSA_65_PUB_LEN 1952
+# define ML_DSA_65_SIG_LEN 3309
+
+/* See FIPS 204 Section 4 Table 1 & Table 2 */
+# define ML_DSA_87_PRIV_LEN 4896
+# define ML_DSA_87_PUB_LEN 2592
+# define ML_DSA_87_SIG_LEN 4627
+
+/* Key and signature size maximums taken from values above */
+# define MAX_ML_DSA_PRIV_LEN ML_DSA_87_PRIV_LEN
+# define MAX_ML_DSA_PUB_LEN ML_DSA_87_PUB_LEN
+# define MAX_ML_DSA_SIG_LEN ML_DSA_87_SIG_LEN
+
 __owur ML_DSA_KEY *ossl_ml_dsa_key_new(OSSL_LIB_CTX *libctx, const char *propq,
                                        const char *alg);
 __owur int ossl_ml_dsa_key_pub_alloc(ML_DSA_KEY *key);
@@ -43,6 +65,8 @@ __owur size_t ossl_ml_dsa_key_get_priv_len(const ML_DSA_KEY *key);
 __owur size_t ossl_ml_dsa_key_get_sig_len(const ML_DSA_KEY *key);
 __owur int ossl_ml_dsa_key_matches(const ML_DSA_KEY *key, const char *alg);
 __owur const char *ossl_ml_dsa_key_get_name(const ML_DSA_KEY *key);
+__owur int ossl_ml_dsa_key_to_text(BIO *out, const ML_DSA_KEY *key, int selection);
+OSSL_LIB_CTX *ossl_ml_dsa_key_get0_libctx(const ML_DSA_KEY *key);
 
 __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);
index abbdd984681bc5853724d124236721db7a5a0b8a..1f1e9ea2e765cdcf1a6ae9b7db485b0cce475ea4 100644 (file)
@@ -23,8 +23,6 @@
 #include "internal/packet.h"
 #include "internal/sizes.h"
 
-#define ML_DSA_ENTROPY_LEN 32
-
 #define ML_DSA_MESSAGE_ENCODE_RAW  0
 #define ML_DSA_MESSAGE_ENCODE_PURE 1