CryptoSys PKI Pro Manual

X509_HashIssuerAndSN

Returns the message digest hash of the PKCS #7 issuerAndSerialNumber value of an X.509 certificate in hexadecimal format.

VBA/VB6 Syntax

Public Declare Function X509_HashIssuerAndSN Lib "diCrPKI.dll" (ByVal strCertFile As String, ByVal strOutput As String, ByVal nOutChars As Long, ByVal nOptions As Long) As Long

nRet = X509_HashIssuerAndSN(strCertFile, strOutput, nOutChars, nOptions)

C/C++ Syntax

long __stdcall X509_HashIssuerAndSN(const char *szCertFile, char *szOutput, long nOutChars, long nOptions);

Parameters

szCertFile
[in] with the filename of the X.509 certificate (or base64 representation).
szOutput
[out] to receive the hash digest.
nOutChars
[in] specifying the maximum number of characters to be received.
nOptions
[in] Option flags. Select one of:
PKI_HASH_SHA1 (0) to use the SHA-1 algorithm (default)
PKI_HASH_SHA224 to use the SHA-224 algorithm
PKI_HASH_SHA256 to use the SHA-256 algorithm
PKI_HASH_SHA384 to use the SHA-384 algorithm
PKI_HASH_SHA512 to use the SHA-512 algorithm
PKI_HASH_MD5 to use the MD5 algorithm

Returns (VBA/C)

Returns the number of characters set in szOutput. If nOutChars is zero it returns the maximum number of characters required. C/C++ users should allocate one extra for the terminating NUL character. If an error occurs, it returns a negative error code.

VBA Wrapper Syntax

Public Function x509HashIssuerAndSN (szCertFile As String, Optional nOptions As Long = 0) As String

.NET Equivalent

X509.HashIssuerAndSN Method

C++ (STL) Equivalent

static std::string dipki::X509::HashIssuerAndSN (const std::string &certFile, HashAlg hashAlg=HashAlg::Sha1)

Python Equivalent

static X509.cert_hashissuersn(certfilename, hashalg=0)

Remarks

For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length. ANSI C users must add one to this value when allocating memory.

The certificate may be in binary BER format or base64 PEM format.

Example (VBA core function)

    Dim nRet As Long
    Dim strCertName As String
    Dim strOutput As String * PKI_MAX_HASH_CHARS
     
    strCertName = "BobRSASignByCarl.cer"	' Set dir to suit
    nRet = X509_HashIssuerAndSN(strCertName, strOutput, Len(strOutput), 0)
    Debug.Print "X509_HashIssuerAndSN returns " & nRet & " for " & strCertName & ": " & Left(strOutput, nRet)

Should result in

X509_HashIssuerAndSN returns 40 for BobRSASignByCarl.cer: 
483538bca32adeb3134fe9f74d1ae74cc9ed2e9e

Example (VBA wrapper function)

Dim strCertString As String
strCertString = x509ReadStringFromFile("AliceRSASignByCarl.cer")
Debug.Print strCertString
Debug.Print "CertThumb=" & x509CertThumb(strCertString)
strCertString = x509ReadCertStringFromP7Chain("alice_bob_carl_certs.p7c", 3)
Debug.Print strCertString
Debug.Print "CertThumb=" & x509CertThumb(strCertString)
Debug.Print "HashIssuerAndSN=" & x509HashIssuerAndSN(strCertString, PKI_HASH_SHA256)

See Also

X509_CertIsValidNow X509_CertThumb

[Contents] [Index]

[PREV: X509_GetCertFromPFX...]   [Contents]   [Index]   
   [NEXT: X509_KeyUsageFlags...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.