使用WebCrypto生成对加密和签名都有用的密钥对

时间:2015-11-26 02:34:01

标签: encryption rsa webcryptoapi

在Chrome中,这会失败:

window.crypto.subtle.generateKey(
    {
        name: "RSA-OAEP",
        modulusLength: 4096,
        hash: {name: "SHA-256"},
    },
    true,
    ["sign", "verify", "encrypt", "decrypt"]
)

为什么这不可能?为什么我无法创建可用于加密和签名的密钥对? RSA密钥本身没有此限制。

1 个答案:

答案 0 :(得分:3)

RSA-OAEP表示使用加密算法RSA和填充方案OAEP。 OAEP仅指定用于加密而不用于签名。例如,您可以查看source code of Firefox以查找相应的支票。

如果您想签名,则需要使用"RSA-PSS"

您无法直接对加密和签名使用相同的RSA密钥参考,you should never use the same key for different operations.