jose 4.1.3 → 4.1.4
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.
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
export default (alg, key) => {
|
|
2
|
-
if (alg.startsWith('HS')) {
|
|
3
|
-
const bitlen = parseInt(alg.substr(-3), 10);
|
|
4
|
-
const { length } = key.algorithm;
|
|
5
|
-
if (typeof length !== 'number' || length < bitlen) {
|
|
6
|
-
throw new TypeError(`${alg} requires symmetric keys to be ${bitlen} bits or larger`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
2
|
if (alg.startsWith('RS') || alg.startsWith('PS')) {
|
|
10
3
|
const { modulusLength } = key.algorithm;
|
|
11
4
|
if (typeof modulusLength !== 'number' || modulusLength < 2048) {
|
|
@@ -16,10 +16,6 @@ else {
|
|
|
16
16
|
const sign = async (alg, key, data) => {
|
|
17
17
|
const keyObject = (0, get_sign_verify_key_js_1.default)(alg, key, 'sign');
|
|
18
18
|
if (alg.startsWith('HS')) {
|
|
19
|
-
const bitlen = parseInt(alg.substr(-3), 10);
|
|
20
|
-
if (!keyObject.symmetricKeySize || keyObject.symmetricKeySize << 3 < bitlen) {
|
|
21
|
-
throw new TypeError(`${alg} requires symmetric keys to be ${bitlen} bits or larger`);
|
|
22
|
-
}
|
|
23
19
|
const hmac = crypto.createHmac((0, hmac_digest_js_1.default)(alg), keyObject);
|
|
24
20
|
hmac.update(data);
|
|
25
21
|
return hmac.digest();
|
|
@@ -14,10 +14,6 @@ else {
|
|
|
14
14
|
const sign = async (alg, key, data) => {
|
|
15
15
|
const keyObject = getSignKey(alg, key, 'sign');
|
|
16
16
|
if (alg.startsWith('HS')) {
|
|
17
|
-
const bitlen = parseInt(alg.substr(-3), 10);
|
|
18
|
-
if (!keyObject.symmetricKeySize || keyObject.symmetricKeySize << 3 < bitlen) {
|
|
19
|
-
throw new TypeError(`${alg} requires symmetric keys to be ${bitlen} bits or larger`);
|
|
20
|
-
}
|
|
21
17
|
const hmac = crypto.createHmac(hmacDigest(alg), keyObject);
|
|
22
18
|
hmac.update(data);
|
|
23
19
|
return hmac.digest();
|