Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update tls test to use better terminology #36851

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions test/common/tls.js
Expand Up @@ -15,9 +15,9 @@ class TestTLSSocket extends net.Socket {
this.handshake_list = [];
// AES128-GCM-SHA256
this.ciphers = Buffer.from('000002009c0', 'hex');
this.pre_master_secret =
this.pre_primary_secret =
Buffer.concat([this.version, crypto.randomBytes(46)]);
this.master_secret = null;
this.primary_secret = null;
this.write_seq = 0;
this.client_random = crypto.randomBytes(32);

Expand All @@ -26,12 +26,12 @@ class TestTLSSocket extends net.Socket {
});

this.on('server_random', (server_random) => {
this.master_secret = PRF12('sha256', this.pre_master_secret,
'master secret',
Buffer.concat([this.client_random,
server_random]),
48);
const key_block = PRF12('sha256', this.master_secret,
this.primary_secret = PRF12('sha256', this.pre_primary_secret,
'primary secret',
Buffer.concat([this.client_random,
server_random]),
48);
const key_block = PRF12('sha256', this.primary_secret,
'key expansion',
Buffer.concat([server_random,
this.client_random]),
Expand All @@ -51,14 +51,14 @@ class TestTLSSocket extends net.Socket {
}

createClientKeyExchange() {
const encrypted_pre_master_secret = crypto.publicEncrypt({
const encrypted_pre_primary_secret = crypto.publicEncrypt({
key: this.server_cert,
padding: crypto.constants.RSA_PKCS1_PADDING
}, this.pre_master_secret);
}, this.pre_primary_secret);
const length = Buffer.alloc(2);
length.writeUIntBE(encrypted_pre_master_secret.length, 0, 2);
length.writeUIntBE(encrypted_pre_primary_secret.length, 0, 2);
const msg = addHandshakeHeader(0x10, Buffer.concat([
length, encrypted_pre_master_secret]));
length, encrypted_pre_primary_secret]));
this.emit('handshake', msg);
return addRecordHeader(0x16, msg);
}
Expand All @@ -67,7 +67,7 @@ class TestTLSSocket extends net.Socket {
const shasum = crypto.createHash('sha256');
shasum.update(Buffer.concat(this.handshake_list));
const message_hash = shasum.digest();
const r = PRF12('sha256', this.master_secret,
const r = PRF12('sha256', this.primary_secret,
'client finished', message_hash, 12);
const msg = addHandshakeHeader(0x14, r);
this.emit('handshake', msg);
Expand Down