Rsa ActiveX Reference Documentation

Rsa

Current Version: 10.1.0

  • Create and validate RSA signatures
  • RSA encryption and decryption
  • Supports operations on smartcards and USB tokens
  • Generate RSA keys
  • Supports both PKCS#1 v1.5 and RSA-PSS padding for signatures
  • Supports both PKCS#1 v1.5 and OAEP padding for encryption

Object Creation

Note:
For versions of Chilkat < 10.0.0, use "Chilkat_9_5_0.Rsa" instead of "Chilkat.Rsa"
For a specific major version, use "Chilkat.Rsa.<major_version>", such as "Chilkat.Rsa.10" for Chilkat v10.*.*
See Chilkat ActiveX Object Creation

(ASP)
set obj = Server.CreateObject("Chilkat.Rsa")

(AutoIt)
$obj = ObjCreate("Chilkat.Rsa")

(Visual Basic 6.0)
Dim obj As New ChilkatRsa

(VBScript)
set obj = CreateObject("Chilkat.Rsa")

(Delphi)
obj := TChilkatRsa.Create(Self);

(FoxPro)
loObject = CreateObject('Chilkat.Rsa')

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat.Rsa")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.Rsa', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat.Rsa");

Properties

Charset
Charset As String

This property is relevant when signing or validating data originally provided as a string, but not when dealing with hashes or binary data. When hashing a string for these purposes, it's important to know its byte representation, such as UTF-8, ISO-8859-1, UTF-16, etc. This property defines the byte representation to use for the string before hashing, with the default being "ANSI", which is the default multibyte charset on a given computer.

Note: It is recommended that your application explicitly set this property to "utf-8".

top
DebugLogFilePath
DebugLogFilePath As String

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

top
EncodingMode
EncodingMode As String

This property defines the encoding for methods ending in "ENC", such as EncryptStringENC. Valid modes include "base64", "hex", "hex_lower", and more. The encoding mode applies to signatures, encrypted data, and hashes used in or returned by a method.

top
LastBinaryResult
LastBinaryResult As Variant (read-only)

This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.

top
LastErrorHtml
LastErrorHtml As String (read-only)

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
LastErrorText As String (read-only)

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
LastErrorXml As String (read-only)

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
LastMethodSuccess As Long

Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages.

top
LastStringResult
LastStringResult As String (read-only)

In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.

top
LastStringResultLen
LastStringResultLen As Long (read-only)

The length, in characters, of the string contained in the LastStringResult property.

top
LittleEndian
LittleEndian As Long

When creating RSA signatures, this property determines the endianness: set it to 1 for little-endian signatures and 0 for big-endian signatures.

More Information and Examples
top
NoUnpad
NoUnpad As Long

If 1, skips unpadding when decrypting. The default is 0. This property value is typically left unchanged.

top
NumBits
NumBits As Long (read-only)

The bit length, such as 2048, of the imported or generated RSA key.

top
OaepHash
OaepHash As String
Introduced in version 9.5.0.48

Selects the hash algorithm for use within OAEP padding for encryption. The valid choices are "sha256", "sha384", "sha512", or "sha1".

The default is SHA1. You'll likely want to change this to to SHA256. The next major version of Chilkat (11.0.0) will change the default to SHA256.

top
OaepLabel
OaepLabel As String
Introduced in version 9.5.0.95

The optional RSA encryption OAEP label is a hex representation of the label bytes used for encrypting with OAEP padding. Typically, this is left empty (0 bytes) unless there's a specific requirement to set it.

top
OaepMgfHash
OaepMgfHash As String
Introduced in version 9.5.0.71

Selects the MGF (mask generation) hash algorithm for use within OAEP padding for encryption. The valid choices are "sha256", "sha384", "sha512", or "sha1".

Note: This property should typically be set to the same value as the OaepHash property. Many software implementations are not able to handle cases where the MGF hash is different than the OAEP hash.

The default is SHA1. You'll likely want to change this to to SHA256. The next major version of Chilkat (11.0.0) will change the default to SHA256.

top
OaepPadding
OaepPadding As Long

This property controls both RSA-PSS and OAEP. When set to 0, Chilkat uses PKCS#1 v1.5 padding for both encryption and signature creation. When set to 1, Chilkat uses RSA-PSS padding for signatures, and OAEP padding for encryption.

