概述RSA-PSS 提供强健的基于填充的签名方案。本文给出生成、签名与验证流程。生成与签名验证async function genPSS() {
return crypto.subtle.generateKey({ name:'RSA-PSS', modulusLength:2048, publicExponent:new Uint8Array([1,0,1]), hash:'SHA-256' }, true, ['sign','verify']);
}
async function signPSS(key, bytes) {
const sig = await crypto.subtle.sign({ name:'RSA-PSS', saltLength:32 }, key.privateKey, bytes);
return new Uint8Array(sig);
}
async function verifyPSS(key, bytes, sig) {
return crypto.subtle.verify({ name:'RSA-PSS', saltLength:32 }, key.publicKey, sig, bytes);
}

发表评论 取消回复