in src/recordlayer.js [98:112]
nonce() {
// Ref https://tools.ietf.org/html/rfc8446#section-5.3:
// * left-pad the sequence number with zeros to IV_LENGTH
// * xor with the provided iv
// Our sequence numbers are always less than 2^24, so fit in a Uint32
// in the last 4 bytes of the nonce.
const nonce = this.iv.slice();
const dv = new DataView(nonce.buffer, nonce.byteLength - 4, 4);
dv.setUint32(0, dv.getUint32(0) ^ this.seqnum);
this.seqnum += 1;
if (this.seqnum > MAX_SEQUENCE_NUMBER) {
throw new TLSError(ALERT_DESCRIPTION.INTERNAL_ERROR);
}
return nonce;
}