| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f6b2466 commit b5cf012
24 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,13 @@ export default [ | |||
| 61 | 61 | rules: { | |
| 62 | 62 | 'prefer-object-spread': 'error', | |
| 63 | 63 | 'no-buffer-constructor': 'error', | |
| 64 | - 'no-restricted-syntax': noRestrictedSyntax, | ||
| 64 | + 'no-restricted-syntax': [ | ||
| 65 | + ...noRestrictedSyntax, | ||
| 66 | + { | ||
| 67 | + selector: "VariableDeclarator[init.type='CallExpression'][init.callee.name='internalBinding'][init.arguments.0.value='crypto'] > ObjectPattern > Property[key.name='getKeyObjectSlots']", | ||
| 68 | + message: "Use `const { getKeyObjectSlots } = require('internal/crypto/keys');` instead of destructuring it from `internalBinding('crypto')`.", | ||
| 69 | + }, | ||
| 70 | + ], | ||
| 65 | 71 | 'no-restricted-globals': [ | |
| 66 | 72 | 'error', | |
| 67 | 73 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ const { | |||
| 30 | 30 | getUsagesMask, | |
| 31 | 31 | hasAnyNotIn, | |
| 32 | 32 | jobPromise, | |
| 33 | - kHandle, | ||
| 34 | 33 | } = require('internal/crypto/util'); | |
| 35 | 34 | ||
| 36 | 35 | const { | |
@@ -41,6 +40,8 @@ const { | |||
| 41 | 40 | InternalCryptoKey, | |
| 42 | 41 | getCryptoKeyAlgorithm, | |
| 43 | 42 | getCryptoKeyHandle, | |
| 43 | + getKeyObjectHandle, | ||
| 44 | + getKeyObjectSymmetricKeySize, | ||
| 44 | 45 | } = require('internal/crypto/keys'); | |
| 45 | 46 | ||
| 46 | 47 | const { | |
@@ -219,9 +220,9 @@ function aesImportKey( | |||
| 219 | 220 | let length; | |
| 220 | 221 | switch (format) { | |
| 221 | 222 | case 'KeyObject': { | |
| 222 | - length = keyData.symmetricKeySize * 8; | ||
| 223 | + length = getKeyObjectSymmetricKeySize(keyData) * 8; | ||
| 223 | 224 | validateKeyLength(length); | |
| 224 | - handle = keyData[kHandle]; | ||
| 225 | + handle = getKeyObjectHandle(keyData); | ||
| 225 | 226 | break; | |
| 226 | 227 | } | |
| 227 | 228 | case 'raw-secret': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,6 @@ const { | |||
| 30 | 30 | getUsagesUnion, | |
| 31 | 31 | hasAnyNotIn, | |
| 32 | 32 | jobPromise, | |
| 33 | - kHandle, | ||
| 34 | 33 | } = require('internal/crypto/util'); | |
| 35 | 34 | ||
| 36 | 35 | const { | |
@@ -40,6 +39,8 @@ const { | |||
| 40 | 39 | const { | |
| 41 | 40 | getCryptoKeyHandle, | |
| 42 | 41 | getCryptoKeyType, | |
| 42 | + getKeyObjectHandle, | ||
| 43 | + getKeyObjectType, | ||
| 43 | 44 | InternalCryptoKey, | |
| 44 | 45 | } = require('internal/crypto/keys'); | |
| 45 | 46 | ||
@@ -190,8 +191,9 @@ function cfrgImportKey( | |||
| 190 | 191 | const usagesSet = new SafeSet(keyUsages); | |
| 191 | 192 | switch (format) { | |
| 192 | 193 | case 'KeyObject': { | |
| 193 | - verifyAcceptableCfrgKeyUse(name, keyData.type === 'public', usagesSet); | ||
| 194 | - handle = keyData[kHandle]; | ||
| 194 | + verifyAcceptableCfrgKeyUse( | ||
| 195 | + name, getKeyObjectType(keyData) === 'public', usagesSet); | ||
| 196 | + handle = getKeyObjectHandle(keyData); | ||
| 195 | 197 | break; | |
| 196 | 198 | } | |
| 197 | 199 | case 'spki': { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,6 @@ const { | |||
| 14 | 14 | getUsagesMask, | |
| 15 | 15 | hasAnyNotIn, | |
| 16 | 16 | jobPromise, | |
| 17 | - kHandle, | ||
| 18 | 17 | } = require('internal/crypto/util'); | |
| 19 | 18 | ||
| 20 | 19 | const { | |
@@ -24,6 +23,7 @@ const { | |||
| 24 | 23 | const { | |
| 25 | 24 | InternalCryptoKey, | |
| 26 | 25 | getCryptoKeyHandle, | |
| 26 | + getKeyObjectHandle, | ||
| 27 | 27 | } = require('internal/crypto/keys'); | |
| 28 | 28 | ||
| 29 | 29 | const { | |
@@ -87,7 +87,7 @@ function c20pImportKey( | |||
| 87 | 87 | let handle; | |
| 88 | 88 | switch (format) { | |
| 89 | 89 | case 'KeyObject': { | |
| 90 | - handle = keyData[kHandle]; | ||
| 90 | + handle = getKeyObjectHandle(keyData); | ||
| 91 | 91 | break; | |
| 92 | 92 | } | |
| 93 | 93 | case 'raw-secret': { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,6 @@ const { | |||
| 34 | 34 | hasAnyNotIn, | |
| 35 | 35 | jobPromise, | |
| 36 | 36 | normalizeHashName, | |
| 37 | - kHandle, | ||
| 38 | 37 | kNamedCurveAliases, | |
| 39 | 38 | } = require('internal/crypto/util'); | |
| 40 | 39 | ||
@@ -47,6 +46,8 @@ const { | |||
| 47 | 46 | getCryptoKeyAlgorithm, | |
| 48 | 47 | getCryptoKeyHandle, | |
| 49 | 48 | getCryptoKeyType, | |
| 49 | + getKeyObjectHandle, | ||
| 50 | + getKeyObjectType, | ||
| 50 | 51 | } = require('internal/crypto/keys'); | |
| 51 | 52 | ||
| 52 | 53 | const { | |
@@ -189,8 +190,9 @@ function ecImportKey( | |||
| 189 | 190 | const usagesSet = new SafeSet(keyUsages); | |
| 190 | 191 | switch (format) { | |
| 191 | 192 | case 'KeyObject': { | |
| 192 | - verifyAcceptableEcKeyUse(name, keyData.type === 'public', usagesSet); | ||
| 193 | - handle = keyData[kHandle]; | ||
| 193 | + verifyAcceptableEcKeyUse( | ||
| 194 | + name, getKeyObjectType(keyData) === 'public', usagesSet); | ||
| 195 | + handle = getKeyObjectHandle(keyData); | ||
| 194 | 196 | break; | |
| 195 | 197 | } | |
| 196 | 198 | case 'spki': { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ const { | |||
| 29 | 29 | const { | |
| 30 | 30 | createSecretKey, | |
| 31 | 31 | getCryptoKeyHandle, | |
| 32 | + getKeyObjectHandle, | ||
| 32 | 33 | isKeyObject, | |
| 33 | 34 | } = require('internal/crypto/keys'); | |
| 34 | 35 | ||
@@ -75,10 +76,10 @@ const validateParameters = hideStackFrames((hash, key, salt, info, length) => { | |||
| 75 | 76 | ||
| 76 | 77 | function prepareKey(key) { | |
| 77 | 78 | if (isKeyObject(key)) | |
| 78 | - return key; | ||
| 79 | + return getKeyObjectHandle(key); | ||
| 79 | 80 | ||
| 80 | 81 | if (isAnyArrayBuffer(key)) | |
| 81 | - return createSecretKey(key); | ||
| 82 | + return getKeyObjectHandle(createSecretKey(key)); | ||
| 82 | 83 | ||
| 83 | 84 | key = toBuf(key); | |
| 84 | 85 | ||
@@ -96,7 +97,7 @@ function prepareKey(key) { | |||
| 96 | 97 | key); | |
| 97 | 98 | } | |
| 98 | 99 | ||
| 99 | - return createSecretKey(key); | ||
| 100 | + return getKeyObjectHandle(createSecretKey(key)); | ||
| 100 | 101 | } | |
| 101 | 102 | ||
| 102 | 103 | function hkdf(hash, key, salt, info, length, callback) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments