Skip to content

Commit 6acd6d4

Browse files
committed
style: alg containers
1 parent 671ef9d commit 6acd6d4

File tree

3 files changed

+9
-39
lines changed

3 files changed

+9
-39
lines changed

lib/jwk/key/ec.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ const { THUMBPRINT_MATERIAL, PUBLIC_MEMBERS, PRIVATE_MEMBERS, JWK_MEMBERS } = re
66
const Key = require('./base')
77

88
const generateKeyPair = promisify(async)
9-
const WRAP_ALGS = new Set([
10-
'ECDH-ES',
11-
'ECDH-ES+A128KW',
12-
'ECDH-ES+A192KW',
13-
'ECDH-ES+A256KW'
14-
])
9+
10+
const WRAP_ALGS = ['ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW']
1511

1612
const EC_PUBLIC = new Set(['crv', 'x', 'y'])
1713
Object.freeze(EC_PUBLIC)

lib/jwk/key/oct.js

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,11 @@ const { THUMBPRINT_MATERIAL, PUBLIC_MEMBERS, PRIVATE_MEMBERS } = require('../../
66

77
const Key = require('./base')
88

9-
const SIG_ALGS = new Set([
10-
'HS256',
11-
'HS384',
12-
'HS512'
13-
])
14-
15-
const ENC_LEN = new Set([
16-
128,
17-
192,
18-
256,
19-
384,
20-
512
21-
])
22-
23-
const ENC_ALGS = new Set([
24-
'A128CBC-HS256',
25-
'A128GCM',
26-
'A192CBC-HS384',
27-
'A192GCM',
28-
'A256CBC-HS512',
29-
'A256GCM'
30-
])
31-
9+
const ENC_ALGS = new Set(['A128CBC-HS256', 'A128GCM', 'A192CBC-HS384', 'A192GCM', 'A256CBC-HS512', 'A256GCM'])
10+
const ENC_LEN = new Set([128, 192, 256, 384, 512])
3211
const PBES2 = ['PBES2-HS256+A128KW', 'PBES2-HS384+A192KW', 'PBES2-HS512+A256KW']
33-
const WRAP_LEN = new Set([
34-
128,
35-
192,
36-
256
37-
])
12+
const SIG_ALGS = ['HS256', 'HS384', 'HS512']
13+
const WRAP_LEN = new Set([128, 192, 256])
3814

3915
const OCT_PUBLIC = new Set()
4016
Object.freeze(OCT_PUBLIC)

lib/jwk/key/rsa.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ const Key = require('./base')
77

88
const generateKeyPair = promisify(async)
99

10-
const WRAP_ALGS = new Set([
11-
'RSA-OAEP',
12-
'RSA1_5'
13-
])
10+
const SIG_ALGS = ['PS256', 'RS256', 'PS384', 'RS384', 'PS512', 'RS512']
11+
const WRAP_ALGS = ['RSA-OAEP', 'RSA1_5']
1412

1513
const RSA_PUBLIC = new Set(['e', 'n'])
1614
Object.freeze(RSA_PUBLIC)
@@ -20,7 +18,7 @@ Object.freeze(RSA_PRIVATE)
2018
const sigAlgsAvailableFor = (length) => {
2119
switch (true) {
2220
case length >= 1040:
23-
return new Set(['PS256', 'RS256', 'PS384', 'RS384', 'PS512', 'RS512'])
21+
return new Set(SIG_ALGS)
2422
case length >= 784:
2523
return new Set(['PS256', 'RS256', 'PS384', 'RS384', 'RS512'])
2624
case length >= 752:

0 commit comments

Comments
 (0)