Certificate Usage

In some cases it might be essential to evaluate for which usages a certificate has been created. Aloaha provides two properties for this evaluation. The content of those properties are bitmask encoded values.

CertCapabilities

CertCapabilities(fingerprint, ctype) returns the certificate capabilities in "CSP Notation". Fingerprint has to be the fingerprint of the certificate and ctype can be of type 0-2.

The result bitmask encodes the following parameter:

IsCritical = 1
CRLSignEnabled = 2
DataEnciphermentEnabled = 4
DecipherOnlyEnabled = 8
DigitalSignatureEnabled = 16
EncipherOnlyEnabled = 32
KeyAgreementEnabled = 64
KeyCertSignEnabled = 128
KeyEnciphermentEnabled = 256
NonRepudiationEnabled = 512
IsPresent = 1024


CertUsage

CertUsage(fingerprint, ctype) returns the certificate capabilities in "CSP Notation". Fingerprint has to be the fingerprint of the certificate and ctype can be of type 0-2.

The result bitmask encodes the following parameter:

decrypt = 1
sign = 2
SignRecover = 4
Derive = 8
Unwrap = 16
NonRepudiation = 32

Code Sample

Dim csp As Object
Dim parser As Object

Private Sub Command1_Click() 
     Dim LngReader As Long
     Dim CertificateBA() As Byte
     Dim CA_BA() As Byte
     Dim ctype As Long
     Dim searchfilter As Long
     Dim fingerprint As String


     LngReader = 0   'for 1st connected card reader
     searchfilter = 2   'searchfilter "Fingerprint"

     ctype = 0             'NonRepudiation Certificate on Card

     If csp.get_certificate_by_reader(LngReader, CertificateBA, CA_BA, ctype) = True Then
          Call parser.LoadCertificateToMemory(CertificateBA, False)
          fingerprint = parser.fingerprint(True)

          If csp.FindCertificate(fingerprint, searchfilter, ctype, fingerprint, CertificateBA) > -1 Then
               MsgBox csp.CertUsage(fingerprint, ctype)
               MsgBox csp.CertCapabilities(fingerprint, ctype)
          End If
     End If
End Sub

Private Sub Form_Load() 
     Set csp = CreateObject("AloahaCertInstaller.provider")
     Set parser = CreateObject("AloahaCertInstaller.CertificateParser")
End Sub


Private Sub Form_Terminate()
     Set csp = Nothing
     Set parser = Nothing
End Sub



Please ask...

Although we really tried hard, there are always questions left open.

Please send us your question.
We would be glad to answer it.
PDF SDKPDF Form Saver SDKSmart Card APIAloaha CSP APICSP General InformationLoading of CSP APIUsefull helper functions for scripting languagesCertificate ManagementCertificate UsageCertificate ParserDigital Signature FunctionsData EncryptionAPIs and samplesPin Pad Notifier Pluginp7m / p7s CreationCDO to S/MimeCreate S/Mime PKCS7Create / Validate PKCS #7Create CMS (PKCS #7)Show Card CertificatesADPU TesterSmart Card TesterTimestamp PKCS7 SignatureDES EncryptionHash DataXML HelperEnumerate Card ReaderMifareAloaha Web ServicesAloaha Print MonitorAloaha Remote ConfigurationWebDAVLDAP ClientProgramming Office MacrosIIS Event Sinks