@@ -113,8 +113,6 @@ bool s2n_hash_is_available(s2n_hash_algorithm alg)
113
113
switch (alg ) {
114
114
case S2N_HASH_MD5 :
115
115
case S2N_HASH_MD5_SHA1 :
116
- /* return false if in FIPS mode, as MD5 algs are not available in FIPS mode. */
117
- return !s2n_is_in_fips_mode ();
118
116
case S2N_HASH_NONE :
119
117
case S2N_HASH_SHA1 :
120
118
case S2N_HASH_SHA224 :
@@ -301,20 +299,6 @@ static int s2n_evp_hash_new(struct s2n_hash_state *state)
301
299
return S2N_SUCCESS ;
302
300
}
303
301
304
- static int s2n_evp_hash_allow_md5_for_fips (struct s2n_hash_state * state )
305
- {
306
- /* This is only to be used for s2n_hash_states that will require MD5 to be used
307
- * to comply with the TLS 1.0 and 1.1 RFC's for the PRF. MD5 cannot be used
308
- * outside of the TLS 1.0 and 1.1 PRF when in FIPS mode. When needed, this must
309
- * be called prior to s2n_hash_init().
310
- */
311
- POSIX_GUARD (s2n_digest_allow_md5_for_fips (& state -> digest .high_level .evp ));
312
- if (s2n_use_custom_md5_sha1 ()) {
313
- POSIX_GUARD (s2n_digest_allow_md5_for_fips (& state -> digest .high_level .evp_md5_secondary ));
314
- }
315
- return S2N_SUCCESS ;
316
- }
317
-
318
302
static int s2n_evp_hash_init (struct s2n_hash_state * state , s2n_hash_algorithm alg )
319
303
{
320
304
POSIX_ENSURE_REF (state -> digest .high_level .evp .ctx );
@@ -419,32 +403,16 @@ static int s2n_evp_hash_copy(struct s2n_hash_state *to, struct s2n_hash_state *f
419
403
POSIX_GUARD_OSSL (EVP_MD_CTX_copy_ex (to -> digest .high_level .evp_md5_secondary .ctx , from -> digest .high_level .evp_md5_secondary .ctx ), S2N_ERR_HASH_COPY_FAILED );
420
404
}
421
405
422
- bool is_md5_allowed_for_fips = false;
423
- POSIX_GUARD_RESULT (s2n_digest_is_md5_allowed_for_fips (& from -> digest .high_level .evp , & is_md5_allowed_for_fips ));
424
- if (is_md5_allowed_for_fips && (from -> alg == S2N_HASH_MD5 || from -> alg == S2N_HASH_MD5_SHA1 )) {
425
- POSIX_GUARD (s2n_hash_allow_md5_for_fips (to ));
426
- }
427
406
return S2N_SUCCESS ;
428
407
}
429
408
430
409
static int s2n_evp_hash_reset (struct s2n_hash_state * state )
431
410
{
432
- int reset_md5_for_fips = 0 ;
433
- bool is_md5_allowed_for_fips = false;
434
- POSIX_GUARD_RESULT (s2n_digest_is_md5_allowed_for_fips (& state -> digest .high_level .evp , & is_md5_allowed_for_fips ));
435
- if ((state -> alg == S2N_HASH_MD5 || state -> alg == S2N_HASH_MD5_SHA1 ) && is_md5_allowed_for_fips ) {
436
- reset_md5_for_fips = 1 ;
437
- }
438
-
439
411
POSIX_GUARD_OSSL (S2N_EVP_MD_CTX_RESET (state -> digest .high_level .evp .ctx ), S2N_ERR_HASH_WIPE_FAILED );
440
412
if (state -> alg == S2N_HASH_MD5_SHA1 && s2n_use_custom_md5_sha1 ()) {
441
413
POSIX_GUARD_OSSL (S2N_EVP_MD_CTX_RESET (state -> digest .high_level .evp_md5_secondary .ctx ), S2N_ERR_HASH_WIPE_FAILED );
442
414
}
443
415
444
- if (reset_md5_for_fips ) {
445
- POSIX_GUARD (s2n_hash_allow_md5_for_fips (state ));
446
- }
447
-
448
416
/* hash_init resets the ready_for_input and currently_in_hash fields. */
449
417
return s2n_evp_hash_init (state , state -> alg );
450
418
}
@@ -465,7 +433,6 @@ static int s2n_evp_hash_free(struct s2n_hash_state *state)
465
433
466
434
static const struct s2n_hash s2n_low_level_hash = {
467
435
.alloc = & s2n_low_level_hash_new ,
468
- .allow_md5_for_fips = NULL ,
469
436
.init = & s2n_low_level_hash_init ,
470
437
.update = & s2n_low_level_hash_update ,
471
438
.digest = & s2n_low_level_hash_digest ,
@@ -476,7 +443,6 @@ static const struct s2n_hash s2n_low_level_hash = {
476
443
477
444
static const struct s2n_hash s2n_evp_hash = {
478
445
.alloc = & s2n_evp_hash_new ,
479
- .allow_md5_for_fips = & s2n_evp_hash_allow_md5_for_fips ,
480
446
.init = & s2n_evp_hash_init ,
481
447
.update = & s2n_evp_hash_update ,
482
448
.digest = & s2n_evp_hash_digest ,
@@ -514,19 +480,6 @@ S2N_RESULT s2n_hash_state_validate(struct s2n_hash_state *state)
514
480
return S2N_RESULT_OK ;
515
481
}
516
482
517
- int s2n_hash_allow_md5_for_fips (struct s2n_hash_state * state )
518
- {
519
- POSIX_ENSURE_REF (state );
520
- /* Ensure that hash_impl is set, as it may have been reset for s2n_hash_state on s2n_connection_wipe.
521
- * When in FIPS mode, the EVP API's must be used for hashes.
522
- */
523
- POSIX_GUARD (s2n_hash_set_impl (state ));
524
-
525
- POSIX_ENSURE_REF (state -> hash_impl -> allow_md5_for_fips );
526
-
527
- return state -> hash_impl -> allow_md5_for_fips (state );
528
- }
529
-
530
483
int s2n_hash_init (struct s2n_hash_state * state , s2n_hash_algorithm alg )
531
484
{
532
485
POSIX_ENSURE_REF (state );
@@ -535,15 +488,8 @@ int s2n_hash_init(struct s2n_hash_state *state, s2n_hash_algorithm alg)
535
488
*/
536
489
POSIX_GUARD (s2n_hash_set_impl (state ));
537
490
538
- bool is_md5_allowed_for_fips = false;
539
- POSIX_GUARD_RESULT (s2n_digest_is_md5_allowed_for_fips (& state -> digest .high_level .evp , & is_md5_allowed_for_fips ));
540
-
541
- if (s2n_hash_is_available (alg ) || ((alg == S2N_HASH_MD5 || alg == S2N_HASH_MD5_SHA1 ) && is_md5_allowed_for_fips )) {
542
- /* s2n will continue to initialize an "unavailable" hash when s2n is in FIPS mode and
543
- * FIPS is forcing the hash to be made available.
544
- */
491
+ if (s2n_hash_is_available (alg )) {
545
492
POSIX_ENSURE_REF (state -> hash_impl -> init );
546
-
547
493
return state -> hash_impl -> init (state , alg );
548
494
} else {
549
495
POSIX_BAIL (S2N_ERR_HASH_INVALID_ALGORITHM );
0 commit comments