![]() |
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
(PowerBuilder) Duplicating OpenSSL rsautl (creating RSA signatures)Demonstrates how to duplicate OpenSSL rsautil RSA signatures. The Chilkat RSA component's methods for creating RSA signatures (SignBytes, SignBytesENC, SignString, and SignStringENC) are very different from OpenSSL's rsautl command. First, we'll explain what Chilkat's signing methods do, and then what OpenSSL's rsautl does. New signing methods have been added to Chilkat RSA to duplicate OpenSSL rsautl: OpenSslSignBytes, OpenSslSignBytesENC, OpenSslSignString, and OpenSslSignStringENC.
Here's what Chilkat's RSA Sign* methods do:
OpenSSL rsautl is very different. Here's what it does:
Note: This example requires Chilkat v11.0.0 or greater.
integer li_rc integer li_Success oleobject loo_PrivKey oleobject loo_Rsa string ls_StrData oleobject loo_Bd string ls_HexSig oleobject loo_PubKey oleobject loo_Rsa2 oleobject loo_Bd2 string ls_OriginalData li_Success = 0 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_PrivKey = create oleobject li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey") if li_rc < 0 then destroy loo_PrivKey MessageBox("Error","Connecting to COM object failed") return end if // Load the private key from an RSA PEM file: li_Success = loo_PrivKey.LoadPemFile("private.pem") if li_Success = 0 then Write-Debug loo_PrivKey.LastErrorText destroy loo_PrivKey return end if loo_Rsa = create oleobject li_rc = loo_Rsa.ConnectToNewObject("Chilkat.Rsa") li_Success = loo_Rsa.UsePrivateKey(loo_PrivKey) if li_Success = 0 then Write-Debug loo_Rsa.LastErrorText destroy loo_PrivKey destroy loo_Rsa return end if ls_StrData = "secret" loo_Bd = create oleobject li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData") loo_Bd.AppendString(ls_StrData,"utf-8") li_Success = loo_Rsa.SignRawBd(loo_Bd) ls_HexSig = loo_Bd.GetEncoded("hex") Write-Debug ls_HexSig // Recover the data using the corresponding public key: loo_PubKey = create oleobject li_rc = loo_PubKey.ConnectToNewObject("Chilkat.PublicKey") // Load the public key from a PEM file: li_Success = loo_PubKey.LoadFromFile("public.pem") if li_Success = 0 then Write-Debug loo_PubKey.LastErrorText destroy loo_PrivKey destroy loo_Rsa destroy loo_Bd destroy loo_PubKey return end if loo_Rsa2 = create oleobject li_rc = loo_Rsa2.ConnectToNewObject("Chilkat.Rsa") li_Success = loo_Rsa2.UsePublicKey(loo_PubKey) if li_Success = 0 then Write-Debug loo_Rsa2.LastErrorText destroy loo_PrivKey destroy loo_Rsa destroy loo_Bd destroy loo_PubKey destroy loo_Rsa2 return end if loo_Bd2 = create oleobject li_rc = loo_Bd2.ConnectToNewObject("Chilkat.BinData") loo_Bd2.AppendEncoded(ls_HexSig,"hex") // Recover the original data. li_Success = loo_Rsa2.VerifyRawBd(loo_Bd2) if li_Success = 0 then Write-Debug loo_Rsa2.LastErrorText destroy loo_PrivKey destroy loo_Rsa destroy loo_Bd destroy loo_PubKey destroy loo_Rsa2 destroy loo_Bd2 return end if ls_OriginalData = loo_Bd2.GetString("utf-8") Write-Debug ls_OriginalData destroy loo_PrivKey destroy loo_Rsa destroy loo_Bd destroy loo_PubKey destroy loo_Rsa2 destroy loo_Bd2 |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.