jose 2.0.4 → 2.0.5
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/CHANGELOG.md +7 -0
- package/lib/help/base64url.js +7 -7
- package/lib/jwa/aes_cbc_hmac_sha2.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.0.5](https://github.com/panva/jose/compare/v2.0.4...v2.0.5) (2021-04-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* defer AES CBC w/ HMAC decryption after tag verification passes ([812e03f](https://github.com/panva/jose/commit/812e03fcf4963791ffd9a46417beea5a7a74d995))
|
|
11
|
+
|
|
5
12
|
## [2.0.4](https://github.com/panva/jose/compare/v2.0.3...v2.0.4) (2021-01-18)
|
|
6
13
|
|
|
7
14
|
|
package/lib/help/base64url.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
let encode
|
|
2
|
-
let encodeBuffer
|
|
1
|
+
let encode
|
|
2
|
+
let encodeBuffer
|
|
3
3
|
if (Buffer.isEncoding('base64url')) {
|
|
4
|
-
encode = (input, encoding = 'utf8') => Buffer.from(input, encoding).toString('base64url')
|
|
5
|
-
encodeBuffer = (buf) => buf.toString('base64url')
|
|
4
|
+
encode = (input, encoding = 'utf8') => Buffer.from(input, encoding).toString('base64url')
|
|
5
|
+
encodeBuffer = (buf) => buf.toString('base64url')
|
|
6
6
|
} else {
|
|
7
|
-
const fromBase64 = (base64) => base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
|
|
8
|
-
encode = (input, encoding = 'utf8') => fromBase64(Buffer.from(input, encoding).toString('base64'))
|
|
9
|
-
encodeBuffer = (buf) => fromBase64(buf.toString('base64'))
|
|
7
|
+
const fromBase64 = (base64) => base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
|
|
8
|
+
encode = (input, encoding = 'utf8') => fromBase64(Buffer.from(input, encoding).toString('base64'))
|
|
9
|
+
encodeBuffer = (buf) => fromBase64(buf.toString('base64'))
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const decodeToBuffer = (input) => {
|
|
@@ -44,13 +44,17 @@ const decrypt = (size, sign, { [KEYOBJECT]: keyObject }, ciphertext, { iv, tag =
|
|
|
44
44
|
const expectedTag = sign({ [KEYOBJECT]: macKey }, macData, tag).slice(0, keySize)
|
|
45
45
|
const macCheckPassed = timingSafeEqual(tag, expectedTag)
|
|
46
46
|
|
|
47
|
+
if (!macCheckPassed) {
|
|
48
|
+
throw new JWEDecryptionFailed()
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
let cleartext
|
|
48
52
|
try {
|
|
49
53
|
const cipher = createDecipheriv(`aes-${size}-cbc`, encKey, iv)
|
|
50
54
|
cleartext = Buffer.concat([cipher.update(ciphertext), cipher.final()])
|
|
51
55
|
} catch (err) {}
|
|
52
56
|
|
|
53
|
-
if (!cleartext
|
|
57
|
+
if (!cleartext) {
|
|
54
58
|
throw new JWEDecryptionFailed()
|
|
55
59
|
}
|
|
56
60
|
|