MCPcopy Index your code
hub / github.com/nodejs/node / validateKeyOps

Function validateKeyOps

lib/internal/crypto/util.js:943–971  ·  view source on GitHub ↗
(keyOps, usagesSet)

Source from the content-addressed store, hash-verified

941}
942
943function validateKeyOps(keyOps, usagesSet) {
944 if (keyOps === undefined) return;
945 validateArray(keyOps, 'keyData.key_ops');
946 let keyOpsMask = 0;
947 for (let n = 0; n < keyOps.length; n++) {
948 const op = keyOps[n];
949 const opMask = kUsageMasks[op];
950 // Skipping unknown key ops
951 if (opMask === undefined)
952 continue;
953 // Have we seen it already? if so, error
954 if (keyOpsMask & opMask)
955 throw lazyDOMException('Duplicate key operation', 'DataError');
956 keyOpsMask |= opMask;
957
958 // TODO(@jasnell): RFC7517 section 4.3 strong recommends validating
959 // key usage combinations. Specifically, it says that unrelated key
960 // ops SHOULD NOT be used together. We're not yet validating that here.
961 }
962
963 if (usagesSet !== undefined) {
964 const usagesMask = getUsagesMask(usagesSet);
965 if ((keyOpsMask & usagesMask) !== usagesMask) {
966 throw lazyDOMException(
967 'Key operations and usage mismatch',
968 'DataError');
969 }
970 }
971}
972
973function secureHeapUsed() {
974 const val = _secureHeapUsed();

Callers 2

validateJwkFunction · 0.85

Calls 2

lazyDOMExceptionFunction · 0.85
getUsagesMaskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…