Add MSLogonII security type

This commit is contained in:
Dinglan Peng
2022-12-21 15:52:31 -05:00
parent 4fb2d6c497
commit b776e1495e
2 changed files with 141 additions and 0 deletions

View File

@@ -1336,6 +1336,86 @@ describe('Remote Frame Buffer Protocol Client', function () {
});
});
describe('MSLogonII Authentication (type 113) Handler', function () {
function fakeGetRandomValues(arr) {
if (arr.length == 8) {
arr.set(new Uint8Array([0, 0, 0, 0, 5, 6, 7, 8]));
} else if (arr.length == 256) {
arr.set(new Uint8Array(256));
} else if (arr.length == 64) {
arr.set(new Uint8Array(64));
}
return arr;
}
const expected = new Uint8Array([
0x00, 0x00, 0x00, 0x00, 0x0a, 0xbc, 0x7c, 0xfd,
0x58, 0x34, 0xd2, 0x24, 0x44, 0x60, 0xf0, 0xd1,
0xa3, 0x73, 0x32, 0x02, 0x07, 0xce, 0xc1, 0x3f,
0x10, 0x53, 0xf1, 0xdd, 0x99, 0xad, 0x44, 0x18,
0xa1, 0xc4, 0xac, 0xc1, 0x1c, 0x13, 0x11, 0x85,
0x3a, 0x6f, 0xcb, 0xc6, 0xb1, 0x6c, 0x68, 0x47,
0x85, 0x01, 0xbb, 0xfa, 0x23, 0x8c, 0x59, 0x47,
0x67, 0x47, 0x56, 0x6e, 0x6f, 0x9f, 0x07, 0x76,
0x2e, 0x90, 0x1e, 0xdc, 0x80, 0xc4, 0x4b, 0x72,
0xd2, 0xd5, 0xcd, 0x4b, 0x14, 0xff, 0x05, 0x8b,
0x8d, 0xf1, 0x9b, 0xe0, 0xff, 0xa5, 0x3b, 0x56,
0xb9, 0x6f, 0x84, 0x3e, 0x15, 0x84, 0x31, 0x4e,
0x10, 0x0b, 0x56, 0xf4, 0x10, 0x05, 0x02, 0xc7,
0x05, 0x0b, 0xc9, 0x66, 0x75, 0x32, 0xd3, 0x74,
0xfc, 0x8c, 0xcf, 0xbd, 0x2d, 0x53, 0xd7, 0xa7,
0xca, 0x82, 0x12, 0xce, 0xbb, 0x33, 0x09, 0x3f,
0xff, 0x76, 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x87, 0x60, 0x23, 0xcf, 0xdb,
0x1b, 0xad, 0x42, 0x32, 0x4e, 0x6d, 0x1f, 0x49,
]);
before(() => {
sinon.stub(window.crypto, "getRandomValues").callsFake(fakeGetRandomValues);
});
after(() => {
window.crypto.getRandomValues.restore();
});
it('should send public value and encrypted credentials', function () {
client._rfbCredentials = { username: 'username',
password: 'password123456' };
sendSecurity(113, client);
expect(client._sock).to.have.sent([113]);
const g = new Uint8Array([0, 0, 0, 0, 0, 1, 0, 1]);
const p = new Uint8Array([0, 0, 0, 0, 0x25, 0x18, 0x26, 0x17]);
const A = new Uint8Array([0, 0, 0, 0, 0x0e, 0x12, 0xd0, 0xf5]);
client._sock._websocket._receiveData(g);
client._sock._websocket._receiveData(p);
client._sock._websocket._receiveData(A);
expect(client._sock).to.have.sent(expected);
expect(client._rfbInitState).to.equal('SecurityResult');
});
});
describe('XVP Authentication (type 22) Handler', function () {
it('should fall through to standard VNC authentication upon completion', function () {
client._rfbCredentials = { username: 'user',