Skip to content

WebCrypto 的 PBKDF2 在迭代次数超过 100000 时会报错,建议补充说明或放开限制 #498

@fengyuluoye

Description

@fengyuluoye

环境:

  • AutoJs6 版本:6.7.0
  • Android 版本:16
  • 设备型号:REDMI Turbo 4 Pro

复现代码:

const password = new TextEncoder().encode("test123!@#");
const salt = crypto.getRandomValues(new Uint8Array(16));

crypto.subtle.importKey(
"raw",
password,
{ name: "PBKDF2" },
false,
["deriveBits"]
).then((keyMaterial) => {
return crypto.subtle.deriveBits(
{
name: "PBKDF2",
hash: "SHA-256",
salt,
iterations: 210000
},
keyMaterial,
256
);
}).then((bits) => {
console.log(bits);
}).catch((e) => {
console.error(e);
});

实际结果:
报错:
Pbkdf2 failed: iteration counts above 100000 are not supported (requested 210000)

预期结果:

  1. 如果这是框架限制,希望文档里明确说明 PBKDF2 最大只支持 100000 次迭代
  2. 如果不是有意限制,希望后续版本能支持更高迭代次数
  3. 至少希望相关文档或报错提示更明确一些,避免开发者按常见安全参数使用时踩坑

补充说明:
这里使用的是标准 WebCrypto 接口,按常见安全建议会使用更高一些的迭代次数,但目前超过 100000 就直接失败,容易导致实际项目中登录/密码校验出现兼容性问题。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions