boho 2.2.1 → 3.0.0
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/.github/workflows/pages.yml +51 -0
- package/README.ko.md +92 -275
- package/README.md +95 -309
- package/dist/boho.d.ts +71 -186
- package/dist/boho.js +5 -5
- package/dist/boho.js.map +1 -1
- package/dist/boho.min.js +5 -5
- package/dist/boho.min.js.map +1 -1
- package/package.json +7 -5
- package/src/ascon.js +262 -0
- package/src/boho.js +268 -471
- package/src/constants.js +23 -107
- package/src/index.js +11 -20
- package/test/ascon.test.js +225 -0
- package/test/boho.test.js +190 -0
- package/test/fixtures/boho-vectors.json +370 -0
- package/test/iosignal/full-flow.test.js +4 -4
- package/test/iosignal/host.cpp +1 -1
- package/test/reference.js +175 -0
- package/test/types/api.mts +17 -13
- package/test/vectors.test.js +75 -0
- package/test-browser/index.html +25 -114
- package/tools/make-vectors.mjs +131 -0
- package/test/AUTH_process.js +0 -93
- package/test/ENC_PACK.js +0 -26
- package/test/RAND.js +0 -18
- package/test/arduino/host.cpp +0 -51
- package/test/arduino/interop.test.js +0 -89
- package/test/arduino/shims/Crypto.h +0 -1
- package/test/arduino/shims/SHA256.h +0 -46
- package/test/fixtures/legacy-pack.json +0 -5
- package/test/security-regressions.js +0 -196
package/README.md
CHANGED
|
@@ -2,352 +2,138 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | [한국어](README.ko.md)
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**Shared-key authentication and encrypted messages on standard Ascon, for Node.js, browsers and Arduino**
|
|
6
6
|
|
|
7
|
-
Boho is a JavaScript library
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
Boho is a JavaScript library for shared-key login and binary encrypted messages. It runs in Node.js and
|
|
8
|
+
browsers. Since **3.0.0** it is built on **Ascon** (NIST SP 800-232), the lightweight cryptography standard,
|
|
9
|
+
instead of the earlier custom SHA-256 construction (2.x). The Arduino implementation is part of
|
|
10
|
+
[IOSignal Arduino](https://github.com/remocons/iosignal-arduino) 10.0.0; Kotlin and Python implementations
|
|
11
|
+
exist for the IOSignal clients. All of them produce the same bytes (`test/fixtures/boho-vectors.json`).
|
|
12
12
|
|
|
13
13
|
- `boho` means **protection** in Korean.
|
|
14
14
|
|
|
15
|
+
> **3.0.0 is not compatible with 2.x.** The message codes and keys changed. A server that stored 2.x key
|
|
16
|
+
> hashes must register the keys again (it stores `Boho.deriveKey(key)` instead). IOSignal 10.0.0 uses boho 3.
|
|
17
|
+
|
|
15
18
|
---
|
|
16
19
|
|
|
17
20
|
## Why Boho?
|
|
18
21
|
|
|
19
|
-
Boho is
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
Boho is for environments where **you control the code and key provisioning at both endpoints**: an Arduino
|
|
23
|
+
device, your own web app, a personal server. A key installed over USB, entered by the user or delivered
|
|
24
|
+
through an existing SSH/TLS channel is enough to authenticate the peer and protect messages, without
|
|
25
|
+
certificates.
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
devices and browsers. Boho combines a SHA-256-based keystream, XOR encryption,
|
|
27
|
-
shared-key authentication and binary packets. Its distinction is **a common
|
|
28
|
-
implementation and application model for Arduino, Node.js and browsers**, rather
|
|
29
|
-
than novelty in XOR itself.
|
|
27
|
+
Boho does not invent cryptography. It puts a login handshake, session keys and compact binary packets on
|
|
28
|
+
Ascon, with compatible implementations for Arduino, JavaScript, Kotlin and Python.
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
## Algorithms
|
|
32
31
|
|
|
33
|
-
|
|
|
32
|
+
| Purpose | Algorithm |
|
|
34
33
|
| --- | --- |
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
If initial key sharing is handled, appropriate symmetric encryption and
|
|
40
|
-
authentication can provide secure communication. Peers can authenticate through
|
|
41
|
-
their shared key without a certificate authority. Trust rests on the provisioning
|
|
42
|
-
path and endpoint software. Sharing one key across many devices expands both its
|
|
43
|
-
authentication scope and the impact of a leak; plan device-specific keys,
|
|
44
|
-
rotation and revocation.
|
|
34
|
+
| Message encryption and tamper check | Ascon-AEAD128 (8-byte tag) |
|
|
35
|
+
| Key string → 16-byte key | Ascon-CXOF128 (customization `boho/v2/key`) |
|
|
36
|
+
| Login → session key and both proofs | Ascon-CXOF128 (customization `boho/v2/session`) |
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
Ascon is small and fast on 8-bit microcontrollers (one 320-bit state and one permutation do everything) and
|
|
39
|
+
uses no lookup tables, so it has no timing side channel. `Boho.ascon` exposes the primitives
|
|
40
|
+
(AEAD128, Hash256, XOF128, CXOF128).
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
## Messages
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
| Type | Code | Size | Use |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| `SERVER_TIME_NONCE` | 0xB0 | 13 B | Server challenge (time and random bytes) |
|
|
47
|
+
| `AUTH_REQ` | 0xB4 | 33 B | Client: ID, client nonce, client proof |
|
|
48
|
+
| `AUTH_RES` | 0xB5 | 17 B | Server proof |
|
|
49
|
+
| `AUTH_FAIL` | 0xB3 | 1 B | Login refused |
|
|
50
|
+
| `ENC` | 0xBB | 21 B + data | Message of a logged-in session |
|
|
51
|
+
| `ENC_E2E` | 0xBA | 21 B + header + body | Encrypted routing header followed by an E2E body |
|
|
52
|
+
| `ENC_PACK` | 0xB9 | 29 B + data | Standalone or E2E data with its own key |
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
Encryption: C = P XOR S
|
|
56
|
-
Decryption: P = C XOR S
|
|
54
|
+
Details: [docs/PROTOCOL.md](docs/PROTOCOL.md) (Korean).
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
```
|
|
56
|
+
## Install
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
pad (OTP). Under these conditions even simple XOR forms the basis of strong
|
|
64
|
-
encryption. The practical difficulty is supplying a new 1 MB secret pad to both
|
|
65
|
-
endpoints for every 1 MB of data. Repeating a short fixed key does not meet these
|
|
66
|
-
conditions.
|
|
67
|
-
|
|
68
|
-
Reusing a keystream exposes `C1 XOR C2 = P1 XOR P2`, revealing a relationship
|
|
69
|
-
between the plaintexts. Security depends on keystream generation and avoiding
|
|
70
|
-
reuse, not on the complexity of XOR.
|
|
71
|
-
|
|
72
|
-
### A “virtual OTP” generated with SHA-256
|
|
73
|
-
|
|
74
|
-
Hashing sufficiently unpredictable secret input together with message-specific
|
|
75
|
-
values, while varying a block index, can form a construction that generates a
|
|
76
|
-
keystream of the required length. Both peers can reproduce the same output from
|
|
77
|
-
the same input, without storing or transmitting the entire pad. Boho's usual
|
|
78
|
-
`set_key` path is:
|
|
79
|
-
|
|
80
|
-
```text
|
|
81
|
-
K = SHA256(input key)
|
|
82
|
-
B = SHA256(K || salt12)
|
|
83
|
-
S1 = SHA256(B || LE32(1))
|
|
84
|
-
S2 = SHA256(B || LE32(2))
|
|
85
|
-
…
|
|
86
|
-
S = S1 || S2 || … // use only the plaintext length
|
|
87
|
-
C = P XOR S
|
|
58
|
+
```sh
|
|
59
|
+
npm install boho
|
|
88
60
|
```
|
|
89
61
|
|
|
90
|
-
|
|
91
|
-
SHA-256 produces 32 bytes, so a 70-byte plaintext uses two full blocks and the
|
|
92
|
-
first six bytes of the third. Decryption XORs with the same keystream rather than
|
|
93
|
-
reversing the hash.
|
|
94
|
-
|
|
95
|
-
`salt12` contains seconds (4 bytes), milliseconds (2), a counter (2) and a nonce
|
|
96
|
-
(4). These values are not secret and are available to the receiver. **Anyone can
|
|
97
|
-
compute a hash of public random values alone.** The shared secret key is the
|
|
98
|
-
essential secret input; avoiding reuse of `salt12` under the same key is also
|
|
99
|
-
important.
|
|
100
|
-
|
|
101
|
-
“Virtual OTP” here describes a hash-based pseudorandom keystream. Expanding a short
|
|
102
|
-
key into a long output does not provide the information-theoretic security of a
|
|
103
|
-
true OTP. Using standard SHA-256 does not establish the security of the whole
|
|
104
|
-
construction. Keystream generation followed by XOR also appears in
|
|
105
|
-
[ChaCha20](https://www.rfc-editor.org/rfc/rfc8439.html#section-2.4), but Boho is a
|
|
106
|
-
separate custom construction.
|
|
107
|
-
|
|
108
|
-
XOR alone does not detect tampering. Boho data packets also contain a verification
|
|
109
|
-
tag: the first eight bytes of `SHA256(K || salt12 || plaintext)`. Despite the
|
|
110
|
-
legacy `HMAC` names in the code, this tag is not standard HMAC. Receivers must use
|
|
111
|
-
data only after decryption and tag verification succeed.
|
|
112
|
-
|
|
113
|
-
### Comparing with TLS
|
|
114
|
-
|
|
115
|
-
Typical certificate-based TLS authenticates peers and establishes keys without
|
|
116
|
-
requiring a previously shared secret, then protects application data with
|
|
117
|
-
symmetric encryption. Web services therefore do not need to distribute a secret
|
|
118
|
-
to each visitor in advance. Even users who have not logged in can authenticate a
|
|
119
|
-
server and establish an encrypted connection; this does not imply network
|
|
120
|
-
anonymity.
|
|
121
|
-
|
|
122
|
-
For small embedded projects, certificate chains, trust roots, validity and clock
|
|
123
|
-
management, renewal, handshake work and buffers can be burdensome. Costs include
|
|
124
|
-
code size, memory, power and operating time, not just certificate purchases.
|
|
125
|
-
Systems that can already provision keys securely may be able to omit some of
|
|
126
|
-
this machinery.
|
|
127
|
-
|
|
128
|
-
However, **TLS also supports PSK-only and PSK with (EC)DHE**, so it should not be
|
|
129
|
-
described as always requiring public-key exchange and third-party certificates.
|
|
130
|
-
[TLS 1.3 pre-shared keys](https://www.rfc-editor.org/rfc/rfc8446.html#section-2.2)
|
|
131
|
-
|
|
132
|
-
Boho's lightweight goal is to provide application-packet protection and shared-key
|
|
133
|
-
authentication without public-key operations or certificate handling in its
|
|
134
|
-
construction. This does not mean it is faster or uses less memory than every TLS
|
|
135
|
-
or standard symmetric implementation; actual comparisons require measurement.
|
|
136
|
-
|
|
137
|
-
### Arduino, web apps and IOSignal
|
|
138
|
-
|
|
139
|
-
Boho's Arduino and JavaScript implementations exchange encrypted packets between
|
|
140
|
-
DIY devices, Node.js servers and browser apps. Boho handles encryption and
|
|
141
|
-
authentication, while [IOSignal](https://github.com/remocons/iosignal) and
|
|
142
|
-
[IOSignal for Arduino](https://github.com/remocons/iosignal-arduino) handle
|
|
143
|
-
connections and message delivery.
|
|
144
|
-
|
|
145
|
-
Connection credentials and end-to-end (E2E) data keys serve different purposes.
|
|
146
|
-
To keep the body confidential from a relay, only the final endpoints should hold
|
|
147
|
-
its separate data key. Ordinary connection encryption is not automatically E2E,
|
|
148
|
-
and E2E does not hide all routing information or traffic sizes.
|
|
149
|
-
|
|
150
|
-
Modified web app code can expose keys and plaintext, so normal web deployments
|
|
151
|
-
can use HTTPS/WSS alongside Boho. Boho does not bypass browser mixed content
|
|
152
|
-
rules, and E2E still requires trust in the provider of the web app code.
|
|
153
|
-
|
|
154
|
-
### Conditions to check when applying Boho
|
|
155
|
-
|
|
156
|
-
- Use strong random keys. A single SHA-256 in `set_key` is not a slow password KDF.
|
|
157
|
-
- JavaScript uses `crypto.getRandomValues()`, but Arduino currently uses `micros()` for standalone-packet nonces and the authentication client nonce. This is not a cryptographic random source; consider repeated key/`salt12` combinations across restarts, devices and communication directions.
|
|
158
|
-
- A valid tag alone does not prove that a message is new. The caller manages challenge expiry, replay rejection, ordering and permission to execute commands.
|
|
159
|
-
- Boho is a custom protocol. Do not assume standard AEAD/TLS guarantees or forward secrecy protecting past traffic after a long-term key leak.
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
## Features
|
|
164
|
-
|
|
165
|
-
- General-purpose encryption and decryption
|
|
166
|
-
- Mutual authentication protocol (see below)
|
|
167
|
-
- Encrypted communication after authentication
|
|
168
|
-
- End-to-end symmetric encryption
|
|
169
|
-
- TypeScript declarations
|
|
170
|
-
- JavaScript (Node.js, browsers) and C/C++ (Arduino) implementations
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Libraries
|
|
175
|
-
|
|
176
|
-
- **JavaScript:** Node.js and browsers ([GitHub](https://github.com/remocons/boho))
|
|
177
|
-
- **C/C++:** Arduino ([GitHub](https://github.com/remocons/boho-arduino))
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## Typical use cases
|
|
182
|
-
|
|
183
|
-
- WebSocket authentication and encrypted messaging
|
|
184
|
-
- Encrypted TCP, serial and stream communication
|
|
185
|
-
- Encrypted MQTT payloads
|
|
186
|
-
- Local file encryption
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Main APIs
|
|
191
|
-
|
|
192
|
-
- `encryptPack`, `decryptPack`: general-purpose encryption and decryption
|
|
193
|
-
- `encrypt_488`, `decrypt_488`: encrypted communication after authentication
|
|
194
|
-
- `encrypt_e2e`, `decrypt_e2e`: end-to-end encryption
|
|
195
|
-
- `RAND(size)`: cryptographically secure random buffer generation
|
|
196
|
-
- `sha256.hash`, `sha256.hex`, `sha256.base64`, `sha256.hmac`: hashing utilities
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## Authentication protocol overview
|
|
201
|
-
|
|
202
|
-
The Boho client–server authentication (AUTH) exchange follows these steps.
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
### 1. Server → client: SERVER_TIME_NONCE
|
|
207
|
-
|
|
208
|
-
- The server sends `SERVER_TIME_NONCE` containing the current time (seconds/milliseconds) and a random nonce.
|
|
209
|
-
- Message type: `BohoMsg.SERVER_TIME_NONCE`
|
|
210
|
-
- Contents: unixTime, milTime, nonce
|
|
211
|
-
|
|
212
|
-
### 2. Client → server: AUTH_REQ
|
|
213
|
-
|
|
214
|
-
- The client constructs salt12 from the server's nonce and time, and creates its own nonce. JavaScript uses a random nonce; Arduino currently uses `micros()`.
|
|
215
|
-
- It computes an authentication tag using salt12 and its nonce, then sends `AUTH_REQ`.
|
|
216
|
-
- Message type: `BohoMsg.AUTH_REQ`
|
|
217
|
-
- Contents: id8, clientNonce, hmac32
|
|
218
|
-
|
|
219
|
-
### 3. Server: verify AUTH_REQ and respond
|
|
220
|
-
|
|
221
|
-
- The server verifies the client's authentication tag.
|
|
222
|
-
- On success, it generates its own tag and returns `AUTH_RES`.
|
|
223
|
-
- On failure, it may send `AUTH_FAIL`.
|
|
224
|
-
|
|
225
|
-
### 4. Client: verify AUTH_RES
|
|
226
|
-
|
|
227
|
-
- The client verifies the authentication tag in `AUTH_RES`.
|
|
228
|
-
- Once verification succeeds, both peers have `isAuthorized = true` and can exchange encrypted messages.
|
|
229
|
-
|
|
230
|
-
---
|
|
62
|
+
Browsers: `dist/boho.min.js` (UMD, global `Boho`) or `dist/boho.js` (ES module).
|
|
231
63
|
|
|
232
|
-
|
|
64
|
+
## Usage
|
|
233
65
|
|
|
234
|
-
|
|
235
|
-
sequenceDiagram
|
|
236
|
-
participant Client
|
|
237
|
-
participant Server
|
|
238
|
-
|
|
239
|
-
Server->>Client: SERVER_TIME_NONCE (unixTime, milTime, nonce)
|
|
240
|
-
Client->>Server: AUTH_REQ (id8, clientNonce, hmac32)
|
|
241
|
-
Server->>Client: AUTH_RES (hmac32) / AUTH_FAIL
|
|
242
|
-
Client->>Client: AUTH_RES verification
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
### Purpose of each step
|
|
248
|
-
|
|
249
|
-
- **SERVER_TIME_NONCE**: provides a per-connection server challenge; the caller manages its lifetime and reuse policy.
|
|
250
|
-
- **AUTH_REQ**: the client generates an authentication tag from the server's information for server verification.
|
|
251
|
-
- **AUTH_RES**: the server responds after verifying the client; the client verifies the server's tag for mutual authentication.
|
|
252
|
-
- **AUTH_FAIL**: the server sends this on authentication failure.
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
### Properties and security scope
|
|
257
|
-
|
|
258
|
-
- Authentication verifies against the challenge stored by the server. Challenge expiry and reuse restrictions, attempt limits and final connection approval belong to the caller, such as IOSignal.
|
|
259
|
-
- Tag-based mutual authentication avoids transmitting the key itself.
|
|
260
|
-
- `ENC_488` is used after mutual authentication. `ENC_PACK` and E2E operate with an explicitly configured key without requiring a prior authentication exchange.
|
|
261
|
-
|
|
262
|
-
---
|
|
263
|
-
|
|
264
|
-
Boho exchanges nonces and time information between the server and client, then
|
|
265
|
-
uses authentication tags for mutual authentication. The authenticated session can
|
|
266
|
-
subsequently exchange encrypted messages.
|
|
267
|
-
|
|
268
|
-
---
|
|
269
|
-
|
|
270
|
-
## Usage example
|
|
271
|
-
|
|
272
|
-
### General-purpose encryption and decryption
|
|
66
|
+
### Encrypt and decrypt data with a key
|
|
273
67
|
|
|
274
68
|
```js
|
|
275
69
|
import Boho from 'boho'
|
|
276
70
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
let data = 'aaaaaaaa'
|
|
283
|
-
|
|
284
|
-
let encData = boho.encryptPack( data )
|
|
285
|
-
console.log('encData buffer:', encData )
|
|
286
|
-
let result = boho.decryptPack( encData )
|
|
287
|
-
|
|
288
|
-
if(result){
|
|
289
|
-
console.log('result object:', result )
|
|
290
|
-
printMessage(result.data) // decode to string.
|
|
291
|
-
}else{
|
|
292
|
-
console.log('decryption is fail')
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function printMessage(data){
|
|
296
|
-
let dataStr = new TextDecoder().decode( data )
|
|
297
|
-
console.log('\n result string:',dataStr)
|
|
298
|
-
}
|
|
71
|
+
const boho = new Boho()
|
|
72
|
+
boho.set_key('a long random key')
|
|
73
|
+
const packet = boho.encryptPack('hello') // ENC_PACK
|
|
74
|
+
console.log(boho.decryptPack(packet).data.toString()) // 'hello'
|
|
299
75
|
|
|
76
|
+
// E2E: a separate data key shared only by the final endpoints
|
|
77
|
+
const sealed = boho.encrypt_e2e('secret', 'e2e-key')
|
|
78
|
+
console.log(boho.decrypt_e2e(sealed, 'e2e-key').data.toString())
|
|
300
79
|
```
|
|
301
80
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
See `IOSignal` and the authentication example:
|
|
81
|
+
`decryptPack` and `decrypt_e2e` return `{ data, ... }`, or `undefined` for a wrong key or a damaged packet.
|
|
305
82
|
|
|
306
|
-
|
|
307
|
-
- test/AUTH_process.js
|
|
83
|
+
### Login and session messages
|
|
308
84
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
85
|
+
```js
|
|
86
|
+
// Server: stores Boho.deriveKey(key) for the ID, never the key string
|
|
87
|
+
const server = new Boho()
|
|
88
|
+
server.copy_key(Boho.deriveKey('a long random key'))
|
|
89
|
+
const challenge = server.server_time_nonce() // send to the client
|
|
90
|
+
|
|
91
|
+
// Client
|
|
92
|
+
const client = new Boho()
|
|
93
|
+
client.set_id_key('dev1.a long random key')
|
|
94
|
+
const authReq = client.auth_req(challenge) // send to the server
|
|
95
|
+
|
|
96
|
+
// Server
|
|
97
|
+
const authRes = server.verify_auth_req(authReq) // false when the proof is wrong
|
|
98
|
+
// Client
|
|
99
|
+
client.verify_auth_res(authRes) // true: both sides are logged in
|
|
100
|
+
|
|
101
|
+
const up = client.encrypt_session('to server') // ENC
|
|
102
|
+
server.decrypt_session(up) // Buffer 'to server'
|
|
103
|
+
```
|
|
316
104
|
|
|
317
|
-
##
|
|
105
|
+
## Main APIs
|
|
318
106
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
107
|
+
| API | Description |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `Boho.deriveKey(key)` | Key string → 16-byte key (what a server stores) |
|
|
110
|
+
| `set_id8(id)`, `set_key(key)`, `set_id_key('id.key')`, `copy_key(key16)` | ID and key |
|
|
111
|
+
| `server_time_nonce()`, `verify_auth_req(packet[, challenge])` | Server side of the login |
|
|
112
|
+
| `auth_req(challenge)`, `verify_auth_res(packet)` | Client side of the login |
|
|
113
|
+
| `encrypt_session(data[, type])`, `decrypt_session(packet)` | `ENC` / `ENC_E2E` after login |
|
|
114
|
+
| `encryptPack(data)`, `decryptPack(packet)` | `ENC_PACK` with this side's key |
|
|
115
|
+
| `encrypt_e2e(data, key)`, `decrypt_e2e(packet, key)` | `ENC_PACK` with an E2E key |
|
|
116
|
+
| `Boho.BohoMsg`, `Boho.MetaSize` | Message codes and sizes |
|
|
117
|
+
| `Boho.ascon`, `Boho.sha256`, `Boho.RAND`, `Boho.MBP` | Primitives and helpers |
|
|
118
|
+
|
|
119
|
+
TypeScript definitions are in `dist/boho.d.ts`.
|
|
120
|
+
|
|
121
|
+
## Security scope
|
|
122
|
+
|
|
123
|
+
- Use sufficiently random keys. Key derivation is not a slow password KDF.
|
|
124
|
+
- Every login makes a new session key; senders keep increasing the clock and counter so nonces never repeat.
|
|
125
|
+
- Boho does not reject replays or expire challenges by itself; the application (the IOSignal server) does.
|
|
126
|
+
- There is no forward secrecy: a leaked long-term key exposes the traffic it protected.
|
|
127
|
+
- Boho does not replace HTTPS for delivering browser code that handles keys.
|
|
327
128
|
|
|
328
129
|
## Development checks
|
|
329
130
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
`npm run test:arduino` compiles the adjacent `../boho-arduino/src/Boho.cpp`
|
|
335
|
-
unchanged with a host C++ compiler and checks bidirectional JS communication.
|
|
336
|
-
Set `BOHO_ARDUINO_PATH` for a different location. macOS uses CommonCrypto; other
|
|
337
|
-
hosts need OpenSSL development libraries. Test clock, Serial and SHA-256 adapters
|
|
338
|
-
mean this does not replace physical device tests.
|
|
339
|
-
|
|
340
|
-
`npm run test:iosignal` uses the actual sources in adjacent `../iosignal` and
|
|
341
|
-
`../iosignal-arduino`. A loader injects the modified Boho into the JS server and
|
|
342
|
-
client, and tests authentication plus ordinary/E2EE traffic in both directions
|
|
343
|
-
using Arduino IOSignal's 80-byte RX buffer and an in-memory transport.
|
|
344
|
-
`IOSIGNAL_PATH` and `IOSIGNAL_ARDUINO_PATH` override those locations. This does not
|
|
345
|
-
test actual AVR SRAM usage or physical networking.
|
|
346
|
-
|
|
347
|
-
See [security fixes](docs/SECURITY_FIXES.md) for the issue list and compatibility
|
|
348
|
-
impact.
|
|
131
|
+
```sh
|
|
132
|
+
npm test # Ascon KATs, shared vectors, class tests, types
|
|
133
|
+
BOHO_ARDUINO_SRC=../iosignal-arduino/src npm test # also JS ↔ Arduino C++ (host build)
|
|
134
|
+
```
|
|
349
135
|
|
|
350
|
-
|
|
136
|
+
The earlier 2.x source is not part of the package; see the 2.x releases.
|
|
351
137
|
|
|
352
138
|
## License
|
|
353
139
|
|