Reputation: 7913
I'm using the .NET version of BouncyCastle, and I have to save a private RSA key to file, obviously encrypted with a password for security reasons.
What I'm trying right now is this:
Dim rand As New SecureRandom
Dim arr As Byte() = New Byte(7) {}
rand.NextBytes(arr)
Dim privateKeyInfo As EncryptedPrivateKeyInfo = EncryptedPrivateKeyInfoFactory.CreateEncryptedPrivateKeyInfo(
"PBEwithHmacSHA-256",
Repository.Password.ToCharArray,
arr,
1,
data.BouncyCastlePrivateKey
)
But BouncyCastle is thwrowing a NullReferenceException on the last instruction. Since the method is totally undocumented >:( I wonder if any of you know how to use it correctly...
(none of my parameters are NULL by the way, already checked that)
Upvotes: 5
Views: 1584
Reputation: 41967
That particular PBE algorithm won't work. Try this instead: "PBEwithSHA-1and3-keyDESEDE-CBC"
Upvotes: 3