@@ -312,10 +312,6 @@ otcrypto_status_t otcrypto_aes_gcm_encrypt(otcrypto_blinded_key_t *key,
312312 // Check the tag length.
313313 HARDENED_TRY (aes_gcm_check_tag_length (auth_tag -> len , tag_len ));
314314
315- // Store the iCache state (on or off) and disable it when it is on.
316- hardened_bool_t icache_saved_state ;
317- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
318-
319315 // Construct the AES key.
320316 aes_key_t aes_key ;
321317 HARDENED_TRY (aes_gcm_key_construct (key , & aes_key ));
@@ -328,9 +324,6 @@ otcrypto_status_t otcrypto_aes_gcm_encrypt(otcrypto_blinded_key_t *key,
328324
329325 HARDENED_TRY (clear_key_if_sideloaded (aes_key ));
330326
331- // Enable the iCache if it was previously enabled.
332- ibex_restore_icache (icache_saved_state );
333-
334327 // Verify the input buffers
335328 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (plaintext ));
336329 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (iv ));
@@ -360,10 +353,6 @@ otcrypto_status_t otcrypto_aes_gcm_decrypt(
360353 return OTCRYPTO_BAD_ARGS ;
361354 }
362355
363- // Store the iCache state (on or off) and disable it when it is on.
364- hardened_bool_t icache_saved_state ;
365- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
366-
367356 // Construct the AES key.
368357 aes_key_t aes_key ;
369358 HARDENED_TRY (aes_gcm_key_construct (key , & aes_key ));
@@ -385,9 +374,6 @@ otcrypto_status_t otcrypto_aes_gcm_decrypt(
385374
386375 HARDENED_TRY (clear_key_if_sideloaded (aes_key ));
387376
388- // Enable the iCache if it was previously enabled.
389- ibex_restore_icache (icache_saved_state );
390-
391377 // Verify the input buffers
392378 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (plaintext ));
393379 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (iv ));
@@ -405,10 +391,6 @@ otcrypto_status_t otcrypto_aes_gcm_encrypt_init(
405391 return OTCRYPTO_BAD_ARGS ;
406392 }
407393
408- // Store the iCache state (on or off) and disable it when it is on.
409- hardened_bool_t icache_saved_state ;
410- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
411-
412394 // Construct the AES key.
413395 aes_key_t aes_key ;
414396 HARDENED_TRY (aes_gcm_key_construct (key , & aes_key ));
@@ -423,9 +405,6 @@ otcrypto_status_t otcrypto_aes_gcm_encrypt_init(
423405 HARDENED_TRY (gcm_context_save (& internal_ctx , ctx ));
424406 HARDENED_TRY (clear_key_if_sideloaded (internal_ctx .key ));
425407
426- // Enable the iCache if it was previously enabled.
427- ibex_restore_icache (icache_saved_state );
428-
429408 // Verify the input buffer
430409 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (iv ));
431410
@@ -439,10 +418,6 @@ otcrypto_status_t otcrypto_aes_gcm_decrypt_init(
439418 return OTCRYPTO_BAD_ARGS ;
440419 }
441420
442- // Store the iCache state (on or off) and disable it when it is on.
443- hardened_bool_t icache_saved_state ;
444- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
445-
446421 // Construct the AES key.
447422 aes_key_t aes_key ;
448423 HARDENED_TRY (aes_gcm_key_construct (key , & aes_key ));
@@ -457,9 +432,6 @@ otcrypto_status_t otcrypto_aes_gcm_decrypt_init(
457432 HARDENED_TRY (gcm_context_save (& internal_ctx , ctx ));
458433 HARDENED_TRY (clear_key_if_sideloaded (internal_ctx .key ));
459434
460- // Enable the iCache if it was previously enabled.
461- ibex_restore_icache (icache_saved_state );
462-
463435 // Verify the input buffer
464436 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (iv ));
465437
@@ -477,10 +449,6 @@ otcrypto_status_t otcrypto_aes_gcm_update_aad(otcrypto_aes_gcm_context_t *ctx,
477449 return OTCRYPTO_OK ;
478450 }
479451
480- // Store the iCache state (on or off) and disable it when it is on.
481- hardened_bool_t icache_saved_state ;
482- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
483-
484452 // Restore the AES-GCM context object and load the key if needed.
485453 aes_gcm_context_t internal_ctx ;
486454 HARDENED_TRY (gcm_context_restore (ctx , & internal_ctx ));
@@ -493,9 +461,6 @@ otcrypto_status_t otcrypto_aes_gcm_update_aad(otcrypto_aes_gcm_context_t *ctx,
493461 HARDENED_TRY (gcm_context_save (& internal_ctx , ctx ));
494462 HARDENED_TRY (clear_key_if_sideloaded (internal_ctx .key ));
495463
496- // Enable the iCache if it was previously enabled.
497- ibex_restore_icache (icache_saved_state );
498-
499464 // Verify the input buffer
500465 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (aad ));
501466
@@ -516,10 +481,6 @@ otcrypto_status_t otcrypto_aes_gcm_update_encrypted_data(
516481 return OTCRYPTO_OK ;
517482 }
518483
519- // Store the iCache state (on or off) and disable it when it is on.
520- hardened_bool_t icache_saved_state ;
521- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
522-
523484 // Restore the AES-GCM context object and load the key if needed.
524485 aes_gcm_context_t internal_ctx ;
525486 HARDENED_TRY (gcm_context_restore (ctx , & internal_ctx ));
@@ -549,9 +510,6 @@ otcrypto_status_t otcrypto_aes_gcm_update_encrypted_data(
549510 HARDENED_TRY (gcm_context_save (& internal_ctx , ctx ));
550511 HARDENED_TRY (clear_key_if_sideloaded (internal_ctx .key ));
551512
552- // Enable the iCache if it was previously enabled.
553- ibex_restore_icache (icache_saved_state );
554-
555513 // Verify the input buffers
556514 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (input ));
557515 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (output ));
@@ -575,10 +533,6 @@ otcrypto_status_t otcrypto_aes_gcm_encrypt_final(
575533 // Randomize the tag before the operation.
576534 HARDENED_TRY (hardened_memshred (auth_tag -> data , auth_tag -> len ));
577535
578- // Store the iCache state (on or off) and disable it when it is on.
579- hardened_bool_t icache_saved_state ;
580- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
581-
582536 // Check the tag length.
583537 HARDENED_TRY (aes_gcm_check_tag_length (auth_tag -> len , tag_len ));
584538
@@ -605,9 +559,6 @@ otcrypto_status_t otcrypto_aes_gcm_encrypt_final(
605559 HARDENED_TRY (hardened_memshred (ctx -> data , ARRAYSIZE (ctx -> data )));
606560 HARDENED_TRY (clear_key_if_sideloaded (internal_ctx .key ));
607561
608- // Enable the iCache if it was previously enabled.
609- ibex_restore_icache (icache_saved_state );
610-
611562 // Verify the input buffers
612563 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (ciphertext ));
613564 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (auth_tag ));
@@ -629,10 +580,6 @@ otcrypto_status_t otcrypto_aes_gcm_decrypt_final(
629580 * plaintext_bytes_written = 0 ;
630581 * success = kHardenedBoolFalse ;
631582
632- // Store the iCache state (on or off) and disable it when it is on.
633- hardened_bool_t icache_saved_state ;
634- HARDENED_TRY (ibex_disable_icache (& icache_saved_state ));
635-
636583 // Check the tag length.
637584 HARDENED_TRY (aes_gcm_check_tag_length (auth_tag -> len , tag_len ));
638585
@@ -659,9 +606,6 @@ otcrypto_status_t otcrypto_aes_gcm_decrypt_final(
659606 HARDENED_TRY (hardened_memshred (ctx -> data , ARRAYSIZE (ctx -> data )));
660607 HARDENED_TRY (clear_key_if_sideloaded (internal_ctx .key ));
661608
662- // Enable the iCache if it was previously enabled.
663- ibex_restore_icache (icache_saved_state );
664-
665609 // Verify the input buffers
666610 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (auth_tag ));
667611 HARDENED_CHECK_EQ (kHardenedBoolTrue , OTCRYPTO_CHECK_BUF (plaintext ));
0 commit comments