PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Checks the correspondence between a signature and a string.
Versions 23 and later
Android Widget This function is now available in Android Widget mode.
Android This function is now available for Android applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 23
Android Widget This function is now available in Android Widget mode.
Android This function is now available for Android applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Android Widget This function is now available in Android Widget mode.
Android This function is now available for Android applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Example
AndroidiPhone/iPad
// Check the signature of data transmitted by PayBox
sData is string = [
act=ps_validated&secid=190&fpay=1&montant=25000&reference=CMD2019021309341242&auto=XXXXXX
&trans=33015345&abo=0&paiement=CARTE&carte=Maestro
&idtrans=14515770&erreur=00000&payscarte=FRA&fincb=44&debcb=111122
]
sSignatureBase64 is string = [
DVD+nMNaQatCBdS/qVjZGE8DtwPvIA3jxGhKlU83MyYC98ezKori/
3cceClqNhtmzD6MDhuKbm8Lw5sFTYdaKWzy79tXzxMLCq814u0+fc5KSihExS6
gIaixjCHiOTgqQXmPP29MkFPpfAFz/wKU/fu+FPGp2dpgLcoRAv0+m1o=
]
sPublicKeyFile is string = fDataDir() + "\pubkey.pem"
// Signature Base64 decoding
bufSignature is Buffer = Decode(Replace(sSignatureBase64, CR, ""), encodeBASE64URL)
// SHA-1 digest ==> certSHA160
IF CertificateCheckString(sData, bufSignature, sPublicKeyFile,
"", "", certSignatureOnly + certSHA160) = certificateOk THEN
Info("The signature is correct")
ELSE
Error("The signature is incorrect", ErrorInfo())
END
Syntax

Checking the correspondence between a signature and a string (numeric signature) Hide the details

<Result> = CertificateCheckString(<String to check> , <Signature buffer> , <Certificate file> [, <Password> [, <Trusted authorities>]] , <Options>)
<Result>: Integer constant
Result of signature check:
certificateExpiredValid signature but expired certificate.
certificateInvalidInvalid signature or certificate.
certificateUntrustedValid signature but untrusted certificate root.
certificateOkTrusted signature and certificate.
<String to check>: Character string (with quotes) or buffer
Character string on which the check will be performed.
This parameter can correspond to an ANSI string, a UNICODE string or a Buffer. The string will be processed as a buffer.
If this parameter corresponds to a string (without specifying the type), the type of string taken into account depends on the type of string defined by default in the current project configuration.
Remark: In the case of a UNICODE string, note that Unicode is not the same on Linux and Windows.
<Signature buffer>: Buffer
Buffer containing the signature of the string. This buffer is returned by CertificateSignString.
<Certificate file>: Character string (with quotes)
Full path of certificate file to use (in PEM, DER or P12 format).
  • For a PKCS7 signature, this file allows you to add certificates used to search for trusted string.
  • for the rough signature, this file contains the public key.
<Password>: Character string (with quotes)
Versions 23 and later
Password that will be used to decrypt the certificate file if this one is password-protected.
Remark: This parameter is useful if the certificate used is identical to the one used for the signature.
New in version 23
Password that will be used to decrypt the certificate file if this one is password-protected.
Remark: This parameter is useful if the certificate used is identical to the one used for the signature.
Password that will be used to decrypt the certificate file if this one is password-protected.
Remark: This parameter is useful if the certificate used is identical to the one used for the signature.
<Trusted authorities>: Character string (with quotes) or array of strings
Versions 23 and later
Full path of trusted certificate to use.
This parameter can also correspond to an array of strings containing the full path of different trusted certificates to use.
Versions 24 and later
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
New in version 24
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
AndroidAndroid Widget Caution: This parameter is required in the recent systems (Android 2.6 and later).
New in version 23
Full path of trusted certificate to use.
This parameter can also correspond to an array of strings containing the full path of different trusted certificates to use.
Versions 24 and later
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
New in version 24
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
AndroidAndroid Widget Caution: This parameter is required in the recent systems (Android 2.6 and later).
Full path of trusted certificate to use.
This parameter can also correspond to an array of strings containing the full path of different trusted certificates to use.
Versions 24 and later
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
New in version 24
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
Remark: The trusted certificates added with TrustedCertificateAdd are also taken into account.
AndroidAndroid Widget Caution: This parameter is required in the recent systems (Android 2.6 and later).
<Options>: Integer constant (or combination of constants)
Signature format:
certPKCS7Signature in PKCS7 format.
certSignatureOnlySignature only. In this case, the certSignatureOnly constant must be combined with the hashing algorithm:
  • certSignatureOnly + certMD5: MD5 algorithm.
  • certSignatureOnly + certSHA160: SHA1 algorithm.
  • certSignatureOnly + certSHA256: SHA2 algorithm. A 256-bit result is produced.
  • certSignatureOnly + certSHA384: SHA-384 algorithm. A 384-bit result is produced
  • certSignatureOnly + certSHA512: SHA-512 algorithm. A 512-bit result is produced.
In this case, the trusted string is not checked. Only the validity of signature in relation to the public key is checked.
Remarks
Business / UI classification : Business Logic
Component : wd250std.dll
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment