Skip to content

Commit

Permalink
fix: contactKDF iteration count fixed for key sizes larger than 256 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Jan 25, 2020
1 parent e3ad39f commit 70ff222
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
2 changes: 1 addition & 1 deletion lib/jwa/ecdh/derive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { createHash } = require('crypto')
const ecdhComputeSecret = require('./compute_secret')

const concat = (key, length, value) => {
const iterations = Math.ceil(length / 256)
const iterations = Math.ceil(length / 32)
let res

for (let iter = 1; iter <= iterations; iter++) {
Expand Down
1 change: 0 additions & 1 deletion test/jwe/smoke.P-256K.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const dKey = asKey(key)

;[...eKey.algorithms('wrapKey'), ...eKey.algorithms('deriveKey')].forEach((alg) => {
ENCS.forEach((enc) => {
if (alg === 'ECDH-ES' && ['A192CBC-HS384', 'A256CBC-HS512'].includes(enc)) return
test(`key ${type} > alg ${alg} > ${enc}`, success, eKey, dKey, alg, enc)
test(`key ${type} > alg ${alg} > ${enc} (negative cases)`, failure, eKey, dKey, alg, enc)
})
Expand Down
2 changes: 0 additions & 2 deletions test/jwe/smoke.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Object.entries(fixtures.PEM).forEach(([type, { private: key, public: pub }]) =>

;[...eKey.algorithms('wrapKey'), ...eKey.algorithms('deriveKey')].forEach((alg) => {
ENCS.forEach((enc) => {
if (alg === 'ECDH-ES' && ['A192CBC-HS384', 'A256CBC-HS512'].includes(enc)) return
test(`key ${type} > alg ${alg} > ${enc}`, success, eKey, dKey, alg, enc)
test(`key ${type} > alg ${alg} > ${enc} (key as bare input)`, success, pub, key, alg, enc)
if (keyObjectSupported) {
Expand Down Expand Up @@ -71,7 +70,6 @@ Object.entries(fixtures.PEM).forEach(([type, { private: key, public: pub }]) =>
const eKey = asKey({ kty: 'RSA', e: rsa.e, n: rsa.n })
eKey.algorithms('wrapKey').forEach((alg) => {
ENCS.forEach((enc) => {
if (alg === 'ECDH-ES' && ['A192CBC-HS384', 'A256CBC-HS512'].includes(enc)) return
test(`key RSA (min) > alg ${alg} > ${enc}`, success, eKey, dKey, alg, enc)
test(`key RSA (min) > alg ${alg} > ${enc} (negative cases)`, failure, eKey, dKey, alg, enc)
})
Expand Down

0 comments on commit 70ff222

Please sign in to comment.