- memcpy(crypto_info.rec_seq, &s->rlayer.write_sequence,
- TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
+ if (which & SSL3_CC_WRITE)
+ memcpy(crypto_info.rec_seq, &s->rlayer.write_sequence,
+ TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
+ else
+ memcpy(crypto_info.rec_seq, &s->rlayer.read_sequence,
+ TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
+
+ if (which & SSL3_CC_READ) {
+ count_unprocessed = count_unprocessed_records(s);
+ if (count_unprocessed < 0)
+ goto skip_ktls;
+
+ /* increment the crypto_info record sequence */
+ while (count_unprocessed) {
+ for (bit = 7; bit >= 0; bit--) { /* increment */
+ ++crypto_info.rec_seq[bit];
+ if (crypto_info.rec_seq[bit] != 0)
+ break;
+ }
+ count_unprocessed--;
+ }
+ }