Split RSA-AES test data

Make the tests more clear what data is expected in the different stages
of the handshake.
This commit is contained in:
Pierre Ossman 2023-05-17 13:15:11 +02:00
parent 42bc251eb4
commit 549ccc7121
1 changed files with 43 additions and 17 deletions

View File

@ -1378,8 +1378,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
expect(client._sock).to.have.sent(new Uint8Array([6])); expect(client._sock).to.have.sent(new Uint8Array([6]));
}); });
const receiveData = new Uint8Array([ const serverPublicKey = [
// server public key
0x00, 0x00, 0x08, 0x00, 0xac, 0x1a, 0xbc, 0x42, 0x00, 0x00, 0x08, 0x00, 0xac, 0x1a, 0xbc, 0x42,
0x8a, 0x2a, 0x69, 0x65, 0x54, 0xf8, 0x9a, 0xe6, 0x8a, 0x2a, 0x69, 0x65, 0x54, 0xf8, 0x9a, 0xe6,
0x43, 0xaa, 0xf7, 0x27, 0xf6, 0x2a, 0xf8, 0x8f, 0x43, 0xaa, 0xf7, 0x27, 0xf6, 0x2a, 0xf8, 0x8f,
@ -1445,7 +1444,9 @@ describe('Remote Frame Buffer Protocol Client', function () {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
// server random ];
const serverRandom = [
0x01, 0x00, 0x5b, 0x58, 0x2a, 0x96, 0x2d, 0xbb, 0x01, 0x00, 0x5b, 0x58, 0x2a, 0x96, 0x2d, 0xbb,
0x88, 0xec, 0xc3, 0x54, 0x00, 0xf3, 0xbb, 0xbe, 0x88, 0xec, 0xc3, 0x54, 0x00, 0xf3, 0xbb, 0xbe,
0x17, 0xa3, 0x84, 0xd3, 0xef, 0xd8, 0x4a, 0x31, 0x17, 0xa3, 0x84, 0xd3, 0xef, 0xd8, 0x4a, 0x31,
@ -1479,20 +1480,23 @@ describe('Remote Frame Buffer Protocol Client', function () {
0xcf, 0x76, 0x80, 0xc2, 0x24, 0x0a, 0x39, 0x7e, 0xcf, 0x76, 0x80, 0xc2, 0x24, 0x0a, 0x39, 0x7e,
0x60, 0x64, 0xce, 0xd9, 0xb8, 0xad, 0x24, 0xa8, 0x60, 0x64, 0xce, 0xd9, 0xb8, 0xad, 0x24, 0xa8,
0xdf, 0xcb, 0xdf, 0xcb,
// server hash ];
const serverHash = [
0x00, 0x14, 0x39, 0x30, 0x66, 0xb5, 0x66, 0x8a, 0x00, 0x14, 0x39, 0x30, 0x66, 0xb5, 0x66, 0x8a,
0xcd, 0xb9, 0xda, 0xe0, 0xde, 0xcb, 0xf6, 0x47, 0xcd, 0xb9, 0xda, 0xe0, 0xde, 0xcb, 0xf6, 0x47,
0x5f, 0x54, 0x66, 0xe0, 0xbc, 0x49, 0x37, 0x01, 0x5f, 0x54, 0x66, 0xe0, 0xbc, 0x49, 0x37, 0x01,
0xf2, 0x9e, 0xef, 0xcc, 0xcd, 0x4d, 0x6c, 0x0e, 0xf2, 0x9e, 0xef, 0xcc, 0xcd, 0x4d, 0x6c, 0x0e,
0xc6, 0xab, 0x28, 0xd4, 0x7b, 0x13, 0xc6, 0xab, 0x28, 0xd4, 0x7b, 0x13,
// subtype ];
const subType = [
0x00, 0x01, 0x30, 0x2a, 0xc3, 0x0b, 0xc2, 0x1c, 0x00, 0x01, 0x30, 0x2a, 0xc3, 0x0b, 0xc2, 0x1c,
0xeb, 0x02, 0x44, 0x92, 0x5d, 0xfd, 0xf9, 0xa7, 0xeb, 0x02, 0x44, 0x92, 0x5d, 0xfd, 0xf9, 0xa7,
0x94, 0xd0, 0x19, 0x94, 0xd0, 0x19,
]); ];
const sendData = new Uint8Array([ const clientPublicKey = [
// client public key
0x00, 0x00, 0x08, 0x00, 0x9b, 0x57, 0x3d, 0xd9, 0x00, 0x00, 0x08, 0x00, 0x9b, 0x57, 0x3d, 0xd9,
0x91, 0x64, 0xf5, 0x92, 0x3a, 0x97, 0xf3, 0xb8, 0x91, 0x64, 0xf5, 0x92, 0x3a, 0x97, 0xf3, 0xb8,
0x60, 0x58, 0x8d, 0xc5, 0xbb, 0xf4, 0x36, 0x0f, 0x60, 0x58, 0x8d, 0xc5, 0xbb, 0xf4, 0x36, 0x0f,
@ -1558,7 +1562,9 @@ describe('Remote Frame Buffer Protocol Client', function () {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
// client random ];
const clientRandom = [
0x01, 0x00, 0x84, 0x7f, 0x26, 0x54, 0x74, 0xf6, 0x01, 0x00, 0x84, 0x7f, 0x26, 0x54, 0x74, 0xf6,
0x47, 0xaf, 0x33, 0x64, 0x0d, 0xa6, 0xe5, 0x30, 0x47, 0xaf, 0x33, 0x64, 0x0d, 0xa6, 0xe5, 0x30,
0xba, 0xe6, 0xe4, 0x8e, 0x50, 0x40, 0x71, 0x1c, 0xba, 0xe6, 0xe4, 0x8e, 0x50, 0x40, 0x71, 0x1c,
@ -1592,18 +1598,22 @@ describe('Remote Frame Buffer Protocol Client', function () {
0x7c, 0xab, 0x63, 0x9c, 0xae, 0xc3, 0xc9, 0x71, 0x7c, 0xab, 0x63, 0x9c, 0xae, 0xc3, 0xc9, 0x71,
0x1a, 0xec, 0x34, 0x18, 0x47, 0xec, 0x5c, 0x4d, 0x1a, 0xec, 0x34, 0x18, 0x47, 0xec, 0x5c, 0x4d,
0xed, 0x84, 0xed, 0x84,
// client hash ];
const clientHash = [
0x00, 0x14, 0x9c, 0x91, 0x9e, 0x76, 0xcf, 0x1e, 0x00, 0x14, 0x9c, 0x91, 0x9e, 0x76, 0xcf, 0x1e,
0x66, 0x87, 0x5e, 0x29, 0xf1, 0x13, 0x80, 0xea, 0x66, 0x87, 0x5e, 0x29, 0xf1, 0x13, 0x80, 0xea,
0x7d, 0xec, 0xae, 0xf9, 0x60, 0x01, 0xd3, 0x6f, 0x7d, 0xec, 0xae, 0xf9, 0x60, 0x01, 0xd3, 0x6f,
0xb7, 0x9e, 0xb2, 0xcd, 0x2d, 0xc8, 0xf8, 0x84, 0xb7, 0x9e, 0xb2, 0xcd, 0x2d, 0xc8, 0xf8, 0x84,
0xb2, 0x9f, 0xc3, 0x7e, 0xb4, 0xbe, 0xb2, 0x9f, 0xc3, 0x7e, 0xb4, 0xbe,
// credentials ];
const credentialsData = [
0x00, 0x08, 0x9d, 0xc8, 0x3a, 0xb8, 0x80, 0x4f, 0x00, 0x08, 0x9d, 0xc8, 0x3a, 0xb8, 0x80, 0x4f,
0xe3, 0x52, 0xdb, 0x62, 0x9e, 0x97, 0x64, 0x82, 0xe3, 0x52, 0xdb, 0x62, 0x9e, 0x97, 0x64, 0x82,
0xa8, 0xa1, 0x6b, 0x7e, 0x4d, 0x68, 0x8c, 0x29, 0xa8, 0xa1, 0x6b, 0x7e, 0x4d, 0x68, 0x8c, 0x29,
0x91, 0x38, 0x91, 0x38,
]); ];
it('should fire the serververification event', async function () { it('should fire the serververification event', async function () {
let verification = new Promise((resolve, reject) => { let verification = new Promise((resolve, reject) => {
@ -1612,9 +1622,10 @@ describe('Remote Frame Buffer Protocol Client', function () {
}); });
}); });
client._sock._websocket._receiveData(receiveData); client._sock._websocket._receiveData(new Uint8Array(serverPublicKey));
client._sock._websocket._receiveData(new Uint8Array(serverRandom));
expect(await verification).to.deep.equal(receiveData.slice(0, 516)); expect(await verification).to.deep.equal(new Uint8Array(serverPublicKey));
}); });
it('should handle approveServer and fire the credentialsrequired event', async function () { it('should handle approveServer and fire the credentialsrequired event', async function () {
@ -1629,11 +1640,15 @@ describe('Remote Frame Buffer Protocol Client', function () {
}); });
}); });
client._sock._websocket._receiveData(receiveData); client._sock._websocket._receiveData(new Uint8Array(serverPublicKey));
client._sock._websocket._receiveData(new Uint8Array(serverRandom));
await verification; await verification;
client.approveServer(); client.approveServer();
client._sock._websocket._receiveData(new Uint8Array(serverHash));
client._sock._websocket._receiveData(new Uint8Array(subType));
expect(await credentials).to.have.members(["password"]); expect(await credentials).to.have.members(["password"]);
}); });
@ -1649,12 +1664,23 @@ describe('Remote Frame Buffer Protocol Client', function () {
}); });
}); });
client._sock._websocket._receiveData(receiveData); client._sock._websocket._receiveData(new Uint8Array(serverPublicKey));
client._sock._websocket._receiveData(new Uint8Array(serverRandom));
await verification; await verification;
client.approveServer(); client.approveServer();
client._sock._websocket._receiveData(new Uint8Array(serverHash));
client._sock._websocket._receiveData(new Uint8Array(subType));
await credentials; await credentials;
let expected = [];
expected = expected.concat(clientPublicKey);
expected = expected.concat(clientRandom);
expected = expected.concat(clientHash);
expect(client._sock).to.have.sent(new Uint8Array(expected));
client.sendCredentials({ "password": "123456" }); client.sendCredentials({ "password": "123456" });
clock.tick(); clock.tick();
@ -1670,7 +1696,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
}); });
}); });
expect(client._sock).to.have.sent(sendData); expect(client._sock).to.have.sent(new Uint8Array(credentialsData));
}); });
}); });