src/wolfSSL/src/internal.c
static int TimingPadVerify(WOLFSSL* ssl, const byte* input, int padLen, int t,
                           int pLen, int content)
{
    byte verify[MAX_DIGEST_SIZE];
    byte dmy[sizeof(WOLFSSL) >= MAX_PAD_SIZE ? 1 : MAX_PAD_SIZE] = {0};
    byte* dummy = sizeof(dmy) < MAX_PAD_SIZE ? (byte*) ssl : dmy;
    int  ret = 0;

    (void)dmy;

    if ( (t + padLen + 1) > pLen) {
        WOLFSSL_MSG("Plain Len not long enough for pad/mac");
        PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE);
        ssl->hmac(ssl, verify, input, pLen - t, content, 1); /* still compare */
        ConstantCompare(verify, input + pLen - t, t);

        return VERIFY_MAC_ERROR;
    }

    if (PadCheck(input + pLen - (padLen + 1), (byte)padLen, padLen + 1) != 0) {
        WOLFSSL_MSG("PadCheck failed");
        PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);
        ssl->hmac(ssl, verify, input, pLen - t, content, 1); /* still compare */
        ConstantCompare(verify, input + pLen - t, t);

        return VERIFY_MAC_ERROR;
    }

    PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);
    ret = ssl->hmac(ssl, verify, input, pLen - padLen - 1 - t, content, 1);

    CompressRounds(ssl, GetRounds(pLen, padLen, t), dummy);

    if (ConstantCompare(verify, input + (pLen - padLen - 1 - t), t) != 0) {
        WOLFSSL_MSG("Verify MAC compare failed");
        return VERIFY_MAC_ERROR;
    }

    if (ret != 0)
        return VERIFY_MAC_ERROR;
    return 0;
}
/* timing resistant pad/verify check, return 0 on success */
timing resistant pad/verify check, return 0 on success
timing resistant pad / verify check return 0 on success
static int TimingPadVerify(WOLFSSL* ssl, const byte* input, int padLen, int t,
                           int pLen, int content)
{
    byte verify[MAX_DIGEST_SIZE];
    byte dmy[sizeof(WOLFSSL) >= MAX_PAD_SIZE ? 1 : MAX_PAD_SIZE] = {0};
    byte* dummy = sizeof(dmy) < MAX_PAD_SIZE ? (byte*) ssl : dmy;
    int  ret = 0;
    (void)dmy;
    if ( (t + padLen + 1) > pLen) {
        WOLFSSL_MSG("Plain Len not long enough for pad/mac");
        PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE);
        ssl->hmac(ssl, verify, input, pLen - t, content, 1); 
        ConstantCompare(verify, input + pLen - t, t);
        return VERIFY_MAC_ERROR;
    }
    if (PadCheck(input + pLen - (padLen + 1), (byte)padLen, padLen + 1) != 0) {
        WOLFSSL_MSG("PadCheck failed");
        PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);
        ssl->hmac(ssl, verify, input, pLen - t, content, 1); 
        ConstantCompare(verify, input + pLen - t, t);
        return VERIFY_MAC_ERROR;
    }
    PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);
    ret = ssl->hmac(ssl, verify, input, pLen - padLen - 1 - t, content, 1);
    CompressRounds(ssl, GetRounds(pLen, padLen, t), dummy);
    if (ConstantCompare(verify, input + (pLen - padLen - 1 - t), t) != 0) {
        WOLFSSL_MSG("Verify MAC compare failed");
        return VERIFY_MAC_ERROR;
    }
    if (ret != 0)
        return VERIFY_MAC_ERROR;
    return 0;
}
static int TimingPadVerify ( WOLFSSL * ssl , const byte * input , int padLen , int t , int pLen , int content ) { byte verify [ MAX_DIGEST_SIZE ] ; byte dmy [ sizeof ( WOLFSSL ) >= MAX_PAD_SIZE ? 1 : MAX_PAD_SIZE ] = { 0 } ; byte * dummy = sizeof ( dmy ) < MAX_PAD_SIZE ? ( byte * ) ssl : dmy ; int ret = 0 ; ( void ) dmy ; if ( ( t + padLen + 1 ) > pLen ) { WOLFSSL_MSG ( " " ) ; PadCheck ( dummy , ( byte ) padLen , MAX_PAD_SIZE ) ; ssl -> hmac ( ssl , verify , input , pLen - t , content , 1 ) ; ConstantCompare ( verify , input + pLen - t , t ) ; return VERIFY_MAC_ERROR ; } if ( PadCheck ( input + pLen - ( padLen + 1 ) , ( byte ) padLen , padLen + 1 ) != 0 ) { WOLFSSL_MSG ( " " ) ; PadCheck ( dummy , ( byte ) padLen , MAX_PAD_SIZE - padLen - 1 ) ; ssl -> hmac ( ssl , verify , input , pLen - t , content , 1 ) ; ConstantCompare ( verify , input + pLen - t , t ) ; return VERIFY_MAC_ERROR ; } PadCheck ( dummy , ( byte ) padLen , MAX_PAD_SIZE - padLen - 1 ) ; ret = ssl -> hmac ( ssl , verify , input , pLen - padLen - 1 - t , content , 1 ) ; CompressRounds ( ssl , GetRounds ( pLen , padLen , t ) , dummy ) ; if ( ConstantCompare ( verify , input + ( pLen - padLen - 1 - t ) , t ) != 0 ) { WOLFSSL_MSG ( " " ) ; return VERIFY_MAC_ERROR ; } if ( ret != 0 ) return VERIFY_MAC_ERROR ; return 0 ; }
timing resistant pad/verify check, return 0 on success
timing resistant pad / verify check return 0 on success
/* still compare */ /* still compare */