meteor-node-stubs 1.2.12 → 1.2.13

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.
@@ -115,9 +115,19 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
115
115
  if (!options)
116
116
  options = {};
117
117
 
118
+ if (typeof msg !== 'string' && typeof msg !== 'number' && !BN.isBN(msg)) {
119
+ assert(typeof msg === 'object' && msg && typeof msg.length === 'number',
120
+ 'Expected message to be an array-like, a hex string, or a BN instance');
121
+ assert((msg.length >>> 0) === msg.length); // non-negative 32-bit integer
122
+ for (var i = 0; i < msg.length; i++) assert((msg[i] & 255) === msg[i]);
123
+ }
124
+
118
125
  key = this.keyFromPrivate(key, enc);
119
126
  msg = this._truncateToN(msg, false, options.msgBitLength);
120
127
 
128
+ // Would fail further checks, but let's make the error message clear
129
+ assert(!msg.isNeg(), 'Can not sign a negative message');
130
+
121
131
  // Zero-extend key to provide enough entropy
122
132
  var bytes = this.n.byteLength();
123
133
  var bkey = key.getPrivate().toArray('be', bytes);
@@ -125,6 +135,9 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
125
135
  // Zero-extend nonce to have the same byte size as N
126
136
  var nonce = msg.toArray('be', bytes);
127
137
 
138
+ // Recheck nonce to be bijective to msg
139
+ assert((new BN(nonce)).eq(msg), 'Can not sign message');
140
+
128
141
  // Instantiate Hmac_DRBG
129
142
  var drbg = new HmacDRBG({
130
143
  hash: this.hash,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elliptic",
3
- "version": "6.6.0",
3
+ "version": "6.6.1",
4
4
  "description": "EC cryptography",
5
5
  "main": "lib/elliptic.js",
6
6
  "files": [
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "meteor-node-stubs",
3
3
  "author": "Ben Newman <ben@meteor.com>",
4
4
  "description": "Stub implementations of Node built-in modules, a la Browserify",
5
- "version": "1.2.12",
5
+ "version": "1.2.13",
6
6
  "main": "index.js",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/meteor/meteor/blob/devel/npm-packages/meteor-node-stubs/README.md",
@@ -18,7 +18,7 @@
18
18
  "console-browserify": "^1.2.0",
19
19
  "constants-browserify": "^1.0.0",
20
20
  "domain-browser": "^4.23.0",
21
- "elliptic": "^6.6.0",
21
+ "elliptic": "^6.6.1",
22
22
  "events": "^3.3.0",
23
23
  "https-browserify": "^1.0.0",
24
24
  "os-browserify": "^0.3.0",