将RSA键从一台计算机传输到另一台计算机



机器上的a"我创建了一个RSA公共/私钥:

CspParameters cp = new CspParameters();
cp.KeyContainerName = containerName;
// Create a new instance of RSACryptoServiceProvider that accesses  
// the key container MyKeyContainerName.  
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);
publicKeyXml = rsa.ToXmlString(false);

每次都为我提供了相同的公共和私钥。然后,我将公开密钥存储在计算机B上。然后,我可以从计算机上解密消息:

RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
// set the public key of the crypto service provider
RSA.FromXmlString(publicKeyXml);
// create a deformatter
RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(RSA);
// set the hash algorithm. The sender must use the same algorithm
RSADeformatter.SetHashAlgorithm(hashAlgorithm);
// verify the signature
verified = RSADeformatter.VerifySignature(hashValue, signaturebytes);

我的问题是:如果我想从第三台计算机发送消息,(称其为c(到b怎么办?如何将密钥库从A转移到C,以确保生成相同的密钥对?我只有一个在计算机B上存储公钥的地方。它需要从A和C中解密消息。我可以从Windows文件夹复制键盘吗?还是这项工作是:用ToxmlString(true(在B上导出键,并使用rsa.fromxmlstring((在C上导入它们。如果我这样做,它将将其存储在C?

看看这个要旨。它包含一些PowerShell功能,以导出和导入RSA键。我们遇到了同一问题,并使用这些脚本将键

转移

编辑:为了澄清,我没有写出要点,我只找到了它并用它来解决这个确切的问题

最新更新