Rsa Delphi DLL 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

Create/Dispose

var
myObject: HCkRsa;

begin
myObject := CkRsa_Create();

// ...

CkRsa_Dispose(myObject);
end;
function CkRsa_Create: HCkRsa; stdcall;

Creates an instance of the HCkRsa object and returns a handle (i.e. a Pointer). The handle is passed in the 1st argument for the functions listed on this page.

procedure CkRsa_Dispose(handle: HCkRsa); stdcall;

Objects created by calling CkRsa_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

Properties

Charset
procedure CkRsa_getCharset(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putCharset(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__charset(objHandle: HCkRsa): PWideChar; stdcall;

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".

See the notes about PWideChar memory ownership and validity.

top
DebugLogFilePath
procedure CkRsa_getDebugLogFilePath(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putDebugLogFilePath(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__debugLogFilePath(objHandle: HCkRsa): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
EncodingMode
procedure CkRsa_getEncodingMode(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putEncodingMode(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__encodingMode(objHandle: HCkRsa): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
LastErrorHtml
procedure CkRsa_getLastErrorHtml(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
function CkRsa__lastErrorHtml(objHandle: HCkRsa): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastErrorText
procedure CkRsa_getLastErrorText(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
function CkRsa__lastErrorText(objHandle: HCkRsa): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastErrorXml
procedure CkRsa_getLastErrorXml(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
function CkRsa__lastErrorXml(objHandle: HCkRsa): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastMethodSuccess
function CkRsa_getLastMethodSuccess(objHandle: HCkRsa): wordbool; stdcall;
procedure CkRsa_putLastMethodSuccess(objHandle: HCkRsa; newPropVal: wordbool); stdcall;

Indicates the success or failure of the most recent method call: True means success, False 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
LittleEndian
function CkRsa_getLittleEndian(objHandle: HCkRsa): wordbool; stdcall;
procedure CkRsa_putLittleEndian(objHandle: HCkRsa; newPropVal: wordbool); stdcall;

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

More Information and Examples
top
NoUnpad
function CkRsa_getNoUnpad(objHandle: HCkRsa): wordbool; stdcall;
procedure CkRsa_putNoUnpad(objHandle: HCkRsa; newPropVal: wordbool); stdcall;

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

top
NumBits
function CkRsa_getNumBits(objHandle: HCkRsa): Integer; stdcall;

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

top
OaepHash
procedure CkRsa_getOaepHash(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putOaepHash(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__oaepHash(objHandle: HCkRsa): PWideChar; stdcall;
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.

See the notes about PWideChar memory ownership and validity.

top
OaepLabel
procedure CkRsa_getOaepLabel(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putOaepLabel(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__oaepLabel(objHandle: HCkRsa): PWideChar; stdcall;
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.

See the notes about PWideChar memory ownership and validity.

top
OaepMgfHash
procedure CkRsa_getOaepMgfHash(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putOaepMgfHash(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__oaepMgfHash(objHandle: HCkRsa): PWideChar; stdcall;
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.

See the notes about PWideChar memory ownership and validity.

top
OaepPadding
function CkRsa_getOaepPadding(objHandle: HCkRsa): wordbool; stdcall;
procedure CkRsa_putOaepPadding(objHandle: HCkRsa; newPropVal: wordbool); stdcall;

This property controls both RSA-PSS and OAEP. When set to False, Chilkat uses PKCS#1 v1.5 padding for both encryption and signature creation. When set to True, 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 False.

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
function CkRsa_getPssSaltLen(objHandle: HCkRsa): Integer; stdcall;
procedure CkRsa_putPssSaltLen(objHandle: HCkRsa; newPropVal: Integer); stdcall;
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
procedure CkRsa_getUncommonOptions(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
procedure CkRsa_putUncommonOptions(objHandle: HCkRsa; newPropVal: PWideChar); stdcall;
function CkRsa__uncommonOptions(objHandle: HCkRsa): PWideChar; stdcall;
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.

See the notes about PWideChar memory ownership and validity.

top
VerboseLogging
function CkRsa_getVerboseLogging(objHandle: HCkRsa): wordbool; stdcall;
procedure CkRsa_putVerboseLogging(objHandle: HCkRsa; newPropVal: wordbool); stdcall;

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

top
Version
procedure CkRsa_getVersion(objHandle: HCkRsa; outPropVal: HCkString); stdcall;
function CkRsa__version(objHandle: HCkRsa): PWideChar; stdcall;

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

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top

Methods

DecryptBd
function CkRsa_DecryptBd(objHandle: HCkRsa;
    bd: HCkBinData;
    usePrivateKey: wordbool): wordbool; stdcall;
Introduced in version 9.5.0.76

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

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

Returns True for success, False for failure.

top
DecryptBytes Deprecated
function CkRsa_DecryptBytes(objHandle: HCkRsa;
    inData: HCkByteData;
    usePrivateKey: wordbool;
    outData: HCkByteData): wordbool; stdcall;

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

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

Returns True for success, False for failure.

More Information and Examples
top
DecryptBytesENC Deprecated
function CkRsa_DecryptBytesENC(objHandle: HCkRsa;
    str: PWideChar;
    bUsePrivateKey: wordbool;
    outData: HCkByteData): wordbool; stdcall;

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 True to use the private key for decryption; otherwise, set it to False to use the public key (in rare cases).

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

Returns True for success, False for failure.

top
DecryptString Deprecated
function CkRsa_DecryptString(objHandle: HCkRsa;
    encBytes: HCkByteData;
    usePrivateKey: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__decryptString(objHandle: HCkRsa;
    encBytes: HCkByteData;
    usePrivateKey: wordbool): PWideChar; stdcall;

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 True to use the private key for decryption; otherwise, set usePrivateKey to False to use the public key (used rarely). Returns the decrypted string.

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

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
DecryptStringENC
function CkRsa_DecryptStringENC(objHandle: HCkRsa;
    str: PWideChar;
    usePrivateKey: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__decryptStringENC(objHandle: HCkRsa;
    str: PWideChar;
    usePrivateKey: wordbool): PWideChar; stdcall;

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 True to use the private key for decryption; otherwise, set usePrivateKey to False to use the public key (used rarely). Returns the decrypted string.

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

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
EncryptBd
function CkRsa_EncryptBd(objHandle: HCkRsa;
    bd: HCkBinData;
    usePrivateKey: wordbool): wordbool; stdcall;
Introduced in version 9.5.0.76

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

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

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 True for success, False for failure.

top
EncryptBytes
function CkRsa_EncryptBytes(objHandle: HCkRsa;
    binaryData: HCkByteData;
    usePrivateKey: wordbool;
    outData: HCkByteData): wordbool; stdcall;

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

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

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 True for success, False for failure.

More Information and Examples
top
EncryptBytesENC Deprecated
function CkRsa_EncryptBytesENC(objHandle: HCkRsa;
    data: HCkByteData;
    bUsePrivateKey: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__encryptBytesENC(objHandle: HCkRsa;
    data: HCkByteData;
    bUsePrivateKey: wordbool): PWideChar; stdcall;

Encrypts data using the RSA algorithm. Set bUsePrivateKey to False to use the public key for encrypting; otherwise, set it to True 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 = False.

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
EncryptString Deprecated
function CkRsa_EncryptString(objHandle: HCkRsa;
    stringToEncrypt: PWideChar;
    usePrivateKey: wordbool;
    outData: HCkByteData): wordbool; stdcall;

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

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

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 True for success, False for failure.

top
EncryptStringENC
function CkRsa_EncryptStringENC(objHandle: HCkRsa;
    str: PWideChar;
    bUsePrivateKey: wordbool;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__encryptStringENC(objHandle: HCkRsa;
    str: PWideChar;
    bUsePrivateKey: wordbool): PWideChar; stdcall;

Encrypts str with the RSA algorithm. The Charset property specifies the byte representation of the string that is encrypted. Set bUsePrivateKey to False to use the public key for encrypting; otherwise, set it to True 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 = False.

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
ExportPrivateKey
function CkRsa_ExportPrivateKey(objHandle: HCkRsa;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__exportPrivateKey(objHandle: HCkRsa): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
ExportPrivateKeyObj
function CkRsa_ExportPrivateKeyObj(objHandle: HCkRsa): HCkPrivateKey; stdcall;
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 nil on failure

top
ExportPublicKey
function CkRsa_ExportPublicKey(objHandle: HCkRsa;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__exportPublicKey(objHandle: HCkRsa): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
ExportPublicKeyObj
function CkRsa_ExportPublicKeyObj(objHandle: HCkRsa): HCkPublicKey; stdcall;
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 nil on failure

More Information and Examples
top
GenerateKey
function CkRsa_GenerateKey(objHandle: HCkRsa;
    numBits: Integer): wordbool; stdcall;

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 True for success, False for failure.

top
ImportPrivateKey
function CkRsa_ImportPrivateKey(objHandle: HCkRsa;
    xmlKey: PWideChar): wordbool; stdcall;

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 True for success, False for failure.

top
ImportPrivateKeyObj
function CkRsa_ImportPrivateKeyObj(objHandle: HCkRsa;
    key: HCkPrivateKey): wordbool; stdcall;
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 True for success, False for failure.

top
ImportPublicKey
function CkRsa_ImportPublicKey(objHandle: HCkRsa;
    xmlKey: PWideChar): wordbool; stdcall;

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 True for success, False for failure.

top
ImportPublicKeyObj
function CkRsa_ImportPublicKeyObj(objHandle: HCkRsa;
    key: HCkPublicKey): wordbool; stdcall;
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 True for success, False for failure.

top
OpenSslSignBd
function CkRsa_OpenSslSignBd(objHandle: HCkRsa;
    bd: HCkBinData): wordbool; stdcall;
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 True for success, False for failure.

top
OpenSslSignBytes Deprecated
function CkRsa_OpenSslSignBytes(objHandle: HCkRsa;
    data: HCkByteData;
    outBytes: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
OpenSslSignBytesENC Deprecated
function CkRsa_OpenSslSignBytesENC(objHandle: HCkRsa;
    data: HCkByteData;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__openSslSignBytesENC(objHandle: HCkRsa;
    data: HCkByteData): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
OpenSslSignString Deprecated
function CkRsa_OpenSslSignString(objHandle: HCkRsa;
    str: PWideChar;
    outBytes: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
OpenSslSignStringENC
function CkRsa_OpenSslSignStringENC(objHandle: HCkRsa;
    str: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__openSslSignStringENC(objHandle: HCkRsa;
    str: PWideChar): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
OpenSslVerifyBd
function CkRsa_OpenSslVerifyBd(objHandle: HCkRsa;
    bd: HCkBinData): wordbool; stdcall;
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 True for success, False for failure.

top
OpenSslVerifyBytes Deprecated
function CkRsa_OpenSslVerifyBytes(objHandle: HCkRsa;
    signature: HCkByteData;
    outBytes: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
OpenSslVerifyBytesENC Deprecated
function CkRsa_OpenSslVerifyBytesENC(objHandle: HCkRsa;
    str: PWideChar;
    outBytes: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
OpenSslVerifyString Deprecated
function CkRsa_OpenSslVerifyString(objHandle: HCkRsa;
    data: HCkByteData;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__openSslVerifyString(objHandle: HCkRsa;
    data: HCkByteData): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
OpenSslVerifyStringENC
function CkRsa_OpenSslVerifyStringENC(objHandle: HCkRsa;
    str: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__openSslVerifyStringENC(objHandle: HCkRsa;
    str: PWideChar): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
SetX509Cert
function CkRsa_SetX509Cert(objHandle: HCkRsa;
    cert: HCkCert;
    usePrivateKey: wordbool): wordbool; stdcall;
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 True for success, False for failure.

top
SignBd
function CkRsa_SignBd(objHandle: HCkRsa;
    bdData: HCkBinData;
    hashAlgorithm: PWideChar;
    bdSig: HCkBinData): wordbool; stdcall;
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 Deprecated
function CkRsa_SignBytes(objHandle: HCkRsa;
    binaryData: HCkByteData;
    hashAlgorithm: PWideChar;
    outData: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
SignBytesENC Deprecated
function CkRsa_SignBytesENC(objHandle: HCkRsa;
    binaryData: HCkByteData;
    hashAlgorithm: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__signBytesENC(objHandle: HCkRsa;
    binaryData: HCkByteData;
    hashAlgorithm: PWideChar): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
SignHash Deprecated
function CkRsa_SignHash(objHandle: HCkRsa;
    hashBytes: HCkByteData;
    hashAlg: PWideChar;
    outBytes: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
SignHashENC
function CkRsa_SignHashENC(objHandle: HCkRsa;
    encodedHash: PWideChar;
    hashAlg: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__signHashENC(objHandle: HCkRsa;
    encodedHash: PWideChar;
    hashAlg: PWideChar): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
SignString Deprecated
function CkRsa_SignString(objHandle: HCkRsa;
    strToBeHashed: PWideChar;
    hashAlgorithm: PWideChar;
    outData: HCkByteData): wordbool; stdcall;

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 True for success, False for failure.

top
SignStringENC
function CkRsa_SignStringENC(objHandle: HCkRsa;
    strToBeHashed: PWideChar;
    hashAlgorithm: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__signStringENC(objHandle: HCkRsa;
    strToBeHashed: PWideChar;
    hashAlgorithm: PWideChar): PWideChar; stdcall;

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 True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
SnkToXml
function CkRsa_SnkToXml(objHandle: HCkRsa;
    filename: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkRsa__snkToXml(objHandle: HCkRsa;
    filename: PWideChar): PWideChar; stdcall;

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

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
VerifyBd
function CkRsa_VerifyBd(objHandle: HCkRsa;
    bdData: HCkBinData;
    hashAlgorithm: PWideChar;
    bdSig: HCkBinData): wordbool; stdcall;
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 True if the signature is validated, and False 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 True for success, False for failure.

top
VerifyBytes Deprecated
function CkRsa_VerifyBytes(objHandle: HCkRsa;
    originalData: HCkByteData;
    hashAlgorithm: PWideChar;
    signatureBytes: HCkByteData): wordbool; stdcall;

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 True if the signature is validated, and False 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 True for success, False for failure.

top
VerifyBytesENC Deprecated
function CkRsa_VerifyBytesENC(objHandle: HCkRsa;
    originalData: HCkByteData;
    hashAlgorithm: PWideChar;
    encodedSig: PWideChar): wordbool; stdcall;

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 True if the signature is validated, and False 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 True for success, False for failure.

top
VerifyHash Deprecated
function CkRsa_VerifyHash(objHandle: HCkRsa;
    hashBytes: HCkByteData;
    hashAlg: PWideChar;
    sigBytes: HCkByteData): wordbool; stdcall;

Validates an RSA signature provided in sigBytes against the hash of the original data in hashBytes. Returns True if validation is successful, otherwise returns False. 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 True for success, False for failure.

top
VerifyHashENC
function CkRsa_VerifyHashENC(objHandle: HCkRsa;
    encodedHash: PWideChar;
    hashAlg: PWideChar;
    encodedSig: PWideChar): wordbool; stdcall;

Validates an RSA signature provided in encodedSig against the hash of the original data in encodedHash. Returns True if validation is successful, otherwise returns False. 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 True for success, False for failure.

top
VerifyString Deprecated
function CkRsa_VerifyString(objHandle: HCkRsa;
    originalString: PWideChar;
    hashAlgorithm: PWideChar;
    binarySig: HCkByteData): wordbool; stdcall;

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 True if the signature is validated, and False 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 True for success, False for failure.

top
VerifyStringENC
function CkRsa_VerifyStringENC(objHandle: HCkRsa;
    originalString: PWideChar;
    hashAlgorithm: PWideChar;
    encodedSig: PWideChar): wordbool; stdcall;

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 True if the signature is validated, and False 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 True for success, False for failure.

top