Create / Validate PKCS #7 Signature File
Sometimes it is essential to be able to sign any possible filetype. For example to be able to detect modifications or to sign legally binding a non PDF document.
PKCS7 Signatures can be easily created via the shell extension. Please see a flash video
here.
Aloaha offers an easy to use API to use a supported smartcard to create such a PKCS7 signature.
Please find some sample code below:
Dim csp
Dim FileToBeSigned
Dim CardReader 'Card Reader to be used. Can have a value from 0 to 9
Dim CardPIN 'holds the PIN of the Card - if empty string a dialog will pop up
FileToBeSigned = "d:\mymailer.exe"
CardReader = 2 'for the 3rd connected reader
CardPIN = "123456"
Set csp = CreateObject("aloahacsp.aloaha_csp")
If csp.sign_file(CStr(FileToBeSigned), CLng(CardReader), CStr(CardPIN)) = true Then
MsgBox "File Signed"
Else
MsgBox "Problem"
End If
Set csp = nothing
Validation of PKCS7 Signature File
Please have a look below to learn how to use Aloaha to validate a PKCS7 Signature.
Dim csp
Dim SignedFile
Dim SigFilePATH
Dim Signers
SignedFile = "d:\mymailer.exe"
SigFilePATH = "d:\mymailer.exe.pkcs7"
Set csp = CreateObject("aloahacsp.aloaha_csp")
If csp.VerifyPKCS7File(CStr(SignedFile), CStr(SigFilePATH), true, signers) = true Then
MsgBox "File Signed"
Else
MsgBox "Problem"
End if
Set csp = nothing
Aloaha Software / Knowledge Base / Smart Card API / Create / Validate PKCS #7