CryptoSys PKI Toolkit Manual

Example: Cms.MakeSigData  Rsa.KeyBits  Rsa.ReadPrivateKeyInfo 

[VB6 equivalent: CMS_MakeSigData]

Dim strPriFile As String
Dim sbPrivateKey As StringBuilder
''Dim nIntKeyLen As Integer
Dim nRet As Integer
Dim strInputFile As String
Dim strOutputFile As String
Dim strCertFile As String

strPriFile = "AlicePrivRSASign.pri"
strCertFile = "AliceRSASignByCarl.cer"
strInputFile = "excontent.txt"
strOutputFile = "BasicSignByAlice.bin"

' First we need to read in the private key string
' NB: This version is not encrypted
sbPrivateKey = Rsa.ReadPrivateKeyInfo(strPriFile)
Console.WriteLine("nIntKeyLen = " & sbPrivateKey.Length)
If sbPrivateKey.Length = 0 Then
    Console.WriteLine(General.LastError())
    Console.WriteLine("Unable to retrieve private key")
    Exit Sub
End If
Console.WriteLine("Key size=" & Rsa.KeyBits(sbPrivateKey.ToString()) & " bits")

' Now we can sign our message
nRet = Cms.MakeSigData(strOutputFile, strInputFile, strCertFile, sbPrivateKey.ToString, 0)
Console.WriteLine("CMS_MakeSigData returns " & nRet)

See Also:
Cms.MakeSigData Method ( String, String, String, String, Cms.Options )
Cms.MakeSigData Method ( String, String, String, String, HashAlgorithm, Cms.SigDataOptions )

[Contents] [Index]

[HOME]   [NEXT: Example: Cms.MakeSigData ...]

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