-
- if (!sending) {
- for (ctr = 0; ctr < n_recs; ctr++) {
- /* Adjust the record to remove the explicit IV/MAC/Tag */
- if (EVP_CIPHER_get_mode(enc) == EVP_CIPH_GCM_MODE) {
- recs[ctr].data += EVP_GCM_TLS_EXPLICIT_IV_LEN;
- recs[ctr].input += EVP_GCM_TLS_EXPLICIT_IV_LEN;
- recs[ctr].length -= EVP_GCM_TLS_EXPLICIT_IV_LEN;
- } else if (EVP_CIPHER_get_mode(enc) == EVP_CIPH_CCM_MODE) {
- recs[ctr].data += EVP_CCM_TLS_EXPLICIT_IV_LEN;
- recs[ctr].input += EVP_CCM_TLS_EXPLICIT_IV_LEN;
- recs[ctr].length -= EVP_CCM_TLS_EXPLICIT_IV_LEN;
- } else if (bs != 1 && SSL_USE_EXPLICIT_IV(s)) {
- if (recs[ctr].length < bs)
- return 0;
- recs[ctr].data += bs;
- recs[ctr].input += bs;
- recs[ctr].length -= bs;
- recs[ctr].orig_len -= bs;
- }
-
- /*
- * If using Mac-then-encrypt, then this will succeed but
- * with a random MAC if padding is invalid
- */
- if (!tls1_cbc_remove_padding_and_mac(&recs[ctr].length,
- recs[ctr].orig_len,
- recs[ctr].data,
- (macs != NULL) ? &macs[ctr].mac : NULL,
- (macs != NULL) ? &macs[ctr].alloced
- : NULL,
- bs,
- pad ? (size_t)pad : macsize,
- (EVP_CIPHER_get_flags(enc)
- & EVP_CIPH_FLAG_AEAD_CIPHER) != 0,
- SSL_CONNECTION_GET_CTX(s)->libctx))
- return 0;
- }
- }