Note: Both OAEP and RSA-PSS incorporate random bytes in the output. Therefore, the output is different each time even if all of the inputs are identical.

The default value of this property is 0.

PS> Please accept our apology for not having a separate RsaPss property. This oversight in design happened approximately 20 years ago. We've refrained from fixing to avoid backward compatibility problems.

top
PssSaltLen
PssSaltLen As Long
Introduced in version 9.5.0.80

When using RSASSA-PSS padding for signatures, you can choose the PSS salt length. By default, the salt length is set to -1, which uses the length of the hash function. For instance, with the SHA256 hash function, the salt length will be 32 bytes. You can specify a different salt length, like 20 bytes, if needed, but it's generally recommended to keep the default setting.

top
UncommonOptions
UncommonOptions As String
Introduced in version 10.1.0

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.

top
VerboseLogging
VerboseLogging As Long

If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
Version As String (read-only)

Version of the component/library, such as "10.1.0"

top

Methods

DecryptBd
DecryptBd(bd As ChilkatBinData, ByVal usePrivateKey As Long) As Long
Introduced in version 9.5.0.76

RSA decrypts the contents of bd. usePrivateKey should be set to 1 if the private key is to be used for decrypting. Otherwise it should be set to 0 if (in rare cases) the public key is to be used for decrypting.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Returns 1 for success, 0 for failure.

top
DecryptBytes
DecryptBytes(inData As Variant, ByVal usePrivateKey As Long) As Variant

Decrypts byte data using the RSA encryption algorithm. usePrivateKey should be set to 1 if the private key is to be used for decrypting. Otherwise it should be set to 0 if (in rare cases) the public key is to be used for decrypting.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
DecryptBytesENC
DecryptBytesENC(str As String, ByVal bUsePrivateKey As Long) As Variant

Decrypts str using the RSA algorithm. str is the encoded form of the encrypted binary data. The EncodingMode property defines str's encoding. Set bUsePrivateKey to 1 to use the private key for decryption; otherwise, set it to 0 to use the public key (in rare cases).

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
DecryptString
DecryptString(encBytes As Variant, ByVal usePrivateKey As Long) As String

Decrypts encBytes with the RSA algorithm. encBytes holds the encrypted binary data. The Charset property specifies the byte representation for interpreting the decrypted text. Set usePrivateKey to 1 to use the private key for decryption; otherwise, set usePrivateKey to 0 to use the public key (used rarely). Returns the decrypted string.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Returns Nothing on failure

top
DecryptStringENC
DecryptStringENC(str As String, ByVal usePrivateKey As Long) As String

Decrypts str with the RSA algorithm. str is the encoded form of the encrypted binary data. The EncodingMode property defines str's encoding. The Charset property specifies the byte representation for interpreting the decrypted text. Set usePrivateKey to 1 to use the private key for decryption; otherwise, set usePrivateKey to 0 to use the public key (used rarely). Returns the decrypted string.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Returns Nothing on failure

More Information and Examples
(AutoIt) RSA Encrypt String to Encoded Result and Reverse(Classic ASP) RSA Encrypt String to Encoded Result and Reverse(PowerBuilder) RSA Encrypt String to Encoded Result and Reverse(SQL Server) RSA Encrypt String to Encoded Result and Reverse(VBScript) RSA Encrypt String to Encoded Result and Reverse(Visual Basic 6.0) RSA Encrypt String to Encoded Result and Reverse(Visual FoxPro) RSA Encrypt String to Encoded Result and Reverse(AutoIt) RSA Encrypt and Decrypt Strings(Classic ASP) RSA Encrypt and Decrypt Strings(PowerBuilder) RSA Encrypt and Decrypt Strings(SQL Server) RSA Encrypt and Decrypt Strings(VBScript) RSA Encrypt and Decrypt Strings(Visual Basic 6.0) RSA Encrypt and Decrypt Strings(Visual FoxPro) RSA Encrypt and Decrypt Strings(AutoIt) RSA Encryption -- Same Key Different Results(Classic ASP) RSA Encryption -- Same Key Different Results(PowerBuilder) RSA Encryption -- Same Key Different Results(SQL Server) RSA Encryption -- Same Key Different Results(VBScript) RSA Encryption -- Same Key Different Results(Visual Basic 6.0) RSA Encryption -- Same Key Different Results(Visual FoxPro) RSA Encryption -- Same Key Different Results(AutoIt) RSA Encrypting Symmetric Secret Key(Classic ASP) RSA Encrypting Symmetric Secret Key(PowerBuilder) RSA Encrypting Symmetric Secret Key(SQL Server) RSA Encrypting Symmetric Secret Key(VBScript) RSA Encrypting Symmetric Secret Key(Visual Basic 6.0) RSA Encrypting Symmetric Secret Key(Visual FoxPro) RSA Encrypting Symmetric Secret Key(AutoIt) RSA Encrypt/Decrypt AES Key(Classic ASP) RSA Encrypt/Decrypt AES Key(PowerBuilder) RSA Encrypt/Decrypt AES Key(SQL Server) RSA Encrypt/Decrypt AES Key(VBScript) RSA Encrypt/Decrypt AES Key(Visual Basic 6.0) RSA Encrypt/Decrypt AES Key(Visual FoxPro) RSA Encrypt/Decrypt AES Key
top
EncryptBd
EncryptBd(bd As ChilkatBinData, ByVal usePrivateKey As Long) As Long
Introduced in version 9.5.0.76

