Skip to content

Commit e21fea1

Browse files
committed
revert: add EC P-256K JWK and ES256K sign/verify support
BREAKING CHANGE: removing ES256K alg and EC P-256K crv support until the IETF WG decides on what the final names will be.
1 parent 9e763ac commit e21fea1

File tree

14 files changed

+6
-56
lines changed

14 files changed

+6
-56
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Legend:
4343
| -- | -- | -- |
4444
| RSASSA-PKCS1-v1_5 || RS256, RS384, RS512 |
4545
| RSASSA-PSS || PS256, PS384, PS512 |
46-
| ECDSA || ES256, ES256K, ES384, ES512 |
46+
| ECDSA || ES256, ES384, ES512 |
4747
| HMAC with SHA-2 || HS256, HS384, HS512 |
4848

4949
| JWE Key Management Algorithms | Supported ||

lib/help/ecdsa_signatures.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const getParamSize = keySize => ((keySize / 8) | 0) + (keySize % 8 === 0 ? 0 : 1
1010

1111
const paramBytesForAlg = {
1212
ES256: getParamSize(256),
13-
ES256K: getParamSize(256),
1413
ES384: getParamSize(384),
1514
ES512: getParamSize(521)
1615
}

lib/help/key_utils.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,21 @@ const base64url = require('./base64url')
22
const errors = require('../errors')
33
const asn1 = require('./asn1')
44

5-
const EC_CURVES = new Set(['P-256', 'P-256K', 'P-384', 'P-521'])
5+
const EC_CURVES = new Set(['P-256', 'P-384', 'P-521'])
66

77
const oidHexToCurve = new Map([
88
['06082a8648ce3d030107', 'P-256'],
9-
['06052b8104000a', 'P-256K'],
109
['06052b81040022', 'P-384'],
1110
['06052b81040023', 'P-521']
1211
])
1312
const EC_KEY_OID = '1.2.840.10045.2.1'.split('.')
1413
const crvToOid = new Map([
1514
['P-256', '1.2.840.10045.3.1.7'.split('.')],
16-
['P-256K', '1.3.132.0.10'.split('.')],
1715
['P-384', '1.3.132.0.34'.split('.')],
1816
['P-521', '1.3.132.0.35'.split('.')]
1917
])
2018
const crvToOidBuf = new Map([
2119
['P-256', Buffer.from('06082a8648ce3d030107', 'hex')],
22-
['P-256K', Buffer.from('06052b8104000a', 'hex')],
2320
['P-384', Buffer.from('06052b81040022', 'hex')],
2421
['P-521', Buffer.from('06052b81040023', 'hex')]
2522
])

lib/help/node_alg.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module.exports = (alg) => {
44
case 'PS256':
55
case 'HS256':
66
case 'ES256':
7-
case 'ES256K':
87
return 'sha256'
98
case 'RS384':
109
case 'PS384':

lib/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface KeyParameters {
88
use?: use
99
kid?: string
1010
}
11-
type curve = 'P-256' | 'P-256K' | 'P-384' | 'P-521'
11+
type curve = 'P-256' | 'P-384' | 'P-521'
1212
type keyType = 'RSA' | 'EC' | 'oct'
1313
type keyOperation = 'encrypt' | 'decrypt' | 'sign' | 'verify' | 'wrapKey' | 'unwrapKey'
1414
type asymmetricKeyObjectTypes = 'private' | 'public'

lib/jwa/ecdh/derive.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ const crvToCurve = (crv) => {
66
switch (crv) {
77
case 'P-256':
88
return 'prime256v1'
9-
case 'P-256K':
10-
return 'secp256k1'
119
case 'P-384':
1210
return 'secp384r1'
1311
case 'P-521':

lib/jwa/ecdsa.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const verify = (jwaAlg, nodeAlg, { [KEYOBJECT]: keyObject }, payload, signature)
2323
}
2424

2525
module.exports = (JWA) => {
26-
['ES256', 'ES384', 'ES512', 'ES256K'].forEach((jwaAlg) => {
26+
['ES256', 'ES384', 'ES512'].forEach((jwaAlg) => {
2727
const nodeAlg = resolveNodeAlg(jwaAlg)
2828

2929
assert(!JWA.sign.has(jwaAlg), `sign alg ${jwaAlg} already registered`)

lib/jwk/key/ec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { promisify } = require('util')
33

44
const { THUMBPRINT_MATERIAL, PUBLIC_MEMBERS, PRIVATE_MEMBERS, JWK_MEMBERS } = require('../../help/symbols')
55
const errors = require('../../errors')
6-
const EC_CURVES = new Set(['P-256', 'P-256K', 'P-384', 'P-521'])
6+
const EC_CURVES = new Set(['P-256', 'P-384', 'P-521'])
77

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

@@ -20,8 +20,6 @@ const crvToDSA = (crv) => {
2020
switch (crv) {
2121
case 'P-256':
2222
return 'ES256'
23-
case 'P-256K':
24-
return 'ES256K'
2523
case 'P-384':
2624
return 'ES384'
2725
case 'P-521':
@@ -104,9 +102,6 @@ class ECKey extends Key {
104102
throw new errors.JOSENotSupported(`unsupported EC key curve: ${crv}`)
105103
}
106104

107-
if (crv === 'P-256K') {
108-
crv = 'secp256k1'
109-
}
110105
const { privateKey, publicKey } = await generateKeyPair('ec', { namedCurve: crv })
111106

112107
return privat ? privateKey : publicKey
@@ -117,9 +112,6 @@ class ECKey extends Key {
117112
throw new errors.JOSENotSupported(`unsupported EC key curve: ${crv}`)
118113
}
119114

120-
if (crv === 'P-256K') {
121-
crv = 'secp256k1'
122-
}
123115
const { privateKey, publicKey } = generateKeyPairSync('ec', { namedCurve: crv })
124116

125117
return privat ? privateKey : publicKey

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"jwks",
1717
"jws",
1818
"jwt",
19-
"secp256k1",
2019
"sign",
2120
"verify"
2221
],

test/fixtures/P-256K.key

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)