CryptoSys PKI Toolkit Manual

Example: Rsa.CheckKey  Rsa.KeyBits  Rsa.KeyHashCode  Rsa.ReadPrivateKeyFromPFX  Wipe.String 

[VB6 equivalent: RSA_ReadPrivateKeyFromPFX]

Dim strPfxFile As String
Dim sbPrivateKey As StringBuilder
Dim sbPassword As StringBuilder
Dim nCode As Integer
Dim nRet As Integer

strPfxFile = "bob.pfx"
sbPassword = New StringBuilder("password")

' Read private key from PFX file into internal string form
sbPrivateKey = Rsa.ReadPrivateKeyFromPFX(strPfxFile, sbPassword.ToString())
If sbPrivateKey.Length = 0 Then Exit Sub ' Catch error here

' Display some info about it
Console.WriteLine("Private key length = {0} bits", Rsa.KeyBits(sbPrivateKey.ToString()))
nCode = Rsa.KeyHashCode(sbPrivateKey.ToString())
Console.WriteLine("KeyHashCode={0,8:X}", nCode)
nRet = Rsa.CheckKey(sbPrivateKey)
Console.WriteLine("Rsa.CheckKey returns " & nRet & ": (PKI_VALID_PRIVATEKEY=" & 0 & ")")

' Clean up
Wipe.String(sbPrivateKey)
Wipe.String(sbPassword)

See Also:
Rsa.ReadPrivateKeyFromPFX Method

[Contents] [Index]

[HOME]   [NEXT: Example: Rsa.MakeKeys ...]

Copyright © 2004-12 D.I. Management Services Pty Ltd. All rights reserved.