3131 } \
3232 } while (0)
3333
34+ #define TEST_MSG_LEN 62 /* Length of the test message string */
35+
3436int main (void )
3537{
3638 const char * test_msg =
3739 "This is a test message for ML-DSA digital signature algorithm!" ;
3840 const char * test_ctx = "test_context_123" ;
39- size_t msglen = strlen (test_msg );
4041 size_t ctxlen = strlen (test_ctx );
4142
4243 uint8_t pk [CRYPTO_PUBLICKEYBYTES ];
4344 uint8_t sk [CRYPTO_SECRETKEYBYTES ];
4445 uint8_t sig [CRYPTO_BYTES ];
45- uint8_t sm [msglen + CRYPTO_BYTES ]; /* signed message buffer */
46- uint8_t m2 [msglen ]; /* recovered message buffer */
46+ uint8_t sm [TEST_MSG_LEN + CRYPTO_BYTES ]; /* signed message buffer */
47+ uint8_t m2 [TEST_MSG_LEN + CRYPTO_BYTES ]; /* recovered message buffer */
4748 size_t siglen ;
4849 size_t smlen ;
4950 size_t mlen ;
@@ -67,21 +68,22 @@ int main(void)
6768 printf ("Signing message... " );
6869
6970 /* Alice signs the message */
70- CHECK (crypto_sign_signature (sig , & siglen , (const uint8_t * )test_msg , msglen ,
71- (const uint8_t * )test_ctx , ctxlen , sk ) == 0 );
71+ CHECK (crypto_sign_signature (sig , & siglen , (const uint8_t * )test_msg ,
72+ TEST_MSG_LEN , (const uint8_t * )test_ctx , ctxlen ,
73+ sk ) == 0 );
7274
7375 printf ("DONE\n" );
7476 printf ("Verifying signature... " );
7577
7678 /* Bob verifies Alice's signature */
77- CHECK (crypto_sign_verify (sig , siglen , (const uint8_t * )test_msg , msglen ,
79+ CHECK (crypto_sign_verify (sig , siglen , (const uint8_t * )test_msg , TEST_MSG_LEN ,
7880 (const uint8_t * )test_ctx , ctxlen , pk ) == 0 );
7981
8082 printf ("DONE\n" );
8183 printf ("Creating signed message... " );
8284
8385 /* Alternative API: Create a signed message (signature + message combined) */
84- CHECK (crypto_sign (sm , & smlen , (const uint8_t * )test_msg , msglen ,
86+ CHECK (crypto_sign (sm , & smlen , (const uint8_t * )test_msg , TEST_MSG_LEN ,
8587 (const uint8_t * )test_ctx , ctxlen , sk ) == 0 );
8688
8789 printf ("DONE\n" );
@@ -95,8 +97,8 @@ int main(void)
9597 printf ("Compare messages... " );
9698
9799 /* Verify the recovered message matches the original */
98- CHECK (mlen == msglen );
99- CHECK (memcmp (test_msg , m2 , msglen ) == 0 );
100+ CHECK (mlen == TEST_MSG_LEN );
101+ CHECK (memcmp (test_msg , m2 , TEST_MSG_LEN ) == 0 );
100102
101103 printf ("DONE\n\n" );
102104
@@ -105,9 +107,9 @@ int main(void)
105107 printf ("Public key size: %d bytes\n" , CRYPTO_PUBLICKEYBYTES );
106108 printf ("Secret key size: %d bytes\n" , CRYPTO_SECRETKEYBYTES );
107109 printf ("Signature size: %d bytes\n" , CRYPTO_BYTES );
108- printf ("Message length: %zu bytes\n" , msglen );
109- printf ("Signature length: %zu bytes\n" , siglen );
110- printf ("Signed msg length: %zu bytes\n" , smlen );
110+ printf ("Message length: %d bytes\n" , TEST_MSG_LEN );
111+ printf ("Signature length: %lu bytes\n" , ( unsigned long ) siglen );
112+ printf ("Signed msg length: %lu bytes\n" , ( unsigned long ) smlen );
111113
112114#if !defined(MLD_CONFIG_KEYGEN_PCT )
113115 /* Check against expected signature to make sure that
0 commit comments