int ssl3_cbc_remove_padding(const SSL *s,
                            SSL3_RECORD *rec,
                            unsigned block_size, unsigned mac_size)
{
    unsigned padding_length, good;
    const unsigned overhead = 1    + mac_size;
    if (overhead > rec->length)
        return 0;
    padding_length = rec->data[rec->length - 1];
    good = constant_time_ge(rec->length, padding_length + overhead);
    good &= constant_time_ge(block_size, padding_length + 1);
    rec->length -= good & (padding_length + 1);
    return constant_time_select_int(good, 1, -1);
}
['int ssl3_enc(SSL *s, int send)\n{\n    SSL3_RECORD *rec;\n    EVP_CIPHER_CTX *ds;\n    unsigned long l;\n    int bs, i, mac_size = 0;\n    const EVP_CIPHER *enc;\n    if (send) {\n        ds = s->enc_write_ctx;\n        rec = RECORD_LAYER_get_wrec(&s->rlayer);\n        if (s->enc_write_ctx == NULL)\n            enc = NULL;\n        else\n            enc = EVP_CIPHER_CTX_cipher(s->enc_write_ctx);\n    } else {\n        ds = s->enc_read_ctx;\n        rec = RECORD_LAYER_get_rrec(&s->rlayer);\n        if (s->enc_read_ctx == NULL)\n            enc = NULL;\n        else\n            enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx);\n    }\n    if ((s->session == NULL) || (ds == NULL) || (enc == NULL)) {\n        memmove(rec->data, rec->input, rec->length);\n        rec->input = rec->data;\n    } else {\n        l = rec->length;\n        bs = EVP_CIPHER_block_size(ds->cipher);\n        if ((bs != 1) && send) {\n            i = bs - ((int)l % bs);\n            l += i;\n            memset(&rec->input[rec->length], 0, i);\n            rec->length += i;\n            rec->input[l - 1] = (i - 1);\n        }\n        if (!send) {\n            if (l == 0 || l % bs != 0)\n                return 0;\n        }\n        if (EVP_Cipher(ds, rec->data, rec->input, l) < 1)\n            return -1;\n        if (EVP_MD_CTX_md(s->read_hash) != NULL)\n            mac_size = EVP_MD_CTX_size(s->read_hash);\n        if ((bs != 1) && !send)\n            return ssl3_cbc_remove_padding(s, rec, bs, mac_size);\n    }\n    return (1);\n}', 'int ssl3_cbc_remove_padding(const SSL *s,\n                            SSL3_RECORD *rec,\n                            unsigned block_size, unsigned mac_size)\n{\n    unsigned padding_length, good;\n    const unsigned overhead = 1    + mac_size;\n    if (overhead > rec->length)\n        return 0;\n    padding_length = rec->data[rec->length - 1];\n    good = constant_time_ge(rec->length, padding_length + overhead);\n    good &= constant_time_ge(block_size, padding_length + 1);\n    rec->length -= good & (padding_length + 1);\n    return constant_time_select_int(good, 1, -1);\n}']