You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,6 +259,33 @@ const jwe = new clientEncryption.JweEncryption(config);
259
259
let responsePayload =jwe.decrypt(encryptedResponsePayload);
260
260
```
261
261
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
+
262
289
##### • Configuring the JWE Encryption <aname="configuring-the-jwe-encryption"></a>
263
290
264
291
`JweEncryption` needs a config object to instruct how to decrypt/decrypt the payloads. Example:
0 commit comments