RSA encrypts the contents of bd. Set usePrivateKey to 0 to use the public key for encrypting; otherwise, set it to 1 to use the private key (in rare cases).

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Note: The public key's role is to make encryption accessible to anyone while ensuring that only the private key holder can decrypt the messages. The public key is designed to be widely distributed so anyone can use it to encrypt messages intended for the owner of the private key.

Returns 1 for success, 0 for failure.

top
EncryptBytes
EncryptBytes(binaryData As Variant, ByVal usePrivateKey As Long) As Variant

Encrypts byte data using the RSA encryption algorithm. Set usePrivateKey to 0 to use the public key for encrypting; otherwise, set it to 1 to use the private key (in rare cases).

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Note: The public key's role is to make encryption accessible to anyone while ensuring that only the private key holder can decrypt the messages. The public key is designed to be widely distributed so anyone can use it to encrypt messages intended for the owner of the private key.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
EncryptBytesENC
EncryptBytesENC(data As Variant, ByVal bUsePrivateKey As Long) As String

Encrypts data using the RSA algorithm. Set bUsePrivateKey to 0 to use the public key for encrypting; otherwise, set it to 1 to use the private key (in rare cases). The encrypted data is returned in the format specified by the EncodingMode property.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Note: The public key's role is to make encryption accessible to anyone while ensuring that only the private key holder can decrypt the messages. The public key is designed to be widely distributed so anyone can use it to encrypt messages intended for the owner of the private key.

Returns Nothing on failure

top
EncryptString
EncryptString(stringToEncrypt As String, ByVal usePrivateKey As Long) As Variant

Encrypts stringToEncrypt with the RSA algorithm. The Charset property specifies the byte representation of the string that is encrypted. Set usePrivateKey to 0 to use the public key for encrypting; otherwise, set it to 1 to use the private key (in rare cases).

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Note: The public key's role is to make encryption accessible to anyone while ensuring that only the private key holder can decrypt the messages. The public key is designed to be widely distributed so anyone can use it to encrypt messages intended for the owner of the private key.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
EncryptStringENC
EncryptStringENC(str As String, ByVal bUsePrivateKey As Long) As String

Encrypts str with the RSA algorithm. The Charset property specifies the byte representation of the string that is encrypted. Set bUsePrivateKey to 0 to use the public key for encrypting; otherwise, set it to 1 to use the private key (in rare cases). The encrypted data is returned in the format specified by the EncodingMode property.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0.

Note: The public key's role is to make encryption accessible to anyone while ensuring that only the private key holder can decrypt the messages. The public key is designed to be widely distributed so anyone can use it to encrypt messages intended for the owner of the private key.

Returns Nothing on failure

