Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

RSA.Verify

Verifies RSA digital signature.

Component Version macOS Windows Linux Server iOS SDK
Sign Encryption 6.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "RSA.Verify"; Algorithm; InputType; InputData; InputEncoding; KeyType; KeyData; KeyEncoding; SigType; SigData; SigEncoding { ; PasswordType; PasswordData; PasswordEncoding } )   More

Parameters

Parameter Description Example Flags
Algorithm Which algorithm to use. Can be MD4, MD5, SHA, SHA1, MDC2, RIPEMD160, SHA224, SHA256, SHA384 or SHA512. "SHA512"
InputType The type of input data.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text"
InputData The actual input data.
Text, container or file path.
"Hello World"
InputEncoding The text encoding for text input.
Parameter is ignored for other cases.
"UTF-8"
KeyType The type of input for private or public key.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text"
KeyData The actual input data for the key.
Text, container or file path. Must not be longer than the maximum key length of the given algorithm. If key is too short, we pad it with zero bytes.
"Hello World"
KeyEncoding The text encoding for text input for the key.
Parameter is ignored for other cases.
"UTF-8"
SigType The type of input data for signature.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text"
SigData The actual input data for signature.
Text, container or file path.
"Hello World"
SigEncoding The text encoding for text input.
Parameter is ignored for other cases.
"UTF-8"
PasswordType The type of input for the password of the private key.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text" Optional
PasswordData The actual input data for the password of the private key.
Text, container or file path. Must not be longer than the maximum key length of the given algorithm. If key is too short, we pad it with zero bytes.
"Hello World" Optional
PasswordEncoding The text encoding for text input.
Parameter is ignored for other cases.
"UTF-8" Optional

Result

Returns 1, 0 or error.

Description

Verifies RSA digital signature.
Returns 1 if signature is valid or 0 if not or an error if parameters are wrong.
Key can be the public or private key, but of course normally you use the public key.
A hash is created with given algorithm and verified with the signature.
Signature must be the string returned like from RSA.Sign function.

Optional you can pass a password to read password protected keys.

Examples

Verify with all data in files:

MBS( "RSA.Verify";
"SHA1";
"Path"; "/Users/cs/Desktop/Sign and Verify/Create Keys.rtf"; "";
"Path"; "/Users/cs/Desktop/Sign and Verify/test.pub"; "";
"Path"; "/Users/cs/Desktop/Sign and Verify/signature.sha1"; "";
"Text"; ""; "" )

Verify with passing signature as hex text:

MBS( "RSA.Verify";
"SHA512";
"Text"; "Hello World. This is test data to sign."; "UTF8";
"Path"; "/Users/cs/Desktop/Sign and Verify/test.pub"; "";
"Hex"; "CD603612768BD33F2C0C0DE1E71658F9191..."; "";
"Text"; ""; "" )

Verify some text:

Set Variable [$r; Value:MBS( "RSA.Verify"; Table::Algorithm; "Text"; Table::Text to Sign; "UTF8"; "Text"; Table::PublicKey; "UTF8"; "Hex"; Table::Signature )]
If [$r = 1]
    Show Custom Dialog ["Signature valid"]
Else If [$r = 0]
    Show Custom Dialog ["Signature invalid"]
Else
    Show Custom Dialog ["Error"; MBS("Text.RemovePrefix"; $r; "[MBS] ")]
End If

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 12nd March 2016, last changed 15th April 2024


RSA.Sign - RegEx.CaptureCount