Skip to content

Commit

Permalink
style: alg containers
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Mar 17, 2019
1 parent 671ef9d commit 6acd6d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
8 changes: 2 additions & 6 deletions lib/jwk/key/ec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ const { THUMBPRINT_MATERIAL, PUBLIC_MEMBERS, PRIVATE_MEMBERS, JWK_MEMBERS } = re
const Key = require('./base')

const generateKeyPair = promisify(async)
const WRAP_ALGS = new Set([
'ECDH-ES',
'ECDH-ES+A128KW',
'ECDH-ES+A192KW',
'ECDH-ES+A256KW'
])

const WRAP_ALGS = ['ECDH-ES', 'ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW']

const EC_PUBLIC = new Set(['crv', 'x', 'y'])
Object.freeze(EC_PUBLIC)
Expand Down
32 changes: 4 additions & 28 deletions lib/jwk/key/oct.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,11 @@ const { THUMBPRINT_MATERIAL, PUBLIC_MEMBERS, PRIVATE_MEMBERS } = require('../../

const Key = require('./base')

const SIG_ALGS = new Set([
'HS256',
'HS384',
'HS512'
])

const ENC_LEN = new Set([
128,
192,
256,
384,
512
])

const ENC_ALGS = new Set([
'A128CBC-HS256',
'A128GCM',
'A192CBC-HS384',
'A192GCM',
'A256CBC-HS512',
'A256GCM'
])

const ENC_ALGS = new Set(['A128CBC-HS256', 'A128GCM', 'A192CBC-HS384', 'A192GCM', 'A256CBC-HS512', 'A256GCM'])
const ENC_LEN = new Set([128, 192, 256, 384, 512])
const PBES2 = ['PBES2-HS256+A128KW', 'PBES2-HS384+A192KW', 'PBES2-HS512+A256KW']
const WRAP_LEN = new Set([
128,
192,
256
])
const SIG_ALGS = ['HS256', 'HS384', 'HS512']
const WRAP_LEN = new Set([128, 192, 256])

const OCT_PUBLIC = new Set()
Object.freeze(OCT_PUBLIC)
Expand Down
8 changes: 3 additions & 5 deletions lib/jwk/key/rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ const Key = require('./base')

const generateKeyPair = promisify(async)

const WRAP_ALGS = new Set([
'RSA-OAEP',
'RSA1_5'
])
const SIG_ALGS = ['PS256', 'RS256', 'PS384', 'RS384', 'PS512', 'RS512']
const WRAP_ALGS = ['RSA-OAEP', 'RSA1_5']

const RSA_PUBLIC = new Set(['e', 'n'])
Object.freeze(RSA_PUBLIC)
Expand All @@ -20,7 +18,7 @@ Object.freeze(RSA_PRIVATE)
const sigAlgsAvailableFor = (length) => {
switch (true) {
case length >= 1040:
return new Set(['PS256', 'RS256', 'PS384', 'RS384', 'PS512', 'RS512'])
return new Set(SIG_ALGS)
case length >= 784:
return new Set(['PS256', 'RS256', 'PS384', 'RS384', 'RS512'])
case length >= 752:
Expand Down

0 comments on commit 6acd6d4

Please sign in to comment.