node-opcua-crypto-web 6.2.0 → 6.2.1

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.
Files changed (2) hide show
  1. package/dist/index_web.js +360 -106
  2. package/package.json +3 -3
package/dist/index_web.js CHANGED
@@ -9979,16 +9979,16 @@ var require_sha = __commonJS({
9979
9979
  var inherits = require_inherits_browser();
9980
9980
  var Hash = require_hash();
9981
9981
  var Buffer2 = require_buffer().Buffer;
9982
- var K = [
9982
+ var K2 = [
9983
9983
  1518500249,
9984
9984
  1859775393,
9985
9985
  2400959708 | 0,
9986
9986
  3395469782 | 0
9987
9987
  ];
9988
- var W = new Array(80);
9988
+ var W2 = new Array(80);
9989
9989
  function Sha() {
9990
9990
  this.init();
9991
- this._w = W;
9991
+ this._w = W2;
9992
9992
  Hash.call(this, 64, 56);
9993
9993
  }
9994
9994
  inherits(Sha, Hash);
@@ -10030,7 +10030,7 @@ var require_sha = __commonJS({
10030
10030
  }
10031
10031
  for (var j = 0; j < 80; ++j) {
10032
10032
  var s = ~~(j / 20);
10033
- var t2 = rotl5(a) + ft(s, b, c, d) + e + w[j] + K[s] | 0;
10033
+ var t2 = rotl5(a) + ft(s, b, c, d) + e + w[j] + K2[s] | 0;
10034
10034
  e = d;
10035
10035
  d = c;
10036
10036
  c = rotl30(b);
@@ -10044,13 +10044,13 @@ var require_sha = __commonJS({
10044
10044
  this._e = e + this._e | 0;
10045
10045
  };
10046
10046
  Sha.prototype._hash = function() {
10047
- var H = Buffer2.allocUnsafe(20);
10048
- H.writeInt32BE(this._a | 0, 0);
10049
- H.writeInt32BE(this._b | 0, 4);
10050
- H.writeInt32BE(this._c | 0, 8);
10051
- H.writeInt32BE(this._d | 0, 12);
10052
- H.writeInt32BE(this._e | 0, 16);
10053
- return H;
10047
+ var H2 = Buffer2.allocUnsafe(20);
10048
+ H2.writeInt32BE(this._a | 0, 0);
10049
+ H2.writeInt32BE(this._b | 0, 4);
10050
+ H2.writeInt32BE(this._c | 0, 8);
10051
+ H2.writeInt32BE(this._d | 0, 12);
10052
+ H2.writeInt32BE(this._e | 0, 16);
10053
+ return H2;
10054
10054
  };
10055
10055
  module2.exports = Sha;
10056
10056
  }
@@ -10064,16 +10064,16 @@ var require_sha1 = __commonJS({
10064
10064
  var inherits = require_inherits_browser();
10065
10065
  var Hash = require_hash();
10066
10066
  var Buffer2 = require_buffer().Buffer;
10067
- var K = [
10067
+ var K2 = [
10068
10068
  1518500249,
10069
10069
  1859775393,
10070
10070
  2400959708 | 0,
10071
10071
  3395469782 | 0
10072
10072
  ];
10073
- var W = new Array(80);
10073
+ var W2 = new Array(80);
10074
10074
  function Sha1() {
10075
10075
  this.init();
10076
- this._w = W;
10076
+ this._w = W2;
10077
10077
  Hash.call(this, 64, 56);
10078
10078
  }
10079
10079
  inherits(Sha1, Hash);
@@ -10118,7 +10118,7 @@ var require_sha1 = __commonJS({
10118
10118
  }
10119
10119
  for (var j = 0; j < 80; ++j) {
10120
10120
  var s = ~~(j / 20);
10121
- var t2 = rotl5(a) + ft(s, b, c, d) + e + w[j] + K[s] | 0;
10121
+ var t2 = rotl5(a) + ft(s, b, c, d) + e + w[j] + K2[s] | 0;
10122
10122
  e = d;
10123
10123
  d = c;
10124
10124
  c = rotl30(b);
@@ -10132,13 +10132,13 @@ var require_sha1 = __commonJS({
10132
10132
  this._e = e + this._e | 0;
10133
10133
  };
10134
10134
  Sha1.prototype._hash = function() {
10135
- var H = Buffer2.allocUnsafe(20);
10136
- H.writeInt32BE(this._a | 0, 0);
10137
- H.writeInt32BE(this._b | 0, 4);
10138
- H.writeInt32BE(this._c | 0, 8);
10139
- H.writeInt32BE(this._d | 0, 12);
10140
- H.writeInt32BE(this._e | 0, 16);
10141
- return H;
10135
+ var H2 = Buffer2.allocUnsafe(20);
10136
+ H2.writeInt32BE(this._a | 0, 0);
10137
+ H2.writeInt32BE(this._b | 0, 4);
10138
+ H2.writeInt32BE(this._c | 0, 8);
10139
+ H2.writeInt32BE(this._d | 0, 12);
10140
+ H2.writeInt32BE(this._e | 0, 16);
10141
+ return H2;
10142
10142
  };
10143
10143
  module2.exports = Sha1;
10144
10144
  }
@@ -10152,7 +10152,7 @@ var require_sha256 = __commonJS({
10152
10152
  var inherits = require_inherits_browser();
10153
10153
  var Hash = require_hash();
10154
10154
  var Buffer2 = require_buffer().Buffer;
10155
- var K = [
10155
+ var K2 = [
10156
10156
  1116352408,
10157
10157
  1899447441,
10158
10158
  3049323471,
@@ -10218,10 +10218,10 @@ var require_sha256 = __commonJS({
10218
10218
  3204031479,
10219
10219
  3329325298
10220
10220
  ];
10221
- var W = new Array(64);
10221
+ var W2 = new Array(64);
10222
10222
  function Sha256() {
10223
10223
  this.init();
10224
- this._w = W;
10224
+ this._w = W2;
10225
10225
  Hash.call(this, 64, 56);
10226
10226
  }
10227
10227
  inherits(Sha256, Hash);
@@ -10271,7 +10271,7 @@ var require_sha256 = __commonJS({
10271
10271
  w[i] = gamma1(w[i - 2]) + w[i - 7] + gamma0(w[i - 15]) + w[i - 16] | 0;
10272
10272
  }
10273
10273
  for (var j = 0; j < 64; ++j) {
10274
- var T1 = h + sigma1(e) + ch(e, f2, g) + K[j] + w[j] | 0;
10274
+ var T1 = h + sigma1(e) + ch(e, f2, g) + K2[j] + w[j] | 0;
10275
10275
  var T2 = sigma0(a) + maj(a, b, c) | 0;
10276
10276
  h = g;
10277
10277
  g = f2;
@@ -10292,16 +10292,16 @@ var require_sha256 = __commonJS({
10292
10292
  this._h = h + this._h | 0;
10293
10293
  };
10294
10294
  Sha256.prototype._hash = function() {
10295
- var H = Buffer2.allocUnsafe(32);
10296
- H.writeInt32BE(this._a, 0);
10297
- H.writeInt32BE(this._b, 4);
10298
- H.writeInt32BE(this._c, 8);
10299
- H.writeInt32BE(this._d, 12);
10300
- H.writeInt32BE(this._e, 16);
10301
- H.writeInt32BE(this._f, 20);
10302
- H.writeInt32BE(this._g, 24);
10303
- H.writeInt32BE(this._h, 28);
10304
- return H;
10295
+ var H2 = Buffer2.allocUnsafe(32);
10296
+ H2.writeInt32BE(this._a, 0);
10297
+ H2.writeInt32BE(this._b, 4);
10298
+ H2.writeInt32BE(this._c, 8);
10299
+ H2.writeInt32BE(this._d, 12);
10300
+ H2.writeInt32BE(this._e, 16);
10301
+ H2.writeInt32BE(this._f, 20);
10302
+ H2.writeInt32BE(this._g, 24);
10303
+ H2.writeInt32BE(this._h, 28);
10304
+ return H2;
10305
10305
  };
10306
10306
  module2.exports = Sha256;
10307
10307
  }
@@ -10316,10 +10316,10 @@ var require_sha224 = __commonJS({
10316
10316
  var Sha256 = require_sha256();
10317
10317
  var Hash = require_hash();
10318
10318
  var Buffer2 = require_buffer().Buffer;
10319
- var W = new Array(64);
10319
+ var W2 = new Array(64);
10320
10320
  function Sha224() {
10321
10321
  this.init();
10322
- this._w = W;
10322
+ this._w = W2;
10323
10323
  Hash.call(this, 64, 56);
10324
10324
  }
10325
10325
  inherits(Sha224, Sha256);
@@ -10335,15 +10335,15 @@ var require_sha224 = __commonJS({
10335
10335
  return this;
10336
10336
  };
10337
10337
  Sha224.prototype._hash = function() {
10338
- var H = Buffer2.allocUnsafe(28);
10339
- H.writeInt32BE(this._a, 0);
10340
- H.writeInt32BE(this._b, 4);
10341
- H.writeInt32BE(this._c, 8);
10342
- H.writeInt32BE(this._d, 12);
10343
- H.writeInt32BE(this._e, 16);
10344
- H.writeInt32BE(this._f, 20);
10345
- H.writeInt32BE(this._g, 24);
10346
- return H;
10338
+ var H2 = Buffer2.allocUnsafe(28);
10339
+ H2.writeInt32BE(this._a, 0);
10340
+ H2.writeInt32BE(this._b, 4);
10341
+ H2.writeInt32BE(this._c, 8);
10342
+ H2.writeInt32BE(this._d, 12);
10343
+ H2.writeInt32BE(this._e, 16);
10344
+ H2.writeInt32BE(this._f, 20);
10345
+ H2.writeInt32BE(this._g, 24);
10346
+ return H2;
10347
10347
  };
10348
10348
  module2.exports = Sha224;
10349
10349
  }
@@ -10357,7 +10357,7 @@ var require_sha512 = __commonJS({
10357
10357
  var inherits = require_inherits_browser();
10358
10358
  var Hash = require_hash();
10359
10359
  var Buffer2 = require_buffer().Buffer;
10360
- var K = [
10360
+ var K2 = [
10361
10361
  1116352408,
10362
10362
  3609767458,
10363
10363
  1899447441,
@@ -10519,10 +10519,10 @@ var require_sha512 = __commonJS({
10519
10519
  1816402316,
10520
10520
  1246189591
10521
10521
  ];
10522
- var W = new Array(160);
10522
+ var W2 = new Array(160);
10523
10523
  function Sha512() {
10524
10524
  this.init();
10525
- this._w = W;
10525
+ this._w = W2;
10526
10526
  Hash.call(this, 128, 112);
10527
10527
  }
10528
10528
  inherits(Sha512, Hash);
@@ -10625,8 +10625,8 @@ var require_sha512 = __commonJS({
10625
10625
  var sigma0l = sigma0(al, ah);
10626
10626
  var sigma1h = sigma1(eh, el);
10627
10627
  var sigma1l = sigma1(el, eh);
10628
- var Kih = K[j];
10629
- var Kil = K[j + 1];
10628
+ var Kih = K2[j];
10629
+ var Kil = K2[j + 1];
10630
10630
  var chh = Ch(eh, fh, gh);
10631
10631
  var chl = Ch(el, fl, gl);
10632
10632
  var t1l = hl + sigma1l | 0;
@@ -10674,10 +10674,10 @@ var require_sha512 = __commonJS({
10674
10674
  this._hh = this._hh + hh + getCarry(this._hl, hl) | 0;
10675
10675
  };
10676
10676
  Sha512.prototype._hash = function() {
10677
- var H = Buffer2.allocUnsafe(64);
10677
+ var H2 = Buffer2.allocUnsafe(64);
10678
10678
  function writeInt64BE(h, l, offset) {
10679
- H.writeInt32BE(h, offset);
10680
- H.writeInt32BE(l, offset + 4);
10679
+ H2.writeInt32BE(h, offset);
10680
+ H2.writeInt32BE(l, offset + 4);
10681
10681
  }
10682
10682
  writeInt64BE(this._ah, this._al, 0);
10683
10683
  writeInt64BE(this._bh, this._bl, 8);
@@ -10687,7 +10687,7 @@ var require_sha512 = __commonJS({
10687
10687
  writeInt64BE(this._fh, this._fl, 40);
10688
10688
  writeInt64BE(this._gh, this._gl, 48);
10689
10689
  writeInt64BE(this._hh, this._hl, 56);
10690
- return H;
10690
+ return H2;
10691
10691
  };
10692
10692
  module2.exports = Sha512;
10693
10693
  }
@@ -10702,10 +10702,10 @@ var require_sha384 = __commonJS({
10702
10702
  var SHA512 = require_sha512();
10703
10703
  var Hash = require_hash();
10704
10704
  var Buffer2 = require_buffer().Buffer;
10705
- var W = new Array(160);
10705
+ var W2 = new Array(160);
10706
10706
  function Sha384() {
10707
10707
  this.init();
10708
- this._w = W;
10708
+ this._w = W2;
10709
10709
  Hash.call(this, 128, 112);
10710
10710
  }
10711
10711
  inherits(Sha384, SHA512);
@@ -10729,10 +10729,10 @@ var require_sha384 = __commonJS({
10729
10729
  return this;
10730
10730
  };
10731
10731
  Sha384.prototype._hash = function() {
10732
- var H = Buffer2.allocUnsafe(48);
10732
+ var H2 = Buffer2.allocUnsafe(48);
10733
10733
  function writeInt64BE(h, l, offset) {
10734
- H.writeInt32BE(h, offset);
10735
- H.writeInt32BE(l, offset + 4);
10734
+ H2.writeInt32BE(h, offset);
10735
+ H2.writeInt32BE(l, offset + 4);
10736
10736
  }
10737
10737
  writeInt64BE(this._ah, this._al, 0);
10738
10738
  writeInt64BE(this._bh, this._bl, 8);
@@ -10740,7 +10740,7 @@ var require_sha384 = __commonJS({
10740
10740
  writeInt64BE(this._dh, this._dl, 24);
10741
10741
  writeInt64BE(this._eh, this._el, 32);
10742
10742
  writeInt64BE(this._fh, this._fl, 40);
10743
- return H;
10743
+ return H2;
10744
10744
  };
10745
10745
  module2.exports = Sha384;
10746
10746
  }
@@ -13411,9 +13411,9 @@ var require_authCipher = __commonJS({
13411
13411
  }
13412
13412
  ghash.update(Buffer2.alloc(8, 0));
13413
13413
  var ivBits = len * 8;
13414
- var tail2 = Buffer2.alloc(8);
13415
- tail2.writeUIntBE(ivBits, 0, 8);
13416
- ghash.update(tail2);
13414
+ var tail3 = Buffer2.alloc(8);
13415
+ tail3.writeUIntBE(ivBits, 0, 8);
13416
+ ghash.update(tail3);
13417
13417
  self2._finID = ghash.state;
13418
13418
  var out = Buffer2.from(self2._finID);
13419
13419
  incr32(out);
@@ -27817,19 +27817,19 @@ var require__ = __commonJS({
27817
27817
  SHA1.hmacStrength = 80;
27818
27818
  SHA1.padLength = 64;
27819
27819
  SHA1.prototype._update = function _update(msg, start) {
27820
- var W = this.W;
27820
+ var W2 = this.W;
27821
27821
  for (var i = 0; i < 16; i++)
27822
- W[i] = msg[start + i];
27823
- for (; i < W.length; i++)
27824
- W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
27822
+ W2[i] = msg[start + i];
27823
+ for (; i < W2.length; i++)
27824
+ W2[i] = rotl32(W2[i - 3] ^ W2[i - 8] ^ W2[i - 14] ^ W2[i - 16], 1);
27825
27825
  var a = this.h[0];
27826
27826
  var b = this.h[1];
27827
27827
  var c = this.h[2];
27828
27828
  var d = this.h[3];
27829
27829
  var e = this.h[4];
27830
- for (i = 0; i < W.length; i++) {
27830
+ for (i = 0; i < W2.length; i++) {
27831
27831
  var s = ~~(i / 20);
27832
- var t2 = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
27832
+ var t2 = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W2[i], sha1_K[s]);
27833
27833
  e = d;
27834
27834
  d = c;
27835
27835
  c = rotl32(b, 30);
@@ -27960,11 +27960,11 @@ var require__2 = __commonJS({
27960
27960
  SHA256.hmacStrength = 192;
27961
27961
  SHA256.padLength = 64;
27962
27962
  SHA256.prototype._update = function _update(msg, start) {
27963
- var W = this.W;
27963
+ var W2 = this.W;
27964
27964
  for (var i = 0; i < 16; i++)
27965
- W[i] = msg[start + i];
27966
- for (; i < W.length; i++)
27967
- W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
27965
+ W2[i] = msg[start + i];
27966
+ for (; i < W2.length; i++)
27967
+ W2[i] = sum32_4(g1_256(W2[i - 2]), W2[i - 7], g0_256(W2[i - 15]), W2[i - 16]);
27968
27968
  var a = this.h[0];
27969
27969
  var b = this.h[1];
27970
27970
  var c = this.h[2];
@@ -27973,9 +27973,9 @@ var require__2 = __commonJS({
27973
27973
  var f2 = this.h[5];
27974
27974
  var g = this.h[6];
27975
27975
  var h = this.h[7];
27976
- assert8(this.k.length === W.length);
27977
- for (i = 0; i < W.length; i++) {
27978
- var T1 = sum32_5(h, s1_256(e), ch32(e, f2, g), this.k[i], W[i]);
27976
+ assert8(this.k.length === W2.length);
27977
+ for (i = 0; i < W2.length; i++) {
27978
+ var T1 = sum32_5(h, s1_256(e), ch32(e, f2, g), this.k[i], W2[i]);
27979
27979
  var T2 = sum32(s0_256(a), maj32(a, b, c));
27980
27980
  h = g;
27981
27981
  g = f2;
@@ -28255,19 +28255,19 @@ var require__4 = __commonJS({
28255
28255
  SHA512.hmacStrength = 192;
28256
28256
  SHA512.padLength = 128;
28257
28257
  SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
28258
- var W = this.W;
28258
+ var W2 = this.W;
28259
28259
  for (var i = 0; i < 32; i++)
28260
- W[i] = msg[start + i];
28261
- for (; i < W.length; i += 2) {
28262
- var c0_hi = g1_512_hi(W[i - 4], W[i - 3]);
28263
- var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
28264
- var c1_hi = W[i - 14];
28265
- var c1_lo = W[i - 13];
28266
- var c2_hi = g0_512_hi(W[i - 30], W[i - 29]);
28267
- var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
28268
- var c3_hi = W[i - 32];
28269
- var c3_lo = W[i - 31];
28270
- W[i] = sum64_4_hi(
28260
+ W2[i] = msg[start + i];
28261
+ for (; i < W2.length; i += 2) {
28262
+ var c0_hi = g1_512_hi(W2[i - 4], W2[i - 3]);
28263
+ var c0_lo = g1_512_lo(W2[i - 4], W2[i - 3]);
28264
+ var c1_hi = W2[i - 14];
28265
+ var c1_lo = W2[i - 13];
28266
+ var c2_hi = g0_512_hi(W2[i - 30], W2[i - 29]);
28267
+ var c2_lo = g0_512_lo(W2[i - 30], W2[i - 29]);
28268
+ var c3_hi = W2[i - 32];
28269
+ var c3_lo = W2[i - 31];
28270
+ W2[i] = sum64_4_hi(
28271
28271
  c0_hi,
28272
28272
  c0_lo,
28273
28273
  c1_hi,
@@ -28277,7 +28277,7 @@ var require__4 = __commonJS({
28277
28277
  c3_hi,
28278
28278
  c3_lo
28279
28279
  );
28280
- W[i + 1] = sum64_4_lo(
28280
+ W2[i + 1] = sum64_4_lo(
28281
28281
  c0_hi,
28282
28282
  c0_lo,
28283
28283
  c1_hi,
@@ -28291,7 +28291,7 @@ var require__4 = __commonJS({
28291
28291
  };
28292
28292
  SHA512.prototype._update = function _update(msg, start) {
28293
28293
  this._prepareBlock(msg, start);
28294
- var W = this.W;
28294
+ var W2 = this.W;
28295
28295
  var ah = this.h[0];
28296
28296
  var al = this.h[1];
28297
28297
  var bh = this.h[2];
@@ -28308,8 +28308,8 @@ var require__4 = __commonJS({
28308
28308
  var gl = this.h[13];
28309
28309
  var hh = this.h[14];
28310
28310
  var hl = this.h[15];
28311
- assert8(this.k.length === W.length);
28312
- for (var i = 0; i < W.length; i += 2) {
28311
+ assert8(this.k.length === W2.length);
28312
+ for (var i = 0; i < W2.length; i += 2) {
28313
28313
  var c0_hi = hh;
28314
28314
  var c0_lo = hl;
28315
28315
  var c1_hi = s1_512_hi(eh, el);
@@ -28318,8 +28318,8 @@ var require__4 = __commonJS({
28318
28318
  var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
28319
28319
  var c3_hi = this.k[i];
28320
28320
  var c3_lo = this.k[i + 1];
28321
- var c4_hi = W[i];
28322
- var c4_lo = W[i + 1];
28321
+ var c4_hi = W2[i];
28322
+ var c4_lo = W2[i + 1];
28323
28323
  var T1_hi = sum64_5_hi(
28324
28324
  c0_hi,
28325
28325
  c0_lo,
@@ -28578,7 +28578,7 @@ var require_ripemd = __commonJS({
28578
28578
  for (var j = 0; j < 80; j++) {
28579
28579
  var T = sum32(
28580
28580
  rotl32(
28581
- sum32_4(A, f2(j, B, C, D), msg[r[j] + start], K(j)),
28581
+ sum32_4(A, f2(j, B, C, D), msg[r[j] + start], K2(j)),
28582
28582
  s[j]
28583
28583
  ),
28584
28584
  E
@@ -28626,7 +28626,7 @@ var require_ripemd = __commonJS({
28626
28626
  else
28627
28627
  return x ^ (y | ~z);
28628
28628
  }
28629
- function K(j) {
28629
+ function K2(j) {
28630
28630
  if (j <= 15)
28631
28631
  return 0;
28632
28632
  else if (j <= 31)
@@ -35673,13 +35673,13 @@ var require_sign2 = __commonJS({
35673
35673
  var g = priv.params.g;
35674
35674
  var r = new BN(0);
35675
35675
  var k;
35676
- var H = bits2int(hash, q).mod(q);
35676
+ var H2 = bits2int(hash, q).mod(q);
35677
35677
  var s = false;
35678
35678
  var kv = getKey(x, q, hash, algo);
35679
35679
  while (s === false) {
35680
35680
  k = makeKey(q, kv, algo);
35681
35681
  r = makeR(g, k, p, q);
35682
- s = k.invm(q).imul(H.add(x.mul(r))).mod(q);
35682
+ s = k.invm(q).imul(H2.add(x.mul(r))).mod(q);
35683
35683
  if (s.cmpn(0) === 0) {
35684
35684
  s = false;
35685
35685
  r = new BN(0);
@@ -62839,6 +62839,190 @@ function rsaLengthRsaPublicKey(key) {
62839
62839
  init_inject_buffer();
62840
62840
  var import_node_assert7 = __toESM(require_assert(), 1);
62841
62841
  init_node_crypto_shim();
62842
+
62843
+ // ../node-opcua-crypto/source/hmac_sha256.ts
62844
+ init_inject_buffer();
62845
+ var K = new Uint32Array([
62846
+ 1116352408,
62847
+ 1899447441,
62848
+ 3049323471,
62849
+ 3921009573,
62850
+ 961987163,
62851
+ 1508970993,
62852
+ 2453635748,
62853
+ 2870763221,
62854
+ 3624381080,
62855
+ 310598401,
62856
+ 607225278,
62857
+ 1426881987,
62858
+ 1925078388,
62859
+ 2162078206,
62860
+ 2614888103,
62861
+ 3248222580,
62862
+ 3835390401,
62863
+ 4022224774,
62864
+ 264347078,
62865
+ 604807628,
62866
+ 770255983,
62867
+ 1249150122,
62868
+ 1555081692,
62869
+ 1996064986,
62870
+ 2554220882,
62871
+ 2821834349,
62872
+ 2952996808,
62873
+ 3210313671,
62874
+ 3336571891,
62875
+ 3584528711,
62876
+ 113926993,
62877
+ 338241895,
62878
+ 666307205,
62879
+ 773529912,
62880
+ 1294757372,
62881
+ 1396182291,
62882
+ 1695183700,
62883
+ 1986661051,
62884
+ 2177026350,
62885
+ 2456956037,
62886
+ 2730485921,
62887
+ 2820302411,
62888
+ 3259730800,
62889
+ 3345764771,
62890
+ 3516065817,
62891
+ 3600352804,
62892
+ 4094571909,
62893
+ 275423344,
62894
+ 430227734,
62895
+ 506948616,
62896
+ 659060556,
62897
+ 883997877,
62898
+ 958139571,
62899
+ 1322822218,
62900
+ 1537002063,
62901
+ 1747873779,
62902
+ 1955562222,
62903
+ 2024104815,
62904
+ 2227730452,
62905
+ 2361852424,
62906
+ 2428436474,
62907
+ 2756734187,
62908
+ 3204031479,
62909
+ 3329325298
62910
+ ]);
62911
+ var INITIAL_STATE = new Uint32Array([
62912
+ 1779033703,
62913
+ 3144134277,
62914
+ 1013904242,
62915
+ 2773480762,
62916
+ 1359893119,
62917
+ 2600822924,
62918
+ 528734635,
62919
+ 1541459225
62920
+ ]);
62921
+ var BLOCK_SIZE = 64;
62922
+ var W = new Uint32Array(64);
62923
+ var H = new Uint32Array(8);
62924
+ var tail2 = new Uint8Array(2 * BLOCK_SIZE);
62925
+ var innerDigest = new Uint8Array(32);
62926
+ function compress(state, bytes, offset) {
62927
+ for (let i = 0; i < 16; i++, offset += 4) {
62928
+ W[i] = bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3];
62929
+ }
62930
+ for (let i = 16; i < 64; i++) {
62931
+ const w15 = W[i - 15];
62932
+ const w2 = W[i - 2];
62933
+ const s0 = (w15 >>> 7 | w15 << 25) ^ (w15 >>> 18 | w15 << 14) ^ w15 >>> 3;
62934
+ const s1 = (w2 >>> 17 | w2 << 15) ^ (w2 >>> 19 | w2 << 13) ^ w2 >>> 10;
62935
+ W[i] = W[i - 16] + s0 + W[i - 7] + s1 | 0;
62936
+ }
62937
+ let a = state[0];
62938
+ let b = state[1];
62939
+ let c = state[2];
62940
+ let d = state[3];
62941
+ let e = state[4];
62942
+ let f2 = state[5];
62943
+ let g = state[6];
62944
+ let h = state[7];
62945
+ for (let i = 0; i < 64; i++) {
62946
+ const S1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
62947
+ const t1 = h + S1 + (e & f2 ^ ~e & g) + K[i] + W[i] | 0;
62948
+ const S0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
62949
+ const t2 = S0 + (a & b ^ a & c ^ b & c) | 0;
62950
+ h = g;
62951
+ g = f2;
62952
+ f2 = e;
62953
+ e = d + t1 | 0;
62954
+ d = c;
62955
+ c = b;
62956
+ b = a;
62957
+ a = t1 + t2 | 0;
62958
+ }
62959
+ state[0] = state[0] + a | 0;
62960
+ state[1] = state[1] + b | 0;
62961
+ state[2] = state[2] + c | 0;
62962
+ state[3] = state[3] + d | 0;
62963
+ state[4] = state[4] + e | 0;
62964
+ state[5] = state[5] + f2 | 0;
62965
+ state[6] = state[6] + g | 0;
62966
+ state[7] = state[7] + h | 0;
62967
+ }
62968
+ function finish(state, data, out) {
62969
+ const length = data.length;
62970
+ let offset = 0;
62971
+ for (; offset + BLOCK_SIZE <= length; offset += BLOCK_SIZE) {
62972
+ compress(state, data, offset);
62973
+ }
62974
+ const rest = length - offset;
62975
+ tail2.fill(0);
62976
+ tail2.set(data.subarray(offset), 0);
62977
+ tail2[rest] = 128;
62978
+ const end = rest + 9 > BLOCK_SIZE ? 2 * BLOCK_SIZE : BLOCK_SIZE;
62979
+ const bits = (BLOCK_SIZE + length) * 8;
62980
+ tail2[end - 5] = Math.floor(bits / 4294967296);
62981
+ tail2[end - 4] = bits >>> 24;
62982
+ tail2[end - 3] = bits >>> 16;
62983
+ tail2[end - 2] = bits >>> 8;
62984
+ tail2[end - 1] = bits;
62985
+ compress(state, tail2, 0);
62986
+ if (end > BLOCK_SIZE) {
62987
+ compress(state, tail2, BLOCK_SIZE);
62988
+ }
62989
+ for (let i = 0, o = 0; i < 8; i++) {
62990
+ const v = state[i];
62991
+ out[o++] = v >>> 24;
62992
+ out[o++] = v >>> 16;
62993
+ out[o++] = v >>> 8;
62994
+ out[o++] = v;
62995
+ }
62996
+ }
62997
+ var KeyedHmacSha256 = class {
62998
+ #inner = new Uint32Array(8);
62999
+ #outer = new Uint32Array(8);
63000
+ /** @param key at most 64 bytes, as every derived signing key of the OPC UA security policies */
63001
+ constructor(key) {
63002
+ if (key.length > BLOCK_SIZE) {
63003
+ throw new Error("KeyedHmacSha256: keys longer than 64 bytes are not supported");
63004
+ }
63005
+ const pad2 = new Uint8Array(BLOCK_SIZE);
63006
+ pad2.fill(54);
63007
+ for (let i = 0; i < key.length; i++) pad2[i] ^= key[i];
63008
+ this.#inner.set(INITIAL_STATE);
63009
+ compress(this.#inner, pad2, 0);
63010
+ pad2.fill(92);
63011
+ for (let i = 0; i < key.length; i++) pad2[i] ^= key[i];
63012
+ this.#outer.set(INITIAL_STATE);
63013
+ compress(this.#outer, pad2, 0);
63014
+ }
63015
+ digest(message) {
63016
+ const signature = import_buffer.Buffer.allocUnsafe(32);
63017
+ H.set(this.#inner);
63018
+ finish(H, message, innerDigest);
63019
+ H.set(this.#outer);
63020
+ finish(H, innerDigest, signature);
63021
+ return signature;
63022
+ }
63023
+ };
63024
+
63025
+ // ../node-opcua-crypto/source/derived_keys.ts
62842
63026
  function HMAC_HASH(sha1or256, secret, message) {
62843
63027
  return createHmac(sha1or256, secret).update(message).digest();
62844
63028
  }
@@ -62923,32 +63107,95 @@ function derivedKeys_algorithm(derivedKeys) {
62923
63107
  (0, import_node_assert7.default)(algorithm === "aes-128-cbc" || algorithm === "aes-256-cbc");
62924
63108
  return algorithm;
62925
63109
  }
63110
+ var cipherStates = /* @__PURE__ */ new WeakMap();
63111
+ var canKeepCiphers = typeof createSecretKey === "function";
63112
+ function cipherStateOf(derivedKeys) {
63113
+ let state = cipherStates.get(derivedKeys.encryptingKey);
63114
+ if (!state || state.initializationVector !== derivedKeys.initializationVector) {
63115
+ state = { initializationVector: derivedKeys.initializationVector };
63116
+ cipherStates.set(derivedKeys.encryptingKey, state);
63117
+ }
63118
+ return state;
63119
+ }
63120
+ var scratch = import_buffer.Buffer.alloc(0);
63121
+ function withLeadingBlock(block, buffer) {
63122
+ const length = block.length + buffer.length;
63123
+ if (scratch.length < length) {
63124
+ scratch = import_buffer.Buffer.alloc(Math.max(length, 2 * scratch.length));
63125
+ }
63126
+ block.copy(scratch, 0);
63127
+ buffer.copy(scratch, block.length);
63128
+ return scratch.subarray(0, length);
63129
+ }
63130
+ function isWholeBlocks(buffer, derivedKeys) {
63131
+ const blockSize = derivedKeys.initializationVector.length;
63132
+ return blockSize === 16 && buffer.length > 0 && buffer.length % blockSize === 0;
63133
+ }
62926
63134
  function encryptBufferWithDerivedKeys(buffer, derivedKeys) {
62927
63135
  const algorithm = derivedKeys_algorithm(derivedKeys);
62928
63136
  const key = derivedKeys.encryptingKey;
62929
63137
  const initVector = derivedKeys.initializationVector;
63138
+ if (canKeepCiphers && isWholeBlocks(buffer, derivedKeys)) {
63139
+ const state = cipherStateOf(derivedKeys);
63140
+ if (!state.encrypt) {
63141
+ const blockDecipher = createDecipheriv(algorithm.replace("-cbc", "-ecb"), keyObjectOf(key), null);
63142
+ blockDecipher.setAutoPadding(false);
63143
+ const decryptedIv = blockDecipher.update(initVector);
63144
+ const cipher2 = createCipheriv(algorithm, keyObjectOf(key), initVector);
63145
+ cipher2.setAutoPadding(false);
63146
+ state.encrypt = { cipher: cipher2, decryptedIv, lastBlock: initVector };
63147
+ }
63148
+ const encrypt = state.encrypt;
63149
+ const blockSize = initVector.length;
63150
+ const reset = import_buffer.Buffer.allocUnsafe(blockSize);
63151
+ for (let i = 0; i < blockSize; i++) {
63152
+ reset[i] = encrypt.decryptedIv[i] ^ encrypt.lastBlock[i];
63153
+ }
63154
+ const encrypted2 = encrypt.cipher.update(withLeadingBlock(reset, buffer));
63155
+ encrypt.lastBlock = encrypted2.subarray(encrypted2.length - blockSize);
63156
+ return encrypted2.subarray(blockSize);
63157
+ }
62930
63158
  const cipher = createCipheriv(algorithm, keyObjectOf(key), initVector);
62931
63159
  cipher.setAutoPadding(false);
62932
63160
  const encrypted = cipher.update(buffer);
62933
- const tail2 = cipher.final();
62934
- return tail2.length === 0 ? encrypted : import_buffer.Buffer.concat([encrypted, tail2]);
63161
+ const tail3 = cipher.final();
63162
+ return tail3.length === 0 ? encrypted : import_buffer.Buffer.concat([encrypted, tail3]);
62935
63163
  }
62936
63164
  function decryptBufferWithDerivedKeys(buffer, derivedKeys) {
62937
63165
  const algorithm = derivedKeys_algorithm(derivedKeys);
62938
63166
  const key = derivedKeys.encryptingKey;
62939
63167
  const initVector = derivedKeys.initializationVector;
63168
+ if (canKeepCiphers && isWholeBlocks(buffer, derivedKeys)) {
63169
+ const state = cipherStateOf(derivedKeys);
63170
+ if (!state.decrypt) {
63171
+ state.decrypt = createDecipheriv(algorithm, keyObjectOf(key), initVector);
63172
+ state.decrypt.setAutoPadding(false);
63173
+ }
63174
+ return state.decrypt.update(withLeadingBlock(initVector, buffer)).subarray(initVector.length);
63175
+ }
62940
63176
  const cipher = createDecipheriv(algorithm, keyObjectOf(key), initVector);
62941
63177
  cipher.setAutoPadding(false);
62942
63178
  const decrypted = cipher.update(buffer);
62943
- const tail2 = cipher.final();
62944
- return tail2.length === 0 ? decrypted : import_buffer.Buffer.concat([decrypted, tail2]);
63179
+ const tail3 = cipher.final();
63180
+ return tail3.length === 0 ? decrypted : import_buffer.Buffer.concat([decrypted, tail3]);
63181
+ }
63182
+ var KEYED_HMAC_MAX_MESSAGE = 256;
63183
+ var keyedHmacs = /* @__PURE__ */ new WeakMap();
63184
+ function keyedHmacOf(signingKey) {
63185
+ let hmac = keyedHmacs.get(signingKey);
63186
+ if (!hmac) {
63187
+ hmac = new KeyedHmacSha256(signingKey);
63188
+ keyedHmacs.set(signingKey, hmac);
63189
+ }
63190
+ return hmac;
62945
63191
  }
62946
63192
  function makeMessageChunkSignatureWithDerivedKeys(message, derivedKeys) {
62947
63193
  (0, import_node_assert7.default)(import_buffer.Buffer.isBuffer(message));
62948
63194
  (0, import_node_assert7.default)(import_buffer.Buffer.isBuffer(derivedKeys.signingKey));
62949
63195
  (0, import_node_assert7.default)(typeof derivedKeys.sha1or256 === "string");
62950
63196
  (0, import_node_assert7.default)(derivedKeys.sha1or256 === "SHA1" || derivedKeys.sha1or256 === "SHA256");
62951
- const signature = createHmac(derivedKeys.sha1or256, keyObjectOf(derivedKeys.signingKey)).update(message).digest();
63197
+ const useKeyedHmac = derivedKeys.sha1or256 === "SHA256" && message.length <= KEYED_HMAC_MAX_MESSAGE && derivedKeys.signingKey.length <= 64;
63198
+ const signature = useKeyedHmac ? keyedHmacOf(derivedKeys.signingKey).digest(message) : createHmac(derivedKeys.sha1or256, keyObjectOf(derivedKeys.signingKey)).update(message).digest();
62952
63199
  (0, import_node_assert7.default)(signature.length === derivedKeys.signatureLength);
62953
63200
  return signature;
62954
63201
  }
@@ -62956,7 +63203,14 @@ function verifyChunkSignatureWithDerivedKeys(chunk, derivedKeys) {
62956
63203
  const message = chunk.subarray(0, chunk.length - derivedKeys.signatureLength);
62957
63204
  const expectedSignature = chunk.subarray(chunk.length - derivedKeys.signatureLength);
62958
63205
  const computedSignature = makeMessageChunkSignatureWithDerivedKeys(message, derivedKeys);
62959
- return computedSignature.equals(expectedSignature);
63206
+ if (computedSignature.length !== expectedSignature.length) {
63207
+ return false;
63208
+ }
63209
+ let difference = 0;
63210
+ for (let i = 0; i < computedSignature.length; i++) {
63211
+ difference |= computedSignature[i] ^ expectedSignature[i];
63212
+ }
63213
+ return difference === 0;
62960
63214
  }
62961
63215
 
62962
63216
  // ../node-opcua-crypto/source/key_operations/local_key_operations.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-crypto-web",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "type": "module",
5
5
  "description": "Pre-bundled, zero-config browser build of node-opcua-crypto",
6
6
  "//why": "This package exists so node-opcua-crypto can stay lean for Node. The pre-bundled browser build inlines its polyfills (crypto-browserify, stream-browserify, ...) and weighs ~344 KB gzip - more than the entire node-opcua-crypto tarball. Shipping it there would make every Node consumer download a browser bundle they never import. Browser consumers install this package explicitly, or let node-opcua-crypto's \"browser\" export condition redirect to it (see node-opcua-crypto/browser/index.js).",
@@ -44,7 +44,7 @@
44
44
  "crypto-browserify": "^3.12.1",
45
45
  "esbuild": "^0.28.2",
46
46
  "events": "^3.3.0",
47
- "node-opcua-crypto": "^6.2.0",
47
+ "node-opcua-crypto": "^6.2.1",
48
48
  "path-browserify": "^1.0.1",
49
49
  "process": "^0.11.10",
50
50
  "stream-browserify": "^3.0.0",
@@ -67,5 +67,5 @@
67
67
  "LICENSE",
68
68
  "README.md"
69
69
  ],
70
- "gitHead": "ba3f9e5151ed01aab242b2807556a49692bc59db"
70
+ "gitHead": "cd71638b8918a00cdc85d3e2f9ac010803e9bc7a"
71
71
  }