boho 2.2.0 → 2.2.1
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/README.ko.md +320 -0
- package/README.md +255 -76
- package/package.json +1 -1
package/README.ko.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Boho
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [한국어](README.ko.md)
|
|
4
|
+
|
|
5
|
+
**Node.js, 브라우저, Arduino를 위한 경량 암호화 및 인증 프로토콜**
|
|
6
|
+
|
|
7
|
+
Boho는 공유 키 기반 인증과 바이너리 암호화 메시지를 제공하는 JavaScript 라이브러리입니다. Node.js와 브라우저에서 동작하며, Arduino용 구현은 별도 저장소에서 제공합니다. 현재 프로토콜은 SHA-256을 조합한 자체 암호 구성이며, 표준 AEAD나 TLS의 보안 보장과 동일하게 취급하지 않아야 합니다.
|
|
8
|
+
|
|
9
|
+
- `boho`는 **보호**를 의미합니다.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 왜 boho를 만들었나요?
|
|
14
|
+
|
|
15
|
+
boho는 **통신할 양쪽의 코드와 키 설정을 직접 관리할 수 있는 환경**을 위해
|
|
16
|
+
만들었습니다. Arduino 장치와 직접 작성한 웹앱, 개인 서버처럼 통신 상대가
|
|
17
|
+
정해져 있다면, 먼저 비밀 키를 안전하게 설정하고 그 키로 인증과 암호화를
|
|
18
|
+
수행하는 구성이 가능합니다.
|
|
19
|
+
|
|
20
|
+
이미 많은 암호 알고리즘이 있지만, 실제 개발에는 상대 인증, 메시지 형식,
|
|
21
|
+
키 설정, 장치와 브라우저의 호환성도 필요합니다. boho는 SHA-256 기반 키스트림,
|
|
22
|
+
XOR 암호화, 공유 키 인증과 바이너리 패킷을 묶어 이 연결을 구성합니다.
|
|
23
|
+
차별점은 XOR 자체의 새로움이 아니라 **Arduino·Node.js·브라우저에서 같은
|
|
24
|
+
방식으로 사용할 수 있는 구현과 응용 구조**입니다.
|
|
25
|
+
|
|
26
|
+
### 사전 공유 대칭키가 적합한 환경
|
|
27
|
+
|
|
28
|
+
| 환경 | 키를 설정하는 방법의 예 |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| 직접 제작하는 임베디드 장치 | 제작·설치 시 USB나 직렬 연결로 장치별 키 주입 |
|
|
31
|
+
| 직접 관리하는 웹앱과 개인 장치 | 사용자가 별도 경로로 받은 키를 입력하거나 신뢰할 수 있는 페어링 절차로 등록 |
|
|
32
|
+
| 관리 주체가 같은 서버 사이 | SSH, 기존 TLS 연결, 비밀 관리 시스템으로 키 배포 |
|
|
33
|
+
|
|
34
|
+
이처럼 최초 키 공유를 해결할 수 있다면, 적절한 대칭키 암호화와 인증으로도
|
|
35
|
+
안전한 통신을 설계할 수 있습니다. 인증기관 없이 공유 키를 확인하는 상대 인증도
|
|
36
|
+
가능합니다. 이때 신뢰의 기반은 키 설정 경로와 양쪽 프로그램입니다.
|
|
37
|
+
키를 여러 장치에 공통으로 배포하면 유출 영향과 인증 범위도 함께 넓어지므로
|
|
38
|
+
장치별 키와 교체·폐기 방법을 마련해야 합니다.
|
|
39
|
+
|
|
40
|
+
웹앱의 코드를 직접 작성한다고 키가 자동으로 비밀이 되지는 않습니다.
|
|
41
|
+
공개 JavaScript 번들에 공통 비밀 키를 포함하면 방문자가 읽을 수 있습니다.
|
|
42
|
+
|
|
43
|
+
### XOR와 OTP의 기초 원리
|
|
44
|
+
|
|
45
|
+
XOR는 같은 값으로 두 번 연산하면 원래 값으로 돌아오는 매우 단순한 연산입니다.
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
암호화: C = P XOR S
|
|
49
|
+
복호화: P = C XOR S
|
|
50
|
+
|
|
51
|
+
P: 평문, C: 암호문, S: 키스트림
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
평문과 독립적인 완전한 무작위 키스트림을 데이터 길이만큼 준비하여 비밀로
|
|
55
|
+
유지하고 한 번만 쓰면, 일회용 패드(One-Time Pad, OTP)의 완전한 비밀성을
|
|
56
|
+
얻습니다. 단순한 XOR도 이런 조건에서는 강력한 암호화의 기반이 됩니다.
|
|
57
|
+
문제는 1MB 데이터를 보낼 때마다 새로운 1MB 비밀 패드를 양쪽에 공급해야 한다는
|
|
58
|
+
점입니다. 짧은 고정 키를 반복하여 XOR하는 방식은 이 조건을 만족하지 않습니다.
|
|
59
|
+
|
|
60
|
+
같은 키스트림을 두 번 사용하면 `C1 XOR C2 = P1 XOR P2`가 되어 평문 사이의
|
|
61
|
+
관계가 노출됩니다. 안전성을 결정하는 것은 XOR의 복잡도가 아니라 키스트림의
|
|
62
|
+
생성과 재사용 방지입니다.
|
|
63
|
+
|
|
64
|
+
### SHA-256 출력으로 만드는 ‘가상 OTP’
|
|
65
|
+
|
|
66
|
+
충분히 예측하기 어려운 비밀 입력과 메시지별 값을 해시에 넣고, 블록 번호를
|
|
67
|
+
바꾸며 출력을 생성하면 필요한 길이의 키스트림을 만드는 구성을 생각할 수 있습니다.
|
|
68
|
+
양쪽이 같은 입력을 사용하면 같은 출력을 재현하므로 전체 패드를 미리 저장하거나
|
|
69
|
+
전송할 필요가 없습니다. boho의 일반적인 `set_key` 경로는 다음과 같습니다.
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
K = SHA256(입력 키)
|
|
73
|
+
B = SHA256(K || salt12)
|
|
74
|
+
S1 = SHA256(B || LE32(1))
|
|
75
|
+
S2 = SHA256(B || LE32(2))
|
|
76
|
+
…
|
|
77
|
+
S = S1 || S2 || … // 평문 길이만큼 사용
|
|
78
|
+
C = P XOR S
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`||`는 바이트열 연결, `LE32`는 4바이트 little-endian 정수입니다.
|
|
82
|
+
SHA-256 출력은 32바이트이므로 70바이트 평문에는 두 블록과 세 번째 블록의
|
|
83
|
+
앞 6바이트를 사용합니다. 복호화는 해시를 역산하지 않고 같은 키스트림으로 XOR합니다.
|
|
84
|
+
|
|
85
|
+
`salt12`는 초 단위 시각 4바이트, 밀리초 2바이트, 카운터 2바이트와 nonce
|
|
86
|
+
4바이트로 구성됩니다. 이 정보는 비밀 키가 아니며 수신자도 얻을 수 있습니다.
|
|
87
|
+
**공개된 랜덤 값만 해시하면 누구나 같은 출력을 계산할 수 있습니다.** 비밀
|
|
88
|
+
키스트림의 핵심은 공유 비밀 키이고, 같은 키 아래에서 `salt12`를 재사용하지
|
|
89
|
+
않는 것도 중요합니다.
|
|
90
|
+
|
|
91
|
+
여기서 ‘가상 OTP’는 해시 기반 의사난수 키스트림을 설명하는 표현입니다.
|
|
92
|
+
짧은 키에서 긴 출력을 만들기 때문에 진짜 OTP의 정보이론적 안전성과는 다릅니다.
|
|
93
|
+
표준 SHA-256을 사용한다는 사실만으로 조합 전체의 안전성이 보장되지는 않습니다.
|
|
94
|
+
키스트림과 XOR라는 큰 구조는 [ChaCha20](https://www.rfc-editor.org/rfc/rfc8439.html#section-2.4)에도
|
|
95
|
+
쓰이지만, boho는 이와 별개의 자체 구성입니다.
|
|
96
|
+
|
|
97
|
+
XOR만으로는 변조를 검출할 수 없으므로, boho의 데이터 패킷에는
|
|
98
|
+
`SHA256(K || salt12 || 평문)`의 앞 8바이트로 계산한 검증 태그도 포함됩니다.
|
|
99
|
+
기존 코드의 `HMAC` 명칭과 달리 이 태그는 표준 HMAC이 아닙니다.
|
|
100
|
+
수신자는 복호화와 태그 검증이 모두 성공한 데이터만 사용해야 합니다.
|
|
101
|
+
|
|
102
|
+
### TLS와 비교할 때의 관점
|
|
103
|
+
|
|
104
|
+
일반적인 인증서 기반 TLS는 미리 비밀을 공유하지 않은 상대와 인증 및 키 합의를
|
|
105
|
+
수행하고, 실제 데이터는 대칭키로 보호합니다. 따라서 웹 서비스는 방문자에게
|
|
106
|
+
비밀 키를 미리 배포하지 않아도 됩니다. 로그인하지 않은 사용자도 서버를 인증하고
|
|
107
|
+
암호화 연결을 만들 수 있지만, 이는 네트워크 익명성을 제공한다는 뜻은 아닙니다.
|
|
108
|
+
|
|
109
|
+
작은 임베디드 프로젝트에서는 인증서 체인, 신뢰 루트, 유효기간과 시각 관리,
|
|
110
|
+
갱신, 핸드셰이크 연산과 버퍼가 부담이 될 수 있습니다. 비용은 인증서 구매비만이
|
|
111
|
+
아니라 코드 크기, 메모리, 전력과 운영 시간도 포함합니다. 이미 안전하게 키를
|
|
112
|
+
설정할 수 있는 환경에서는 이런 구성 중 일부를 줄일 여지가 있습니다.
|
|
113
|
+
|
|
114
|
+
다만 **TLS도 PSK-only 및 PSK+(EC)DHE 방식을 지원**하므로, TLS를 항상 공개키와
|
|
115
|
+
제3자 인증서가 필요한 방식으로 구분해서는 안 됩니다.
|
|
116
|
+
[TLS 1.3의 PSK 방식](https://www.rfc-editor.org/rfc/rfc8446.html#section-2.2)
|
|
117
|
+
|
|
118
|
+
boho의 경량화 목표는 공개키 연산과 인증서 처리를 구성에서 제외하고, 응용 패킷
|
|
119
|
+
보호와 공유 키 인증을 제공하는 것입니다. 모든 장치에서 TLS나 표준 대칭키
|
|
120
|
+
구현보다 빠르거나 메모리를 덜 사용한다는 뜻은 아니며 실제 비교에는 측정이 필요합니다.
|
|
121
|
+
|
|
122
|
+
### Arduino·웹앱·IOSignal에서의 활용
|
|
123
|
+
|
|
124
|
+
boho의 Arduino와 JavaScript 구현으로 DIY 장치, Node.js 서버, 브라우저 웹앱
|
|
125
|
+
사이에 암호화 패킷을 교환할 수 있습니다. boho가 암호화·인증을 담당하고,
|
|
126
|
+
[IOSignal](https://github.com/remocons/iosignal)과
|
|
127
|
+
[IOSignal for Arduino](https://github.com/remocons/iosignal-arduino)가 연결과 메시지 전달을 담당합니다.
|
|
128
|
+
|
|
129
|
+
연결 인증용 키와 종단간 암호화(E2E)용 데이터 키는 목적이 다릅니다. 중계 서버가
|
|
130
|
+
본문을 읽지 못하게 하려면 최종 송수신자만 별도의 데이터 키를 공유해야 합니다.
|
|
131
|
+
일반 연결 암호화만으로 E2E가 되지는 않으며, E2E도 라우팅 정보와 트래픽 크기를
|
|
132
|
+
모두 숨기지는 않습니다.
|
|
133
|
+
|
|
134
|
+
웹앱 코드가 변조되면 키와 평문도 노출될 수 있으므로 일반 웹 배포에서는
|
|
135
|
+
HTTPS/WSS와 함께 사용할 수 있습니다. boho는 브라우저의 mixed content 정책을
|
|
136
|
+
우회하지 않으며, E2E에서도 웹앱 코드 제공자에 대한 신뢰는 필요합니다.
|
|
137
|
+
|
|
138
|
+
### 적용할 때 함께 확인할 조건
|
|
139
|
+
|
|
140
|
+
- 강한 무작위 키를 사용해야 합니다. `set_key`의 SHA-256 한 번은 짧은 비밀번호용 느린 KDF가 아닙니다.
|
|
141
|
+
- JavaScript는 `crypto.getRandomValues()`를 사용하지만 현재 Arduino 구현은 독립 패킷과 인증 요청의 클라이언트 nonce에 `micros()`를 사용합니다. 이는 암호학적 난수가 아니므로 재시작·여러 장치·통신 방향을 포함한 키와 `salt12` 중복을 검토해야 합니다.
|
|
142
|
+
- 유효한 태그만으로 새 메시지임을 알 수 없습니다. challenge 만료, 재전송 거부, 순서와 실행 권한은 호출 측에서 관리해야 합니다.
|
|
143
|
+
- boho는 자체 프로토콜입니다. 표준 AEAD/TLS와 같은 보안 보장이나 장기 키 유출 후 과거 통신을 보호하는 순방향 비밀성을 제공한다고 취급해서는 안 됩니다.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 주요 기능
|
|
148
|
+
|
|
149
|
+
- 범용 암호화 및 복호화
|
|
150
|
+
- 상호 인증 프로토콜 (아래 참조)
|
|
151
|
+
- 인증 후 보안 통신
|
|
152
|
+
- 종단간(End-to-End) 대칭 암호화
|
|
153
|
+
- TypeScript 타입 정의 포함
|
|
154
|
+
- JavaScript (Node.js, 브라우저) 및 C/C++ (Arduino) 지원
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 라이브러리
|
|
159
|
+
|
|
160
|
+
- **JavaScript:** Node.js, 웹 브라우저 ([GitHub](https://github.com/remocons/boho))
|
|
161
|
+
- **C/C++:** Arduino ([GitHub](https://github.com/remocons/boho-arduino))
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 대표적인 사용 사례
|
|
166
|
+
|
|
167
|
+
- WebSocket 인증 및 보안 메시징
|
|
168
|
+
- 보안 TCP/직렬/스트림 통신
|
|
169
|
+
- 보안 MQTT 페이로드
|
|
170
|
+
- 로컬 파일 암호화
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 주요 API
|
|
175
|
+
|
|
176
|
+
- `encryptPack`, `decryptPack`: 범용 암호화/복호화
|
|
177
|
+
- `encrypt_488`, `decrypt_488`: 인증 후 보안 통신
|
|
178
|
+
- `encrypt_e2e`, `decrypt_e2e`: 종단간 암호화
|
|
179
|
+
- `RAND(size)`: 안전한 랜덤 버퍼 생성
|
|
180
|
+
- `sha256.hash`, `sha256.hex`, `sha256.base64`, `sha256.hmac`: 해싱 유틸리티
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 인증 프로토콜 (요약)
|
|
185
|
+
|
|
186
|
+
boho 라이브러리의 서버-클라이언트 인증(AUTH) 프로세스는 다음과 같은 단계로 이루어집니다.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### 1. 서버 → 클라이언트: SERVER_TIME_NONCE
|
|
191
|
+
|
|
192
|
+
- 서버는 현재 시각(초/밀리초)과 랜덤 nonce를 포함한 `SERVER_TIME_NONCE` 메시지를 클라이언트에 보냅니다.
|
|
193
|
+
- 메시지 타입: `BohoMsg.SERVER_TIME_NONCE`
|
|
194
|
+
- 내용: unixTime, milTime, nonce
|
|
195
|
+
|
|
196
|
+
### 2. 클라이언트 → 서버: AUTH_REQ
|
|
197
|
+
|
|
198
|
+
- 클라이언트는 서버로부터 받은 nonce와 시각 정보를 바탕으로 salt12를 생성하고, 자신의 nonce를 새로 만듭니다. JavaScript는 랜덤 nonce를, 현재 Arduino는 `micros()`를 사용합니다.
|
|
199
|
+
- salt12와 자신의 nonce를 합쳐 인증 태그를 생성한 뒤, `AUTH_REQ` 메시지로 서버에 전송합니다.
|
|
200
|
+
- 메시지 타입: `BohoMsg.AUTH_REQ`
|
|
201
|
+
- 내용: id8, clientNonce, hmac32
|
|
202
|
+
|
|
203
|
+
### 3. 서버: AUTH_REQ 검증 및 응답
|
|
204
|
+
|
|
205
|
+
- 서버는 클라이언트의 인증 태그가 올바른지 검증합니다.
|
|
206
|
+
- 검증 성공 시, 서버는 자신의 인증 태그를 생성하여 `AUTH_RES` 메시지로 클라이언트에 응답합니다.
|
|
207
|
+
- 실패 시, `AUTH_FAIL` 메시지를 보낼 수 있습니다.
|
|
208
|
+
|
|
209
|
+
### 4. 클라이언트: AUTH_RES 검증
|
|
210
|
+
|
|
211
|
+
- 클라이언트는 서버의 `AUTH_RES` 메시지에 포함된 인증 태그가 올바른지 검증합니다.
|
|
212
|
+
- 검증이 성공하면, 양쪽 모두 `isAuthorized = true` 상태가 되어 이후 암호화 통신이 가능합니다.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### 메시지 플로우 요약
|
|
217
|
+
|
|
218
|
+
```mermaid
|
|
219
|
+
sequenceDiagram
|
|
220
|
+
participant Client
|
|
221
|
+
participant Server
|
|
222
|
+
|
|
223
|
+
Server->>Client: SERVER_TIME_NONCE (unixTime, milTime, nonce)
|
|
224
|
+
Client->>Server: AUTH_REQ (id8, clientNonce, hmac32)
|
|
225
|
+
Server->>Client: AUTH_RES (hmac32) / AUTH_FAIL
|
|
226
|
+
Client->>Client: AUTH_RES verification
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### 각 단계의 목적
|
|
232
|
+
|
|
233
|
+
- **SERVER_TIME_NONCE**: 서버가 연결별 challenge를 제공하고, 사용 수명과 재사용 정책은 호출 측이 관리
|
|
234
|
+
- **AUTH_REQ**: 클라이언트가 서버의 정보를 바탕으로 인증 태그 생성(서버가 검증)
|
|
235
|
+
- **AUTH_RES**: 서버가 클라이언트의 인증 성공을 알리고, 클라이언트는 서버의 인증 태그 검증 상호 인증
|
|
236
|
+
- **AUTH_FAIL**: 인증 실패 시 서버가 전송
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
### 특징 및 보안성
|
|
241
|
+
|
|
242
|
+
- 인증은 서버가 보관한 challenge 값에 대해 검증합니다. challenge의 만료·재사용 제한, 인증 시도 제한 및 최종 접속 승인은 iosignal 등 호출 측에서 관리합니다.
|
|
243
|
+
- 인증 태그 기반 상호 인증으로, 키를 노출하지 않고 인증 가능
|
|
244
|
+
- `ENC_488`은 양측 인증 후 사용합니다. `ENC_PACK`과 E2E는 별도의 사전 인증 없이 명시적으로 설정한 키로 동작합니다.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
boho의 인증 프로토콜은 서버와 클라이언트가 nonce와 시각 정보를 교환하고, 인증 태그를 통해 상호 인증하는 구조입니다. 이후 인증된 세션에서 암호화 메시지를 교환합니다.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 사용 예제
|
|
253
|
+
|
|
254
|
+
### 일반 데이터 암호화 및 복호화
|
|
255
|
+
|
|
256
|
+
```js
|
|
257
|
+
import Boho from 'boho'
|
|
258
|
+
|
|
259
|
+
let boho = new Boho()
|
|
260
|
+
|
|
261
|
+
// 실제 통신에서는 상대와 안전하게 공유한 무작위 키를 사용합니다.
|
|
262
|
+
boho.set_key(Boho.RAND(32))
|
|
263
|
+
|
|
264
|
+
let data = 'aaaaaaaa'
|
|
265
|
+
|
|
266
|
+
let encData = boho.encryptPack( data )
|
|
267
|
+
console.log('encData buffer:', encData )
|
|
268
|
+
let result = boho.decryptPack( encData )
|
|
269
|
+
|
|
270
|
+
if(result){
|
|
271
|
+
console.log('result object:', result )
|
|
272
|
+
printMessage(result.data) // decode to string.
|
|
273
|
+
}else{
|
|
274
|
+
console.log('decryption is fail')
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function printMessage(data){
|
|
278
|
+
let dataStr = new TextDecoder().decode( data )
|
|
279
|
+
console.log('\n result string:',dataStr)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Boho를 사용한 인증 및 보안 통신 예제는 `IOSignal`을 참고하세요.
|
|
285
|
+
|
|
286
|
+
- `iosignal` ([GitHub](https://github.com/remocons/iosignal))
|
|
287
|
+
- test/AUTH_process.js
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## TypeScript 지원
|
|
292
|
+
|
|
293
|
+
기본 export인 `Boho` 클래스와 `Boho.RAND`, `Boho.Buffer`, `Boho.MBP` 등의 정적 속성에 타입 정의를 제공합니다. `import Boho from 'boho'`를 사용하세요. `import { Boho, RAND } from 'boho'` 형태의 값 export는 제공하지 않습니다.
|
|
294
|
+
|
|
295
|
+
## 수신 정책과 보안 범위
|
|
296
|
+
|
|
297
|
+
- 내부 메서드 이름의 `HMAC`과 패킷 필드의 `hmac`은 호환성을 위한 기존 이름입니다. 실제 프로토콜 태그는 `SHA256(내부 키 || salt || 데이터)`이며, 표준 HMAC이 아닙니다. 유틸리티 `Boho.sha256.hmac(key, data)`는 표준 HMAC입니다.
|
|
298
|
+
- `set_key`는 비어 있지 않은 키를 요구합니다. 키 미설정 상태의 `encryptPack`은 예외를 발생시키며, `clearAuth`는 키도 삭제합니다. `copy_key`는 정확히 32바이트만 허용합니다.
|
|
299
|
+
- Boho는 중복 수신 캐시나 인증 단계 제한을 강제하지 않습니다. `ENC_488`의 중복·순서·시간 신선도 검사, challenge 만료 및 접속 상태 관리는 iosignal 등 호출 측 책임입니다. 인증 태그가 유효하다는 사실만으로 새 메시지임을 보장하지 않습니다.
|
|
300
|
+
- `set_key`/`copy_key`는 기존 `isAuthorized`를 자동 변경하지 않습니다. 재인증·키 교체·종료 시 호출 측이 상태를 명시적으로 관리해야 합니다.
|
|
301
|
+
- JS 송신은 시계가 뒤로 이동하거나 카운터가 같은 밀리초 안에 순환해도 값이 증가하도록 유지합니다. 수신은 기존 Arduino의 시간 보정·카운터 순환을 허용하며 수신 이력 정책을 적용하지 않습니다.
|
|
302
|
+
- `ENC_PACK`과 E2E는 독립 메시지/저장 데이터용이며 반복 복호화를 허용합니다. 이 API의 재전송 검출은 호출 측 책임입니다.
|
|
303
|
+
- 잘린 패킷, 잘못된 유형/길이, 검증값 불일치는 복호화 시 `undefined`로 거부합니다. `ENC_PACK`/`ENC_488`은 추가 바이트도 거부합니다. iosignal의 `ENC_E2E`는 예외로, 선언된 길이의 라우팅 헤더만 복호화하고 뒤의 E2E 본문은 전달 계층이 보존합니다. 이 본문의 검증은 최종 수신자의 `decrypt_e2e`가 담당합니다.
|
|
304
|
+
- 짧은 비밀번호를 위한 느린 KDF, 순방향 비밀성, E2E 키 배포는 제공하지 않습니다. nonce 및 태그 크기를 포함한 암호 설계 개선은 새 프로토콜 버전에서 다뤄야 합니다.
|
|
305
|
+
|
|
306
|
+
## 개발 검증
|
|
307
|
+
|
|
308
|
+
`npm test`는 배포 파일을 먼저 재빌드하고, 소스·ESM·브라우저 UMD(Node VM)의 회귀 테스트와 TypeScript 검사를 수행합니다. 실제 브라우저 및 물리 Arduino 장치 검사는 별도입니다.
|
|
309
|
+
|
|
310
|
+
`npm run test:arduino`는 인접한 `../boho-arduino/src/Boho.cpp`를 수정 없이 호스트 C++ 컴파일러로 빌드해 JS와 양방향 통신을 검증합니다. 다른 위치는 `BOHO_ARDUINO_PATH` 환경 변수로 지정하세요. macOS는 CommonCrypto, 다른 호스트는 OpenSSL 개발 라이브러리가 필요합니다. 테스트용 시계·Serial·SHA-256 어댑터를 사용하므로 물리 장치 테스트를 대체하지 않습니다.
|
|
311
|
+
|
|
312
|
+
`npm run test:iosignal`은 인접한 `../iosignal` 및 `../iosignal-arduino`의 실제 소스를 사용합니다. 수정 Boho를 JS 서버와 클라이언트에 로더로 주입하고, Arduino IOSignal의 80바이트 RX 버퍼와 메모리 전송 계층으로 인증·일반 통신·E2EE 양방향 경로를 검사합니다. `IOSIGNAL_PATH`, `IOSIGNAL_ARDUINO_PATH`로 경로를 지정할 수 있습니다. 실제 AVR의 SRAM 사용량이나 물리 네트워크를 검증하는 테스트는 아닙니다.
|
|
313
|
+
|
|
314
|
+
오류 목록과 호환성 영향은 [수정 내역](docs/SECURITY_FIXES.md)을 참고하세요.
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## 라이선스
|
|
319
|
+
|
|
320
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,77 +1,235 @@
|
|
|
1
|
+
# Boho
|
|
1
2
|
|
|
3
|
+
[English](README.md) | [한국어](README.ko.md)
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
**Lightweight encryption and authentication for Node.js, browsers and Arduino**
|
|
6
|
+
|
|
7
|
+
Boho is a JavaScript library providing shared-key authentication and encrypted
|
|
8
|
+
binary messages. It runs in Node.js and browsers; the Arduino implementation is
|
|
9
|
+
available in a separate repository. The current protocol is a custom SHA-256-based
|
|
10
|
+
construction and must not be treated as providing the same guarantees as standard
|
|
11
|
+
AEAD or TLS.
|
|
12
|
+
|
|
13
|
+
- `boho` means **protection** in Korean.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Why Boho?
|
|
18
|
+
|
|
19
|
+
Boho is designed for environments where **you control the code and key provisioning
|
|
20
|
+
at both endpoints**. With known peers such as an Arduino device, your own web app
|
|
21
|
+
and a personal server, you can provision a secret securely before using it for
|
|
22
|
+
authentication and encryption.
|
|
4
23
|
|
|
5
|
-
|
|
24
|
+
Many encryption algorithms already exist, but practical development also needs
|
|
25
|
+
peer authentication, packet formats, key provisioning and compatibility between
|
|
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.
|
|
6
30
|
|
|
7
|
-
|
|
31
|
+
### Where pre-shared symmetric keys fit
|
|
8
32
|
|
|
9
|
-
|
|
33
|
+
| Environment | Example provisioning path |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| Embedded devices you build | Provision device-specific keys over USB or serial during manufacture or installation |
|
|
36
|
+
| Your own web app and personal device | Users enter a key obtained separately, or register it through trusted pairing |
|
|
37
|
+
| Servers under common administration | Distribute keys through SSH, an existing TLS channel or a secret management system |
|
|
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.
|
|
45
|
+
|
|
46
|
+
Writing a web app yourself does not automatically keep its key secret. A common
|
|
47
|
+
secret included in a public JavaScript bundle is readable by visitors.
|
|
48
|
+
|
|
49
|
+
### XOR and one-time pads
|
|
50
|
+
|
|
51
|
+
XOR is a simple operation: applying it twice with the same value restores the
|
|
52
|
+
original value.
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
Encryption: C = P XOR S
|
|
56
|
+
Decryption: P = C XOR S
|
|
57
|
+
|
|
58
|
+
P: plaintext, C: ciphertext, S: keystream
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A uniformly random keystream that is independent of the plaintext, as long as the
|
|
62
|
+
data, kept secret and used only once provides the perfect secrecy of a one-time
|
|
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
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`||` means byte concatenation; `LE32` is a four-byte little-endian integer.
|
|
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.
|
|
10
160
|
|
|
11
161
|
---
|
|
12
162
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
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
|
|
20
171
|
|
|
21
172
|
---
|
|
22
173
|
|
|
23
|
-
##
|
|
24
|
-
|
|
174
|
+
## Libraries
|
|
175
|
+
|
|
176
|
+
- **JavaScript:** Node.js and browsers ([GitHub](https://github.com/remocons/boho))
|
|
25
177
|
- **C/C++:** Arduino ([GitHub](https://github.com/remocons/boho-arduino))
|
|
26
178
|
|
|
27
179
|
---
|
|
28
180
|
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
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
|
|
34
187
|
|
|
35
188
|
---
|
|
36
189
|
|
|
37
|
-
##
|
|
38
|
-
|
|
39
|
-
- `
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
- `
|
|
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
|
|
43
197
|
|
|
44
198
|
---
|
|
45
199
|
|
|
46
|
-
##
|
|
200
|
+
## Authentication protocol overview
|
|
47
201
|
|
|
48
|
-
|
|
202
|
+
The Boho client–server authentication (AUTH) exchange follows these steps.
|
|
49
203
|
|
|
50
204
|
---
|
|
51
205
|
|
|
52
|
-
### 1.
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
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
|
|
56
213
|
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
- 내용: id8, clientNonce, hmac32
|
|
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
|
|
62
218
|
|
|
63
|
-
### 3.
|
|
64
|
-
- 서버는 클라이언트의 인증 태그가 올바른지 검증합니다.
|
|
65
|
-
- 검증 성공 시, 서버는 자신의 인증 태그를 생성하여 `AUTH_RES` 메시지로 클라이언트에 응답합니다.
|
|
66
|
-
- 실패 시, `AUTH_FAIL` 메시지를 보낼 수 있습니다.
|
|
219
|
+
### 3. Server: verify AUTH_REQ and respond
|
|
67
220
|
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
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.
|
|
71
229
|
|
|
72
230
|
---
|
|
73
231
|
|
|
74
|
-
###
|
|
232
|
+
### Message flow
|
|
75
233
|
|
|
76
234
|
```mermaid
|
|
77
235
|
sequenceDiagram
|
|
@@ -86,36 +244,39 @@ sequenceDiagram
|
|
|
86
244
|
|
|
87
245
|
---
|
|
88
246
|
|
|
89
|
-
###
|
|
247
|
+
### Purpose of each step
|
|
90
248
|
|
|
91
|
-
- **SERVER_TIME_NONCE**:
|
|
92
|
-
- **AUTH_REQ**:
|
|
93
|
-
- **AUTH_RES**:
|
|
94
|
-
- **AUTH_FAIL**:
|
|
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.
|
|
95
253
|
|
|
96
254
|
---
|
|
97
255
|
|
|
98
|
-
###
|
|
256
|
+
### Properties and security scope
|
|
99
257
|
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
- `ENC_488
|
|
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.
|
|
103
261
|
|
|
104
262
|
---
|
|
105
263
|
|
|
106
|
-
|
|
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.
|
|
107
267
|
|
|
108
268
|
---
|
|
109
269
|
|
|
110
|
-
##
|
|
270
|
+
## Usage example
|
|
271
|
+
|
|
272
|
+
### General-purpose encryption and decryption
|
|
111
273
|
|
|
112
|
-
### 일반 데이터 암호화 및 복호화
|
|
113
274
|
```js
|
|
114
275
|
import Boho from 'boho'
|
|
115
276
|
|
|
116
277
|
let boho = new Boho()
|
|
117
278
|
|
|
118
|
-
//
|
|
279
|
+
// In real communication, use a random key securely shared with the peer.
|
|
119
280
|
boho.set_key(Boho.RAND(32))
|
|
120
281
|
|
|
121
282
|
let data = 'aaaaaaaa'
|
|
@@ -133,43 +294,61 @@ import Boho from 'boho'
|
|
|
133
294
|
|
|
134
295
|
function printMessage(data){
|
|
135
296
|
let dataStr = new TextDecoder().decode( data )
|
|
136
|
-
console.log('
|
|
137
|
-
result string:',dataStr)
|
|
297
|
+
console.log('\n result string:',dataStr)
|
|
138
298
|
}
|
|
139
299
|
|
|
140
300
|
```
|
|
141
301
|
|
|
142
|
-
###
|
|
302
|
+
### Authentication and encrypted communication examples
|
|
303
|
+
|
|
304
|
+
See `IOSignal` and the authentication example:
|
|
305
|
+
|
|
143
306
|
- `iosignal` ([GitHub](https://github.com/remocons/iosignal))
|
|
144
307
|
- test/AUTH_process.js
|
|
145
308
|
|
|
146
309
|
---
|
|
147
310
|
|
|
148
|
-
## TypeScript
|
|
149
|
-
|
|
311
|
+
## TypeScript support
|
|
312
|
+
|
|
313
|
+
Declarations cover the default-exported `Boho` class and static properties such
|
|
314
|
+
as `Boho.RAND`, `Boho.Buffer` and `Boho.MBP`. Use `import Boho from 'boho'`.
|
|
315
|
+
Named value exports such as `import { Boho, RAND } from 'boho'` are not provided.
|
|
150
316
|
|
|
151
|
-
##
|
|
317
|
+
## Receive policy and security scope
|
|
152
318
|
|
|
153
|
-
-
|
|
154
|
-
- `set_key
|
|
155
|
-
- Boho
|
|
156
|
-
- `set_key`/`copy_key
|
|
157
|
-
- JS
|
|
158
|
-
- `ENC_PACK
|
|
159
|
-
-
|
|
160
|
-
-
|
|
319
|
+
- Internal `HMAC` names and packet `hmac` fields are retained for compatibility. Protocol tags actually use `SHA256(internal key || salt || data)`, not standard HMAC. The utility `Boho.sha256.hmac(key, data)` is standard HMAC.
|
|
320
|
+
- `set_key` requires a nonempty key. `encryptPack` throws if no key is configured, and `clearAuth` also clears the key. `copy_key` accepts exactly 32 bytes.
|
|
321
|
+
- Boho does not enforce a duplicate-receive cache or authentication-stage restrictions. Duplicate, ordering and freshness checks for `ENC_488`, challenge expiry and connection state belong to the caller, such as IOSignal. A valid tag alone does not prove freshness.
|
|
322
|
+
- `set_key`/`copy_key` do not automatically change `isAuthorized`. The caller must explicitly manage state during reauthentication, key changes and shutdown.
|
|
323
|
+
- JS sending maintains increasing clock/counter values even if the clock moves backward or the counter wraps within the same millisecond. Receiving permits existing Arduino clock adjustments and counter wrapping, without enforcing receive-history policy.
|
|
324
|
+
- `ENC_PACK` and E2E support independent messages and stored data, permitting repeated decryption. Replay detection for these APIs belongs to the caller.
|
|
325
|
+
- Decryption rejects truncated packets, invalid types/lengths and tag mismatches with `undefined`. `ENC_PACK`/`ENC_488` also reject extra bytes. IOSignal's `ENC_E2E` is an exception: only the routing header of the declared length is decrypted, and the delivery layer preserves the trailing E2E body. The final recipient verifies that body with `decrypt_e2e`.
|
|
326
|
+
- A slow KDF for short passwords, forward secrecy and E2E key distribution are not provided. Cryptographic design changes, including nonce and tag sizes, require a new protocol version.
|
|
161
327
|
|
|
162
|
-
##
|
|
328
|
+
## Development checks
|
|
163
329
|
|
|
164
|
-
`npm test
|
|
330
|
+
`npm test` first rebuilds distribution files, then runs regression tests for the
|
|
331
|
+
source, ESM and browser UMD (in a Node VM), plus TypeScript checks. Actual browser
|
|
332
|
+
and physical Arduino tests are separate.
|
|
165
333
|
|
|
166
|
-
`npm run test:arduino
|
|
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.
|
|
167
339
|
|
|
168
|
-
`npm run test:iosignal
|
|
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.
|
|
169
346
|
|
|
170
|
-
|
|
347
|
+
See [security fixes](docs/SECURITY_FIXES.md) for the issue list and compatibility
|
|
348
|
+
impact.
|
|
171
349
|
|
|
172
350
|
---
|
|
173
351
|
|
|
174
|
-
##
|
|
352
|
+
## License
|
|
353
|
+
|
|
175
354
|
MIT
|