Skip to content

Commit 36444a3

Browse files
authored
Apply remaining changes
1 parent 9d1221a commit 36444a3

2 files changed

Lines changed: 10 additions & 28 deletions

File tree

test/Test.Ecdh.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,9 @@ function ecdhTests() {
226226
});
227227
}
228228

229-
var ecdhKeyLengths = {
230-
"P-256": 32,
231-
"P-384": 48,
232-
"P-521": 66,
233-
"BN-254": 32,
234-
"NUMSP256D1": 32,
235-
"NUMSP256T1": 32,
236-
"NUMSP384D1": 48,
237-
"NUMSP384T1": 48,
238-
"NUMSP512D1": 64,
239-
"NUMSP512T1": 64
240-
};
229+
function ecdhCurveElementLength(namedCurve) {
230+
return cryptoECC.curveElementLength(namedCurve);
231+
}
241232

242233
function ecdhKeyAlg(namedCurve) {
243234
return {
@@ -250,7 +241,7 @@ var inspectEcdhKey = {
250241
public: function(keyObj, algorithm, usages, reason) {
251242

252243
var fail = [];
253-
var expLenMax = ecdhKeyLengths[algorithm.namedCurve];
244+
var expLenMax = ecdhCurveElementLength(algorithm.namedCurve);
254245
var expLenMin = expLenMax;
255246

256247
// has crv property equal to "P-521"
@@ -309,7 +300,7 @@ var inspectEcdhKey = {
309300
// }
310301
// }
311302

312-
var expLenMax = ecdhKeyLengths[algorithm.namedCurve];
303+
var expLenMax = ecdhCurveElementLength(algorithm.namedCurve);
313304
var expLenMin = expLenMax;
314305

315306
this.public(keyObj, algorithm, usages, reason);

test/Test.Ecdsa.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,9 @@ function ecdsaTests() {
423423
});
424424
}
425425

426-
var ecdsaKeyLengths = {
427-
"P-256": 32,
428-
"P-384": 48,
429-
"P-521": 66,
430-
"BN-254": 32,
431-
"NUMSP256D1": 32,
432-
"NUMSP256T1": 32,
433-
"NUMSP384D1": 48,
434-
"NUMSP384T1": 48,
435-
"NUMSP512D1": 64,
436-
"NUMSP512T1": 64
437-
};
426+
function ecdsaCurveElementLength(namedCurve) {
427+
return cryptoECC.curveElementLength(namedCurve);
428+
}
438429

439430
function ecdsaKeyAlg(curve) {
440431
return {
@@ -455,7 +446,7 @@ var inspectEcdsaKey = {
455446

456447
var fail = [];
457448

458-
var expLenMax = ecdsaKeyLengths[algorithm.namedCurve];
449+
var expLenMax = ecdsaCurveElementLength(algorithm.namedCurve);
459450
var expLenMin = expLenMax;
460451

461452
// has crv property equal to "P-521"
@@ -498,7 +489,7 @@ var inspectEcdsaKey = {
498489
},
499490
private: function(keyObj, algorithm, usages, reason) {
500491

501-
var expLenMax = ecdsaKeyLengths[algorithm.namedCurve];
492+
var expLenMax = ecdsaCurveElementLength(algorithm.namedCurve);
502493
var expLenMin = expLenMax;
503494

504495
this.public(keyObj, algorithm, usages, reason);

0 commit comments

Comments
 (0)