src/wolfSSL/src/internal.c
static int SanityCheckCipherText(WOLFSSL* ssl, word32 encryptSz)
{
#ifdef HAVE_TRUNCATED_HMAC
    word32 minLength = ssl->truncated_hmac ? TRUNCATED_HMAC_SZ
                                           : ssl->specs.hash_size;
#else
    word32 minLength = ssl->specs.hash_size; /* covers stream */
#endif

    if (ssl->specs.cipher_type == block) {
        if (encryptSz % ssl->specs.block_size) {
            WOLFSSL_MSG("Block ciphertext not block size");
            return SANITY_CIPHER_E;
        }

        minLength++;  /* pad byte */

        if (ssl->specs.block_size > minLength)
            minLength = ssl->specs.block_size;

        if (ssl->options.tls1_1)
            minLength += ssl->specs.block_size;  /* explicit IV */
    }
    else if (ssl->specs.cipher_type == aead) {
        minLength = ssl->specs.aead_mac_size;    /* authTag size */
        if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
           minLength += AESGCM_EXP_IV_SZ;          /* explicit IV  */
    }

    if (encryptSz < minLength) {
        WOLFSSL_MSG("Ciphertext not minimum size");
        return SANITY_CIPHER_E;
    }

    return 0;
}
/* check cipher text size for sanity */
check cipher text size for sanity
check cipher text size for sanity
static int SanityCheckCipherText(WOLFSSL* ssl, word32 encryptSz)
{
#ifdef HAVE_TRUNCATED_HMAC
    word32 minLength = ssl->truncated_hmac ? TRUNCATED_HMAC_SZ
                                           : ssl->specs.hash_size;
#else
    word32 minLength = ssl->specs.hash_size; 
#endif
    if (ssl->specs.cipher_type == block) {
        if (encryptSz % ssl->specs.block_size) {
            WOLFSSL_MSG("Block ciphertext not block size");
            return SANITY_CIPHER_E;
        }
        minLength++;  
        if (ssl->specs.block_size > minLength)
            minLength = ssl->specs.block_size;
        if (ssl->options.tls1_1)
            minLength += ssl->specs.block_size;  
    }
    else if (ssl->specs.cipher_type == aead) {
        minLength = ssl->specs.aead_mac_size;    
        if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha)
           minLength += AESGCM_EXP_IV_SZ;          
    }
    if (encryptSz < minLength) {
        WOLFSSL_MSG("Ciphertext not minimum size");
        return SANITY_CIPHER_E;
    }
    return 0;
}
static int SanityCheckCipherText ( WOLFSSL * ssl , word32 encryptSz ) { #ifdef HAVE_TRUNCATED_HMAC word32 minLength = ssl -> truncated_hmac ? TRUNCATED_HMAC_SZ : ssl -> specs . hash_size ; #else word32 minLength = ssl -> specs . hash_size ; #endif if ( ssl -> specs . cipher_type == block ) { if ( encryptSz % ssl -> specs . block_size ) { WOLFSSL_MSG ( " " ) ; return SANITY_CIPHER_E ; } minLength ++ ; if ( ssl -> specs . block_size > minLength ) minLength = ssl -> specs . block_size ; if ( ssl -> options . tls1_1 ) minLength += ssl -> specs . block_size ; } else if ( ssl -> specs . cipher_type == aead ) { minLength = ssl -> specs . aead_mac_size ; if ( ssl -> specs . bulk_cipher_algorithm != wolfssl_chacha ) minLength += AESGCM_EXP_IV_SZ ; } if ( encryptSz < minLength ) { WOLFSSL_MSG ( " " ) ; return SANITY_CIPHER_E ; } return 0 ; }
check cipher text size for sanity
check cipher text size for sanity
/* covers stream */ /* pad byte */ /* explicit IV */ /* authTag size */ /* explicit IV  */