More Information and Examples
(AutoIt) RSA Encrypt String to Encoded Result and Reverse(Classic ASP) RSA Encrypt String to Encoded Result and Reverse(PowerBuilder) RSA Encrypt String to Encoded Result and Reverse(SQL Server) RSA Encrypt String to Encoded Result and Reverse(VBScript) RSA Encrypt String to Encoded Result and Reverse(Visual Basic 6.0) RSA Encrypt String to Encoded Result and Reverse(Visual FoxPro) RSA Encrypt String to Encoded Result and Reverse(AutoIt) RSA Encrypt and Decrypt Strings(Classic ASP) RSA Encrypt and Decrypt Strings(PowerBuilder) RSA Encrypt and Decrypt Strings(SQL Server) RSA Encrypt and Decrypt Strings(VBScript) RSA Encrypt and Decrypt Strings(Visual Basic 6.0) RSA Encrypt and Decrypt Strings(Visual FoxPro) RSA Encrypt and Decrypt Strings(AutoIt) RSA Encryption -- Same Key Different Results(Classic ASP) RSA Encryption -- Same Key Different Results(PowerBuilder) RSA Encryption -- Same Key Different Results(SQL Server) RSA Encryption -- Same Key Different Results(VBScript) RSA Encryption -- Same Key Different Results(Visual Basic 6.0) RSA Encryption -- Same Key Different Results(Visual FoxPro) RSA Encryption -- Same Key Different Results(AutoIt) RSA Encrypting Symmetric Secret Key(Classic ASP) RSA Encrypting Symmetric Secret Key(PowerBuilder) RSA Encrypting Symmetric Secret Key(SQL Server) RSA Encrypting Symmetric Secret Key(VBScript) RSA Encrypting Symmetric Secret Key(Visual Basic 6.0) RSA Encrypting Symmetric Secret Key(Visual FoxPro) RSA Encrypting Symmetric Secret Key(AutoIt) RSA Encrypt/Decrypt AES Key(Classic ASP) RSA Encrypt/Decrypt AES Key(PowerBuilder) RSA Encrypt/Decrypt AES Key(SQL Server) RSA Encrypt/Decrypt AES Key(VBScript) RSA Encrypt/Decrypt AES Key(Visual Basic 6.0) RSA Encrypt/Decrypt AES Key(Visual FoxPro) RSA Encrypt/Decrypt AES Key
top
ExportPrivateKey
ExportPrivateKey() As String

Exports the private-key of an RSA key pair to XML format. This is typically called after generating a new RSA key via the GenerateKey method.

Returns Nothing on failure

top
ExportPrivateKeyObj
ExportPrivateKeyObj() As PrivateKey
Introduced in version 9.5.0.40

Exports the private-key to a private key object. This is typically called after generating a new RSA key via the GenerateKey method. Once the private key object is obtained, it may be saved in a variety of different formats.

Returns Nothing on failure

top
ExportPublicKey
ExportPublicKey() As String

Exports the public-key of an RSA key pair to XML format. This is typically called after generating a new RSA key via the GenerateKey method.

Returns Nothing on failure

top
ExportPublicKeyObj
ExportPublicKeyObj() As PublicKey
Introduced in version 9.5.0.40

Exports the public key to a public key object. Once the public key object is obtained, it may be saved in a variety of different formats.

Returns Nothing on failure

top
GenerateKey
GenerateKey(ByVal numBits As Long) As Long

Generates a new RSA public/private key pair. The number of bits can range from 512 to 8192. Typical key lengths are 1024, 2048, or 4096 bits. After successful generation, the public/private parts of the key can be exported to XML via the ExportPrivateKey and ExportPublicKey methods.

Note: Generating an 8192-bit RSA key can take a considerable amount of time. There are no event callbacks or progress monitoring for RSA key generation. Calling this will block the thread until it returns.

Returns 1 for success, 0 for failure.

top
ImportPrivateKey
ImportPrivateKey(xmlKey As String) As Long

Imports a private key from XML format. After successful import, the private key can be used to encrypt or decrypt. A private key (by definition) contains both private and public parts. This is because the public key consist of modulus and exponent. The private key consists of modulus, exponent, P, Q, DP, DQ, InverseQ, and D using base64 representation:

<RSAKeyValue>
  <Modulus>...</Modulus>
  <Exponent>...</Exponent>
  <P>...</P>
  <Q>...</Q>
  <DP>...</DP>
  <DQ>...</DQ>
  <InverseQ>...</InverseQ>
  <D>...</D>
</RSAKeyValue>

Important: The Rsa object can contain either a private key or a public key, but not both. Importing a private key overwrites the existing key regardless of whether the type of key is public or private.

Returns 1 for success, 0 for failure.

