Skip to content

Commit 3e10b18

Browse files
committed
update README
1 parent b114034 commit 3e10b18

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,33 @@ const jwe = new clientEncryption.JweEncryption(config);
259259
let responsePayload = jwe.decrypt(encryptedResponsePayload);
260260
```
261261

262+
**AES-CBC HMAC Authentication (A128CBC-HS256)**
263+
264+
For enhanced security when using AES-CBC mode (A128CBC-HS256), you can enable HMAC authentication tag verification. This ensures data authenticity and integrity according to the JWE specification (RFC 7516).
265+
266+
By default, HMAC verification is **disabled** for backward compatibility. To enable it:
267+
268+
```js
269+
config.enableHmacVerification = true;
270+
```
271+
272+
**When to enable HMAC verification:**
273+
- ✅ New integrations with systems that properly implement JWE A128CBC-HS256
274+
- ✅ When security and data authenticity are critical
275+
- ✅ When working with compliant JWE encryption sources
276+
277+
**When to keep it disabled (default):**
278+
- ⚠️ Legacy systems that don't compute HMAC tags correctly
279+
- ⚠️ Maintaining backward compatibility with existing deployments
280+
- ⚠️ Encryption sources that don't fully follow the JWE specification
281+
282+
**Technical Details:**
283+
When enabled, the library:
284+
- Splits the 256-bit Content Encryption Key (CEK) into a 128-bit HMAC key and 128-bit AES key
285+
- Computes HMAC-SHA256 over: AAD || IV || Ciphertext || AL (AAD length in bits)
286+
- Verifies the authentication tag (first 128 bits of HMAC output) before decryption
287+
- Throws an `Error` if the authentication tag is invalid
288+
262289
##### • Configuring the JWE Encryption <a name="configuring-the-jwe-encryption"></a>
263290

264291
`JweEncryption` needs a config object to instruct how to decrypt/decrypt the payloads. Example:

0 commit comments

Comments
 (0)