@@ -752,6 +752,7 @@ static int slhdsakey_hash_f_sha2(SlhDsaKey* key, const byte* pk_seed,
752752 return ret ;
753753}
754754
755+ #ifndef WOLFSSL_SLHDSA_VERIFY_ONLY
755756/* SHA2 H function.
756757 *
757758 * FIPS 205. Section 11.2.
@@ -820,6 +821,7 @@ static int slhdsakey_hash_h_sha2(SlhDsaKey* key, const byte* pk_seed,
820821
821822 return ret ;
822823}
824+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
823825
824826/* SHA2 H function with two separate n-byte halves.
825827 *
@@ -895,6 +897,7 @@ static int slhdsakey_hash_h_2_sha2(SlhDsaKey* key, const byte* pk_seed,
895897 return ret ;
896898}
897899
900+ #ifndef WOLFSSL_SLHDSA_VERIFY_ONLY
898901/* SHA2 PRF function.
899902 *
900903 * FIPS 205. Section 11.2.
@@ -938,6 +941,7 @@ static int slhdsakey_hash_prf_sha2(SlhDsaKey* key, const byte* pk_seed,
938941
939942 return ret ;
940943}
944+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
941945
942946/* SHA2 T_l streaming: start with address.
943947 *
@@ -1106,6 +1110,7 @@ static int slhdsakey_mgf1_sha2(SlhDsaKey* key, const byte* seed,
11061110 return ret ;
11071111}
11081112
1113+ #ifndef WOLFSSL_SLHDSA_VERIFY_ONLY
11091114/* SHA2 PRF_msg function.
11101115 *
11111116 * FIPS 205. Section 11.2.
@@ -1167,6 +1172,7 @@ static int slhdsakey_prf_msg_sha2(SlhDsaKey* key, const byte* sk_prf,
11671172
11681173 return ret ;
11691174}
1175+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
11701176
11711177/* SHA2 H_msg function.
11721178 *
@@ -1301,6 +1307,7 @@ static int slhdsakey_hash_f_shake(SlhDsaKey* key, const byte* pk_seed,
13011307#endif
13021308}
13031309
1310+ #ifndef WOLFSSL_SLHDSA_VERIFY_ONLY
13041311static int slhdsakey_hash_h_shake (SlhDsaKey * key , const byte * pk_seed ,
13051312 const word32 * adrs , const byte * node , byte n , byte * hash )
13061313{
@@ -1312,6 +1319,7 @@ static int slhdsakey_hash_h_shake(SlhDsaKey* key, const byte* pk_seed,
13121319 2 * n , NULL , 0 , hash , n );
13131320#endif
13141321}
1322+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
13151323
13161324static int slhdsakey_hash_h_2_shake (SlhDsaKey * key , const byte * pk_seed ,
13171325 const word32 * adrs , const byte * m1 , const byte * m2 , byte n , byte * hash )
@@ -1320,6 +1328,7 @@ static int slhdsakey_hash_h_2_shake(SlhDsaKey* key, const byte* pk_seed,
13201328 n , m2 , n , hash , n );
13211329}
13221330
1331+ #ifndef WOLFSSL_SLHDSA_VERIFY_ONLY
13231332static int slhdsakey_hash_prf_shake (SlhDsaKey * key , const byte * pk_seed ,
13241333 const byte * sk_seed , const word32 * adrs , byte n , byte * hash )
13251334{
@@ -1331,6 +1340,7 @@ static int slhdsakey_hash_prf_shake(SlhDsaKey* key, const byte* pk_seed,
13311340 sk_seed , n , NULL , 0 , hash , n );
13321341#endif
13331342}
1343+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
13341344
13351345#define HASH_PRF (k , pk_seed , sk_seed , adrs , n , o ) \
13361346 (SLHDSA_IS_SHA2((k)->params->param) ? \
@@ -1928,7 +1938,7 @@ static int slhdsakey_shake256_set_seed_ha_hash_x4(word64* state,
19281938
19291939 return ret ;
19301940}
1931- #endif
1941+ #endif /* WOLFSSL_SLHDSA_VERIFY_ONLY */
19321942
19331943/* Get the four SHAKE-256 n-byte hash results.
19341944 *
@@ -1963,7 +1973,7 @@ do { \
19631973 ((word8*)((state) + (o) - 2))[3] = (a) + 2; \
19641974 ((word8*)((state) + (o) - 1))[3] = (a) + 3; \
19651975} while (0)
1966- #endif
1976+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
19671977
19681978/* Set the chain address indices into the SHAKE-256 x4 state.
19691979 *
@@ -2007,7 +2017,7 @@ do { \
20072017 c32toa((ti) + 2, (byte*)&((word32*)((state) + (o) - 2))[1]); \
20082018 c32toa((ti) + 3, (byte*)&((word32*)((state) + (o) - 1))[1]); \
20092019} while (0)
2010- #endif
2020+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
20112021
20122022/* Set the tree indices into the SHAKE-256 x4 state.
20132023 *
@@ -2349,7 +2359,7 @@ static int slhdsakey_chain_x4_16(byte* sk, const byte* pk_seed, byte* addr,
23492359 WC_FREE_VAR_EX (fixed , heap , DYNAMIC_TYPE_SLHDSA );
23502360 return ret ;
23512361}
2352- #endif
2362+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
23532363
23542364#if !defined(WOLFSSL_SLHDSA_PARAM_NO_192 )
23552365/* Iterate the hash function 15 times with 4 hashes when n=24.
@@ -3886,10 +3896,6 @@ static int slhdsakey_wots_pk_from_sig_x4(SlhDsaKey* key, const byte* sig,
38863896 const byte * msg , const byte * pk_seed , word32 * adrs , byte * pk_sig )
38873897{
38883898 int ret = 0 ;
3889- byte idx [4 ] = {0 };
3890- int i ;
3891- byte ii ;
3892- sword8 j ;
38933899 HashAddress wotspk_adrs ;
38943900 byte n = key -> params -> n ;
38953901 byte len = key -> params -> len ;
@@ -3899,7 +3905,10 @@ static int slhdsakey_wots_pk_from_sig_x4(SlhDsaKey* key, const byte* sig,
38993905 DYNAMIC_TYPE_SLHDSA , ret = MEMORY_E );
39003906#if !defined(WOLFSSL_SLHDSA_PARAM_NO_128 )
39013907 if ((ret == 0 ) && (n == WC_SLHDSA_N_128 )) {
3902- ii = 0 ;
3908+ int i ;
3909+ sword8 j ;
3910+ byte ii = 0 ;
3911+ byte idx [4 ] = {0 };
39033912 for (j = 0 ; j <= SLHDSA_WM1 ; j ++ ) {
39043913 for (i = 0 ; i < len ; i ++ ) {
39053914 if ((sword8 )msg [i ] == j ) {
@@ -3926,7 +3935,10 @@ static int slhdsakey_wots_pk_from_sig_x4(SlhDsaKey* key, const byte* sig,
39263935#endif
39273936#if !defined(WOLFSSL_SLHDSA_PARAM_NO_192 )
39283937 if ((ret == 0 ) && (n == 24 )) {
3929- ii = 0 ;
3938+ int i ;
3939+ sword8 j ;
3940+ byte ii = 0 ;
3941+ byte idx [4 ] = {0 };
39303942 for (j = 0 ; j <= SLHDSA_WM1 ; j ++ ) {
39313943 for (i = 0 ; i < len ; i ++ ) {
39323944 if ((sword8 )msg [i ] == j ) {
@@ -3953,7 +3965,10 @@ static int slhdsakey_wots_pk_from_sig_x4(SlhDsaKey* key, const byte* sig,
39533965#endif
39543966#if !defined(WOLFSSL_SLHDSA_PARAM_NO_256 )
39553967 if ((ret == 0 ) && (n == 32 )) {
3956- ii = 0 ;
3968+ int i ;
3969+ sword8 j ;
3970+ byte ii = 0 ;
3971+ byte idx [4 ] = {0 };
39573972 for (j = 0 ; j <= SLHDSA_WM1 ; j ++ ) {
39583973 for (i = 0 ; i < len ; i ++ ) {
39593974 if ((sword8 )msg [i ] == j ) {
@@ -3978,9 +3993,14 @@ static int slhdsakey_wots_pk_from_sig_x4(SlhDsaKey* key, const byte* sig,
39783993 }
39793994 else
39803995#endif
3981- if (ret == 0 ) {
3982- ret = NOT_COMPILED_IN ;
3996+ {
3997+ (void )msg ;
3998+ (void )key ;
3999+ if (ret == 0 ) {
4000+ ret = NOT_COMPILED_IN ;
4001+ }
39834002 }
4003+
39844004 if (ret == 0 ) {
39854005 HA_Copy (wotspk_adrs , adrs );
39864006 HA_SetTypeAndClearNotKPA (wotspk_adrs , HA_WOTS_PK );
@@ -4457,7 +4477,7 @@ static int slhdsakey_xmss_sign(SlhDsaKey* key, const byte* m,
44574477
44584478 return ret ;
44594479}
4460- #endif
4480+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
44614481
44624482/* Compute XMSS public key from XMSS signature.
44634483 *
@@ -4651,7 +4671,7 @@ static int slhdsakey_ht_sign(SlhDsaKey* key, const byte* pk_fors,
46514671
46524672 return ret ;
46534673}
4654- #endif
4674+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
46554675
46564676/* Verify hypertree signature.
46574677 *
@@ -5680,7 +5700,7 @@ static int slhdsakey_fors_sign(SlhDsaKey* key, const byte* md,
56805700
56815701 return ret ;
56825702}
5683- #endif
5703+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
56845704
56855705#if defined(USE_INTEL_SPEEDUP ) && !defined(WOLFSSL_WC_SLHDSA_SMALL )
56865706/* F hash 4 simultaneously.
@@ -7112,7 +7132,7 @@ int wc_SlhDsaKey_SignMsgWithRandom(SlhDsaKey* key, const byte* mprime,
71127132 addRnd );
71137133}
71147134
7115- #endif
7135+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
71167136
71177137/* Verify SLH-DSA signature.
71187138 *
@@ -7857,7 +7877,7 @@ int wc_SlhDsaKey_SignHash(SlhDsaKey* key, const byte* ctx, byte ctxSz,
78577877
78587878 return ret ;
78597879}
7860- #endif
7880+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
78617881
78627882/* Verify SLH-DSA signature.
78637883 *
@@ -8044,7 +8064,7 @@ int wc_SlhDsaKey_ImportPrivate(SlhDsaKey* key, const byte* priv, word32 privLen)
80448064
80458065 return ret ;
80468066}
8047- #endif
8067+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
80488068
80498069/* Import public key from data.
80508070 *
@@ -8157,7 +8177,7 @@ int wc_SlhDsaKey_ExportPrivate(SlhDsaKey* key, byte* priv, word32* privLen)
81578177
81588178 return ret ;
81598179}
8160- #endif
8180+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
81618181
81628182/* Export the public key.
81638183 *
@@ -8215,7 +8235,7 @@ int wc_SlhDsaKey_PrivateSize(SlhDsaKey* key)
82158235
82168236 return ret ;
82178237}
8218- #endif
8238+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
82198239
82208240/* Return the size of the public key for the parameters.
82218241 *
@@ -8318,7 +8338,7 @@ int wc_SlhDsaKey_PrivateSizeFromParam(enum SlhDsaParam param)
83188338
83198339 return ret ;
83208340}
8321- #endif
8341+ #endif /* !WOLFSSL_SLHDSA_VERIFY_ONLY */
83228342
83238343/* Return the size of the public key for the parameters.
83248344 *
0 commit comments