Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Verfies an RSA SignatureSee more Apple Keychain ExamplesVerifies an RSA signature against the original data.
Use ChilkatAx-win32.pkg Procedure Test Variant vBd Handle hoBd Integer i Boolean iSuccess Variant vBdSig Handle hoBdSig Boolean iSuccess Variant vPubKey Handle hoPubKey Handle hoRsa String sTemp1 // The following data was signed by the following example: // RSA Sign using a Private Key on a USB Token or Smartcard Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End For i From 0 To 100 Get ComAppendEncoded Of hoBd "000102030405060708090A0B0C0D0E0F" "hex" To iSuccess Loop // Load the signature Get Create (RefClass(cComChilkatBinData)) To hoBdSig If (Not(IsComObjectCreated(hoBdSig))) Begin Send CreateComObject of hoBdSig End Get ComLoadFile Of hoBdSig "rsaSignatures/test1.sig" To iSuccess If (iSuccess = False) Begin Showln "Failed to load the RSA signature" Procedure_Return End // Get the public key to be used for signature verification. Get Create (RefClass(cComChilkatPublicKey)) To hoPubKey If (Not(IsComObjectCreated(hoPubKey))) Begin Send CreateComObject of hoPubKey End Get ComLoadFromFile Of hoPubKey "rsaKeys/chilkat-rsa-2048.pem" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoPubKey To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatRsa)) To hoRsa If (Not(IsComObjectCreated(hoRsa))) Begin Send CreateComObject of hoRsa End Get pvComObject of hoPubKey to vPubKey Get ComImportPublicKeyObj Of hoRsa vPubKey To iSuccess // Verify the hash of the data against the signature. // We pass in the original data. Internally, the hash is generated // and used to validate the signature. // Validating the RSA signature means two things: // (1) the original data is exactly what was signed, and // (2) it was signed by the owner of the RSA private key. Get pvComObject of hoBd to vBd Get pvComObject of hoBdSig to vBdSig Get ComVerifyBd Of hoRsa vBd "sha256" vBdSig To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoRsa To sTemp1 Showln sTemp1 Showln "Signature invalid." End Else Begin Showln "Signature valid." End End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.