@@ -1538,7 +1538,7 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
15381538 byte * optLabel , word32 labelLen , void * heap )
15391539{
15401540 word32 hLen ;
1541- volatile int ret ;
1541+ int ret ;
15421542 byte h [WC_MAX_DIGEST_SIZE ]; /* max digest size */
15431543 word32 idx ;
15441544 word32 i ;
@@ -1573,8 +1573,9 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
15731573#endif
15741574
15751575 /* find seedMask value */
1576- if ((ret = RsaMGF (mgf , (byte * )(pkcsBlock + (hLen + 1 )),
1577- pkcsBlockLen - hLen - 1 , tmp , hLen , heap )) != 0 ) {
1576+ ret = RsaMGF (mgf , (byte * )(pkcsBlock + (hLen + 1 )),
1577+ pkcsBlockLen - hLen - 1 , tmp , hLen , heap );
1578+ if (ret != 0 ) {
15781579 WC_FREE_VAR_EX (tmp , heap , DYNAMIC_TYPE_RSA_BUFFER );
15791580 return ret ;
15801581 }
@@ -1583,8 +1584,8 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
15831584 xorbuf (tmp , pkcsBlock + 1 , hLen );
15841585
15851586 /* get dbMask value */
1586- if (( ret = RsaMGF (mgf , tmp , hLen , tmp + hLen ,
1587- pkcsBlockLen - hLen - 1 , heap )) != 0 ) {
1587+ ret = RsaMGF (mgf , tmp , hLen , tmp + hLen , pkcsBlockLen - hLen - 1 , heap );
1588+ if ( ret != 0 ) {
15881589 ForceZero (tmp , hLen );
15891590#ifdef WOLFSSL_SMALL_STACK
15901591 XFREE (tmp , NULL , DYNAMIC_TYPE_RSA_BUFFER );
@@ -1616,7 +1617,8 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
16161617 }
16171618
16181619 /* create hash of label for comparison with hash sent */
1619- if ((ret = wc_Hash (hType , optLabel , labelLen , h , hLen )) != 0 ) {
1620+ ret = wc_Hash (hType , optLabel , labelLen , h , hLen );
1621+ if (ret != 0 ) {
16201622 return ret ;
16211623 }
16221624
@@ -1626,13 +1628,14 @@ static int RsaUnPad_OAEP(byte *pkcsBlock, unsigned int pkcsBlockLen,
16261628 Attackers should not be able to get error condition from the timing of
16271629 these checks.
16281630 */
1629- ret = 0 ;
1630- ret | = ConstantCompare (pkcsBlock + hLen + 1 , h , (int )hLen );
1631- ret += pkcsBlock [idx ++ ] ^ 0x01 ; /* separator value is 0x01 */
1632- ret += pkcsBlock [0 ] ^ 0x00 ; /* Y, the first value, should be 0 */
1631+ {
1632+ volatile int c = ConstantCompare (pkcsBlock + hLen + 1 , h , (int )hLen );
1633+ c = c + ( pkcsBlock [idx ++ ] ^ 0x01 ) ; /* separator value is 0x01 */
1634+ c = c + ( pkcsBlock [0 ] ^ 0x00 ) ; /* Y, the first value, should be 0 */
16331635
1634- /* Return 0 data length on error. */
1635- idx = ctMaskSelWord32 (ctMaskEq (ret , 0 ), idx , pkcsBlockLen );
1636+ /* Return 0 data length on error. */
1637+ idx = ctMaskSelWord32 (ctMaskEq (c , 0 ), idx , pkcsBlockLen );
1638+ }
16361639
16371640 /* adjust pointer to correct location in array and return size of M */
16381641 * output = (byte * )(pkcsBlock + idx );
0 commit comments