Skip to content

Commit 4889d7c

Browse files
committed
Rebuild dist for BN-254 padding fix (PR #26)
1 parent 1b0cca2 commit 4889d7c

2 files changed

Lines changed: 27 additions & 25 deletions

File tree

dist/msrcrypto.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,6 +3978,19 @@ function MsrcryptoECC() {
39783978

39793979
var curvesInternal = {};
39803980

3981+
var curveElementLengths = {
3982+
"P-256": 32,
3983+
"P-384": 48,
3984+
"P-521": 66,
3985+
"BN-254": 32,
3986+
"NUMSP256D1": 32,
3987+
"NUMSP256T1": 32,
3988+
"NUMSP384D1": 48,
3989+
"NUMSP384T1": 48,
3990+
"NUMSP512D1": 64,
3991+
"NUMSP512T1": 64
3992+
};
3993+
39813994
var createCurve = function(curveName) {
39823995

39833996
var curveData = curvesInternal[curveName.toUpperCase()];
@@ -4004,8 +4017,17 @@ function MsrcryptoECC() {
40044017
return opp.validatePoint(point);
40054018
};
40064019

4020+
var curveElementLength = function(curveName) {
4021+
if (!curveName) {
4022+
return undefined;
4023+
}
4024+
4025+
return curveElementLengths[curveName.toUpperCase()];
4026+
};
4027+
40074028
return {
40084029
createCurve: createCurve,
4030+
curveElementLength: curveElementLength,
40094031
curves: curvesInternal,
40104032
sec1EncodingFp: sec1EncodingFp,
40114033
validatePoint: validateEccPoint,
@@ -8089,12 +8111,7 @@ if ( typeof operations !== "undefined" ) {
80898111

80908112
var keyPairData = ecdhInstance.generateKey();
80918113

8092-
var partLen = {
8093-
"P-256": 32, "P-384": 48, "P-521": 66,
8094-
"NUMSP256D1": 32, "NUMSP256T1": 32,
8095-
"NUMSP384D1": 48, "NUMSP384T1": 48,
8096-
"NUMSP512D1": 64, "NUMSP512T1": 64
8097-
}[p.algorithm.namedCurve];
8114+
var partLen = cryptoECC.curveElementLength(p.algorithm.namedCurve);
80988115
var pad = msrcryptoUtilities.padFront;
80998116
keyPairData.publicKey.x = pad(keyPairData.publicKey.x, 0, partLen);
81008117
keyPairData.publicKey.y = pad(keyPairData.publicKey.y, 0, partLen);
@@ -8177,12 +8194,7 @@ if ( typeof operations !== "undefined" ) {
81778194
keyObject.y = publicKey.y;
81788195
}
81798196

8180-
var partLen = {
8181-
"P-256": 32, "P-384": 48, "P-521": 66,
8182-
"NUMSP256D1": 32, "NUMSP256T1": 32,
8183-
"NUMSP384D1": 48, "NUMSP384T1": 48,
8184-
"NUMSP512D1": 64, "NUMSP512T1": 64
8185-
}[p.algorithm.namedCurve];
8197+
var partLen = cryptoECC.curveElementLength(p.algorithm.namedCurve);
81868198
if ( keyObject.x ) { keyObject.x = msrcryptoUtilities.padFront(keyObject.x, 0, partLen); }
81878199
if ( keyObject.y ) { keyObject.y = msrcryptoUtilities.padFront(keyObject.y, 0, partLen); }
81888200
if ( keyObject.d ) { keyObject.d = msrcryptoUtilities.padFront(keyObject.d, 0, partLen); }
@@ -8583,12 +8595,7 @@ if (typeof operations !== "undefined") {
85838595

85848596
var dtb = cryptoMath.digitsToBytes;
85858597

8586-
var partLen = {
8587-
"P-256": 32, "P-384": 48, "P-521": 66,
8588-
"NUMSP256D1": 32, "NUMSP256T1": 32,
8589-
"NUMSP384D1": 48, "NUMSP384T1": 48,
8590-
"NUMSP512D1": 64, "NUMSP512T1": 64
8591-
}[p.algorithm.namedCurve];
8598+
var partLen = cryptoECC.curveElementLength(p.algorithm.namedCurve);
85928599

85938600
function padToCurveLength( array ) {
85948601
return msrcryptoUtilities.padFront(array, 0, partLen);
@@ -8677,12 +8684,7 @@ if (typeof operations !== "undefined") {
86778684
keyObject.y = publicKey.y;
86788685
}
86798686

8680-
var partLen = {
8681-
"P-256": 32, "P-384": 48, "P-521": 66,
8682-
"NUMSP256D1": 32, "NUMSP256T1": 32,
8683-
"NUMSP384D1": 48, "NUMSP384T1": 48,
8684-
"NUMSP512D1": 64, "NUMSP512T1": 64
8685-
}[p.algorithm.namedCurve];
8687+
var partLen = cryptoECC.curveElementLength(p.algorithm.namedCurve);
86868688
if ( keyObject.x ) { keyObject.x = msrcryptoUtilities.padFront(keyObject.x, 0, partLen); }
86878689
if ( keyObject.y ) { keyObject.y = msrcryptoUtilities.padFront(keyObject.y, 0, partLen); }
86888690
if ( keyObject.d ) { keyObject.d = msrcryptoUtilities.padFront(keyObject.d, 0, partLen); }

dist/msrcrypto.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)