Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
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:
LOCAL lnSuccess LOCAL loPkey LOCAL lcPkeyXml LOCAL loRsa LOCAL lcStrData LOCAL lcHexSig LOCAL loPubkey LOCAL lcPubkeyXml LOCAL loRsa2 LOCAL lcOriginalData loPkey = CreateObject('Chilkat.PrivateKey') * Load the private key from an RSA PEM file: lnSuccess = loPkey.LoadPemFile("private.pem") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loPkey.LastErrorText) QUIT ENDIF * Get the private key in XML format: lcPkeyXml = loPkey.GetXml() loRsa = CreateObject('Chilkat.Rsa') * Any string argument automatically begins the 30-day trial. lnSuccess = loRsa.UnlockComponent("30-day trial") IF (lnSuccess <> 1) THEN =MESSAGEBOX("RSA component unlock failed") QUIT ENDIF * Import the private key into the RSA component: lnSuccess = loRsa.ImportPrivateKey(lcPkeyXml) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loRsa.LastErrorText) QUIT ENDIF * This example will sign a string, and receive the signature * in a hex-encoded string. Therefore, set the encoding mode * to "hex": loRsa.EncodingMode = "hex" lcStrData = "secret" * Create an OpenSSL style signature: lcHexSig = loRsa.OpenSslSignStringENC(lcStrData) ? lcHexSig * Recover the data using the corresponding public key: loPubkey = CreateObject('Chilkat.PublicKey') * Load the public key from a PEM file: lnSuccess = loPubkey.LoadOpenSslPemFile("public.pem") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loPubkey.LastErrorText) QUIT ENDIF * Get the public key in XML format: lcPubkeyXml = loPubkey.GetXml() loRsa2 = CreateObject('Chilkat.Rsa') * Import the public key into the RSA component: lnSuccess = loRsa2.ImportPublicKey(lcPubkeyXml) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loRsa2.LastErrorText) QUIT ENDIF loRsa2.EncodingMode = "hex" * Recover the original data. lcOriginalData = loRsa2.OpenSslVerifyStringENC(lcHexSig) ? lcOriginalData |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser