Verify a signature value over data in a byte array.
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntaxpublic static int VerifyData(
string sigStr,
byte[] data,
string certOrKeyFile,
SigAlgorithm sigAlg,
SigVerifyOpts opts = SigVerifyOpts.Default
)
Public Shared Function VerifyData (
sigStr As String,
data As Byte(),
certOrKeyFile As String,
sigAlg As SigAlgorithm,
Optional opts As SigVerifyOpts = SigVerifyOpts.Default
) As Integer
Parameters
- sigStr String
- Encoded signature value
- data Byte
- Input data to be verified
- certOrKeyFile String
- The X.509 certificate or public key file name
(or a string containing the certificate or key in PEM format or base64 representation,
or an internal key string).
- sigAlg SigAlgorithm
- Signature algorithm used to create signature.
- opts SigVerifyOpts (Optional)
- (optional) Advanced options for RSA-PSS only.
Return Value
Int32Zero (0) if the signature is valid; otherwise a negative
error code.
RemarksAny valid encodings of the signature value are detected automatically.
Examplestring certFile = "AliceRSASignByCarl.cer";
byte[] b = System.Text.Encoding.Default.GetBytes("abc");
string sig =
"YK1aePtKQDDsVCyJdM0V9VOE6DZVTO3ZoyLV9BNcYmep0glwxU5mUQcLAUTUOETImTIN2Pp4Gffr" +
"xqdxUoczLshnXBNhg7P4ofge+WlBgmcTCnVv27LHHZpmdEbjTg6tnPMb+2b4FvMZ0LfkMKXyiRVTmG4A" +
"NyAmHH6QIsDZ8R8=";
int n = Sig.VerifyData(sig, b, certFile, SigAlgorithm.Default);
Console.WriteLine("Sig.VerifyData returns " + n + " (expecting 0)");
Debug.Assert(0 == n, "Sig.VerifyData failed");
See Also