@@ -787,7 +787,7 @@ static int _ExportRamKey(whServerContext* server, uint16_t magic,
787787 /* set the counter, flags and ram key */
788788 memset (resp .messageTwo , 0 , sizeof (resp .messageTwo ));
789789 /* set count to 1 */
790- counter_val = ( wh_Utils_htonl (1 ) << 4 );
790+ counter_val = wh_Utils_htonl (1 << 4 );
791791 memcpy (resp .messageTwo , & counter_val , sizeof (uint32_t ));
792792 keySz = WH_SHE_KEY_SZ ;
793793 ret = wh_Server_KeystoreReadKey (
@@ -857,7 +857,7 @@ static int _ExportRamKey(whServerContext* server, uint16_t magic,
857857 if (ret == 0 ) {
858858 memset (resp .messageFour , 0 , sizeof (resp .messageFour ));
859859 /* set counter to 1, pad with 1 bit */
860- counter_val = ( wh_Utils_htonl (1 ) << 4 );
860+ counter_val = wh_Utils_htonl (1 << 4 );
861861 memcpy (resp .messageFour + WH_SHE_KEY_SZ , & counter_val ,
862862 sizeof (uint32_t ));
863863 resp .messageFour [WH_SHE_KEY_SZ + 3 ] |= 0x08 ;
@@ -1539,12 +1539,15 @@ static int _VerifyMac(whServerContext* server, uint16_t magic,
15391539 ret = wc_AesCmacVerify_ex (server -> she -> sheCmac , mac , req .macLen ,
15401540 message , req .messageLen , tmpKey , keySz ,
15411541 NULL , server -> devId );
1542- /* only evaluate if key was found */
15431542 if (ret == 0 ) {
15441543 resp .status = 0 ;
15451544 }
15461545 else {
1546+ /* Verify is allowed to fail, per SHE spec.
1547+ Capture status in the response, but return success to ensure
1548+ that the response is sent. */
15471549 resp .status = 1 ;
1550+ ret = 0 ;
15481551 }
15491552 }
15501553 else {
0 commit comments