@@ -162,7 +162,51 @@ int wp_provctx_lock_rng(WOLFPROV_CTX* provCtx);
162162void wp_provctx_unlock_rng (WOLFPROV_CTX * provCtx );
163163
164164#ifdef HAVE_FIPS
165- wolfSSL_Mutex * wp_get_cast_mutex (void );
165+ /* CAST self-test algorithm categories */
166+ #define WP_CAST_ALGO_AES 0
167+ #define WP_CAST_ALGO_HMAC 1
168+ #define WP_CAST_ALGO_DRBG 2
169+ #define WP_CAST_ALGO_RSA 3
170+ #define WP_CAST_ALGO_ECDSA 4
171+ #define WP_CAST_ALGO_ECDH 5
172+ #define WP_CAST_ALGO_DH 6
173+ #define WP_CAST_ALGO_COUNT 7
174+
175+ wolfSSL_Mutex * wp_get_cast_mutex (int algo );
176+ int wp_get_cast_init (int algo );
177+ void wp_set_cast_init (int algo , int init );
178+ int wp_init_cast (int algo );
179+
180+ /**
181+ * Check FIPS CAST for algorithm. Returns 0 on failure.
182+ * Use at function entry points that return int (1=success, 0=failure).
183+ */
184+ #define WP_CHECK_FIPS_ALGO (algo ) \
185+ do { \
186+ if (wp_init_cast(algo) != 1) { \
187+ WOLFPROV_ERROR_MSG(WP_LOG_COMP_PROVIDER, \
188+ "FIPS CAST initialization failed"); \
189+ return 0; \
190+ } \
191+ } while (0)
192+
193+ /**
194+ * Check FIPS CAST for algorithm. Returns NULL on failure.
195+ * Use at function entry points that return pointers (NULL=failure).
196+ */
197+ #define WP_CHECK_FIPS_ALGO_PTR (algo ) \
198+ do { \
199+ if (wp_init_cast(algo) != 1) { \
200+ WOLFPROV_ERROR_MSG(WP_LOG_COMP_PROVIDER, \
201+ "FIPS CAST initialization failed"); \
202+ return NULL; \
203+ } \
204+ } while (0)
205+
206+ #else
207+ /* Non-FIPS: no-op */
208+ #define WP_CHECK_FIPS_ALGO (algo ) do { } while (0)
209+ #define WP_CHECK_FIPS_ALGO_PTR (algo ) do { } while (0)
166210#endif
167211#endif
168212
0 commit comments