boho 1.1.0 → 1.1.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.md CHANGED
@@ -1,56 +1,113 @@
1
+ [ en | [kr](./docs/README-kr.md) ]
2
+
1
3
  # Boho
2
4
 
3
- Secure Lightweight Encryption & Authentication Library for Node.js, Browsers and Arduino.
5
+ **Secure Lightweight Encryption & Authentication Library for Node.js, Browsers, and Arduino**
6
+
7
+ Boho is a lightweight JavaScript library for robust encryption, authentication, and secure communication. Designed for Node.js, browsers, and embedded systems (such as Arduino), Boho provides simple APIs for random value generation, SHA256 hashing, HMAC, and secure message packing. It is ideal for IoT, embedded, and web applications that require strong security with minimal overhead.
8
+
9
+ - `boho` means Protection
10
+
11
+ ---
12
+
13
+ ## Features
14
+ - General-purpose encryption and decryption
15
+ - Mutual authentication protocol (see below)
16
+ - Secure communication after authentication
17
+ - End-to-End symmetric encryption
18
+ - TypeScript type definitions included
19
+ - Supports JavaScript (Node.js, Browser) and C/C++ (Arduino)
20
+
21
+ ---
22
+
23
+ ## Libraries
24
+ - **JavaScript:** Node.js, Web Browser ([GitHub](https://github.com/remocons/boho))
25
+ - **C/C++:** Arduino ([GitHub](https://github.com/remocons/boho-arduino))
26
+
27
+ ---
28
+
29
+ ## Typical Applications
30
+ - WebSocket authentication and secure messaging
31
+ - Secure TCP/Serial/Stream communication
32
+ - Secure MQTT payloads
33
+ - Local file encryption
34
+
35
+ ---
36
+
37
+ ## Core Concepts
38
+ - **SHA256** for hashing
39
+ - **xotp**: XOR-based one-time pad
40
+ - **generateOTP**: OTP generation
41
+ - **generateHMAC**: HMAC for authentication
42
+
43
+ ---
44
+
45
+ ## Main APIs
46
+ - `encryptPack`, `decryptPack`: General-purpose encryption/decryption
47
+ - `encrypt_488`, `decrypt_488`: Secure communication after authentication
48
+ - `encrypt_e2e`, `decrypt_e2e`: End-to-end encryption
49
+ - `RAND(size)`: Secure random buffer generation
50
+ - `sha256.hash`, `sha256.hex`, `sha256.base64`, `sha256.hmac`: Hashing utilities
51
+
52
+ ---
53
+
54
+ ## Authentication Protocol (Summary)
55
+ Boho uses a mutual authentication protocol based on random nonces and HMAC:
56
+
57
+ 1. **AUTH_REQ**: Client initiates authentication
58
+ 2. **AUTH_NONCE**: Server responds with time and random nonce
59
+ 3. **AUTH_HMAC**: Client sends HMAC using server's nonce and its own
60
+ 4. **AUTH_ACK**: Server verifies and responds with its own HMAC
61
+ 5. **AUTH_FAIL**: Sent by server if authentication fails
62
+
63
+ See [`AUTH_PROCESS.md`](./docs/AUTH_PROCESS.md) for a detailed protocol description.
4
64
 
5
- Boho is a lightweight JavaScript library that provides easy-to-use encryption, authentication, and secure communication features. Designed for both Node.js and browser environments, Boho offers simple APIs for generating random values, hashing, HMAC, and secure message packing, making it ideal for IoT, embedded, and web applications that require robust security with minimal overhead.
65
+ ### Authentication Message Flow Diagram
6
66
 
7
- - ``boho`` means Protection
67
+ ![Boho Auth Message Flow](./docs/auth_process_flow.svg)
8
68
 
9
- ## features
10
- - general encryption.
11
- - authentication.
12
- - secure communication.
13
- - End-to-End Encryption with Symmetric.
14
- - support JS & C/C++ for Arduino.
69
+ ---
15
70
 
16
- ## libraries
17
- - JavaScript: Node.js , Web Browser. [ [github](https://github.com/remocons/boho) ]
18
- - C/C++: Arduino [ [github](https://github.com/remocons/boho-arduino) ]
71
+ ## Example Usage
19
72
 
20
- ## applications
73
+ ### general data encryption & decryption
74
+ ```js
75
+ import Boho from 'boho'
21
76
 
22
- - Websocket authentication, secure communication.
23
- - secure TCP/Serial/Stream communication, authentication.
24
- - secure MQTT payload.
25
- - local file encryption.
77
+ let boho = new Boho()
26
78
 
27
- ## core
28
- - Using SHA256
29
- - xotp
30
- - generateOTP
31
- - generateHMAC
79
+ boho.set_key('abc' )
32
80
 
33
- ## general purpose encryption
81
+ let data = 'aaaaaaaa'
34
82
 
35
- - encryptPack
36
- - decryptPack
83
+ let encData = boho.encryptPack( data )
84
+ console.log('encData buffer:', encData )
85
+ let result = boho.decryptPack( encData )
86
+
87
+ if(result){
88
+ console.log('result object:', result )
89
+ printMessage(result.data) // decode to string.
90
+ }else{
91
+ console.log('decryption is fail')
92
+ }
37
93
 
94
+ function printMessage(data){
95
+ let dataStr = new TextDecoder().decode( data )
96
+ console.log('\n result string:',dataStr)
97
+ }
38
98
 
39
- ## authentication protocol.
99
+ ```
40
100
 
41
- - AUTH_REQ
42
- - AUTH_NONCE
43
- - AUTH_HMAC
44
- - check_auth_hmac
45
- - AUTH_ACK
46
- - check_auth_ack_hamc
47
- - AUTH_FAIL
101
+ ### For examples of authentication and secure communication using Boho, please refer to `IOSignal`.
102
+ - `iosignal` ([GitHub](https://github.com/remocons/iosignal))
103
+ - test/AUTH_process.js
48
104
 
49
- ## secure communication after auth.
105
+ ---
50
106
 
51
- - ENC_488
52
- - ENC_E2E
107
+ ## TypeScript Support
108
+ Boho provides full TypeScript type definitions. Simply install and import to get autocompletion and type checking in your TypeScript projects.
53
109
 
110
+ ---
54
111
 
55
- ## license
56
- - MIT
112
+ ## License
113
+ MIT