我想更多地瞭解.NET中RSA的功能和整個這個有用的帖子,這表明在默認情況下密鑰存儲在Windows中如何來: https://stackoverflow.com/a/5845191/1181412.NET RSA CreateEphemeralKey VS PersistKeyInCsp
我的問題引用下面的示例代碼。假設其意圖是僅在應用程序會話的生命週期中生成一次性密鑰。
問題1:在下面的結構,並在PersistKeyInCsp標誌需要在每次哪怕是訪問同一CspParameters對象的類內的任何地方創建的RSACryptoServiceProvider時間設置爲false?
問題2:設置CspParameters對象上的CreateEphemeralKey標誌是否取代在此示例中使用PersistKeyInCsp的需要?
Public Class RSACrypto
Private RSAKey As CspParameters
Public Sub New(KeySize As Integer)
MyBase.New()
RSAKey = New CspParameters
Using RSA As New RSACryptoServiceProvider(KeySize, RSAKey)
RSA.PersistKeyInCsp = False
End Using
End Sub
Public Function PublicKey() As Byte()
Using RSA As New RSACryptoServiceProvider(RSAKey)
RSA.PersistKeyInCsp = False
Return RSA.ExportCspBlob(False)
End Using
End Function
End Class
您是否找到答案? – Garrann