top
ImportPrivateKeyObj
ImportPrivateKeyObj(key As PrivateKey) As Long
Introduced in version 9.5.0.40

Imports a private key from a private key object. The imported private key is used in methods that sign or decrypt.

Returns 1 for success, 0 for failure.

top
ImportPublicKey
ImportPublicKey(xmlKey As String) As Long

Imports a public key from XML format. After successful import, the public key can be used to encrypt or decrypt.

Note: Importing a public key overwrites the key that is currently contained in this object - even if it's a private key.

A public key consists of modulus and exponent using base64 representation:

<RSAPublicKey>
  <Modulus>...</Modulus>
  <Exponent>...</Exponent>
</RSAPublicKey>

Important: The Rsa object can contain either a private key or a public key, but not both. Importing a private key overwrites the existing key regardless of whether the type of key is public or private.

Returns 1 for success, 0 for failure.

top
ImportPublicKeyObj
ImportPublicKeyObj(key As PublicKey) As Long
Introduced in version 9.5.0.40

Imports a public key from a public key object. The imported public key is used in methods that encrypt data or verify signatures.

Returns 1 for success, 0 for failure.

top
OpenSslSignBd
OpenSslSignBd(bd As ChilkatBinData) As Long
Introduced in version 9.5.0.77

The Chilkat RSA functions having names beginning with "OpenSsl" are provided to duplicate OpenSSL's rsautl functionality, which is to directly sign raw input data using an RSA private key without performing additional steps like hashing or ASN.1 encapsulation. These functions always use PKCS#1 v1.5 padding (because rsautl always uses PKCS#1 v1.5 padding and never RSA-PSS).

The maximum number of bytes that can be signed in any of the "OpenSsl" functions depends on the size of the RSA key. It is equal to the Key Size in Bytes - 11. Thus for a 2048-bit key, the maximum data size = 256 - 11 = 245 bytes.

The bytes to be signed are passed in bd. If successful, the contents of bd are replaced with the RSA signature.

Returns 1 for success, 0 for failure.

top
OpenSslSignBytes
OpenSslSignBytes(data As Variant) As Variant

The Chilkat RSA functions having names beginning with "OpenSsl" are provided to duplicate OpenSSL's rsautl functionality, which is to directly sign raw input data using an RSA private key without performing additional steps like hashing or ASN.1 encapsulation. These functions always use PKCS#1 v1.5 padding (because rsautl always uses PKCS#1 v1.5 padding and never RSA-PSS).

The maximum number of bytes that can be signed in any of the "OpenSsl" functions depends on the size of the RSA key. It is equal to the Key Size in Bytes - 11. Thus for a 2048-bit key, the maximum data size = 256 - 11 = 245 bytes.

The bytes to be signed are passed in data. The binary RSA signature is returned.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
OpenSslSignBytesENC
OpenSslSignBytesENC(data As Variant) As String

The Chilkat RSA functions having names beginning with "OpenSsl" are provided to duplicate OpenSSL's rsautl functionality, which is to directly sign raw input data using an RSA private key without performing additional steps like hashing or ASN.1 encapsulation. These functions always use PKCS#1 v1.5 padding (because rsautl always uses PKCS#1 v1.5 padding and never RSA-PSS).

The maximum number of bytes that can be signed in any of the "OpenSsl" functions depends on the size of the RSA key. It is equal to the Key Size in Bytes - 11. Thus for a 2048-bit key, the maximum data size = 256 - 11 = 245 bytes.

The bytes to be signed are passed in data. Returns the signature encoded based on the EncodingMode property.

Returns Nothing on failure

top
OpenSslSignString
OpenSslSignString(str As String) As Variant

The Chilkat RSA functions having names beginning with "OpenSsl" are provided to duplicate OpenSSL's rsautl functionality, which is to directly sign raw input data using an RSA private key without performing additional steps like hashing or ASN.1 encapsulation. These functions always use PKCS#1 v1.5 padding (because rsautl always uses PKCS#1 v1.5 padding and never RSA-PSS).

The maximum number of bytes that can be signed in any of the "OpenSsl" functions depends on the size of the RSA key. It is equal to the Key Size in Bytes - 11. Thus for a 2048-bit key, the maximum data size = 256 - 11 = 245 bytes.

The string to be signed is passed in str. Returns the binary signature.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
OpenSslSignStringENC
OpenSslSignStringENC(str As String) As String

