![]() |
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
(Tcl) 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.
load ./chilkat.dll set success 0 # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set privKey [new_CkPrivateKey] # Load the private key from an RSA PEM file: set success [CkPrivateKey_LoadPemFile $privKey "private.pem"] if {$success == 0} then { puts [CkPrivateKey_lastErrorText $privKey] delete_CkPrivateKey $privKey exit } set rsa [new_CkRsa] set success [CkRsa_UsePrivateKey $rsa $privKey] if {$success == 0} then { puts [CkRsa_lastErrorText $rsa] delete_CkPrivateKey $privKey delete_CkRsa $rsa exit } set strData "secret" set bd [new_CkBinData] CkBinData_AppendString $bd $strData "utf-8" set success [CkRsa_SignRawBd $rsa $bd] set hexSig [CkBinData_getEncoded $bd "hex"] puts "$hexSig" # Recover the data using the corresponding public key: set pubKey [new_CkPublicKey] # Load the public key from a PEM file: set success [CkPublicKey_LoadFromFile $pubKey "public.pem"] if {$success == 0} then { puts [CkPublicKey_lastErrorText $pubKey] delete_CkPrivateKey $privKey delete_CkRsa $rsa delete_CkBinData $bd delete_CkPublicKey $pubKey exit } set rsa2 [new_CkRsa] set success [CkRsa_UsePublicKey $rsa2 $pubKey] if {$success == 0} then { puts [CkRsa_lastErrorText $rsa2] delete_CkPrivateKey $privKey delete_CkRsa $rsa delete_CkBinData $bd delete_CkPublicKey $pubKey delete_CkRsa $rsa2 exit } set bd2 [new_CkBinData] CkBinData_AppendEncoded $bd2 $hexSig "hex" # Recover the original data. set success [CkRsa_VerifyRawBd $rsa2 $bd2] if {$success == 0} then { puts [CkRsa_lastErrorText $rsa2] delete_CkPrivateKey $privKey delete_CkRsa $rsa delete_CkBinData $bd delete_CkPublicKey $pubKey delete_CkRsa $rsa2 delete_CkBinData $bd2 exit } set originalData [CkBinData_getString $bd2 "utf-8"] puts "$originalData" delete_CkPrivateKey $privKey delete_CkRsa $rsa delete_CkBinData $bd delete_CkPublicKey $pubKey delete_CkRsa $rsa2 delete_CkBinData $bd2 |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.