【发布时间】:2020-05-31 07:38:52
【问题描述】:
以下代码适用于 Firefox 76.0.1:
"use strict"
let RSAKeys
(async () => {
RSAKeys = await crypto.subtle.generateKey({
name: "RSA-OAEP",
modulusLength: 3072,
publicExponent: new Uint8Array([1, 0, 1]),
hash: "SHA-256"},
true,
// Chromium bug causes it to falsely complain that the array is empty. Sometimes adding "encrypt" helps.
["wrapKey"])
})()
但在 Chromium 80 中我得到:
Uncaught (in promise) DOMException: Usages cannot be empty when creating a key.
["wrapKey"] 显然不是一个空数组,所以它似乎是一个浏览器错误。可能是this one。你确定吗?更重要的是,您知道解决方法吗? (添加encrypt 用法有所帮助,但只是第一次,然后是同样的错误。)它必须是支持包装密钥的非对称密码。根据the relevant chapter of the spec中的表格,RSA-OAEP是唯一的可能。
【问题讨论】:
-
它可以在 chrome 83 或更高版本中使用吗?
标签: google-chrome rsa chromium webcrypto-api