| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 64a9dd7 commit 679f191
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,6 +89,11 @@ async function generateKey( | |||
| 89 | 89 | algorithm = normalizeAlgorithm(algorithm); | |
| 90 | 90 | validateBoolean(extractable, 'extractable'); | |
| 91 | 91 | validateArray(keyUsages, 'keyUsages'); | |
| 92 | + if (keyUsages.length === 0) { | ||
| 93 | + throw lazyDOMException( | ||
| 94 | + 'Usages cannot be empty when creating a key', | ||
| 95 | + 'SyntaxError'); | ||
| 96 | + } | ||
| 92 | 97 | switch (algorithm.name) { | |
| 93 | 98 | case 'RSASSA-PKCS1-v1_5': | |
| 94 | 99 | // Fall through | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -210,6 +210,15 @@ const vectors = { | |||
| 210 | 210 | // Test bad usages | |
| 211 | 211 | { | |
| 212 | 212 | async function test(name) { | |
| 213 | + await assert.rejects( | ||
| 214 | + subtle.generateKey( | ||
| 215 | + { | ||
| 216 | + name, ...vectors[name].algorithm | ||
| 217 | + }, | ||
| 218 | + true, | ||
| 219 | + []), | ||
| 220 | + { message: /Usages cannot be empty/ }); | ||
| 221 | + | ||
| 213 | 222 | const invalidUsages = []; | |
| 214 | 223 | allUsages.forEach((usage) => { | |
| 215 | 224 | if (!vectors[name].usages.includes(usage)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -153,7 +153,7 @@ async function testSign({ hash, | |||
| 153 | 153 | } | |
| 154 | 154 | ||
| 155 | 155 | await assert.rejects( | |
| 156 | - subtle.generateKey({ name }, false, []), { | ||
| 156 | + subtle.generateKey({ name }, false, ['sign', 'verify']), { | ||
| 157 | 157 | name: 'TypeError', | |
| 158 | 158 | code: 'ERR_MISSING_OPTION', | |
| 159 | 159 | message: 'algorithm.hash is required' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments