Skip to content

Commit 687fe3b

Browse files
panvadanielleadams
authored andcommitted
crypto: cleanup webcrypto jwk code
PR-URL: #42562 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Akhil Marsonya <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 5951d67 commit 687fe3b

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

lib/internal/crypto/dsa.js

-51
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ const {
77

88
const {
99
DSAKeyExportJob,
10-
KeyObjectHandle,
1110
SignJob,
1211
kCryptoJobAsync,
1312
kSigEncDER,
14-
kKeyTypePrivate,
1513
kSignJobModeSign,
1614
kSignJobModeVerify,
1715
} = internalBinding('crypto');
@@ -29,8 +27,6 @@ const {
2927

3028
const {
3129
InternalCryptoKey,
32-
PrivateKeyObject,
33-
PublicKeyObject,
3430
createPrivateKey,
3531
createPublicKey,
3632
isKeyObject,
@@ -45,7 +41,6 @@ const {
4541
hasAnyNotIn,
4642
jobPromise,
4743
normalizeHashName,
48-
validateKeyOps,
4944
kKeyObject,
5045
kHandle,
5146
} = require('internal/crypto/util');
@@ -178,52 +173,6 @@ async function dsaImportKey(
178173
});
179174
break;
180175
}
181-
case 'jwk': {
182-
if (keyData == null || typeof keyData !== 'object')
183-
throw lazyDOMException('Invalid JWK keyData', 'DataError');
184-
185-
verifyAcceptableDsaKeyUse(
186-
algorithm.name,
187-
keyData.x !== undefined ? 'private' : 'public',
188-
usagesSet);
189-
190-
if (keyData.kty !== 'DSA')
191-
throw lazyDOMException('Invalid key type', 'DataError');
192-
193-
if (usagesSet.size > 0 &&
194-
keyData.use !== undefined &&
195-
keyData.use !== 'sig') {
196-
throw lazyDOMException('Invalid use type', 'DataError');
197-
}
198-
199-
validateKeyOps(keyData.key_ops, usagesSet);
200-
201-
if (keyData.ext !== undefined &&
202-
keyData.ext === false &&
203-
extractable === true) {
204-
throw lazyDOMException('JWK is not extractable', 'DataError');
205-
}
206-
207-
if (keyData.alg !== undefined) {
208-
if (typeof keyData.alg !== 'string')
209-
throw lazyDOMException('Invalid alg', 'DataError');
210-
const hash =
211-
normalizeHashName(keyData.alg, normalizeHashName.kContextWebCrypto);
212-
if (hash !== algorithm.hash.name)
213-
throw lazyDOMException('Hash mismatch', 'DataError');
214-
}
215-
216-
const handle = new KeyObjectHandle();
217-
const type = handle.initJwk(keyData);
218-
if (type === undefined)
219-
throw lazyDOMException('Invalid JWK keyData', 'DataError');
220-
221-
keyObject = type === kKeyTypePrivate ?
222-
new PrivateKeyObject(handle) :
223-
new PublicKeyObject(handle);
224-
225-
break;
226-
}
227176
default:
228177
throw lazyDOMException(
229178
`Unable to import DSA key with format ${format}`,

lib/internal/crypto/webcrypto.js

-5
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,6 @@ async function exportKeyJWK(key) {
403403
key.algorithm.hash.name,
404404
normalizeHashName.kContextJwkHmac);
405405
return jwk;
406-
case 'NODE-DSA':
407-
jwk.alg = normalizeHashName(
408-
key.algorithm.hash.name,
409-
normalizeHashName.kContextJwkDsa);
410-
return jwk;
411406
case 'NODE-ED25519':
412407
// Fall through
413408
case 'NODE-ED448':

0 commit comments

Comments
 (0)