@@ -220,6 +220,24 @@ const OSSL_DISPATCH name##_functions[] = { \
220220 { 0 , NULL } \
221221};
222222
223+ #if defined(HAVE_FIPS ) && !defined(WP_ALLOW_NON_FIPS )
224+ #define IMPLEMENT_DIGEST_NULL (name ) \
225+ /** Dispatch table for digest algorithms. */ \
226+ const OSSL_DISPATCH name##_functions[] = { \
227+ { OSSL_FUNC_DIGEST_NEWCTX, (DFUNC)wp_digest_null }, \
228+ { OSSL_FUNC_DIGEST_INIT, (DFUNC)wp_digest_null }, \
229+ { OSSL_FUNC_DIGEST_UPDATE, (DFUNC)wp_digest_null }, \
230+ { OSSL_FUNC_DIGEST_FINAL, (DFUNC)wp_digest_null }, \
231+ { OSSL_FUNC_DIGEST_FREECTX, (DFUNC)wp_digest_void }, \
232+ { OSSL_FUNC_DIGEST_DUPCTX, (DFUNC)wp_digest_null }, \
233+ { OSSL_FUNC_DIGEST_GET_PARAMS, (DFUNC)wp_digest_null }, \
234+ { OSSL_FUNC_DIGEST_GETTABLE_PARAMS, (DFUNC)wp_digest_null }, \
235+ { 0, NULL } \
236+ };
237+
238+ static int wp_digest_null (void ) { return 0 ; }
239+ static void wp_digest_void (void ) {}
240+ #endif
223241
224242/**
225243 * Get parameters of a digest algorithm.
@@ -292,18 +310,23 @@ static const OSSL_PARAM* wp_digest_gettable_params(void* provCtx)
292310 ******************************************************************************/
293311
294312#ifdef WP_HAVE_MD5
313+ #if defined(HAVE_FIPS ) && !defined(WP_ALLOW_NON_FIPS )
314+ IMPLEMENT_DIGEST_NULL (wp_md5 )
315+ #else
295316IMPLEMENT_DIGEST (wp_md5 , wc_Md5 ,
296317 WC_MD5_BLOCK_SIZE , WC_MD5_DIGEST_SIZE ,
297318 0 ,
298319 wc_InitMd5_ex , wc_Md5Update , wc_Md5Final ,
299320 wc_Md5Copy , wc_Md5Free )
300321#endif
322+ #endif
301323
302324/*******************************************************************************
303325 * SHA1-MD5
304326 ******************************************************************************/
305327
306328#ifdef WP_HAVE_MD5_SHA1
329+ #if !defined(HAVE_FIPS ) || defined(WP_ALLOW_NON_FIPS )
307330/**
308331 * Combined MD5 and SHA-1 digest.
309332 */
@@ -326,7 +349,6 @@ typedef struct wp_Md5Sha {
326349static int wp_InitMd5Sha_ex (wp_Md5Sha * dgst , void * heap , int devId )
327350{
328351 int rc ;
329-
330352 rc = wc_InitMd5_ex (& dgst -> md5 , heap , devId );
331353 if (rc == 0 ) {
332354 rc = wc_InitSha_ex (& dgst -> sha , heap , devId );
@@ -411,12 +433,14 @@ static void wp_Md5ShaFree(wp_Md5Sha* d)
411433 wc_ShaFree (& d -> sha );
412434 }
413435}
414-
415436IMPLEMENT_DIGEST (wp_md5_sha1 , wp_Md5Sha ,
416437 WC_MD5_BLOCK_SIZE , WC_MD5_DIGEST_SIZE + WC_SHA_DIGEST_SIZE ,
417438 0 ,
418439 wp_InitMd5Sha_ex , wp_Md5ShaUpdate , wp_Md5ShaFinal ,
419440 wp_Md5ShaCopy , wp_Md5ShaFree )
441+ #else /* defined(HAVE_FIPS) && !defined(WP_ALLOW_NON_FIPS) */
442+ IMPLEMENT_DIGEST_NULL (wp_md5_sha1 )
443+ #endif
420444#endif
421445
422446/*******************************************************************************
0 commit comments