The Chilkat RSA functions having names beginning with "OpenSsl" are provided to duplicate OpenSSL's rsautl functionality, which is to directly sign raw input data using an RSA private key without performing additional steps like hashing or ASN.1 encapsulation. These functions always use PKCS#1 v1.5 padding (because rsautl always uses PKCS#1 v1.5 padding and never RSA-PSS).

The maximum number of bytes that can be signed in any of the "OpenSsl" functions depends on the size of the RSA key. It is equal to the Key Size in Bytes - 11. Thus for a 2048-bit key, the maximum data size = 256 - 11 = 245 bytes.

The string to be signed is passed in str. Returns the signature encoded based on the EncodingMode property.

Returns Nothing on failure

top
OpenSslVerifyBd
OpenSslVerifyBd(bd As ChilkatBinData) As Long
Introduced in version 9.5.0.77

Duplicates OpenSSL's rsautl utility for verifying RSA signatures and recovering the original data. On input, the bd contains the RSA signature that embeds the original data. If successful (i.e. the signature was verified), then the bd is transformed to contain just the original data.

Returns 1 for success, 0 for failure.

top
OpenSslVerifyBytes
OpenSslVerifyBytes(signature As Variant) As Variant

Duplicates OpenSSL's rsautl utility for verifying RSA signatures and recovering the original data. Input data consists of the raw signature bytes and returns the original bytes.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
OpenSslVerifyBytesENC
OpenSslVerifyBytesENC(str As String) As Variant

Duplicates OpenSSL's rsautl utility for verifying RSA signatures and recovering the original data. Input data is a signature string encoded according to the EncodingMode property (base64, hex, etc.). Returns the original bytes.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
OpenSslVerifyString
OpenSslVerifyString(data As Variant) As String

Duplicates OpenSSL's rsautl utility for verifying RSA signatures and recovering the original data. Input data consists of the raw signature bytes and returns the original string.

Returns Nothing on failure

top
OpenSslVerifyStringENC
OpenSslVerifyStringENC(str As String) As String

Duplicates OpenSSL's rsautl utility for verifying RSA signatures and recovering the original data. Input data is a signature string encoded according to the EncodingMode property (base64, hex, etc.). Returns the original string.

Returns Nothing on failure

top
SetX509Cert
SetX509Cert(cert As ChilkatCert, ByVal usePrivateKey As Long) As Long
Introduced in version 9.5.0.73

Provides the private or public key indirectly through a certificate. This method is used when the private key is inaccessible, such as when stored on a smart card, USB token, in the Windows registry (marked as non-exportable), or in the Apple Keychain.

Returns 1 for success, 0 for failure.

top
SignBd
SignBd(bdData As ChilkatBinData, hashAlgorithm As String, bdSig As ChilkatBinData) As Long
Introduced in version 9.5.0.77

Generates an RSA digital signature by first hashing the contents of bdData with the hash algorithm specified by hashAlgorithm, which can be "sha256", "sha384", "sha512", or "sha1". The resulting signature is written to bdSig.

Note: It is important to be aware of endianness. Make sure the LittleEndian property is set according to your specific needs.

top
SignBytes
SignBytes(binaryData As Variant, hashAlgorithm As String) As Variant

Generates an RSA digital signature by first hashing the contents of binaryData with the hash algorithm specified by hashAlgorithm, which can be "sha256", "sha384", "sha512", or "sha1". The function returns the binary signature.

Note: It is important to be aware of endianness. Make sure the LittleEndian property is set according to your specific needs.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
SignBytesENC
SignBytesENC(binaryData As Variant, hashAlgorithm As String) As String

Generates an RSA digital signature by first hashing the bytes passed in binaryData with the hash algorithm specified by hashAlgorithm, which can be "sha256", "sha384", "sha512", or "sha1". Returns the signature encoded based on the EncodingMode property.

Returns Nothing on failure

top
SignHash
SignHash(hashBytes As Variant, hashAlg As String) As Variant

This function creates an RSA digital signature by signing the hash provided in hashBytes. hashAlg specifies the hash algorithm, which can be "sha256", "sha384", "sha512", or "sha1". The function returns the signature in binary format.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
SignHashENC
SignHashENC(encodedHash As String, hashAlg As String) As String

This function creates an RSA digital signature for the hash provided in encodedHash, which should be encoded according to the EncodingMode setting (e.g., base64 if EncodingMode = "base64"). hashAlg specifies the hash algorithm and can be "sha256", "sha384", "sha512", or "sha1". The function returns the signature encoded as specified by EncodingMode.

Returns Nothing on failure

top
SignString
SignString(strToBeHashed As String, hashAlgorithm As String) As Variant

Generates an RSA digital signature by first hashing strToBeHashed with the hash algorithm specified by hashAlgorithm, which can be "sha256", "sha384", "sha512", or "sha1". The function returns the binary signature.

Note: It is recommended to set the Charset property equal to "utf-8" before signing strings.

Note: It is important to be aware of endianness. Make sure the LittleEndian property is set according to your specific needs.

Returns a zero-length byte array (as a Variant) on failure.
An empty array will have a UBound of -1 meaning 0 elements.

top
SignStringENC
SignStringENC(strToBeHashed As String, hashAlgorithm As String) As String

Generates an RSA digital signature by first hashing strToBeHashed with the hash algorithm specified by hashAlgorithm, which can be "sha256", "sha384", "sha512", or "sha1". Returns the signature encoded based on the EncodingMode property.

Note: It is important to be aware of endianness. Make sure the LittleEndian property is set according to your specific needs.

Note: It is recommended to set the Charset property equal to "utf-8" before signing strings.

Returns Nothing on failure

More Information and Examples
(AutoIt) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(Classic ASP) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(PowerBuilder) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(SQL Server) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(VBScript) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(Visual Basic 6.0) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(Visual FoxPro) RSA Sign utf-8 Bytes of String to get Base64 RSA Signature(AutoIt) Example Code: Create RSA Signature with PEM Private Key(Classic ASP) Example Code: Create RSA Signature with PEM Private Key(PowerBuilder) Example Code: Create RSA Signature with PEM Private Key(SQL Server) Example Code: Create RSA Signature with PEM Private Key(VBScript) Example Code: Create RSA Signature with PEM Private Key(Visual Basic 6.0) Example Code: Create RSA Signature with PEM Private Key(Visual FoxPro) Example Code: Create RSA Signature with PEM Private Key(AutoIt) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(Classic ASP) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(PowerBuilder) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(SQL Server) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(VBScript) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(Visual Basic 6.0) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(Visual FoxPro) Duplicate openssl dgst -md5 -sign myKey.pem something.txt | openssl enc -base64 -A(AutoIt) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(Classic ASP) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(PowerBuilder) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(SQL Server) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(VBScript) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(Visual Basic 6.0) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(Visual FoxPro) RSA Sign Using Private Key from .pfx/.p12 to Base64 Signature(AutoIt) Walmart Partner API Authentication (Generate a Signature for a Request)(Classic ASP) Walmart Partner API Authentication (Generate a Signature for a Request)(PowerBuilder) Walmart Partner API Authentication (Generate a Signature for a Request)(SQL Server) Walmart Partner API Authentication (Generate a Signature for a Request)(VBScript) Walmart Partner API Authentication (Generate a Signature for a Request)(Visual Basic 6.0) Walmart Partner API Authentication (Generate a Signature for a Request)(Visual FoxPro) Walmart Partner API Authentication (Generate a Signature for a Request)(AutoIt) Signing HTTP Messages(Classic ASP) Signing HTTP Messages(PowerBuilder) Signing HTTP Messages(SQL Server) Signing HTTP Messages(VBScript) Signing HTTP Messages(Visual Basic 6.0) Signing HTTP Messages(Visual FoxPro) Signing HTTP Messages
top
SnkToXml
SnkToXml(filename As String) As String

Imports a .snk file to an XML document that can be imported via the ImportPrivateKey method.

Returns Nothing on failure

top
VerifyBd
VerifyBd(bdData As ChilkatBinData, hashAlgorithm As String, bdSig As ChilkatBinData) As Long
Introduced in version 9.5.0.77

Verifies the RSA signature passed in bdSig against the original data passed in bdData. The original data passed in bdData is hashed using the hash algorithm passed in hashAlgorithm (such as "sha256", "sha384", "sha512", or "sha1"). Returns 1 if the signature is validated, and 0 if not.

Note: Knowing the exact hash algorithm used to create the signature is not required. If the signature is not validated using the hash algorithm specified in hashAlgorithm, Chilkat will automatically try validating using the other supported algorithms and return success if any validate.

Returns 1 for success, 0 for failure.

top
VerifyBytes
VerifyBytes(originalData As Variant, hashAlgorithm As String, signatureBytes As Variant) As Long

Verifies the RSA signature passed in signatureBytes against the original data passed in originalData. The original data passed in originalData is hashed using the hash algorithm passed in hashAlgorithm (such as "sha256", "sha384", "sha512", or "sha1"). Returns 1 if the signature is validated, and 0 if not.

Note: Knowing the exact hash algorithm used to create the signature is not required. If the signature is not validated using the hash algorithm specified in hashAlgorithm, Chilkat will automatically try validating using the other supported algorithms and return success if any validate.

Returns 1 for success, 0 for failure.

top
VerifyBytesENC
VerifyBytesENC(originalData As Variant, hashAlgorithm As String, encodedSig As String) As Long

Verifies the encoded RSA signature passed in encodedSig against the original data passed in originalData. The original data passed in originalData is hashed using the hash algorithm passed in hashAlgorithm (such as "sha256", "sha384", "sha512", or "sha1"). Returns 1 if the signature is validated, and 0 if not.

The signature passed in encodedSig should be encoded according to the EncodingMode property (e.g., base64 if EncodingMode = "base64")

Note: Knowing the exact hash algorithm used to create the signature is not required. If the signature is not validated using the hash algorithm specified in hashAlgorithm, Chilkat will automatically try validating using the other supported algorithms and return success if any validate.

Returns 1 for success, 0 for failure.

top
VerifyHash
VerifyHash(hashBytes As Variant, hashAlg As String, sigBytes As Variant) As Long

Validates an RSA signature provided in sigBytes against the hash of the original data in hashBytes. Returns 1 if validation is successful, otherwise returns 0. hashAlg specifies the hash algorithm used for hashBytes, such as "sha256", "sha384", "sha512", or "sha1". Ensure the hash's size (e.g., 32 bytes for sha256, 48 bytes for sha384, 64 bytes for sha512, 20 bytes for sha1) matches that of hashBytes.

Returns 1 for success, 0 for failure.

top
VerifyHashENC
VerifyHashENC(encodedHash As String, hashAlg As String, encodedSig As String) As Long

Validates an RSA signature provided in encodedSig against the hash of the original data in encodedHash. Returns 1 if validation is successful, otherwise returns 0. hashAlg specifies the hash algorithm used for encodedHash, such as "sha256", "sha384", "sha512", or "sha1". Ensure the hash's size (e.g., 32 bytes for sha256, 48 bytes for sha384, 64 bytes for sha512, 20 bytes for sha1) matches that of encodedHash.

Both encodedHash and encodedSig should be encoded according to the EncodingMode property (e.g., base64 if EncodingMode = "base64")

Returns 1 for success, 0 for failure.

top
VerifyString
VerifyString(originalString As String, hashAlgorithm As String, binarySig As Variant) As Long

Verifies the RSA signature passed in binarySig against the original data passed in originalString. The original data passed in originalString is hashed using the hash algorithm passed in hashAlgorithm (such as "sha256", "sha384", "sha512", or "sha1"). Returns 1 if the signature is validated, and 0 if not.

Note: Knowing the exact hash algorithm used to create the signature is not required. If the signature is not validated using the hash algorithm specified in hashAlgorithm, Chilkat will automatically try validating using the other supported algorithms and return success if any validate.

Returns 1 for success, 0 for failure.

top
VerifyStringENC
VerifyStringENC(originalString As String, hashAlgorithm As String, encodedSig As String) As Long

Verifies the encoded RSA signature passed in encodedSig against the original data passed in originalString. The original data passed in originalString is hashed using the hash algorithm passed in hashAlgorithm (such as "sha256", "sha384", "sha512", or "sha1"). Returns 1 if the signature is validated, and 0 if not.

The signature passed in encodedSig should be encoded according to the EncodingMode property (e.g., base64 if EncodingMode = "base64")

Note: Knowing the exact hash algorithm used to create the signature is not required. If the signature is not validated using the hash algorithm specified in hashAlgorithm, Chilkat will automatically try validating using the other supported algorithms and return success if any validate.

Returns 1 for success, 0 for failure.

top