|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | const {
|
4 |
| - ArrayPrototypePush, |
5 | 4 | Promise,
|
6 |
| - ReflectApply, |
7 | 5 | SafeSet,
|
8 | 6 | Uint8Array,
|
9 | 7 | } = primordials;
|
@@ -73,29 +71,29 @@ const kRsaVariants = {
|
73 | 71 | };
|
74 | 72 |
|
75 | 73 | function verifyAcceptableRsaKeyUse(name, type, usages) {
|
76 |
| - const args = [usages]; |
| 74 | + let checkSet; |
77 | 75 | switch (name) {
|
78 | 76 | case 'RSA-OAEP':
|
79 | 77 | switch (type) {
|
80 | 78 | case 'private':
|
81 |
| - ArrayPrototypePush(args, 'decrypt', 'unwrapKey'); |
| 79 | + checkSet = ['decrypt', 'unwrapKey']; |
82 | 80 | break;
|
83 | 81 | case 'public':
|
84 |
| - ArrayPrototypePush(args, 'encrypt', 'wrapKey'); |
| 82 | + checkSet = ['encrypt', 'wrapKey']; |
85 | 83 | break;
|
86 | 84 | }
|
87 | 85 | break;
|
88 | 86 | default:
|
89 | 87 | switch (type) {
|
90 | 88 | case 'private':
|
91 |
| - ArrayPrototypePush(args, 'sign'); |
| 89 | + checkSet = ['sign']; |
92 | 90 | break;
|
93 | 91 | case 'public':
|
94 |
| - ArrayPrototypePush(args, 'verify'); |
| 92 | + checkSet = ['verify']; |
95 | 93 | break;
|
96 | 94 | }
|
97 | 95 | }
|
98 |
| - if (ReflectApply(hasAnyNotIn, null, args)) { |
| 96 | + if (hasAnyNotIn(usages, checkSet)) { |
99 | 97 | throw lazyDOMException(
|
100 | 98 | `Unsupported key usage for an ${name} key`,
|
101 | 99 | 'SyntaxError');
|
@@ -157,14 +155,15 @@ async function rsaKeyGenerate(
|
157 | 155 |
|
158 | 156 | switch (name) {
|
159 | 157 | case 'RSA-OAEP':
|
160 |
| - if (hasAnyNotIn(usageSet, 'encrypt', 'decrypt', 'wrapKey', 'unwrapKey')) { |
| 158 | + if (hasAnyNotIn(usageSet, |
| 159 | + ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'])) { |
161 | 160 | throw lazyDOMException(
|
162 | 161 | 'Unsupported key usage for a RSA key',
|
163 | 162 | 'SyntaxError');
|
164 | 163 | }
|
165 | 164 | break;
|
166 | 165 | default:
|
167 |
| - if (hasAnyNotIn(usageSet, 'sign', 'verify')) { |
| 166 | + if (hasAnyNotIn(usageSet, ['sign', 'verify'])) { |
168 | 167 | throw lazyDOMException(
|
169 | 168 | 'Unsupported key usage for a RSA key',
|
170 | 169 | 'SyntaxError');
|
|
0 commit comments