Verify a signature value over data in a byte array.
Public Declare Function SIG_VerifyData Lib "diCrPKI.dll" (ByVal strSignature As String, ByRef lpData As Byte, ByVal nDataLen As Long, ByVal strCertOrKeyFile As String, ByVal strAlgName As String, ByVal nOptions As Long) As Long
nRet = SIG_VerifyData(strSignature, lpData(0), nDataLen, strCertOrKeyFile, strAlgName, nOptions)
long __stdcall SIG_VerifyData(const char *szSignature, const unsigned char *lpData, long nDataLen, const char *szCertOrKeyFile, const char *szAlgName, long nOptions);
Zero (0) if the signature is valid; otherwise it returns a negative error code.
Public Function sigVerifyData
(szSignature As String, lpData() As Byte, szCertOrKey As String, szAlgName As String, Optional nOptions As Long = 0) As Long
Sig.VerifyData Method
Sig.VerifyDigest Method
static bool dipki::Sig::VerifyData (const std::string &sigStr, const bvec_t &data, const std::string &certOrKey, Alg alg=Alg::Default, VerifyOpts opts=VerifyOpts::Default)
static Sig.digest_is_verified(sig, digest, certorkey, alg, verifyopts=VerifyOpts.DEFAULT)
static Sig.data_is_verified(sig, data, certorkey, alg, verifyopts=VerifyOpts.DEFAULT)
static Sig.digest_is_verified(sig, digest, certorkey, alg, verifyopts=VerifyOpts.DEFAULT)
A signature value is considered valid if it can be decrypted by the public key in szCertOrKeyFile and the digest of the data matches the original digest of the data in the signature. The signature algorithm and hash algorithm used to create the signature value must be provided.
For RSA-PSS, the MGF hash algorithm is assumed to be the same as the signature hash algorithm (see RSA signature and encryption schemes).
If the signature was created using mgf1SHA1
with a signature hash algorithm other than SHA-1, then you must add the option PKI_MGF_MGF1SHA1.
Other combinations of signature hash algorithm/MGF hash algorithm are not supported.
The PKI_SIG_USEDIGEST option cannot be used with Ed25519 or Ed448. The data to be verified must be passed in toto to the verify function.
Dim strSignature As String Dim strData As String Dim abData() As Byte Dim nDataLen As Long Dim strCertFile As String Dim strAlgName As String Dim nRet As Long ' Signature to be verified strSignature = _ "YK1aePtKQDDsVCyJdM0V9VOE6DZVTO3ZoyLV9BNcYmep0glwxU5mUQcLAUTUOETImTIN2Pp4Gffr" & _ "xqdxUoczLshnXBNhg7P4ofge+WlBgmcTCnVv27LHHZpmdEbjTg6tnPMb+2b4FvMZ0LfkMKXyiRVTmG4A" & _ "NyAmHH6QIsDZ8R8=" ' Data to be verified against signature = three-character ASCII string "abc" strData = "abc" strCertFile = "AliceRSASignByCarl.cer" strAlgName = "sha1WithRSAEncryption" ' Convert ASCII string to byte array abData = StrConv(strData, vbFromUnicode) nDataLen = Len(strData) ' Verify the signature... nRet = SIG_VerifyData(strSignature, abData(0), nDataLen, strCertFile, strAlgName, 0) Debug.Print "SIG_VerifyData returns " & nRet & " (expecting 0)"