|
40 | 40 | name: "AES-KW", |
41 | 41 | importParameters: {name: "AES-KW", length: 128}, |
42 | 42 | wrapParameters: {name: "AES-KW"} |
| 43 | + }, |
| 44 | + { |
| 45 | + name: 'ChaCha20-Poly1305', |
| 46 | + importParameters: {name: "ChaCha20-Poly1305"}, |
| 47 | + wrapParameters: {name: "ChaCha20-Poly1305", iv: new Uint8Array(12), additionalData: new Uint8Array(16)} |
43 | 48 | } |
44 | 49 | ]; |
45 | 50 |
|
|
57 | 62 | {algorithm: {name: "AES-CBC", length: 128}, usages: ["encrypt", "decrypt"]}, |
58 | 63 | {algorithm: {name: "AES-GCM", length: 128}, usages: ["encrypt", "decrypt"]}, |
59 | 64 | {algorithm: {name: "AES-KW", length: 128}, usages: ["wrapKey", "unwrapKey"]}, |
60 | | - {algorithm: {name: "HMAC", length: 128, hash: "SHA-256"}, usages: ["sign", "verify"]} |
| 65 | + {algorithm: {name: "HMAC", length: 128, hash: "SHA-256"}, usages: ["sign", "verify"]}, |
| 66 | + {algorithm: {name: "ChaCha20-Poly1305"}, usages: ['encrypt', 'decrypt']} |
61 | 67 | ]; |
62 | 68 |
|
63 | 69 | // Import all the keys needed, then iterate over all combinations |
|
106 | 112 | .then(function(key) { |
107 | 113 | wrappers["RSA-OAEP"].unwrappingKey = key; |
108 | 114 | })); |
| 115 | + } else if (params.name === "ChaCha20-Poly1305") { |
| 116 | + var algorithm = {name: params.name}; |
| 117 | + promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC256"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) |
| 118 | + .then(function(key) { |
| 119 | + wrappers[params.name] = {wrappingKey: key, unwrappingKey: key, parameters: params}; |
| 120 | + })); |
109 | 121 | } else { |
110 | 122 | var algorithm = {name: params.name}; |
111 | | - promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) |
| 123 | + promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC128"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) |
112 | 124 | .then(function(key) { |
113 | 125 | wrappers[params.name] = {wrappingKey: key, unwrappingKey: key, parameters: params}; |
114 | 126 | })); |
|
151 | 163 | var keyData = toWrapKeyDataFromAlg(params.algorithm.name); |
152 | 164 | promises.push(importAndExport("spki", keyData.spki, params.algorithm, params.publicUsages, "public key ")); |
153 | 165 | promises.push(importAndExport("pkcs8", keyData.pkcs8, params.algorithm, params.privateUsages, "private key ")); |
| 166 | + } else if (params.algorithm.name === "ChaCha20-Poly1305") { |
| 167 | + keys[params.algorithm.name] = {}; |
| 168 | + promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC256"].raw, params.algorithm, params.usages, "")); |
154 | 169 | } else { |
155 | 170 | keys[params.algorithm.name] = {}; |
156 | | - promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC"].raw, params.algorithm, params.usages, "")); |
| 171 | + promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC128"].raw, params.algorithm, params.usages, "")); |
157 | 172 | } |
158 | 173 | }); |
159 | 174 | // Using allSettled to skip unsupported test cases. |
|
432 | 447 | case "ECDH" : |
433 | 448 | deriveParams = {name: "ECDH"}; |
434 | 449 | break; |
| 450 | + case "ChaCha20-Poly1305": |
| 451 | + cryptParams = {name: "ChaCha20-Poly1305", iv: new Uint8Array(12)}; |
| 452 | + break; |
435 | 453 | default: |
436 | 454 | throw new Error("Unsupported algorithm for key comparison"); |
437 | 455 | } |
|
0 commit comments