首页 > 解决方案 > 反应原生 rsa-pss 密码学?

问题描述

我的网络应用程序中有这段代码:

let algorithm = {
  name: "RSA-PSS",
  hash: "SHA-256",
  modulusLength: 4096,
  publicExponent: new Uint8Array([1, 0, 1]),
  saltLength: 32,
};

let keyPair = await crypto.subtle.generateKey(
  algorithm,
  true,
  ["sign", "verify"],
);

let [publicKey, privateKey] = await Promise.all([
  crypto.subtle.exportKey("spki", keyPair.publicKey),
  crypto.subtle.exportKey("pkcs8", ketPair.privateKey),
]);

let newKeyPair = await Promise.all([
  crypto.subtle.importKey("spki", publicKey, algorithm, true, ["verify"]),
  crypto.subtle.importKey("pkcs8", privateKey, algorithm, true, ["sign"]),
]).then(([publicKey, privateKey]) => ({publicKey, privateKey}));

let signature = await crypto.subtle.sign(
  algorithm,
  newKeyPair.privateKey,
  new TextEncoder().encode(someMessageToSign).buffer,
);

我需要在本机反应中复制它。有没有可以在 Android 和 iOS 上运行的库?

标签: javascriptreact-nativecryptographywebcrypto-api

解决方案


推荐阅读