![]() |
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
(Lianja) 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.
llSuccess = .F. // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loPrivKey = createobject("CkPrivateKey") // Load the private key from an RSA PEM file: llSuccess = loPrivKey.LoadPemFile("private.pem") if (llSuccess = .F.) then ? loPrivKey.LastErrorText release loPrivKey return endif loRsa = createobject("CkRsa") llSuccess = loRsa.UsePrivateKey(loPrivKey) if (llSuccess = .F.) then ? loRsa.LastErrorText release loPrivKey release loRsa return endif lcStrData = "secret" loBd = createobject("CkBinData") loBd.AppendString(lcStrData,"utf-8") llSuccess = loRsa.SignRawBd(loBd) lcHexSig = loBd.GetEncoded("hex") ? lcHexSig // Recover the data using the corresponding public key: loPubKey = createobject("CkPublicKey") // Load the public key from a PEM file: llSuccess = loPubKey.LoadFromFile("public.pem") if (llSuccess = .F.) then ? loPubKey.LastErrorText release loPrivKey release loRsa release loBd release loPubKey return endif loRsa2 = createobject("CkRsa") llSuccess = loRsa2.UsePublicKey(loPubKey) if (llSuccess = .F.) then ? loRsa2.LastErrorText release loPrivKey release loRsa release loBd release loPubKey release loRsa2 return endif loBd2 = createobject("CkBinData") loBd2.AppendEncoded(lcHexSig,"hex") // Recover the original data. llSuccess = loRsa2.VerifyRawBd(loBd2) if (llSuccess = .F.) then ? loRsa2.LastErrorText release loPrivKey release loRsa release loBd release loPubKey release loRsa2 release loBd2 return endif lcOriginalData = loBd2.GetString("utf-8") ? lcOriginalData release loPrivKey release loRsa release loBd release loPubKey release loRsa2 release loBd2 |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.