Implemented strict switch fall-through handling using new macro FALL_THROUGH.

This commit is contained in:
David Garske
2017-05-11 15:15:19 -07:00
parent c0c98c8f64
commit 562db08c3d
10 changed files with 137 additions and 21 deletions

View File

@@ -4472,9 +4472,9 @@ static int ConfirmSignature(SignatureCtx* sigCtx,
ERROR_OUT(MEMORY_E, exit_cs);
}
/* fall through */
sigCtx->state = SIG_STATE_HASH;
} /* SIG_STATE_BEGIN */
FALL_THROUGH;
case SIG_STATE_HASH:
{
@@ -4550,9 +4550,9 @@ static int ConfirmSignature(SignatureCtx* sigCtx,
goto exit_cs;
}
/* fall through */
sigCtx->state = SIG_STATE_KEY;
} /* SIG_STATE_HASH */
FALL_THROUGH;
case SIG_STATE_KEY:
{
@@ -4625,9 +4625,9 @@ static int ConfirmSignature(SignatureCtx* sigCtx,
goto exit_cs;
}
/* fall through */
sigCtx->state = SIG_STATE_DO;
} /* SIG_STATE_KEY */
FALL_THROUGH;
case SIG_STATE_DO:
{
@@ -4667,9 +4667,9 @@ static int ConfirmSignature(SignatureCtx* sigCtx,
goto exit_cs;
}
/* fall through */
sigCtx->state = SIG_STATE_CHECK;
} /* SIG_STATE_DO */
FALL_THROUGH;
case SIG_STATE_CHECK:
{
@@ -8207,8 +8207,8 @@ static int MakeSignature(CertSignCtx* certSignCtx, const byte* buffer, int sz,
if (ret != 0) {
goto exit_ms;
}
FALL_THROUGH;
/* fall-through */
case CERTSIGN_STATE_ENCODE:
#ifndef NO_RSA
if (rsaKey) {
@@ -8223,8 +8223,8 @@ static int MakeSignature(CertSignCtx* certSignCtx, const byte* buffer, int sz,
certSignCtx->digest, digestSz, typeH);
}
#endif /* !NO_RSA */
FALL_THROUGH;
/* fall-through */
case CERTSIGN_STATE_DO:
certSignCtx->state = CERTSIGN_STATE_DO;
ret = ALGO_ID_E; /* default to error */

View File

@@ -2900,8 +2900,8 @@ int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
if (err < 0) {
break;
}
FALL_THROUGH;
/* fall through */
case ECC_STATE_SHARED_SEC_RES:
private_key->state = ECC_STATE_SHARED_SEC_RES;
err = 0;
@@ -3393,8 +3393,8 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
}
#endif /* WOLFSSL_ATECC508A */
FALL_THROUGH;
/* fall through */
case ECC_STATE_SIGN_ENCODE:
key->state = ECC_STATE_SIGN_ENCODE;
@@ -3924,8 +3924,8 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
if (err < 0) {
break;
}
FALL_THROUGH;
/* fall through */
case ECC_STATE_VERIFY_DO:
key->state = ECC_STATE_VERIFY_DO;
@@ -3933,8 +3933,8 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
if (err < 0) {
break;
}
FALL_THROUGH;
/* fall through */
case ECC_STATE_VERIFY_RES:
key->state = ECC_STATE_VERIFY_RES;
err = 0;

View File

@@ -1282,7 +1282,8 @@ static int RsaPublicEncryptEx(const byte* in, word32 inLen, byte* out,
}
key->state = RSA_STATE_ENCRYPT_EXPTMOD;
/* fall through */
FALL_THROUGH;
case RSA_STATE_ENCRYPT_EXPTMOD:
@@ -1296,7 +1297,7 @@ static int RsaPublicEncryptEx(const byte* in, word32 inLen, byte* out,
break;
}
/* fall through */
FALL_THROUGH;
case RSA_STATE_ENCRYPT_RES:
ret = key->dataLen;
@@ -1402,7 +1403,7 @@ static int RsaPrivateDecryptEx(byte* in, word32 inLen, byte* out,
break;
}
/* fall through */
FALL_THROUGH;
case RSA_STATE_DECRYPT_UNPAD:
{
@@ -1426,7 +1427,8 @@ static int RsaPrivateDecryptEx(byte* in, word32 inLen, byte* out,
}
key->state = RSA_STATE_DECRYPT_RES;
/* fall through */
FALL_THROUGH;
}
case RSA_STATE_DECRYPT_RES:
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_RSA) && \

View File

@@ -206,6 +206,7 @@ int wc_SignatureVerify(
/* Otherwise fall-through and perform normal RSA verify against updated
* DER encoding + hash */
#endif
FALL_THROUGH;
case WC_SIGNATURE_TYPE_RSA:
{
@@ -338,7 +339,7 @@ int wc_SignatureGenerate(
/* Otherwise fall-through and perform normal RSA sign against updated
* DER encoding + hash */
#endif
FALL_THROUGH;
case WC_SIGNATURE_TYPE_RSA:
#ifndef NO_RSA
/* Create signature using provided RSA key */