| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f3570f2 commit fb71337
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,8 @@ const { | |||
| 11 | 11 | ERR_INVALID_CALLBACK, | |
| 12 | 12 | } = require('internal/errors').codes; | |
| 13 | 13 | const { | |
| 14 | - checkIsArrayBufferView, | ||
| 15 | 14 | getDefaultEncoding, | |
| 15 | + validateArrayBufferView, | ||
| 16 | 16 | } = require('internal/crypto/util'); | |
| 17 | 17 | ||
| 18 | 18 | function pbkdf2(password, salt, iterations, keylen, digest, callback) { | |
@@ -57,8 +57,8 @@ function check(password, salt, iterations, keylen, digest, callback) { | |||
| 57 | 57 | digest = 'sha1'; | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | - password = checkIsArrayBufferView('password', password); | ||
| 61 | - salt = checkIsArrayBufferView('salt', salt); | ||
| 60 | + password = validateArrayBufferView(password, 'password'); | ||
| 61 | + salt = validateArrayBufferView(salt, 'salt'); | ||
| 62 | 62 | iterations = validateInt32(iterations, 'iterations', 0, INT_MAX); | |
| 63 | 63 | keylen = validateInt32(keylen, 'keylen', 0, INT_MAX); | |
| 64 | 64 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,8 +10,8 @@ const { | |||
| 10 | 10 | ERR_INVALID_CALLBACK, | |
| 11 | 11 | } = require('internal/errors').codes; | |
| 12 | 12 | const { | |
| 13 | - checkIsArrayBufferView, | ||
| 14 | 13 | getDefaultEncoding, | |
| 14 | + validateArrayBufferView, | ||
| 15 | 15 | } = require('internal/crypto/util'); | |
| 16 | 16 | ||
| 17 | 17 | const defaults = { | |
@@ -74,8 +74,8 @@ function check(password, salt, keylen, options, callback) { | |||
| 74 | 74 | if (_scrypt === undefined) | |
| 75 | 75 | throw new ERR_CRYPTO_SCRYPT_NOT_SUPPORTED(); | |
| 76 | 76 | ||
| 77 | - password = checkIsArrayBufferView('password', password); | ||
| 78 | - salt = checkIsArrayBufferView(salt, 'salt'); | ||
| 77 | + password = validateArrayBufferView(password, 'password'); | ||
| 78 | + salt = validateArrayBufferView(salt, 'salt'); | ||
| 79 | 79 | keylen = validateInt32(keylen, 'keylen', 0, INT_MAX); | |
| 80 | 80 | ||
| 81 | 81 | let { N, r, p, maxmem } = defaults; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,9 +14,9 @@ const { | |||
| 14 | 14 | RSA_PKCS1_PADDING | |
| 15 | 15 | } = process.binding('constants').crypto; | |
| 16 | 16 | const { | |
| 17 | - checkIsArrayBufferView, | ||
| 18 | 17 | getDefaultEncoding, | |
| 19 | - toBuf | ||
| 18 | + toBuf, | ||
| 19 | + validateArrayBufferView, | ||
| 20 | 20 | } = require('internal/crypto/util'); | |
| 21 | 21 | const { Writable } = require('stream'); | |
| 22 | 22 | const { inherits } = require('util'); | |
@@ -41,7 +41,8 @@ Sign.prototype._write = function _write(chunk, encoding, callback) { | |||
| 41 | 41 | ||
| 42 | 42 | Sign.prototype.update = function update(data, encoding) { | |
| 43 | 43 | encoding = encoding || getDefaultEncoding(); | |
| 44 | - data = checkIsArrayBufferView('data', toBuf(data, encoding)); | ||
| 44 | + data = validateArrayBufferView(toBuf(data, encoding), | ||
| 45 | + 'data'); | ||
| 45 | 46 | this._handle.update(data); | |
| 46 | 47 | return this; | |
| 47 | 48 | }; | |
@@ -77,7 +78,7 @@ Sign.prototype.sign = function sign(options, encoding) { | |||
| 77 | 78 | ||
| 78 | 79 | var pssSaltLength = getSaltLength(options); | |
| 79 | 80 | ||
| 80 | - key = checkIsArrayBufferView('key', key); | ||
| 81 | + key = validateArrayBufferView(key, 'key'); | ||
| 81 | 82 | ||
| 82 | 83 | var ret = this._handle.sign(key, passphrase, rsaPadding, pssSaltLength); | |
| 83 | 84 | ||
@@ -114,10 +115,10 @@ Verify.prototype.verify = function verify(options, signature, sigEncoding) { | |||
| 114 | 115 | ||
| 115 | 116 | var pssSaltLength = getSaltLength(options); | |
| 116 | 117 | ||
| 117 | - key = checkIsArrayBufferView('key', key); | ||
| 118 | + key = validateArrayBufferView(key, 'key'); | ||
| 118 | 119 | ||
| 119 | - signature = checkIsArrayBufferView('signature', | ||
| 120 | - toBuf(signature, sigEncoding)); | ||
| 120 | + signature = validateArrayBufferView(toBuf(signature, sigEncoding), | ||
| 121 | + 'signature'); | ||
| 121 | 122 | ||
| 122 | 123 | return this._handle.verify(key, signature, rsaPadding, pssSaltLength); | |
| 123 | 124 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,7 @@ function timingSafeEqual(buf1, buf2) { | |||
| 83 | 83 | return _timingSafeEqual(buf1, buf2); | |
| 84 | 84 | } | |
| 85 | 85 | ||
| 86 | - function checkIsArrayBufferView(name, buffer) { | ||
| 86 | + function validateArrayBufferView(buffer, name) { | ||
| 87 | 87 | buffer = toBuf(buffer); | |
| 88 | 88 | if (!isArrayBufferView(buffer)) { | |
| 89 | 89 | throw new ERR_INVALID_ARG_TYPE( | |
@@ -96,7 +96,7 @@ function checkIsArrayBufferView(name, buffer) { | |||
| 96 | 96 | } | |
| 97 | 97 | ||
| 98 | 98 | module.exports = { | |
| 99 | - checkIsArrayBufferView, | ||
| 99 | + validateArrayBufferView, | ||
| 100 | 100 | getCiphers, | |
| 101 | 101 | getCurves, | |
| 102 | 102 | getDefaultEncoding, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments