@stoprocent/noble 1.9.2-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +11 -0
- package/.eslintrc.js +25 -0
- package/.github/FUNDING.yml +2 -0
- package/.github/workflows/fediverse-action.yml +16 -0
- package/.github/workflows/nodepackage.yml +77 -0
- package/.github/workflows/npm-publish.yml +26 -0
- package/.github/workflows/prebuild.yml +65 -0
- package/.nycrc.json +4 -0
- package/CHANGELOG.md +119 -0
- package/LICENSE +20 -0
- package/MAINTAINERS.md +1 -0
- package/README.md +833 -0
- package/assets/noble-logo.png +0 -0
- package/assets/noble-logo.svg +13 -0
- package/binding.gyp +19 -0
- package/codecov.yml +5 -0
- package/examples/advertisement-discovery.js +65 -0
- package/examples/cache-gatt-discovery.js +198 -0
- package/examples/cache-gatt-reconnect.js +164 -0
- package/examples/echo.js +104 -0
- package/examples/enter-exit.js +78 -0
- package/examples/peripheral-explorer-async.js +133 -0
- package/examples/peripheral-explorer.js +225 -0
- package/examples/pizza/README.md +15 -0
- package/examples/pizza/central.js +194 -0
- package/examples/pizza/pizza.js +60 -0
- package/index.d.ts +203 -0
- package/index.js +6 -0
- package/lib/characteristic.js +161 -0
- package/lib/characteristics.json +449 -0
- package/lib/descriptor.js +72 -0
- package/lib/descriptors.json +47 -0
- package/lib/distributed/bindings.js +326 -0
- package/lib/hci-socket/acl-stream.js +60 -0
- package/lib/hci-socket/bindings.js +788 -0
- package/lib/hci-socket/crypto.js +74 -0
- package/lib/hci-socket/gap.js +432 -0
- package/lib/hci-socket/gatt.js +809 -0
- package/lib/hci-socket/hci-status.json +71 -0
- package/lib/hci-socket/hci.js +1264 -0
- package/lib/hci-socket/signaling.js +76 -0
- package/lib/hci-socket/smp.js +140 -0
- package/lib/hci-uart/bindings.js +569 -0
- package/lib/hci-uart/hci-serial-parser.js +70 -0
- package/lib/hci-uart/hci.js +1336 -0
- package/lib/mac/binding.gyp +26 -0
- package/lib/mac/bindings.js +11 -0
- package/lib/mac/src/ble_manager.h +41 -0
- package/lib/mac/src/ble_manager.mm +435 -0
- package/lib/mac/src/callbacks.cc +222 -0
- package/lib/mac/src/callbacks.h +84 -0
- package/lib/mac/src/napi_objc.h +12 -0
- package/lib/mac/src/napi_objc.mm +50 -0
- package/lib/mac/src/noble_mac.h +34 -0
- package/lib/mac/src/noble_mac.mm +264 -0
- package/lib/mac/src/objc_cpp.h +26 -0
- package/lib/mac/src/objc_cpp.mm +126 -0
- package/lib/mac/src/peripheral.h +23 -0
- package/lib/manufacture.js +48 -0
- package/lib/noble.js +593 -0
- package/lib/peripheral.js +219 -0
- package/lib/resolve-bindings-web.js +9 -0
- package/lib/resolve-bindings.js +44 -0
- package/lib/service.js +72 -0
- package/lib/services.json +92 -0
- package/lib/webbluetooth/bindings.js +368 -0
- package/lib/websocket/bindings.js +321 -0
- package/lib/win/binding.gyp +23 -0
- package/lib/win/bindings.js +11 -0
- package/lib/win/src/ble_manager.cc +802 -0
- package/lib/win/src/ble_manager.h +77 -0
- package/lib/win/src/callbacks.cc +274 -0
- package/lib/win/src/callbacks.h +33 -0
- package/lib/win/src/napi_winrt.cc +76 -0
- package/lib/win/src/napi_winrt.h +12 -0
- package/lib/win/src/noble_winrt.cc +308 -0
- package/lib/win/src/noble_winrt.h +34 -0
- package/lib/win/src/notify_map.cc +62 -0
- package/lib/win/src/notify_map.h +50 -0
- package/lib/win/src/peripheral.h +23 -0
- package/lib/win/src/peripheral_winrt.cc +296 -0
- package/lib/win/src/peripheral_winrt.h +82 -0
- package/lib/win/src/radio_watcher.cc +125 -0
- package/lib/win/src/radio_watcher.h +61 -0
- package/lib/win/src/winrt_cpp.cc +82 -0
- package/lib/win/src/winrt_cpp.h +11 -0
- package/lib/win/src/winrt_guid.cc +12 -0
- package/lib/win/src/winrt_guid.h +13 -0
- package/misc/nrf52840dk.hex +6921 -0
- package/misc/prj.conf +43 -0
- package/package.json +96 -0
- package/test/lib/characteristic.test.js +791 -0
- package/test/lib/descriptor.test.js +249 -0
- package/test/lib/distributed/bindings.test.js +918 -0
- package/test/lib/hci-socket/acl-stream.test.js +188 -0
- package/test/lib/hci-socket/bindings.test.js +1756 -0
- package/test/lib/hci-socket/crypto.test.js +55 -0
- package/test/lib/hci-socket/gap.test.js +1089 -0
- package/test/lib/hci-socket/gatt.test.js +2392 -0
- package/test/lib/hci-socket/hci.test.js +1891 -0
- package/test/lib/hci-socket/signaling.test.js +94 -0
- package/test/lib/hci-socket/smp.test.js +268 -0
- package/test/lib/manufacture.test.js +77 -0
- package/test/lib/peripheral.test.js +623 -0
- package/test/lib/resolve-bindings.test.js +102 -0
- package/test/lib/service.test.js +195 -0
- package/test/lib/webbluetooth/bindings.test.js +190 -0
- package/test/lib/websocket/bindings.test.js +456 -0
- package/test/noble.test.js +1565 -0
- package/test.js +131 -0
- package/with-bindings.js +5 -0
- package/ws-slave.js +404 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const should = require('should');
|
|
2
|
+
const sinon = require('sinon');
|
|
3
|
+
const cryptoLib = require('crypto');
|
|
4
|
+
|
|
5
|
+
const { assert } = sinon;
|
|
6
|
+
|
|
7
|
+
const crypto = require('../../../lib/hci-socket/crypto');
|
|
8
|
+
|
|
9
|
+
describe('hci-socket crypto', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
sinon.spy(cryptoLib, 'randomBytes');
|
|
12
|
+
sinon.spy(cryptoLib, 'createCipheriv');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
cryptoLib.randomBytes.restore();
|
|
17
|
+
cryptoLib.createCipheriv.restore();
|
|
18
|
+
sinon.reset();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should generate a random on 16 bytes', () => {
|
|
22
|
+
const result1 = crypto.r();
|
|
23
|
+
const result2 = crypto.r();
|
|
24
|
+
|
|
25
|
+
should(result1).have.size(16);
|
|
26
|
+
should(result2).have.size(16);
|
|
27
|
+
should(result1).not.equal(result2);
|
|
28
|
+
|
|
29
|
+
assert.calledTwice(cryptoLib.randomBytes);
|
|
30
|
+
assert.calledWithExactly(cryptoLib.randomBytes, 16);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should compute s1', () => {
|
|
34
|
+
const key = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
|
|
35
|
+
const r1 = Buffer.from([29, 30, 31, 32, 33, 34, 35, 36, 4, 5, 6]);
|
|
36
|
+
const r2 = Buffer.from([21, 22, 23, 24, 25, 26, 27, 28, 1, 2, 3]);
|
|
37
|
+
|
|
38
|
+
const result = crypto.s1(key, r1, r2);
|
|
39
|
+
|
|
40
|
+
const expectedResult = Buffer.from([0xab, 0xa0, 0x44, 0x06, 0x3b, 0xdc, 0x1c, 0x5d, 0x3c, 0x68, 0x0e, 0xdb, 0xc7, 0x9b, 0xe7, 0xc3]);
|
|
41
|
+
should(result).deepEqual(expectedResult);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should compute e', () => {
|
|
45
|
+
const key = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
|
|
46
|
+
const data = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36];
|
|
47
|
+
const swapKey = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
|
|
48
|
+
|
|
49
|
+
const result = crypto.e(key, data);
|
|
50
|
+
|
|
51
|
+
const expectedResult = Buffer.from([0xab, 0xa0, 0x44, 0x06, 0x3b, 0xdc, 0x1c, 0x5d, 0x3c, 0x68, 0x0e, 0xdb, 0xc7, 0x9b, 0xe7, 0xc3]);
|
|
52
|
+
should(result).deepEqual(expectedResult);
|
|
53
|
+
assert.calledOnceWithMatch(cryptoLib.createCipheriv, 'aes-128-ecb', sinon.match(Buffer.from(swapKey)), '');
|
|
54
|
+
});
|
|
55
|
+
});
|