vite 2.0.4 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/CHANGELOG.md +60 -0
- package/LICENSE.md +210 -30
- package/dist/node/chunks/{dep-4a30cab3.js → dep-0c7ee4d5.js} +18 -18
- package/dist/node/chunks/{dep-f45d34a0.js → dep-0f464c78.js} +2 -2
- package/dist/node/chunks/{dep-2192e50e.js → dep-685e7ba2.js} +7 -7
- package/dist/node/chunks/{dep-73de6751.js → dep-8a660aa5.js} +159 -159
- package/dist/node/chunks/{dep-e293f0bf.js → dep-ce592790.js} +345 -345
- package/dist/node/chunks/{dep-1bdbec90.js → dep-efe32886.js} +39660 -38798
- package/dist/node/chunks/{dep-47146891.js → dep-fbc42d74.js} +455 -455
- package/dist/node/cli.js +59 -49
- package/dist/node/index.d.ts +3 -1
- package/dist/node/index.js +2 -1
- package/dist/node/terser.js +52 -52
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var build = require('./dep-
|
|
3
|
+
var build = require('./dep-efe32886.js');
|
|
4
4
|
var require$$0 = require('crypto');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
@@ -4385,7 +4385,7 @@ forge.aes = forge.aes || {};
|
|
|
4385
4385
|
* @return the cipher.
|
|
4386
4386
|
*/
|
|
4387
4387
|
forge.aes.startEncrypting = function(key, iv, output, mode) {
|
|
4388
|
-
var cipher = _createCipher({
|
|
4388
|
+
var cipher = _createCipher$1({
|
|
4389
4389
|
key: key,
|
|
4390
4390
|
output: output,
|
|
4391
4391
|
decrypt: false,
|
|
@@ -4411,7 +4411,7 @@ forge.aes.startEncrypting = function(key, iv, output, mode) {
|
|
|
4411
4411
|
* @return the cipher.
|
|
4412
4412
|
*/
|
|
4413
4413
|
forge.aes.createEncryptionCipher = function(key, mode) {
|
|
4414
|
-
return _createCipher({
|
|
4414
|
+
return _createCipher$1({
|
|
4415
4415
|
key: key,
|
|
4416
4416
|
output: null,
|
|
4417
4417
|
decrypt: false,
|
|
@@ -4439,7 +4439,7 @@ forge.aes.createEncryptionCipher = function(key, mode) {
|
|
|
4439
4439
|
* @return the cipher.
|
|
4440
4440
|
*/
|
|
4441
4441
|
forge.aes.startDecrypting = function(key, iv, output, mode) {
|
|
4442
|
-
var cipher = _createCipher({
|
|
4442
|
+
var cipher = _createCipher$1({
|
|
4443
4443
|
key: key,
|
|
4444
4444
|
output: output,
|
|
4445
4445
|
decrypt: true,
|
|
@@ -4465,7 +4465,7 @@ forge.aes.startDecrypting = function(key, iv, output, mode) {
|
|
|
4465
4465
|
* @return the cipher.
|
|
4466
4466
|
*/
|
|
4467
4467
|
forge.aes.createDecryptionCipher = function(key, mode) {
|
|
4468
|
-
return _createCipher({
|
|
4468
|
+
return _createCipher$1({
|
|
4469
4469
|
key: key,
|
|
4470
4470
|
output: null,
|
|
4471
4471
|
decrypt: true,
|
|
@@ -4491,10 +4491,10 @@ forge.aes.Algorithm = function(name, mode) {
|
|
|
4491
4491
|
blockSize: 16,
|
|
4492
4492
|
cipher: {
|
|
4493
4493
|
encrypt: function(inBlock, outBlock) {
|
|
4494
|
-
return _updateBlock(self._w, inBlock, outBlock, false);
|
|
4494
|
+
return _updateBlock$1(self._w, inBlock, outBlock, false);
|
|
4495
4495
|
},
|
|
4496
4496
|
decrypt: function(inBlock, outBlock) {
|
|
4497
|
-
return _updateBlock(self._w, inBlock, outBlock, true);
|
|
4497
|
+
return _updateBlock$1(self._w, inBlock, outBlock, true);
|
|
4498
4498
|
}
|
|
4499
4499
|
}
|
|
4500
4500
|
});
|
|
@@ -4589,18 +4589,18 @@ forge.aes._expandKey = function(key, decrypt) {
|
|
|
4589
4589
|
* @param output an array of block-size 32-bit words.
|
|
4590
4590
|
* @param decrypt true to decrypt, false to encrypt.
|
|
4591
4591
|
*/
|
|
4592
|
-
forge.aes._updateBlock = _updateBlock;
|
|
4592
|
+
forge.aes._updateBlock = _updateBlock$1;
|
|
4593
4593
|
|
|
4594
4594
|
/** Register AES algorithms **/
|
|
4595
4595
|
|
|
4596
|
-
registerAlgorithm('AES-ECB', forge.cipher.modes.ecb);
|
|
4597
|
-
registerAlgorithm('AES-CBC', forge.cipher.modes.cbc);
|
|
4598
|
-
registerAlgorithm('AES-CFB', forge.cipher.modes.cfb);
|
|
4599
|
-
registerAlgorithm('AES-OFB', forge.cipher.modes.ofb);
|
|
4600
|
-
registerAlgorithm('AES-CTR', forge.cipher.modes.ctr);
|
|
4601
|
-
registerAlgorithm('AES-GCM', forge.cipher.modes.gcm);
|
|
4596
|
+
registerAlgorithm$1('AES-ECB', forge.cipher.modes.ecb);
|
|
4597
|
+
registerAlgorithm$1('AES-CBC', forge.cipher.modes.cbc);
|
|
4598
|
+
registerAlgorithm$1('AES-CFB', forge.cipher.modes.cfb);
|
|
4599
|
+
registerAlgorithm$1('AES-OFB', forge.cipher.modes.ofb);
|
|
4600
|
+
registerAlgorithm$1('AES-CTR', forge.cipher.modes.ctr);
|
|
4601
|
+
registerAlgorithm$1('AES-GCM', forge.cipher.modes.gcm);
|
|
4602
4602
|
|
|
4603
|
-
function registerAlgorithm(name, mode) {
|
|
4603
|
+
function registerAlgorithm$1(name, mode) {
|
|
4604
4604
|
var factory = function() {
|
|
4605
4605
|
return new forge.aes.Algorithm(name, mode);
|
|
4606
4606
|
};
|
|
@@ -5140,7 +5140,7 @@ function _expandKey(key, decrypt) {
|
|
|
5140
5140
|
* @param output the updated output block.
|
|
5141
5141
|
* @param decrypt true to decrypt the block, false to encrypt it.
|
|
5142
5142
|
*/
|
|
5143
|
-
function _updateBlock(w, input, output, decrypt) {
|
|
5143
|
+
function _updateBlock$1(w, input, output, decrypt) {
|
|
5144
5144
|
/*
|
|
5145
5145
|
Cipher(byte in[4*Nb], byte out[4*Nb], word w[Nb*(Nr+1)])
|
|
5146
5146
|
begin
|
|
@@ -5402,7 +5402,7 @@ function _updateBlock(w, input, output, decrypt) {
|
|
|
5402
5402
|
*
|
|
5403
5403
|
* @return the cipher.
|
|
5404
5404
|
*/
|
|
5405
|
-
function _createCipher(options) {
|
|
5405
|
+
function _createCipher$1(options) {
|
|
5406
5406
|
options = options || {};
|
|
5407
5407
|
var mode = (options.mode || 'CBC').toUpperCase();
|
|
5408
5408
|
var algorithm = 'AES-' + mode;
|
|
@@ -7744,7 +7744,7 @@ forge.des = forge.des || {};
|
|
|
7744
7744
|
* @return the cipher.
|
|
7745
7745
|
*/
|
|
7746
7746
|
forge.des.startEncrypting = function(key, iv, output, mode) {
|
|
7747
|
-
var cipher = _createCipher
|
|
7747
|
+
var cipher = _createCipher({
|
|
7748
7748
|
key: key,
|
|
7749
7749
|
output: output,
|
|
7750
7750
|
decrypt: false,
|
|
@@ -7769,7 +7769,7 @@ forge.des.startEncrypting = function(key, iv, output, mode) {
|
|
|
7769
7769
|
* @return the cipher.
|
|
7770
7770
|
*/
|
|
7771
7771
|
forge.des.createEncryptionCipher = function(key, mode) {
|
|
7772
|
-
return _createCipher
|
|
7772
|
+
return _createCipher({
|
|
7773
7773
|
key: key,
|
|
7774
7774
|
output: null,
|
|
7775
7775
|
decrypt: false,
|
|
@@ -7798,7 +7798,7 @@ forge.des.createEncryptionCipher = function(key, mode) {
|
|
|
7798
7798
|
* @return the cipher.
|
|
7799
7799
|
*/
|
|
7800
7800
|
forge.des.startDecrypting = function(key, iv, output, mode) {
|
|
7801
|
-
var cipher = _createCipher
|
|
7801
|
+
var cipher = _createCipher({
|
|
7802
7802
|
key: key,
|
|
7803
7803
|
output: output,
|
|
7804
7804
|
decrypt: true,
|
|
@@ -7823,7 +7823,7 @@ forge.des.startDecrypting = function(key, iv, output, mode) {
|
|
|
7823
7823
|
* @return the cipher.
|
|
7824
7824
|
*/
|
|
7825
7825
|
forge.des.createDecryptionCipher = function(key, mode) {
|
|
7826
|
-
return _createCipher
|
|
7826
|
+
return _createCipher({
|
|
7827
7827
|
key: key,
|
|
7828
7828
|
output: null,
|
|
7829
7829
|
decrypt: true,
|
|
@@ -7846,10 +7846,10 @@ forge.des.Algorithm = function(name, mode) {
|
|
|
7846
7846
|
blockSize: 8,
|
|
7847
7847
|
cipher: {
|
|
7848
7848
|
encrypt: function(inBlock, outBlock) {
|
|
7849
|
-
return _updateBlock
|
|
7849
|
+
return _updateBlock(self._keys, inBlock, outBlock, false);
|
|
7850
7850
|
},
|
|
7851
7851
|
decrypt: function(inBlock, outBlock) {
|
|
7852
|
-
return _updateBlock
|
|
7852
|
+
return _updateBlock(self._keys, inBlock, outBlock, true);
|
|
7853
7853
|
}
|
|
7854
7854
|
}
|
|
7855
7855
|
});
|
|
@@ -7883,19 +7883,19 @@ forge.des.Algorithm.prototype.initialize = function(options) {
|
|
|
7883
7883
|
|
|
7884
7884
|
/** Register DES algorithms **/
|
|
7885
7885
|
|
|
7886
|
-
registerAlgorithm
|
|
7887
|
-
registerAlgorithm
|
|
7888
|
-
registerAlgorithm
|
|
7889
|
-
registerAlgorithm
|
|
7890
|
-
registerAlgorithm
|
|
7886
|
+
registerAlgorithm('DES-ECB', forge.cipher.modes.ecb);
|
|
7887
|
+
registerAlgorithm('DES-CBC', forge.cipher.modes.cbc);
|
|
7888
|
+
registerAlgorithm('DES-CFB', forge.cipher.modes.cfb);
|
|
7889
|
+
registerAlgorithm('DES-OFB', forge.cipher.modes.ofb);
|
|
7890
|
+
registerAlgorithm('DES-CTR', forge.cipher.modes.ctr);
|
|
7891
7891
|
|
|
7892
|
-
registerAlgorithm
|
|
7893
|
-
registerAlgorithm
|
|
7894
|
-
registerAlgorithm
|
|
7895
|
-
registerAlgorithm
|
|
7896
|
-
registerAlgorithm
|
|
7892
|
+
registerAlgorithm('3DES-ECB', forge.cipher.modes.ecb);
|
|
7893
|
+
registerAlgorithm('3DES-CBC', forge.cipher.modes.cbc);
|
|
7894
|
+
registerAlgorithm('3DES-CFB', forge.cipher.modes.cfb);
|
|
7895
|
+
registerAlgorithm('3DES-OFB', forge.cipher.modes.ofb);
|
|
7896
|
+
registerAlgorithm('3DES-CTR', forge.cipher.modes.ctr);
|
|
7897
7897
|
|
|
7898
|
-
function registerAlgorithm
|
|
7898
|
+
function registerAlgorithm(name, mode) {
|
|
7899
7899
|
var factory = function() {
|
|
7900
7900
|
return new forge.des.Algorithm(name, mode);
|
|
7901
7901
|
};
|
|
@@ -8033,7 +8033,7 @@ function _createKeys(key) {
|
|
|
8033
8033
|
* @param output the updated output block.
|
|
8034
8034
|
* @param decrypt true to decrypt the block, false to encrypt it.
|
|
8035
8035
|
*/
|
|
8036
|
-
function _updateBlock
|
|
8036
|
+
function _updateBlock(keys, input, output, decrypt) {
|
|
8037
8037
|
// set up loops for single or triple DES
|
|
8038
8038
|
var iterations = keys.length === 32 ? 3 : 9;
|
|
8039
8039
|
var looping;
|
|
@@ -8151,7 +8151,7 @@ function _updateBlock$1(keys, input, output, decrypt) {
|
|
|
8151
8151
|
*
|
|
8152
8152
|
* @return the cipher.
|
|
8153
8153
|
*/
|
|
8154
|
-
function _createCipher
|
|
8154
|
+
function _createCipher(options) {
|
|
8155
8155
|
options = options || {};
|
|
8156
8156
|
var mode = (options.mode || 'CBC').toUpperCase();
|
|
8157
8157
|
var algorithm = 'DES-' + mode;
|
|
@@ -9784,17 +9784,17 @@ forge.jsbn = forge.jsbn || {};
|
|
|
9784
9784
|
var dbits;
|
|
9785
9785
|
|
|
9786
9786
|
// (public) Constructor
|
|
9787
|
-
function BigInteger(a,b,c) {
|
|
9787
|
+
function BigInteger$2(a,b,c) {
|
|
9788
9788
|
this.data = [];
|
|
9789
9789
|
if(a != null)
|
|
9790
9790
|
if("number" == typeof a) this.fromNumber(a,b,c);
|
|
9791
9791
|
else if(b == null && "string" != typeof a) this.fromString(a,256);
|
|
9792
9792
|
else this.fromString(a,b);
|
|
9793
9793
|
}
|
|
9794
|
-
forge.jsbn.BigInteger = BigInteger;
|
|
9794
|
+
forge.jsbn.BigInteger = BigInteger$2;
|
|
9795
9795
|
|
|
9796
9796
|
// return new, unset BigInteger
|
|
9797
|
-
function nbi() { return new BigInteger(null); }
|
|
9797
|
+
function nbi() { return new BigInteger$2(null); }
|
|
9798
9798
|
|
|
9799
9799
|
// am: Compute w_j += (x*this_i), propagate carries,
|
|
9800
9800
|
// c is initial carry, returns final carry.
|
|
@@ -9845,27 +9845,27 @@ function am3(i,x,w,j,c,n) {
|
|
|
9845
9845
|
// node.js (no browser)
|
|
9846
9846
|
if(typeof(navigator) === 'undefined')
|
|
9847
9847
|
{
|
|
9848
|
-
BigInteger.prototype.am = am3;
|
|
9848
|
+
BigInteger$2.prototype.am = am3;
|
|
9849
9849
|
dbits = 28;
|
|
9850
9850
|
} else if((navigator.appName == "Microsoft Internet Explorer")) {
|
|
9851
|
-
BigInteger.prototype.am = am2;
|
|
9851
|
+
BigInteger$2.prototype.am = am2;
|
|
9852
9852
|
dbits = 30;
|
|
9853
9853
|
} else if((navigator.appName != "Netscape")) {
|
|
9854
|
-
BigInteger.prototype.am = am1;
|
|
9854
|
+
BigInteger$2.prototype.am = am1;
|
|
9855
9855
|
dbits = 26;
|
|
9856
9856
|
} else { // Mozilla/Netscape seems to prefer am3
|
|
9857
|
-
BigInteger.prototype.am = am3;
|
|
9857
|
+
BigInteger$2.prototype.am = am3;
|
|
9858
9858
|
dbits = 28;
|
|
9859
9859
|
}
|
|
9860
9860
|
|
|
9861
|
-
BigInteger.prototype.DB = dbits;
|
|
9862
|
-
BigInteger.prototype.DM = ((1<<dbits)-1);
|
|
9863
|
-
BigInteger.prototype.DV = (1<<dbits);
|
|
9861
|
+
BigInteger$2.prototype.DB = dbits;
|
|
9862
|
+
BigInteger$2.prototype.DM = ((1<<dbits)-1);
|
|
9863
|
+
BigInteger$2.prototype.DV = (1<<dbits);
|
|
9864
9864
|
|
|
9865
9865
|
var BI_FP = 52;
|
|
9866
|
-
BigInteger.prototype.FV = Math.pow(2,BI_FP);
|
|
9867
|
-
BigInteger.prototype.F1 = BI_FP-dbits;
|
|
9868
|
-
BigInteger.prototype.F2 = 2*dbits-BI_FP;
|
|
9866
|
+
BigInteger$2.prototype.FV = Math.pow(2,BI_FP);
|
|
9867
|
+
BigInteger$2.prototype.F1 = BI_FP-dbits;
|
|
9868
|
+
BigInteger$2.prototype.F2 = 2*dbits-BI_FP;
|
|
9869
9869
|
|
|
9870
9870
|
// Digit conversions
|
|
9871
9871
|
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
@@ -9938,7 +9938,7 @@ function bnpFromString(s,b) {
|
|
|
9938
9938
|
if(sh > 0) this.data[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
|
|
9939
9939
|
}
|
|
9940
9940
|
this.clamp();
|
|
9941
|
-
if(mi) BigInteger.ZERO.subTo(this,this);
|
|
9941
|
+
if(mi) BigInteger$2.ZERO.subTo(this,this);
|
|
9942
9942
|
}
|
|
9943
9943
|
|
|
9944
9944
|
// (protected) clamp off excess high words
|
|
@@ -9977,7 +9977,7 @@ function bnToString(b) {
|
|
|
9977
9977
|
}
|
|
9978
9978
|
|
|
9979
9979
|
// (public) -this
|
|
9980
|
-
function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
|
|
9980
|
+
function bnNegate() { var r = nbi(); BigInteger$2.ZERO.subTo(this,r); return r; }
|
|
9981
9981
|
|
|
9982
9982
|
// (public) |this|
|
|
9983
9983
|
function bnAbs() { return (this.s<0)?this.negate():this; }
|
|
@@ -10103,7 +10103,7 @@ function bnpMultiplyTo(a,r) {
|
|
|
10103
10103
|
for(i = 0; i < y.t; ++i) r.data[i+x.t] = x.am(0,y.data[i],r,i,0,x.t);
|
|
10104
10104
|
r.s = 0;
|
|
10105
10105
|
r.clamp();
|
|
10106
|
-
if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
|
|
10106
|
+
if(this.s != a.s) BigInteger$2.ZERO.subTo(r,r);
|
|
10107
10107
|
}
|
|
10108
10108
|
|
|
10109
10109
|
// (protected) r = this^2, r != this (HAC 14.16)
|
|
@@ -10149,7 +10149,7 @@ function bnpDivRemTo(m,q,r) {
|
|
|
10149
10149
|
r.data[r.t++] = 1;
|
|
10150
10150
|
r.subTo(t,r);
|
|
10151
10151
|
}
|
|
10152
|
-
BigInteger.ONE.dlShiftTo(ys,t);
|
|
10152
|
+
BigInteger$2.ONE.dlShiftTo(ys,t);
|
|
10153
10153
|
t.subTo(y,y); // "negative" y so we can replace sub with am later
|
|
10154
10154
|
while(y.t < ys) y.data[y.t++] = 0;
|
|
10155
10155
|
while(--j >= 0) {
|
|
@@ -10163,19 +10163,19 @@ function bnpDivRemTo(m,q,r) {
|
|
|
10163
10163
|
}
|
|
10164
10164
|
if(q != null) {
|
|
10165
10165
|
r.drShiftTo(ys,q);
|
|
10166
|
-
if(ts != ms) BigInteger.ZERO.subTo(q,q);
|
|
10166
|
+
if(ts != ms) BigInteger$2.ZERO.subTo(q,q);
|
|
10167
10167
|
}
|
|
10168
10168
|
r.t = ys;
|
|
10169
10169
|
r.clamp();
|
|
10170
10170
|
if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
|
|
10171
|
-
if(ts < 0) BigInteger.ZERO.subTo(r,r);
|
|
10171
|
+
if(ts < 0) BigInteger$2.ZERO.subTo(r,r);
|
|
10172
10172
|
}
|
|
10173
10173
|
|
|
10174
10174
|
// (public) this mod a
|
|
10175
10175
|
function bnMod(a) {
|
|
10176
10176
|
var r = nbi();
|
|
10177
10177
|
this.abs().divRemTo(a,null,r);
|
|
10178
|
-
if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
|
|
10178
|
+
if(this.s < 0 && r.compareTo(BigInteger$2.ZERO) > 0) a.subTo(r,r);
|
|
10179
10179
|
return r;
|
|
10180
10180
|
}
|
|
10181
10181
|
|
|
@@ -10236,7 +10236,7 @@ function montConvert(x) {
|
|
|
10236
10236
|
var r = nbi();
|
|
10237
10237
|
x.abs().dlShiftTo(this.m.t,r);
|
|
10238
10238
|
r.divRemTo(this.m,null,r);
|
|
10239
|
-
if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
|
|
10239
|
+
if(x.s < 0 && r.compareTo(BigInteger$2.ZERO) > 0) this.m.subTo(r,r);
|
|
10240
10240
|
return r;
|
|
10241
10241
|
}
|
|
10242
10242
|
|
|
@@ -10284,7 +10284,7 @@ function bnpIsEven() { return ((this.t>0)?(this.data[0]&1):this.s) == 0; }
|
|
|
10284
10284
|
|
|
10285
10285
|
// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
|
|
10286
10286
|
function bnpExp(e,z) {
|
|
10287
|
-
if(e > 0xffffffff || e < 1) return BigInteger.ONE;
|
|
10287
|
+
if(e > 0xffffffff || e < 1) return BigInteger$2.ONE;
|
|
10288
10288
|
var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
|
|
10289
10289
|
g.copyTo(r);
|
|
10290
10290
|
while(--i >= 0) {
|
|
@@ -10303,34 +10303,34 @@ function bnModPowInt(e,m) {
|
|
|
10303
10303
|
}
|
|
10304
10304
|
|
|
10305
10305
|
// protected
|
|
10306
|
-
BigInteger.prototype.copyTo = bnpCopyTo;
|
|
10307
|
-
BigInteger.prototype.fromInt = bnpFromInt;
|
|
10308
|
-
BigInteger.prototype.fromString = bnpFromString;
|
|
10309
|
-
BigInteger.prototype.clamp = bnpClamp;
|
|
10310
|
-
BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
|
|
10311
|
-
BigInteger.prototype.drShiftTo = bnpDRShiftTo;
|
|
10312
|
-
BigInteger.prototype.lShiftTo = bnpLShiftTo;
|
|
10313
|
-
BigInteger.prototype.rShiftTo = bnpRShiftTo;
|
|
10314
|
-
BigInteger.prototype.subTo = bnpSubTo;
|
|
10315
|
-
BigInteger.prototype.multiplyTo = bnpMultiplyTo;
|
|
10316
|
-
BigInteger.prototype.squareTo = bnpSquareTo;
|
|
10317
|
-
BigInteger.prototype.divRemTo = bnpDivRemTo;
|
|
10318
|
-
BigInteger.prototype.invDigit = bnpInvDigit;
|
|
10319
|
-
BigInteger.prototype.isEven = bnpIsEven;
|
|
10320
|
-
BigInteger.prototype.exp = bnpExp;
|
|
10306
|
+
BigInteger$2.prototype.copyTo = bnpCopyTo;
|
|
10307
|
+
BigInteger$2.prototype.fromInt = bnpFromInt;
|
|
10308
|
+
BigInteger$2.prototype.fromString = bnpFromString;
|
|
10309
|
+
BigInteger$2.prototype.clamp = bnpClamp;
|
|
10310
|
+
BigInteger$2.prototype.dlShiftTo = bnpDLShiftTo;
|
|
10311
|
+
BigInteger$2.prototype.drShiftTo = bnpDRShiftTo;
|
|
10312
|
+
BigInteger$2.prototype.lShiftTo = bnpLShiftTo;
|
|
10313
|
+
BigInteger$2.prototype.rShiftTo = bnpRShiftTo;
|
|
10314
|
+
BigInteger$2.prototype.subTo = bnpSubTo;
|
|
10315
|
+
BigInteger$2.prototype.multiplyTo = bnpMultiplyTo;
|
|
10316
|
+
BigInteger$2.prototype.squareTo = bnpSquareTo;
|
|
10317
|
+
BigInteger$2.prototype.divRemTo = bnpDivRemTo;
|
|
10318
|
+
BigInteger$2.prototype.invDigit = bnpInvDigit;
|
|
10319
|
+
BigInteger$2.prototype.isEven = bnpIsEven;
|
|
10320
|
+
BigInteger$2.prototype.exp = bnpExp;
|
|
10321
10321
|
|
|
10322
10322
|
// public
|
|
10323
|
-
BigInteger.prototype.toString = bnToString;
|
|
10324
|
-
BigInteger.prototype.negate = bnNegate;
|
|
10325
|
-
BigInteger.prototype.abs = bnAbs;
|
|
10326
|
-
BigInteger.prototype.compareTo = bnCompareTo;
|
|
10327
|
-
BigInteger.prototype.bitLength = bnBitLength;
|
|
10328
|
-
BigInteger.prototype.mod = bnMod;
|
|
10329
|
-
BigInteger.prototype.modPowInt = bnModPowInt;
|
|
10323
|
+
BigInteger$2.prototype.toString = bnToString;
|
|
10324
|
+
BigInteger$2.prototype.negate = bnNegate;
|
|
10325
|
+
BigInteger$2.prototype.abs = bnAbs;
|
|
10326
|
+
BigInteger$2.prototype.compareTo = bnCompareTo;
|
|
10327
|
+
BigInteger$2.prototype.bitLength = bnBitLength;
|
|
10328
|
+
BigInteger$2.prototype.mod = bnMod;
|
|
10329
|
+
BigInteger$2.prototype.modPowInt = bnModPowInt;
|
|
10330
10330
|
|
|
10331
10331
|
// "constants"
|
|
10332
|
-
BigInteger.ZERO = nbv(0);
|
|
10333
|
-
BigInteger.ONE = nbv(1);
|
|
10332
|
+
BigInteger$2.ZERO = nbv(0);
|
|
10333
|
+
BigInteger$2.ONE = nbv(1);
|
|
10334
10334
|
|
|
10335
10335
|
// jsbn2 lib
|
|
10336
10336
|
|
|
@@ -10411,7 +10411,7 @@ if(j > 0) {
|
|
|
10411
10411
|
this.dMultiply(Math.pow(b,j));
|
|
10412
10412
|
this.dAddOffset(w,0);
|
|
10413
10413
|
}
|
|
10414
|
-
if(mi) BigInteger.ZERO.subTo(this,this);
|
|
10414
|
+
if(mi) BigInteger$2.ZERO.subTo(this,this);
|
|
10415
10415
|
}
|
|
10416
10416
|
|
|
10417
10417
|
//(protected) alternate constructor
|
|
@@ -10422,11 +10422,11 @@ if("number" == typeof b) {
|
|
|
10422
10422
|
else {
|
|
10423
10423
|
this.fromNumber(a,c);
|
|
10424
10424
|
if(!this.testBit(a-1)) // force MSB set
|
|
10425
|
-
this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
|
|
10425
|
+
this.bitwiseTo(BigInteger$2.ONE.shiftLeft(a-1),op_or,this);
|
|
10426
10426
|
if(this.isEven()) this.dAddOffset(1,0); // force odd
|
|
10427
10427
|
while(!this.isProbablePrime(b)) {
|
|
10428
10428
|
this.dAddOffset(2,0);
|
|
10429
|
-
if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
|
|
10429
|
+
if(this.bitLength() > a) this.subTo(BigInteger$2.ONE.shiftLeft(a-1),this);
|
|
10430
10430
|
}
|
|
10431
10431
|
}
|
|
10432
10432
|
} else {
|
|
@@ -10566,7 +10566,7 @@ return((this.data[j]&(1<<(n%this.DB)))!=0);
|
|
|
10566
10566
|
|
|
10567
10567
|
//(protected) this op (1<<n)
|
|
10568
10568
|
function bnpChangeBit(n,op) {
|
|
10569
|
-
var r = BigInteger.ONE.shiftLeft(n);
|
|
10569
|
+
var r = BigInteger$2.ONE.shiftLeft(n);
|
|
10570
10570
|
this.bitwiseTo(r,op,r);
|
|
10571
10571
|
return r;
|
|
10572
10572
|
}
|
|
@@ -10698,7 +10698,7 @@ function Barrett(m) {
|
|
|
10698
10698
|
// setup Barrett
|
|
10699
10699
|
this.r2 = nbi();
|
|
10700
10700
|
this.q3 = nbi();
|
|
10701
|
-
BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
|
|
10701
|
+
BigInteger$2.ONE.dlShiftTo(2*m.t,this.r2);
|
|
10702
10702
|
this.mu = this.r2.divide(m);
|
|
10703
10703
|
this.m = m;
|
|
10704
10704
|
}
|
|
@@ -10832,7 +10832,7 @@ return r;
|
|
|
10832
10832
|
//(public) 1/this % m (HAC 14.61)
|
|
10833
10833
|
function bnModInverse(m) {
|
|
10834
10834
|
var ac = m.isEven();
|
|
10835
|
-
if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
|
|
10835
|
+
if((this.isEven() && ac) || m.signum() == 0) return BigInteger$2.ZERO;
|
|
10836
10836
|
var u = m.clone(), v = this.clone();
|
|
10837
10837
|
var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
|
|
10838
10838
|
while(u.signum() != 0) {
|
|
@@ -10862,7 +10862,7 @@ while(u.signum() != 0) {
|
|
|
10862
10862
|
d.subTo(b,d);
|
|
10863
10863
|
}
|
|
10864
10864
|
}
|
|
10865
|
-
if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
|
|
10865
|
+
if(v.compareTo(BigInteger$2.ONE) != 0) return BigInteger$2.ZERO;
|
|
10866
10866
|
if(d.compareTo(m) >= 0) return d.subtract(m);
|
|
10867
10867
|
if(d.signum() < 0) d.addTo(m,d); else return d;
|
|
10868
10868
|
if(d.signum() < 0) return d.add(m); else return d;
|
|
@@ -10892,7 +10892,7 @@ return x.millerRabin(t);
|
|
|
10892
10892
|
|
|
10893
10893
|
//(protected) true if probably prime (HAC 4.24, Miller-Rabin)
|
|
10894
10894
|
function bnpMillerRabin(t) {
|
|
10895
|
-
var n1 = this.subtract(BigInteger.ONE);
|
|
10895
|
+
var n1 = this.subtract(BigInteger$2.ONE);
|
|
10896
10896
|
var k = n1.getLowestSetBit();
|
|
10897
10897
|
if(k <= 0) return false;
|
|
10898
10898
|
var r = n1.shiftRight(k);
|
|
@@ -10901,15 +10901,15 @@ var a;
|
|
|
10901
10901
|
for(var i = 0; i < t; ++i) {
|
|
10902
10902
|
// select witness 'a' at random from between 1 and n1
|
|
10903
10903
|
do {
|
|
10904
|
-
a = new BigInteger(this.bitLength(), prng);
|
|
10904
|
+
a = new BigInteger$2(this.bitLength(), prng);
|
|
10905
10905
|
}
|
|
10906
|
-
while(a.compareTo(BigInteger.ONE) <= 0 || a.compareTo(n1) >= 0);
|
|
10906
|
+
while(a.compareTo(BigInteger$2.ONE) <= 0 || a.compareTo(n1) >= 0);
|
|
10907
10907
|
var y = a.modPow(r,this);
|
|
10908
|
-
if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
|
|
10908
|
+
if(y.compareTo(BigInteger$2.ONE) != 0 && y.compareTo(n1) != 0) {
|
|
10909
10909
|
var j = 1;
|
|
10910
10910
|
while(j++ < k && y.compareTo(n1) != 0) {
|
|
10911
10911
|
y = y.modPowInt(2,this);
|
|
10912
|
-
if(y.compareTo(BigInteger.ONE) == 0) return false;
|
|
10912
|
+
if(y.compareTo(BigInteger$2.ONE) == 0) return false;
|
|
10913
10913
|
}
|
|
10914
10914
|
if(y.compareTo(n1) != 0) return false;
|
|
10915
10915
|
}
|
|
@@ -10931,54 +10931,54 @@ function bnGetPrng() {
|
|
|
10931
10931
|
}
|
|
10932
10932
|
|
|
10933
10933
|
//protected
|
|
10934
|
-
BigInteger.prototype.chunkSize = bnpChunkSize;
|
|
10935
|
-
BigInteger.prototype.toRadix = bnpToRadix;
|
|
10936
|
-
BigInteger.prototype.fromRadix = bnpFromRadix;
|
|
10937
|
-
BigInteger.prototype.fromNumber = bnpFromNumber;
|
|
10938
|
-
BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
|
|
10939
|
-
BigInteger.prototype.changeBit = bnpChangeBit;
|
|
10940
|
-
BigInteger.prototype.addTo = bnpAddTo;
|
|
10941
|
-
BigInteger.prototype.dMultiply = bnpDMultiply;
|
|
10942
|
-
BigInteger.prototype.dAddOffset = bnpDAddOffset;
|
|
10943
|
-
BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
|
|
10944
|
-
BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
|
|
10945
|
-
BigInteger.prototype.modInt = bnpModInt;
|
|
10946
|
-
BigInteger.prototype.millerRabin = bnpMillerRabin;
|
|
10934
|
+
BigInteger$2.prototype.chunkSize = bnpChunkSize;
|
|
10935
|
+
BigInteger$2.prototype.toRadix = bnpToRadix;
|
|
10936
|
+
BigInteger$2.prototype.fromRadix = bnpFromRadix;
|
|
10937
|
+
BigInteger$2.prototype.fromNumber = bnpFromNumber;
|
|
10938
|
+
BigInteger$2.prototype.bitwiseTo = bnpBitwiseTo;
|
|
10939
|
+
BigInteger$2.prototype.changeBit = bnpChangeBit;
|
|
10940
|
+
BigInteger$2.prototype.addTo = bnpAddTo;
|
|
10941
|
+
BigInteger$2.prototype.dMultiply = bnpDMultiply;
|
|
10942
|
+
BigInteger$2.prototype.dAddOffset = bnpDAddOffset;
|
|
10943
|
+
BigInteger$2.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
|
|
10944
|
+
BigInteger$2.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
|
|
10945
|
+
BigInteger$2.prototype.modInt = bnpModInt;
|
|
10946
|
+
BigInteger$2.prototype.millerRabin = bnpMillerRabin;
|
|
10947
10947
|
|
|
10948
10948
|
//public
|
|
10949
|
-
BigInteger.prototype.clone = bnClone;
|
|
10950
|
-
BigInteger.prototype.intValue = bnIntValue;
|
|
10951
|
-
BigInteger.prototype.byteValue = bnByteValue;
|
|
10952
|
-
BigInteger.prototype.shortValue = bnShortValue;
|
|
10953
|
-
BigInteger.prototype.signum = bnSigNum;
|
|
10954
|
-
BigInteger.prototype.toByteArray = bnToByteArray;
|
|
10955
|
-
BigInteger.prototype.equals = bnEquals;
|
|
10956
|
-
BigInteger.prototype.min = bnMin;
|
|
10957
|
-
BigInteger.prototype.max = bnMax;
|
|
10958
|
-
BigInteger.prototype.and = bnAnd;
|
|
10959
|
-
BigInteger.prototype.or = bnOr;
|
|
10960
|
-
BigInteger.prototype.xor = bnXor;
|
|
10961
|
-
BigInteger.prototype.andNot = bnAndNot;
|
|
10962
|
-
BigInteger.prototype.not = bnNot;
|
|
10963
|
-
BigInteger.prototype.shiftLeft = bnShiftLeft;
|
|
10964
|
-
BigInteger.prototype.shiftRight = bnShiftRight;
|
|
10965
|
-
BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
|
|
10966
|
-
BigInteger.prototype.bitCount = bnBitCount;
|
|
10967
|
-
BigInteger.prototype.testBit = bnTestBit;
|
|
10968
|
-
BigInteger.prototype.setBit = bnSetBit;
|
|
10969
|
-
BigInteger.prototype.clearBit = bnClearBit;
|
|
10970
|
-
BigInteger.prototype.flipBit = bnFlipBit;
|
|
10971
|
-
BigInteger.prototype.add = bnAdd;
|
|
10972
|
-
BigInteger.prototype.subtract = bnSubtract;
|
|
10973
|
-
BigInteger.prototype.multiply = bnMultiply;
|
|
10974
|
-
BigInteger.prototype.divide = bnDivide;
|
|
10975
|
-
BigInteger.prototype.remainder = bnRemainder;
|
|
10976
|
-
BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
|
|
10977
|
-
BigInteger.prototype.modPow = bnModPow;
|
|
10978
|
-
BigInteger.prototype.modInverse = bnModInverse;
|
|
10979
|
-
BigInteger.prototype.pow = bnPow;
|
|
10980
|
-
BigInteger.prototype.gcd = bnGCD;
|
|
10981
|
-
BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
|
|
10949
|
+
BigInteger$2.prototype.clone = bnClone;
|
|
10950
|
+
BigInteger$2.prototype.intValue = bnIntValue;
|
|
10951
|
+
BigInteger$2.prototype.byteValue = bnByteValue;
|
|
10952
|
+
BigInteger$2.prototype.shortValue = bnShortValue;
|
|
10953
|
+
BigInteger$2.prototype.signum = bnSigNum;
|
|
10954
|
+
BigInteger$2.prototype.toByteArray = bnToByteArray;
|
|
10955
|
+
BigInteger$2.prototype.equals = bnEquals;
|
|
10956
|
+
BigInteger$2.prototype.min = bnMin;
|
|
10957
|
+
BigInteger$2.prototype.max = bnMax;
|
|
10958
|
+
BigInteger$2.prototype.and = bnAnd;
|
|
10959
|
+
BigInteger$2.prototype.or = bnOr;
|
|
10960
|
+
BigInteger$2.prototype.xor = bnXor;
|
|
10961
|
+
BigInteger$2.prototype.andNot = bnAndNot;
|
|
10962
|
+
BigInteger$2.prototype.not = bnNot;
|
|
10963
|
+
BigInteger$2.prototype.shiftLeft = bnShiftLeft;
|
|
10964
|
+
BigInteger$2.prototype.shiftRight = bnShiftRight;
|
|
10965
|
+
BigInteger$2.prototype.getLowestSetBit = bnGetLowestSetBit;
|
|
10966
|
+
BigInteger$2.prototype.bitCount = bnBitCount;
|
|
10967
|
+
BigInteger$2.prototype.testBit = bnTestBit;
|
|
10968
|
+
BigInteger$2.prototype.setBit = bnSetBit;
|
|
10969
|
+
BigInteger$2.prototype.clearBit = bnClearBit;
|
|
10970
|
+
BigInteger$2.prototype.flipBit = bnFlipBit;
|
|
10971
|
+
BigInteger$2.prototype.add = bnAdd;
|
|
10972
|
+
BigInteger$2.prototype.subtract = bnSubtract;
|
|
10973
|
+
BigInteger$2.prototype.multiply = bnMultiply;
|
|
10974
|
+
BigInteger$2.prototype.divide = bnDivide;
|
|
10975
|
+
BigInteger$2.prototype.remainder = bnRemainder;
|
|
10976
|
+
BigInteger$2.prototype.divideAndRemainder = bnDivideAndRemainder;
|
|
10977
|
+
BigInteger$2.prototype.modPow = bnModPow;
|
|
10978
|
+
BigInteger$2.prototype.modInverse = bnModInverse;
|
|
10979
|
+
BigInteger$2.prototype.pow = bnPow;
|
|
10980
|
+
BigInteger$2.prototype.gcd = bnGCD;
|
|
10981
|
+
BigInteger$2.prototype.isProbablePrime = bnIsProbablePrime;
|
|
10982
10982
|
|
|
10983
10983
|
/**
|
|
10984
10984
|
* Secure Hash Algorithm with 160-bit digest (SHA-1) implementation.
|
|
@@ -11938,7 +11938,7 @@ if(typeof BigInteger$1 === 'undefined') {
|
|
|
11938
11938
|
var _crypto = forge.util.isNodejs ? require$$0__default : null;
|
|
11939
11939
|
|
|
11940
11940
|
// shortcut for asn.1 API
|
|
11941
|
-
var asn1 = forge.asn1;
|
|
11941
|
+
var asn1$2 = forge.asn1;
|
|
11942
11942
|
|
|
11943
11943
|
// shortcut for util API
|
|
11944
11944
|
var util = forge.util;
|
|
@@ -11948,43 +11948,43 @@ var util = forge.util;
|
|
|
11948
11948
|
*/
|
|
11949
11949
|
forge.pki = forge.pki || {};
|
|
11950
11950
|
forge.pki.rsa = forge.rsa = forge.rsa || {};
|
|
11951
|
-
var pki = forge.pki;
|
|
11951
|
+
var pki$1 = forge.pki;
|
|
11952
11952
|
|
|
11953
11953
|
// for finding primes, which are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
|
|
11954
11954
|
var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
|
|
11955
11955
|
|
|
11956
11956
|
// validator for a PrivateKeyInfo structure
|
|
11957
|
-
var privateKeyValidator = {
|
|
11957
|
+
var privateKeyValidator$2 = {
|
|
11958
11958
|
// PrivateKeyInfo
|
|
11959
11959
|
name: 'PrivateKeyInfo',
|
|
11960
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
11961
|
-
type: asn1.Type.SEQUENCE,
|
|
11960
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
11961
|
+
type: asn1$2.Type.SEQUENCE,
|
|
11962
11962
|
constructed: true,
|
|
11963
11963
|
value: [{
|
|
11964
11964
|
// Version (INTEGER)
|
|
11965
11965
|
name: 'PrivateKeyInfo.version',
|
|
11966
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
11967
|
-
type: asn1.Type.INTEGER,
|
|
11966
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
11967
|
+
type: asn1$2.Type.INTEGER,
|
|
11968
11968
|
constructed: false,
|
|
11969
11969
|
capture: 'privateKeyVersion'
|
|
11970
11970
|
}, {
|
|
11971
11971
|
// privateKeyAlgorithm
|
|
11972
11972
|
name: 'PrivateKeyInfo.privateKeyAlgorithm',
|
|
11973
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
11974
|
-
type: asn1.Type.SEQUENCE,
|
|
11973
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
11974
|
+
type: asn1$2.Type.SEQUENCE,
|
|
11975
11975
|
constructed: true,
|
|
11976
11976
|
value: [{
|
|
11977
11977
|
name: 'AlgorithmIdentifier.algorithm',
|
|
11978
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
11979
|
-
type: asn1.Type.OID,
|
|
11978
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
11979
|
+
type: asn1$2.Type.OID,
|
|
11980
11980
|
constructed: false,
|
|
11981
11981
|
capture: 'privateKeyOid'
|
|
11982
11982
|
}]
|
|
11983
11983
|
}, {
|
|
11984
11984
|
// PrivateKey
|
|
11985
11985
|
name: 'PrivateKeyInfo',
|
|
11986
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
11987
|
-
type: asn1.Type.OCTETSTRING,
|
|
11986
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
11987
|
+
type: asn1$2.Type.OCTETSTRING,
|
|
11988
11988
|
constructed: false,
|
|
11989
11989
|
capture: 'privateKey'
|
|
11990
11990
|
}]
|
|
@@ -11994,70 +11994,70 @@ var privateKeyValidator = {
|
|
|
11994
11994
|
var rsaPrivateKeyValidator = {
|
|
11995
11995
|
// RSAPrivateKey
|
|
11996
11996
|
name: 'RSAPrivateKey',
|
|
11997
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
11998
|
-
type: asn1.Type.SEQUENCE,
|
|
11997
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
11998
|
+
type: asn1$2.Type.SEQUENCE,
|
|
11999
11999
|
constructed: true,
|
|
12000
12000
|
value: [{
|
|
12001
12001
|
// Version (INTEGER)
|
|
12002
12002
|
name: 'RSAPrivateKey.version',
|
|
12003
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12004
|
-
type: asn1.Type.INTEGER,
|
|
12003
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12004
|
+
type: asn1$2.Type.INTEGER,
|
|
12005
12005
|
constructed: false,
|
|
12006
12006
|
capture: 'privateKeyVersion'
|
|
12007
12007
|
}, {
|
|
12008
12008
|
// modulus (n)
|
|
12009
12009
|
name: 'RSAPrivateKey.modulus',
|
|
12010
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12011
|
-
type: asn1.Type.INTEGER,
|
|
12010
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12011
|
+
type: asn1$2.Type.INTEGER,
|
|
12012
12012
|
constructed: false,
|
|
12013
12013
|
capture: 'privateKeyModulus'
|
|
12014
12014
|
}, {
|
|
12015
12015
|
// publicExponent (e)
|
|
12016
12016
|
name: 'RSAPrivateKey.publicExponent',
|
|
12017
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12018
|
-
type: asn1.Type.INTEGER,
|
|
12017
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12018
|
+
type: asn1$2.Type.INTEGER,
|
|
12019
12019
|
constructed: false,
|
|
12020
12020
|
capture: 'privateKeyPublicExponent'
|
|
12021
12021
|
}, {
|
|
12022
12022
|
// privateExponent (d)
|
|
12023
12023
|
name: 'RSAPrivateKey.privateExponent',
|
|
12024
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12025
|
-
type: asn1.Type.INTEGER,
|
|
12024
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12025
|
+
type: asn1$2.Type.INTEGER,
|
|
12026
12026
|
constructed: false,
|
|
12027
12027
|
capture: 'privateKeyPrivateExponent'
|
|
12028
12028
|
}, {
|
|
12029
12029
|
// prime1 (p)
|
|
12030
12030
|
name: 'RSAPrivateKey.prime1',
|
|
12031
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12032
|
-
type: asn1.Type.INTEGER,
|
|
12031
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12032
|
+
type: asn1$2.Type.INTEGER,
|
|
12033
12033
|
constructed: false,
|
|
12034
12034
|
capture: 'privateKeyPrime1'
|
|
12035
12035
|
}, {
|
|
12036
12036
|
// prime2 (q)
|
|
12037
12037
|
name: 'RSAPrivateKey.prime2',
|
|
12038
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12039
|
-
type: asn1.Type.INTEGER,
|
|
12038
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12039
|
+
type: asn1$2.Type.INTEGER,
|
|
12040
12040
|
constructed: false,
|
|
12041
12041
|
capture: 'privateKeyPrime2'
|
|
12042
12042
|
}, {
|
|
12043
12043
|
// exponent1 (d mod (p-1))
|
|
12044
12044
|
name: 'RSAPrivateKey.exponent1',
|
|
12045
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12046
|
-
type: asn1.Type.INTEGER,
|
|
12045
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12046
|
+
type: asn1$2.Type.INTEGER,
|
|
12047
12047
|
constructed: false,
|
|
12048
12048
|
capture: 'privateKeyExponent1'
|
|
12049
12049
|
}, {
|
|
12050
12050
|
// exponent2 (d mod (q-1))
|
|
12051
12051
|
name: 'RSAPrivateKey.exponent2',
|
|
12052
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12053
|
-
type: asn1.Type.INTEGER,
|
|
12052
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12053
|
+
type: asn1$2.Type.INTEGER,
|
|
12054
12054
|
constructed: false,
|
|
12055
12055
|
capture: 'privateKeyExponent2'
|
|
12056
12056
|
}, {
|
|
12057
12057
|
// coefficient ((inverse of q) mod p)
|
|
12058
12058
|
name: 'RSAPrivateKey.coefficient',
|
|
12059
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12060
|
-
type: asn1.Type.INTEGER,
|
|
12059
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12060
|
+
type: asn1$2.Type.INTEGER,
|
|
12061
12061
|
constructed: false,
|
|
12062
12062
|
capture: 'privateKeyCoefficient'
|
|
12063
12063
|
}]
|
|
@@ -12067,21 +12067,21 @@ var rsaPrivateKeyValidator = {
|
|
|
12067
12067
|
var rsaPublicKeyValidator = {
|
|
12068
12068
|
// RSAPublicKey
|
|
12069
12069
|
name: 'RSAPublicKey',
|
|
12070
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12071
|
-
type: asn1.Type.SEQUENCE,
|
|
12070
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12071
|
+
type: asn1$2.Type.SEQUENCE,
|
|
12072
12072
|
constructed: true,
|
|
12073
12073
|
value: [{
|
|
12074
12074
|
// modulus (n)
|
|
12075
12075
|
name: 'RSAPublicKey.modulus',
|
|
12076
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12077
|
-
type: asn1.Type.INTEGER,
|
|
12076
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12077
|
+
type: asn1$2.Type.INTEGER,
|
|
12078
12078
|
constructed: false,
|
|
12079
12079
|
capture: 'publicKeyModulus'
|
|
12080
12080
|
}, {
|
|
12081
12081
|
// publicExponent (e)
|
|
12082
12082
|
name: 'RSAPublicKey.exponent',
|
|
12083
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12084
|
-
type: asn1.Type.INTEGER,
|
|
12083
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12084
|
+
type: asn1$2.Type.INTEGER,
|
|
12085
12085
|
constructed: false,
|
|
12086
12086
|
capture: 'publicKeyExponent'
|
|
12087
12087
|
}]
|
|
@@ -12089,35 +12089,35 @@ var rsaPublicKeyValidator = {
|
|
|
12089
12089
|
|
|
12090
12090
|
// validator for an SubjectPublicKeyInfo structure
|
|
12091
12091
|
// Note: Currently only works with an RSA public key
|
|
12092
|
-
var publicKeyValidator = forge.pki.rsa.publicKeyValidator = {
|
|
12092
|
+
var publicKeyValidator$2 = forge.pki.rsa.publicKeyValidator = {
|
|
12093
12093
|
name: 'SubjectPublicKeyInfo',
|
|
12094
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12095
|
-
type: asn1.Type.SEQUENCE,
|
|
12094
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12095
|
+
type: asn1$2.Type.SEQUENCE,
|
|
12096
12096
|
constructed: true,
|
|
12097
12097
|
captureAsn1: 'subjectPublicKeyInfo',
|
|
12098
12098
|
value: [{
|
|
12099
12099
|
name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
|
|
12100
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12101
|
-
type: asn1.Type.SEQUENCE,
|
|
12100
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12101
|
+
type: asn1$2.Type.SEQUENCE,
|
|
12102
12102
|
constructed: true,
|
|
12103
12103
|
value: [{
|
|
12104
12104
|
name: 'AlgorithmIdentifier.algorithm',
|
|
12105
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12106
|
-
type: asn1.Type.OID,
|
|
12105
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12106
|
+
type: asn1$2.Type.OID,
|
|
12107
12107
|
constructed: false,
|
|
12108
12108
|
capture: 'publicKeyOid'
|
|
12109
12109
|
}]
|
|
12110
12110
|
}, {
|
|
12111
12111
|
// subjectPublicKey
|
|
12112
12112
|
name: 'SubjectPublicKeyInfo.subjectPublicKey',
|
|
12113
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12114
|
-
type: asn1.Type.BITSTRING,
|
|
12113
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12114
|
+
type: asn1$2.Type.BITSTRING,
|
|
12115
12115
|
constructed: false,
|
|
12116
12116
|
value: [{
|
|
12117
12117
|
// RSAPublicKey
|
|
12118
12118
|
name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
|
|
12119
|
-
tagClass: asn1.Class.UNIVERSAL,
|
|
12120
|
-
type: asn1.Type.SEQUENCE,
|
|
12119
|
+
tagClass: asn1$2.Class.UNIVERSAL,
|
|
12120
|
+
type: asn1$2.Type.SEQUENCE,
|
|
12121
12121
|
constructed: true,
|
|
12122
12122
|
optional: true,
|
|
12123
12123
|
captureAsn1: 'rsaPublicKey'
|
|
@@ -12145,32 +12145,32 @@ var publicKeyValidator = forge.pki.rsa.publicKeyValidator = {
|
|
|
12145
12145
|
var emsaPkcs1v15encode = function(md) {
|
|
12146
12146
|
// get the oid for the algorithm
|
|
12147
12147
|
var oid;
|
|
12148
|
-
if(md.algorithm in pki.oids) {
|
|
12149
|
-
oid = pki.oids[md.algorithm];
|
|
12148
|
+
if(md.algorithm in pki$1.oids) {
|
|
12149
|
+
oid = pki$1.oids[md.algorithm];
|
|
12150
12150
|
} else {
|
|
12151
12151
|
var error = new Error('Unknown message digest algorithm.');
|
|
12152
12152
|
error.algorithm = md.algorithm;
|
|
12153
12153
|
throw error;
|
|
12154
12154
|
}
|
|
12155
|
-
var oidBytes = asn1.oidToDer(oid).getBytes();
|
|
12155
|
+
var oidBytes = asn1$2.oidToDer(oid).getBytes();
|
|
12156
12156
|
|
|
12157
12157
|
// create the digest info
|
|
12158
|
-
var digestInfo = asn1.create(
|
|
12159
|
-
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
|
|
12160
|
-
var digestAlgorithm = asn1.create(
|
|
12161
|
-
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
|
|
12162
|
-
digestAlgorithm.value.push(asn1.create(
|
|
12163
|
-
asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));
|
|
12164
|
-
digestAlgorithm.value.push(asn1.create(
|
|
12165
|
-
asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));
|
|
12166
|
-
var digest = asn1.create(
|
|
12167
|
-
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,
|
|
12158
|
+
var digestInfo = asn1$2.create(
|
|
12159
|
+
asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, []);
|
|
12160
|
+
var digestAlgorithm = asn1$2.create(
|
|
12161
|
+
asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, []);
|
|
12162
|
+
digestAlgorithm.value.push(asn1$2.create(
|
|
12163
|
+
asn1$2.Class.UNIVERSAL, asn1$2.Type.OID, false, oidBytes));
|
|
12164
|
+
digestAlgorithm.value.push(asn1$2.create(
|
|
12165
|
+
asn1$2.Class.UNIVERSAL, asn1$2.Type.NULL, false, ''));
|
|
12166
|
+
var digest = asn1$2.create(
|
|
12167
|
+
asn1$2.Class.UNIVERSAL, asn1$2.Type.OCTETSTRING,
|
|
12168
12168
|
false, md.digest().getBytes());
|
|
12169
12169
|
digestInfo.value.push(digestAlgorithm);
|
|
12170
12170
|
digestInfo.value.push(digest);
|
|
12171
12171
|
|
|
12172
12172
|
// encode digest info
|
|
12173
|
-
return asn1.toDer(digestInfo).getBytes();
|
|
12173
|
+
return asn1$2.toDer(digestInfo).getBytes();
|
|
12174
12174
|
};
|
|
12175
12175
|
|
|
12176
12176
|
/**
|
|
@@ -12338,7 +12338,7 @@ var _modPow = function(x, key, pub) {
|
|
|
12338
12338
|
*
|
|
12339
12339
|
* @return the encrypted bytes as a string.
|
|
12340
12340
|
*/
|
|
12341
|
-
pki.rsa.encrypt = function(m, key, bt) {
|
|
12341
|
+
pki$1.rsa.encrypt = function(m, key, bt) {
|
|
12342
12342
|
var pub = bt;
|
|
12343
12343
|
var eb;
|
|
12344
12344
|
|
|
@@ -12393,7 +12393,7 @@ pki.rsa.encrypt = function(m, key, bt) {
|
|
|
12393
12393
|
*
|
|
12394
12394
|
* @return the decrypted message as a byte string.
|
|
12395
12395
|
*/
|
|
12396
|
-
pki.rsa.decrypt = function(ed, key, pub, ml) {
|
|
12396
|
+
pki$1.rsa.decrypt = function(ed, key, pub, ml) {
|
|
12397
12397
|
// get the length of the modulus in bytes
|
|
12398
12398
|
var k = Math.ceil(key.n.bitLength() / 8);
|
|
12399
12399
|
|
|
@@ -12453,7 +12453,7 @@ pki.rsa.decrypt = function(ed, key, pub, ml) {
|
|
|
12453
12453
|
*
|
|
12454
12454
|
* @return the state object to use to generate the key-pair.
|
|
12455
12455
|
*/
|
|
12456
|
-
pki.rsa.createKeyPairGenerationState = function(bits, e, options) {
|
|
12456
|
+
pki$1.rsa.createKeyPairGenerationState = function(bits, e, options) {
|
|
12457
12457
|
// TODO: migrate step-based prime generation code to forge.prime
|
|
12458
12458
|
|
|
12459
12459
|
// set default bits
|
|
@@ -12532,7 +12532,7 @@ pki.rsa.createKeyPairGenerationState = function(bits, e, options) {
|
|
|
12532
12532
|
*
|
|
12533
12533
|
* @return true if the key-generation completed, false if not.
|
|
12534
12534
|
*/
|
|
12535
|
-
pki.rsa.stepKeyPairGenerationState = function(state, n) {
|
|
12535
|
+
pki$1.rsa.stepKeyPairGenerationState = function(state, n) {
|
|
12536
12536
|
// set default algorithm if not set
|
|
12537
12537
|
if(!('algorithm' in state)) {
|
|
12538
12538
|
state.algorithm = 'PRIMEINC';
|
|
@@ -12655,11 +12655,11 @@ pki.rsa.stepKeyPairGenerationState = function(state, n) {
|
|
|
12655
12655
|
// set keys
|
|
12656
12656
|
var d = state.e.modInverse(state.phi);
|
|
12657
12657
|
state.keys = {
|
|
12658
|
-
privateKey: pki.rsa.setPrivateKey(
|
|
12658
|
+
privateKey: pki$1.rsa.setPrivateKey(
|
|
12659
12659
|
state.n, state.e, d, state.p, state.q,
|
|
12660
12660
|
d.mod(state.p1), d.mod(state.q1),
|
|
12661
12661
|
state.q.modInverse(state.p)),
|
|
12662
|
-
publicKey: pki.rsa.setPublicKey(state.n, state.e)
|
|
12662
|
+
publicKey: pki$1.rsa.setPublicKey(state.n, state.e)
|
|
12663
12663
|
};
|
|
12664
12664
|
}
|
|
12665
12665
|
|
|
@@ -12702,7 +12702,7 @@ pki.rsa.stepKeyPairGenerationState = function(state, n) {
|
|
|
12702
12702
|
*
|
|
12703
12703
|
* @return an object with privateKey and publicKey properties.
|
|
12704
12704
|
*/
|
|
12705
|
-
pki.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
12705
|
+
pki$1.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
12706
12706
|
// (bits), (options), (callback)
|
|
12707
12707
|
if(arguments.length === 1) {
|
|
12708
12708
|
if(typeof bits === 'object') {
|
|
@@ -12771,8 +12771,8 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
|
12771
12771
|
return callback(err);
|
|
12772
12772
|
}
|
|
12773
12773
|
callback(null, {
|
|
12774
|
-
privateKey: pki.privateKeyFromPem(priv),
|
|
12775
|
-
publicKey: pki.publicKeyFromPem(pub)
|
|
12774
|
+
privateKey: pki$1.privateKeyFromPem(priv),
|
|
12775
|
+
publicKey: pki$1.publicKeyFromPem(pub)
|
|
12776
12776
|
});
|
|
12777
12777
|
});
|
|
12778
12778
|
}
|
|
@@ -12793,11 +12793,11 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
|
12793
12793
|
callback(err);
|
|
12794
12794
|
}).then(function(pkcs8) {
|
|
12795
12795
|
if(pkcs8) {
|
|
12796
|
-
var privateKey = pki.privateKeyFromAsn1(
|
|
12797
|
-
asn1.fromDer(forge.util.createBuffer(pkcs8)));
|
|
12796
|
+
var privateKey = pki$1.privateKeyFromAsn1(
|
|
12797
|
+
asn1$2.fromDer(forge.util.createBuffer(pkcs8)));
|
|
12798
12798
|
callback(null, {
|
|
12799
12799
|
privateKey: privateKey,
|
|
12800
|
-
publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)
|
|
12800
|
+
publicKey: pki$1.setRsaPublicKey(privateKey.n, privateKey.e)
|
|
12801
12801
|
});
|
|
12802
12802
|
}
|
|
12803
12803
|
});
|
|
@@ -12816,11 +12816,11 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
|
12816
12816
|
'pkcs8', pair.privateKey);
|
|
12817
12817
|
exportOp.oncomplete = function(e) {
|
|
12818
12818
|
var pkcs8 = e.target.result;
|
|
12819
|
-
var privateKey = pki.privateKeyFromAsn1(
|
|
12820
|
-
asn1.fromDer(forge.util.createBuffer(pkcs8)));
|
|
12819
|
+
var privateKey = pki$1.privateKeyFromAsn1(
|
|
12820
|
+
asn1$2.fromDer(forge.util.createBuffer(pkcs8)));
|
|
12821
12821
|
callback(null, {
|
|
12822
12822
|
privateKey: privateKey,
|
|
12823
|
-
publicKey: pki.setRsaPublicKey(privateKey.n, privateKey.e)
|
|
12823
|
+
publicKey: pki$1.setRsaPublicKey(privateKey.n, privateKey.e)
|
|
12824
12824
|
});
|
|
12825
12825
|
};
|
|
12826
12826
|
exportOp.onerror = function(err) {
|
|
@@ -12848,17 +12848,17 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
|
12848
12848
|
}
|
|
12849
12849
|
});
|
|
12850
12850
|
return {
|
|
12851
|
-
privateKey: pki.privateKeyFromPem(keypair.privateKey),
|
|
12852
|
-
publicKey: pki.publicKeyFromPem(keypair.publicKey)
|
|
12851
|
+
privateKey: pki$1.privateKeyFromPem(keypair.privateKey),
|
|
12852
|
+
publicKey: pki$1.publicKeyFromPem(keypair.publicKey)
|
|
12853
12853
|
};
|
|
12854
12854
|
}
|
|
12855
12855
|
}
|
|
12856
12856
|
}
|
|
12857
12857
|
|
|
12858
12858
|
// use JavaScript implementation
|
|
12859
|
-
var state = pki.rsa.createKeyPairGenerationState(bits, e, options);
|
|
12859
|
+
var state = pki$1.rsa.createKeyPairGenerationState(bits, e, options);
|
|
12860
12860
|
if(!callback) {
|
|
12861
|
-
pki.rsa.stepKeyPairGenerationState(state, 0);
|
|
12861
|
+
pki$1.rsa.stepKeyPairGenerationState(state, 0);
|
|
12862
12862
|
return state.keys;
|
|
12863
12863
|
}
|
|
12864
12864
|
_generateKeyPair(state, options, callback);
|
|
@@ -12872,7 +12872,7 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
|
|
|
12872
12872
|
*
|
|
12873
12873
|
* @return the public key.
|
|
12874
12874
|
*/
|
|
12875
|
-
pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
|
|
12875
|
+
pki$1.setRsaPublicKey = pki$1.rsa.setPublicKey = function(n, e) {
|
|
12876
12876
|
var key = {
|
|
12877
12877
|
n: n,
|
|
12878
12878
|
e: e
|
|
@@ -12922,7 +12922,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
|
|
|
12922
12922
|
|
|
12923
12923
|
// do scheme-based encoding then rsa encryption
|
|
12924
12924
|
var e = scheme.encode(data, key, true);
|
|
12925
|
-
return pki.rsa.encrypt(e, key, true);
|
|
12925
|
+
return pki$1.rsa.encrypt(e, key, true);
|
|
12926
12926
|
};
|
|
12927
12927
|
|
|
12928
12928
|
/**
|
|
@@ -12969,7 +12969,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
|
|
|
12969
12969
|
// remove padding
|
|
12970
12970
|
d = _decodePkcs1_v1_5(d, key, true);
|
|
12971
12971
|
// d is ASN.1 BER-encoded DigestInfo
|
|
12972
|
-
var obj = asn1.fromDer(d);
|
|
12972
|
+
var obj = asn1$2.fromDer(d);
|
|
12973
12973
|
// compare the given digest to the decrypted one
|
|
12974
12974
|
return digest === obj.value[1].value;
|
|
12975
12975
|
}
|
|
@@ -12985,7 +12985,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
|
|
|
12985
12985
|
}
|
|
12986
12986
|
|
|
12987
12987
|
// do rsa decryption w/o any decoding, then verify -- which does decoding
|
|
12988
|
-
var d = pki.rsa.decrypt(signature, key, true, false);
|
|
12988
|
+
var d = pki$1.rsa.decrypt(signature, key, true, false);
|
|
12989
12989
|
return scheme.verify(digest, d, key.n.bitLength());
|
|
12990
12990
|
};
|
|
12991
12991
|
|
|
@@ -13007,7 +13007,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
|
|
|
13007
13007
|
*
|
|
13008
13008
|
* @return the private key.
|
|
13009
13009
|
*/
|
|
13010
|
-
pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
|
|
13010
|
+
pki$1.setRsaPrivateKey = pki$1.rsa.setPrivateKey = function(
|
|
13011
13011
|
n, e, d, p, q, dP, dQ, qInv) {
|
|
13012
13012
|
var key = {
|
|
13013
13013
|
n: n,
|
|
@@ -13041,7 +13041,7 @@ pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
|
|
|
13041
13041
|
}
|
|
13042
13042
|
|
|
13043
13043
|
// do rsa decryption w/o any decoding
|
|
13044
|
-
var d = pki.rsa.decrypt(data, key, false, false);
|
|
13044
|
+
var d = pki$1.rsa.decrypt(data, key, false, false);
|
|
13045
13045
|
|
|
13046
13046
|
if(scheme === 'RSAES-PKCS1-V1_5') {
|
|
13047
13047
|
scheme = {decode: _decodePkcs1_v1_5};
|
|
@@ -13103,7 +13103,7 @@ pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
|
|
|
13103
13103
|
|
|
13104
13104
|
// encode and then encrypt
|
|
13105
13105
|
var d = scheme.encode(md, key.n.bitLength());
|
|
13106
|
-
return pki.rsa.encrypt(d, key, bt);
|
|
13106
|
+
return pki$1.rsa.encrypt(d, key, bt);
|
|
13107
13107
|
};
|
|
13108
13108
|
|
|
13109
13109
|
return key;
|
|
@@ -13116,22 +13116,22 @@ pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
|
|
|
13116
13116
|
*
|
|
13117
13117
|
* @return the ASN.1 PrivateKeyInfo.
|
|
13118
13118
|
*/
|
|
13119
|
-
pki.wrapRsaPrivateKey = function(rsaKey) {
|
|
13119
|
+
pki$1.wrapRsaPrivateKey = function(rsaKey) {
|
|
13120
13120
|
// PrivateKeyInfo
|
|
13121
|
-
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
|
|
13121
|
+
return asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, [
|
|
13122
13122
|
// version (0)
|
|
13123
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13124
|
-
asn1.integerToDer(0).getBytes()),
|
|
13123
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13124
|
+
asn1$2.integerToDer(0).getBytes()),
|
|
13125
13125
|
// privateKeyAlgorithm
|
|
13126
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
|
|
13127
|
-
asn1.create(
|
|
13128
|
-
asn1.Class.UNIVERSAL, asn1.Type.OID, false,
|
|
13129
|
-
asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),
|
|
13130
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
|
|
13126
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, [
|
|
13127
|
+
asn1$2.create(
|
|
13128
|
+
asn1$2.Class.UNIVERSAL, asn1$2.Type.OID, false,
|
|
13129
|
+
asn1$2.oidToDer(pki$1.oids.rsaEncryption).getBytes()),
|
|
13130
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.NULL, false, '')
|
|
13131
13131
|
]),
|
|
13132
13132
|
// PrivateKey
|
|
13133
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
|
|
13134
|
-
asn1.toDer(rsaKey).getBytes())
|
|
13133
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.OCTETSTRING, false,
|
|
13134
|
+
asn1$2.toDer(rsaKey).getBytes())
|
|
13135
13135
|
]);
|
|
13136
13136
|
};
|
|
13137
13137
|
|
|
@@ -13143,18 +13143,18 @@ pki.wrapRsaPrivateKey = function(rsaKey) {
|
|
|
13143
13143
|
*
|
|
13144
13144
|
* @return the private key.
|
|
13145
13145
|
*/
|
|
13146
|
-
pki.privateKeyFromAsn1 = function(obj) {
|
|
13146
|
+
pki$1.privateKeyFromAsn1 = function(obj) {
|
|
13147
13147
|
// get PrivateKeyInfo
|
|
13148
13148
|
var capture = {};
|
|
13149
13149
|
var errors = [];
|
|
13150
|
-
if(asn1.validate(obj, privateKeyValidator, capture, errors)) {
|
|
13151
|
-
obj = asn1.fromDer(forge.util.createBuffer(capture.privateKey));
|
|
13150
|
+
if(asn1$2.validate(obj, privateKeyValidator$2, capture, errors)) {
|
|
13151
|
+
obj = asn1$2.fromDer(forge.util.createBuffer(capture.privateKey));
|
|
13152
13152
|
}
|
|
13153
13153
|
|
|
13154
13154
|
// get RSAPrivateKey
|
|
13155
13155
|
capture = {};
|
|
13156
13156
|
errors = [];
|
|
13157
|
-
if(!asn1.validate(obj, rsaPrivateKeyValidator, capture, errors)) {
|
|
13157
|
+
if(!asn1$2.validate(obj, rsaPrivateKeyValidator, capture, errors)) {
|
|
13158
13158
|
var error = new Error('Cannot read private key. ' +
|
|
13159
13159
|
'ASN.1 object does not contain an RSAPrivateKey.');
|
|
13160
13160
|
error.errors = errors;
|
|
@@ -13175,7 +13175,7 @@ pki.privateKeyFromAsn1 = function(obj) {
|
|
|
13175
13175
|
qInv = forge.util.createBuffer(capture.privateKeyCoefficient).toHex();
|
|
13176
13176
|
|
|
13177
13177
|
// set private key
|
|
13178
|
-
return pki.setRsaPrivateKey(
|
|
13178
|
+
return pki$1.setRsaPrivateKey(
|
|
13179
13179
|
new BigInteger$1(n, 16),
|
|
13180
13180
|
new BigInteger$1(e, 16),
|
|
13181
13181
|
new BigInteger$1(d, 16),
|
|
@@ -13193,35 +13193,35 @@ pki.privateKeyFromAsn1 = function(obj) {
|
|
|
13193
13193
|
*
|
|
13194
13194
|
* @return the ASN.1 representation of an RSAPrivateKey.
|
|
13195
13195
|
*/
|
|
13196
|
-
pki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {
|
|
13196
|
+
pki$1.privateKeyToAsn1 = pki$1.privateKeyToRSAPrivateKey = function(key) {
|
|
13197
13197
|
// RSAPrivateKey
|
|
13198
|
-
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
|
|
13198
|
+
return asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, [
|
|
13199
13199
|
// version (0 = only 2 primes, 1 multiple primes)
|
|
13200
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13201
|
-
asn1.integerToDer(0).getBytes()),
|
|
13200
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13201
|
+
asn1$2.integerToDer(0).getBytes()),
|
|
13202
13202
|
// modulus (n)
|
|
13203
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13203
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13204
13204
|
_bnToBytes(key.n)),
|
|
13205
13205
|
// publicExponent (e)
|
|
13206
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13206
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13207
13207
|
_bnToBytes(key.e)),
|
|
13208
13208
|
// privateExponent (d)
|
|
13209
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13209
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13210
13210
|
_bnToBytes(key.d)),
|
|
13211
13211
|
// privateKeyPrime1 (p)
|
|
13212
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13212
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13213
13213
|
_bnToBytes(key.p)),
|
|
13214
13214
|
// privateKeyPrime2 (q)
|
|
13215
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13215
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13216
13216
|
_bnToBytes(key.q)),
|
|
13217
13217
|
// privateKeyExponent1 (dP)
|
|
13218
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13218
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13219
13219
|
_bnToBytes(key.dP)),
|
|
13220
13220
|
// privateKeyExponent2 (dQ)
|
|
13221
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13221
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13222
13222
|
_bnToBytes(key.dQ)),
|
|
13223
13223
|
// coefficient (qInv)
|
|
13224
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13224
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13225
13225
|
_bnToBytes(key.qInv))
|
|
13226
13226
|
]);
|
|
13227
13227
|
};
|
|
@@ -13233,14 +13233,14 @@ pki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {
|
|
|
13233
13233
|
*
|
|
13234
13234
|
* @return the public key.
|
|
13235
13235
|
*/
|
|
13236
|
-
pki.publicKeyFromAsn1 = function(obj) {
|
|
13236
|
+
pki$1.publicKeyFromAsn1 = function(obj) {
|
|
13237
13237
|
// get SubjectPublicKeyInfo
|
|
13238
13238
|
var capture = {};
|
|
13239
13239
|
var errors = [];
|
|
13240
|
-
if(asn1.validate(obj, publicKeyValidator, capture, errors)) {
|
|
13240
|
+
if(asn1$2.validate(obj, publicKeyValidator$2, capture, errors)) {
|
|
13241
13241
|
// get oid
|
|
13242
|
-
var oid = asn1.derToOid(capture.publicKeyOid);
|
|
13243
|
-
if(oid !== pki.oids.rsaEncryption) {
|
|
13242
|
+
var oid = asn1$2.derToOid(capture.publicKeyOid);
|
|
13243
|
+
if(oid !== pki$1.oids.rsaEncryption) {
|
|
13244
13244
|
var error = new Error('Cannot read public key. Unknown OID.');
|
|
13245
13245
|
error.oid = oid;
|
|
13246
13246
|
throw error;
|
|
@@ -13250,7 +13250,7 @@ pki.publicKeyFromAsn1 = function(obj) {
|
|
|
13250
13250
|
|
|
13251
13251
|
// get RSA params
|
|
13252
13252
|
errors = [];
|
|
13253
|
-
if(!asn1.validate(obj, rsaPublicKeyValidator, capture, errors)) {
|
|
13253
|
+
if(!asn1$2.validate(obj, rsaPublicKeyValidator, capture, errors)) {
|
|
13254
13254
|
var error = new Error('Cannot read public key. ' +
|
|
13255
13255
|
'ASN.1 object does not contain an RSAPublicKey.');
|
|
13256
13256
|
error.errors = errors;
|
|
@@ -13262,7 +13262,7 @@ pki.publicKeyFromAsn1 = function(obj) {
|
|
|
13262
13262
|
var e = forge.util.createBuffer(capture.publicKeyExponent).toHex();
|
|
13263
13263
|
|
|
13264
13264
|
// set public key
|
|
13265
|
-
return pki.setRsaPublicKey(
|
|
13265
|
+
return pki$1.setRsaPublicKey(
|
|
13266
13266
|
new BigInteger$1(n, 16),
|
|
13267
13267
|
new BigInteger$1(e, 16));
|
|
13268
13268
|
};
|
|
@@ -13274,20 +13274,20 @@ pki.publicKeyFromAsn1 = function(obj) {
|
|
|
13274
13274
|
*
|
|
13275
13275
|
* @return the asn1 representation of a SubjectPublicKeyInfo.
|
|
13276
13276
|
*/
|
|
13277
|
-
pki.publicKeyToAsn1 = pki.publicKeyToSubjectPublicKeyInfo = function(key) {
|
|
13277
|
+
pki$1.publicKeyToAsn1 = pki$1.publicKeyToSubjectPublicKeyInfo = function(key) {
|
|
13278
13278
|
// SubjectPublicKeyInfo
|
|
13279
|
-
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
|
|
13279
|
+
return asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, [
|
|
13280
13280
|
// AlgorithmIdentifier
|
|
13281
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
|
|
13281
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, [
|
|
13282
13282
|
// algorithm
|
|
13283
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
|
|
13284
|
-
asn1.oidToDer(pki.oids.rsaEncryption).getBytes()),
|
|
13283
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.OID, false,
|
|
13284
|
+
asn1$2.oidToDer(pki$1.oids.rsaEncryption).getBytes()),
|
|
13285
13285
|
// parameters (null)
|
|
13286
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
|
|
13286
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.NULL, false, '')
|
|
13287
13287
|
]),
|
|
13288
13288
|
// subjectPublicKey
|
|
13289
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, [
|
|
13290
|
-
pki.publicKeyToRSAPublicKey(key)
|
|
13289
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.BITSTRING, false, [
|
|
13290
|
+
pki$1.publicKeyToRSAPublicKey(key)
|
|
13291
13291
|
])
|
|
13292
13292
|
]);
|
|
13293
13293
|
};
|
|
@@ -13299,14 +13299,14 @@ pki.publicKeyToAsn1 = pki.publicKeyToSubjectPublicKeyInfo = function(key) {
|
|
|
13299
13299
|
*
|
|
13300
13300
|
* @return the asn1 representation of a RSAPublicKey.
|
|
13301
13301
|
*/
|
|
13302
|
-
pki.publicKeyToRSAPublicKey = function(key) {
|
|
13302
|
+
pki$1.publicKeyToRSAPublicKey = function(key) {
|
|
13303
13303
|
// RSAPublicKey
|
|
13304
|
-
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
|
|
13304
|
+
return asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.SEQUENCE, true, [
|
|
13305
13305
|
// modulus (n)
|
|
13306
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13306
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13307
13307
|
_bnToBytes(key.n)),
|
|
13308
13308
|
// publicExponent (e)
|
|
13309
|
-
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
|
|
13309
|
+
asn1$2.create(asn1$2.Class.UNIVERSAL, asn1$2.Type.INTEGER, false,
|
|
13310
13310
|
_bnToBytes(key.e))
|
|
13311
13311
|
]);
|
|
13312
13312
|
};
|
|
@@ -13575,11 +13575,11 @@ function _generateKeyPair(state, options, callback) {
|
|
|
13575
13575
|
// set keys
|
|
13576
13576
|
var d = state.e.modInverse(state.phi);
|
|
13577
13577
|
state.keys = {
|
|
13578
|
-
privateKey: pki.rsa.setPrivateKey(
|
|
13578
|
+
privateKey: pki$1.rsa.setPrivateKey(
|
|
13579
13579
|
state.n, state.e, d, state.p, state.q,
|
|
13580
13580
|
d.mod(state.p1), d.mod(state.q1),
|
|
13581
13581
|
state.q.modInverse(state.p)),
|
|
13582
|
-
publicKey: pki.rsa.setPublicKey(state.n, state.e)
|
|
13582
|
+
publicKey: pki$1.rsa.setPublicKey(state.n, state.e)
|
|
13583
13583
|
};
|
|
13584
13584
|
|
|
13585
13585
|
callback(null, state.keys);
|
|
@@ -13713,9 +13713,9 @@ function _intToUint8Array(x) {
|
|
|
13713
13713
|
var asn1$1 = forge.asn1;
|
|
13714
13714
|
|
|
13715
13715
|
/* Password-based encryption implementation. */
|
|
13716
|
-
var pki
|
|
13717
|
-
pki
|
|
13718
|
-
var oids = pki
|
|
13716
|
+
var pki = forge.pki = forge.pki || {};
|
|
13717
|
+
pki.pbe = forge.pbe = forge.pbe || {};
|
|
13718
|
+
var oids = pki.oids;
|
|
13719
13719
|
|
|
13720
13720
|
// validator for an EncryptedPrivateKeyInfo structure
|
|
13721
13721
|
// Note: Currently only works w/algorithm params
|
|
@@ -13891,7 +13891,7 @@ var pkcs12PbeParamsValidator = {
|
|
|
13891
13891
|
*
|
|
13892
13892
|
* @return the ASN.1 EncryptedPrivateKeyInfo.
|
|
13893
13893
|
*/
|
|
13894
|
-
pki
|
|
13894
|
+
pki.encryptPrivateKeyInfo = function(obj, password, options) {
|
|
13895
13895
|
// set default options
|
|
13896
13896
|
options = options || {};
|
|
13897
13897
|
options.saltSize = options.saltSize || 8;
|
|
@@ -13983,8 +13983,8 @@ pki$1.encryptPrivateKeyInfo = function(obj, password, options) {
|
|
|
13983
13983
|
dkLen = 24;
|
|
13984
13984
|
|
|
13985
13985
|
var saltBytes = new forge.util.ByteBuffer(salt);
|
|
13986
|
-
var dk = pki
|
|
13987
|
-
var iv = pki
|
|
13986
|
+
var dk = pki.pbe.generatePkcs12Key(password, saltBytes, 1, count, dkLen);
|
|
13987
|
+
var iv = pki.pbe.generatePkcs12Key(password, saltBytes, 2, count, dkLen);
|
|
13988
13988
|
var cipher = forge.des.createEncryptionCipher(dk);
|
|
13989
13989
|
cipher.start(iv);
|
|
13990
13990
|
cipher.update(asn1$1.toDer(obj));
|
|
@@ -14029,7 +14029,7 @@ pki$1.encryptPrivateKeyInfo = function(obj, password, options) {
|
|
|
14029
14029
|
*
|
|
14030
14030
|
* @return the ASN.1 PrivateKeyInfo on success, null on failure.
|
|
14031
14031
|
*/
|
|
14032
|
-
pki
|
|
14032
|
+
pki.decryptPrivateKeyInfo = function(obj, password) {
|
|
14033
14033
|
var rval = null;
|
|
14034
14034
|
|
|
14035
14035
|
// get PBE params
|
|
@@ -14044,7 +14044,7 @@ pki$1.decryptPrivateKeyInfo = function(obj, password) {
|
|
|
14044
14044
|
|
|
14045
14045
|
// get cipher
|
|
14046
14046
|
var oid = asn1$1.derToOid(capture.encryptionOid);
|
|
14047
|
-
var cipher = pki
|
|
14047
|
+
var cipher = pki.pbe.getCipher(oid, capture.encryptionParams, password);
|
|
14048
14048
|
|
|
14049
14049
|
// get encrypted data
|
|
14050
14050
|
var encrypted = forge.util.createBuffer(capture.encryptedData);
|
|
@@ -14065,7 +14065,7 @@ pki$1.decryptPrivateKeyInfo = function(obj, password) {
|
|
|
14065
14065
|
*
|
|
14066
14066
|
* @return the PEM-formatted encrypted private key.
|
|
14067
14067
|
*/
|
|
14068
|
-
pki
|
|
14068
|
+
pki.encryptedPrivateKeyToPem = function(epki, maxline) {
|
|
14069
14069
|
// convert to DER, then PEM-encode
|
|
14070
14070
|
var msg = {
|
|
14071
14071
|
type: 'ENCRYPTED PRIVATE KEY',
|
|
@@ -14082,7 +14082,7 @@ pki$1.encryptedPrivateKeyToPem = function(epki, maxline) {
|
|
|
14082
14082
|
*
|
|
14083
14083
|
* @return the ASN.1 EncryptedPrivateKeyInfo.
|
|
14084
14084
|
*/
|
|
14085
|
-
pki
|
|
14085
|
+
pki.encryptedPrivateKeyFromPem = function(pem) {
|
|
14086
14086
|
var msg = forge.pem.decode(pem)[0];
|
|
14087
14087
|
|
|
14088
14088
|
if(msg.type !== 'ENCRYPTED PRIVATE KEY') {
|
|
@@ -14126,14 +14126,14 @@ pki$1.encryptedPrivateKeyFromPem = function(pem) {
|
|
|
14126
14126
|
*
|
|
14127
14127
|
* @return the PEM-encoded ASN.1 EncryptedPrivateKeyInfo.
|
|
14128
14128
|
*/
|
|
14129
|
-
pki
|
|
14129
|
+
pki.encryptRsaPrivateKey = function(rsaKey, password, options) {
|
|
14130
14130
|
// standard PKCS#8
|
|
14131
14131
|
options = options || {};
|
|
14132
14132
|
if(!options.legacy) {
|
|
14133
14133
|
// encrypt PrivateKeyInfo
|
|
14134
|
-
var rval = pki
|
|
14135
|
-
rval = pki
|
|
14136
|
-
return pki
|
|
14134
|
+
var rval = pki.wrapRsaPrivateKey(pki.privateKeyToAsn1(rsaKey));
|
|
14135
|
+
rval = pki.encryptPrivateKeyInfo(rval, password, options);
|
|
14136
|
+
return pki.encryptedPrivateKeyToPem(rval);
|
|
14137
14137
|
}
|
|
14138
14138
|
|
|
14139
14139
|
// legacy non-PKCS#8
|
|
@@ -14183,7 +14183,7 @@ pki$1.encryptRsaPrivateKey = function(rsaKey, password, options) {
|
|
|
14183
14183
|
var dk = forge.pbe.opensslDeriveBytes(password, iv.substr(0, 8), dkLen);
|
|
14184
14184
|
var cipher = cipherFn(dk);
|
|
14185
14185
|
cipher.start(iv);
|
|
14186
|
-
cipher.update(asn1$1.toDer(pki
|
|
14186
|
+
cipher.update(asn1$1.toDer(pki.privateKeyToAsn1(rsaKey)));
|
|
14187
14187
|
cipher.finish();
|
|
14188
14188
|
|
|
14189
14189
|
var msg = {
|
|
@@ -14209,7 +14209,7 @@ pki$1.encryptRsaPrivateKey = function(rsaKey, password, options) {
|
|
|
14209
14209
|
*
|
|
14210
14210
|
* @return the RSA key on success, null on failure.
|
|
14211
14211
|
*/
|
|
14212
|
-
pki
|
|
14212
|
+
pki.decryptRsaPrivateKey = function(pem, password) {
|
|
14213
14213
|
var rval = null;
|
|
14214
14214
|
|
|
14215
14215
|
var msg = forge.pem.decode(pem)[0];
|
|
@@ -14288,14 +14288,14 @@ pki$1.decryptRsaPrivateKey = function(pem, password) {
|
|
|
14288
14288
|
}
|
|
14289
14289
|
|
|
14290
14290
|
if(msg.type === 'ENCRYPTED PRIVATE KEY') {
|
|
14291
|
-
rval = pki
|
|
14291
|
+
rval = pki.decryptPrivateKeyInfo(asn1$1.fromDer(rval), password);
|
|
14292
14292
|
} else {
|
|
14293
14293
|
// decryption already performed above
|
|
14294
14294
|
rval = asn1$1.fromDer(rval);
|
|
14295
14295
|
}
|
|
14296
14296
|
|
|
14297
14297
|
if(rval !== null) {
|
|
14298
|
-
rval = pki
|
|
14298
|
+
rval = pki.privateKeyFromAsn1(rval);
|
|
14299
14299
|
}
|
|
14300
14300
|
|
|
14301
14301
|
return rval;
|
|
@@ -14314,7 +14314,7 @@ pki$1.decryptRsaPrivateKey = function(pem, password) {
|
|
|
14314
14314
|
*
|
|
14315
14315
|
* @return a ByteBuffer with the bytes derived from the password.
|
|
14316
14316
|
*/
|
|
14317
|
-
pki
|
|
14317
|
+
pki.pbe.generatePkcs12Key = function(password, salt, id, iter, n, md) {
|
|
14318
14318
|
var j, l;
|
|
14319
14319
|
|
|
14320
14320
|
if(typeof md === 'undefined' || md === null) {
|
|
@@ -14426,14 +14426,14 @@ pki$1.pbe.generatePkcs12Key = function(password, salt, id, iter, n, md) {
|
|
|
14426
14426
|
*
|
|
14427
14427
|
* @return new cipher object instance.
|
|
14428
14428
|
*/
|
|
14429
|
-
pki
|
|
14429
|
+
pki.pbe.getCipher = function(oid, params, password) {
|
|
14430
14430
|
switch(oid) {
|
|
14431
|
-
case pki
|
|
14432
|
-
return pki
|
|
14431
|
+
case pki.oids['pkcs5PBES2']:
|
|
14432
|
+
return pki.pbe.getCipherForPBES2(oid, params, password);
|
|
14433
14433
|
|
|
14434
|
-
case pki
|
|
14435
|
-
case pki
|
|
14436
|
-
return pki
|
|
14434
|
+
case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:
|
|
14435
|
+
case pki.oids['pbewithSHAAnd40BitRC2-CBC']:
|
|
14436
|
+
return pki.pbe.getCipherForPKCS12PBE(oid, params, password);
|
|
14437
14437
|
|
|
14438
14438
|
default:
|
|
14439
14439
|
var error = new Error('Cannot read encrypted PBE data block. Unsupported OID.');
|
|
@@ -14459,7 +14459,7 @@ pki$1.pbe.getCipher = function(oid, params, password) {
|
|
|
14459
14459
|
*
|
|
14460
14460
|
* @return new cipher object instance.
|
|
14461
14461
|
*/
|
|
14462
|
-
pki
|
|
14462
|
+
pki.pbe.getCipherForPBES2 = function(oid, params, password) {
|
|
14463
14463
|
// get PBE params
|
|
14464
14464
|
var capture = {};
|
|
14465
14465
|
var errors = [];
|
|
@@ -14472,7 +14472,7 @@ pki$1.pbe.getCipherForPBES2 = function(oid, params, password) {
|
|
|
14472
14472
|
|
|
14473
14473
|
// check oids
|
|
14474
14474
|
oid = asn1$1.derToOid(capture.kdfOid);
|
|
14475
|
-
if(oid !== pki
|
|
14475
|
+
if(oid !== pki.oids['pkcs5PBKDF2']) {
|
|
14476
14476
|
var error = new Error('Cannot read encrypted private key. ' +
|
|
14477
14477
|
'Unsupported key derivation function OID.');
|
|
14478
14478
|
error.oid = oid;
|
|
@@ -14480,11 +14480,11 @@ pki$1.pbe.getCipherForPBES2 = function(oid, params, password) {
|
|
|
14480
14480
|
throw error;
|
|
14481
14481
|
}
|
|
14482
14482
|
oid = asn1$1.derToOid(capture.encOid);
|
|
14483
|
-
if(oid !== pki
|
|
14484
|
-
oid !== pki
|
|
14485
|
-
oid !== pki
|
|
14486
|
-
oid !== pki
|
|
14487
|
-
oid !== pki
|
|
14483
|
+
if(oid !== pki.oids['aes128-CBC'] &&
|
|
14484
|
+
oid !== pki.oids['aes192-CBC'] &&
|
|
14485
|
+
oid !== pki.oids['aes256-CBC'] &&
|
|
14486
|
+
oid !== pki.oids['des-EDE3-CBC'] &&
|
|
14487
|
+
oid !== pki.oids['desCBC']) {
|
|
14488
14488
|
var error = new Error('Cannot read encrypted private key. ' +
|
|
14489
14489
|
'Unsupported encryption scheme OID.');
|
|
14490
14490
|
error.oid = oid;
|
|
@@ -14499,7 +14499,7 @@ pki$1.pbe.getCipherForPBES2 = function(oid, params, password) {
|
|
|
14499
14499
|
count = count.getInt(count.length() << 3);
|
|
14500
14500
|
var dkLen;
|
|
14501
14501
|
var cipherFn;
|
|
14502
|
-
switch(pki
|
|
14502
|
+
switch(pki.oids[oid]) {
|
|
14503
14503
|
case 'aes128-CBC':
|
|
14504
14504
|
dkLen = 16;
|
|
14505
14505
|
cipherFn = forge.aes.createDecryptionCipher;
|
|
@@ -14546,7 +14546,7 @@ pki$1.pbe.getCipherForPBES2 = function(oid, params, password) {
|
|
|
14546
14546
|
*
|
|
14547
14547
|
* @return the new cipher object instance.
|
|
14548
14548
|
*/
|
|
14549
|
-
pki
|
|
14549
|
+
pki.pbe.getCipherForPKCS12PBE = function(oid, params, password) {
|
|
14550
14550
|
// get PBE params
|
|
14551
14551
|
var capture = {};
|
|
14552
14552
|
var errors = [];
|
|
@@ -14563,13 +14563,13 @@ pki$1.pbe.getCipherForPKCS12PBE = function(oid, params, password) {
|
|
|
14563
14563
|
|
|
14564
14564
|
var dkLen, dIvLen, cipherFn;
|
|
14565
14565
|
switch(oid) {
|
|
14566
|
-
case pki
|
|
14566
|
+
case pki.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:
|
|
14567
14567
|
dkLen = 24;
|
|
14568
14568
|
dIvLen = 8;
|
|
14569
14569
|
cipherFn = forge.des.startDecrypting;
|
|
14570
14570
|
break;
|
|
14571
14571
|
|
|
14572
|
-
case pki
|
|
14572
|
+
case pki.oids['pbewithSHAAnd40BitRC2-CBC']:
|
|
14573
14573
|
dkLen = 5;
|
|
14574
14574
|
dIvLen = 8;
|
|
14575
14575
|
cipherFn = function(key, iv) {
|
|
@@ -14587,9 +14587,9 @@ pki$1.pbe.getCipherForPKCS12PBE = function(oid, params, password) {
|
|
|
14587
14587
|
|
|
14588
14588
|
// get PRF message digest
|
|
14589
14589
|
var md = prfOidToMessageDigest(capture.prfOid);
|
|
14590
|
-
var key = pki
|
|
14590
|
+
var key = pki.pbe.generatePkcs12Key(password, salt, 1, count, dkLen, md);
|
|
14591
14591
|
md.start();
|
|
14592
|
-
var iv = pki
|
|
14592
|
+
var iv = pki.pbe.generatePkcs12Key(password, salt, 2, count, dIvLen, md);
|
|
14593
14593
|
|
|
14594
14594
|
return cipherFn(key, iv);
|
|
14595
14595
|
};
|
|
@@ -14605,7 +14605,7 @@ pki$1.pbe.getCipherForPKCS12PBE = function(oid, params, password) {
|
|
|
14605
14605
|
* @param [options] the options to use:
|
|
14606
14606
|
* [md] an optional message digest object to use.
|
|
14607
14607
|
*/
|
|
14608
|
-
pki
|
|
14608
|
+
pki.pbe.opensslDeriveBytes = function(password, salt, dkLen, md) {
|
|
14609
14609
|
if(typeof md === 'undefined' || md === null) {
|
|
14610
14610
|
if(!('md5' in forge.md)) {
|
|
14611
14611
|
throw new Error('"md5" hash algorithm unavailable.');
|
|
@@ -14632,7 +14632,7 @@ function prfOidToMessageDigest(prfOid) {
|
|
|
14632
14632
|
if(!prfOid) {
|
|
14633
14633
|
prfAlgorithm = 'hmacWithSHA1';
|
|
14634
14634
|
} else {
|
|
14635
|
-
prfAlgorithm = pki
|
|
14635
|
+
prfAlgorithm = pki.oids[asn1$1.derToOid(prfOid)];
|
|
14636
14636
|
if(!prfAlgorithm) {
|
|
14637
14637
|
var error = new Error('Unsupported PRF OID.');
|
|
14638
14638
|
error.oid = prfOid;
|
|
@@ -14689,7 +14689,7 @@ function createPbkdf2Params(salt, countBytes, dkLen, prfAlgorithm) {
|
|
|
14689
14689
|
asn1$1.create(asn1$1.Class.UNIVERSAL, asn1$1.Type.SEQUENCE, true, [
|
|
14690
14690
|
// algorithm
|
|
14691
14691
|
asn1$1.create(asn1$1.Class.UNIVERSAL, asn1$1.Type.OID, false,
|
|
14692
|
-
asn1$1.oidToDer(pki
|
|
14692
|
+
asn1$1.oidToDer(pki.oids[prfAlgorithm]).getBytes()),
|
|
14693
14693
|
// parameters (null)
|
|
14694
14694
|
asn1$1.create(asn1$1.Class.UNIVERSAL, asn1$1.Type.NULL, false, '')
|
|
14695
14695
|
]));
|
|
@@ -25041,39 +25041,39 @@ function _update(s, w, bytes) {
|
|
|
25041
25041
|
* Copyright (c) 2019 Digital Bazaar, Inc.
|
|
25042
25042
|
*/
|
|
25043
25043
|
|
|
25044
|
-
var asn1
|
|
25044
|
+
var asn1 = forge.asn1;
|
|
25045
25045
|
|
|
25046
25046
|
var privateKeyValidator$1 = {
|
|
25047
25047
|
// PrivateKeyInfo
|
|
25048
25048
|
name: 'PrivateKeyInfo',
|
|
25049
|
-
tagClass: asn1
|
|
25050
|
-
type: asn1
|
|
25049
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25050
|
+
type: asn1.Type.SEQUENCE,
|
|
25051
25051
|
constructed: true,
|
|
25052
25052
|
value: [{
|
|
25053
25053
|
// Version (INTEGER)
|
|
25054
25054
|
name: 'PrivateKeyInfo.version',
|
|
25055
|
-
tagClass: asn1
|
|
25056
|
-
type: asn1
|
|
25055
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25056
|
+
type: asn1.Type.INTEGER,
|
|
25057
25057
|
constructed: false,
|
|
25058
25058
|
capture: 'privateKeyVersion'
|
|
25059
25059
|
}, {
|
|
25060
25060
|
// privateKeyAlgorithm
|
|
25061
25061
|
name: 'PrivateKeyInfo.privateKeyAlgorithm',
|
|
25062
|
-
tagClass: asn1
|
|
25063
|
-
type: asn1
|
|
25062
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25063
|
+
type: asn1.Type.SEQUENCE,
|
|
25064
25064
|
constructed: true,
|
|
25065
25065
|
value: [{
|
|
25066
25066
|
name: 'AlgorithmIdentifier.algorithm',
|
|
25067
|
-
tagClass: asn1
|
|
25068
|
-
type: asn1
|
|
25067
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25068
|
+
type: asn1.Type.OID,
|
|
25069
25069
|
constructed: false,
|
|
25070
25070
|
capture: 'privateKeyOid'
|
|
25071
25071
|
}]
|
|
25072
25072
|
}, {
|
|
25073
25073
|
// PrivateKey
|
|
25074
25074
|
name: 'PrivateKeyInfo',
|
|
25075
|
-
tagClass: asn1
|
|
25076
|
-
type: asn1
|
|
25075
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25076
|
+
type: asn1.Type.OCTETSTRING,
|
|
25077
25077
|
constructed: false,
|
|
25078
25078
|
capture: 'privateKey'
|
|
25079
25079
|
}]
|
|
@@ -25081,27 +25081,27 @@ var privateKeyValidator$1 = {
|
|
|
25081
25081
|
|
|
25082
25082
|
var publicKeyValidator$1 = {
|
|
25083
25083
|
name: 'SubjectPublicKeyInfo',
|
|
25084
|
-
tagClass: asn1
|
|
25085
|
-
type: asn1
|
|
25084
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25085
|
+
type: asn1.Type.SEQUENCE,
|
|
25086
25086
|
constructed: true,
|
|
25087
25087
|
captureAsn1: 'subjectPublicKeyInfo',
|
|
25088
25088
|
value: [{
|
|
25089
25089
|
name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
|
|
25090
|
-
tagClass: asn1
|
|
25091
|
-
type: asn1
|
|
25090
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25091
|
+
type: asn1.Type.SEQUENCE,
|
|
25092
25092
|
constructed: true,
|
|
25093
25093
|
value: [{
|
|
25094
25094
|
name: 'AlgorithmIdentifier.algorithm',
|
|
25095
|
-
tagClass: asn1
|
|
25096
|
-
type: asn1
|
|
25095
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25096
|
+
type: asn1.Type.OID,
|
|
25097
25097
|
constructed: false,
|
|
25098
25098
|
capture: 'publicKeyOid'
|
|
25099
25099
|
}]
|
|
25100
25100
|
},
|
|
25101
25101
|
// capture group for ed25519PublicKey
|
|
25102
25102
|
{
|
|
25103
|
-
tagClass: asn1
|
|
25104
|
-
type: asn1
|
|
25103
|
+
tagClass: asn1.Class.UNIVERSAL,
|
|
25104
|
+
type: asn1.Type.BITSTRING,
|
|
25105
25105
|
constructed: false,
|
|
25106
25106
|
composed: true,
|
|
25107
25107
|
captureBitStringValue: 'ed25519PublicKey'
|
|
@@ -25143,8 +25143,8 @@ var asn1Validator = {
|
|
|
25143
25143
|
* https://github.com/dchest/tweetnacl-js
|
|
25144
25144
|
*/
|
|
25145
25145
|
|
|
25146
|
-
var publicKeyValidator
|
|
25147
|
-
var privateKeyValidator
|
|
25146
|
+
var publicKeyValidator = asn1Validator.publicKeyValidator;
|
|
25147
|
+
var privateKeyValidator = asn1Validator.privateKeyValidator;
|
|
25148
25148
|
|
|
25149
25149
|
var ByteBuffer = forge.util.ByteBuffer;
|
|
25150
25150
|
var NativeBuffer = typeof Buffer === 'undefined' ? Uint8Array : Buffer;
|
|
@@ -25203,7 +25203,7 @@ ed25519.generateKeyPair = function(options) {
|
|
|
25203
25203
|
ed25519.privateKeyFromAsn1 = function(obj) {
|
|
25204
25204
|
var capture = {};
|
|
25205
25205
|
var errors = [];
|
|
25206
|
-
var valid = forge.asn1.validate(obj, privateKeyValidator
|
|
25206
|
+
var valid = forge.asn1.validate(obj, privateKeyValidator, capture, errors);
|
|
25207
25207
|
if(!valid) {
|
|
25208
25208
|
var error = new Error('Invalid Key.');
|
|
25209
25209
|
error.errors = errors;
|
|
@@ -25239,7 +25239,7 @@ ed25519.publicKeyFromAsn1 = function(obj) {
|
|
|
25239
25239
|
// get SubjectPublicKeyInfo
|
|
25240
25240
|
var capture = {};
|
|
25241
25241
|
var errors = [];
|
|
25242
|
-
var valid = forge.asn1.validate(obj, publicKeyValidator
|
|
25242
|
+
var valid = forge.asn1.validate(obj, publicKeyValidator, capture, errors);
|
|
25243
25243
|
if(!valid) {
|
|
25244
25244
|
var error = new Error('Invalid Key.');
|
|
25245
25245
|
error.errors = errors;
|
|
@@ -26208,7 +26208,7 @@ function M(o, a, b) {
|
|
|
26208
26208
|
|
|
26209
26209
|
forge.kem = forge.kem || {};
|
|
26210
26210
|
|
|
26211
|
-
var BigInteger
|
|
26211
|
+
var BigInteger = forge.jsbn.BigInteger;
|
|
26212
26212
|
|
|
26213
26213
|
/**
|
|
26214
26214
|
* The API for the RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.
|
|
@@ -26251,10 +26251,10 @@ forge.kem.rsa.create = function(kdf, options) {
|
|
|
26251
26251
|
var byteLength = Math.ceil(publicKey.n.bitLength() / 8);
|
|
26252
26252
|
var r;
|
|
26253
26253
|
do {
|
|
26254
|
-
r = new BigInteger
|
|
26254
|
+
r = new BigInteger(
|
|
26255
26255
|
forge.util.bytesToHex(prng.getBytesSync(byteLength)),
|
|
26256
26256
|
16).mod(publicKey.n);
|
|
26257
|
-
} while(r.compareTo(BigInteger
|
|
26257
|
+
} while(r.compareTo(BigInteger.ONE) <= 0);
|
|
26258
26258
|
|
|
26259
26259
|
// prepend r with zeros
|
|
26260
26260
|
r = forge.util.hexToBytes(r.toString(16));
|