Rsa Tcl Reference Documentation

Rsa

Current Version: 10.1.0

RSA encryption component / library. Encrypt and decrypt byte arrays and strings. Generate public/private key pairs from 384 to 4096 bits in length. Import and export RSA keys. Import keys from SNK files. Input/output in raw binary, base64, hex encoding, quoted-printable, URL-encoding, etc.

Object Creation

set myRsa [new CkRsa]

Properties

Charset
string
# ckStr is a CkString
CkRsa_get_Charset $myRsa $ckStr
set strVal [CkRsa_get_charset $myRsa]
CkRsa_put_Charset $myRsa $strVal

This property only applies when encrypting, decrypting, signing, or verifying signatures for strings. When encrypting strings, the input string is first converted to this charset before encrypting.

When decrypting, the decrypted data is interpreted as a string with this charset encoding and converted to the appropriate return. For example, ActiveX's returning strings always return Unicode (2 bytes/char). Java strings are utf-8. Chilkat C++ strings are ANSI or utf-8. .NET strings are Unicode.

The default value of this property is the ANSI charset of the local computer.

When signing string data, the input string is first converted to this charset before being hashed and signed. When verifying the signature for string data, the input string is first converted to this charset before the verification process begins.

top
DebugLogFilePath
string
# ckStr is a CkString
CkRsa_get_DebugLogFilePath $myRsa $ckStr
set strVal [CkRsa_get_debugLogFilePath $myRsa]
CkRsa_put_DebugLogFilePath $myRsa $strVal

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:

  1. a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
  2. the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
  3. there is an internal problem (bug) in the Chilkat code that causes the hang.

More Information and Examples
top
EncodingMode
string
# ckStr is a CkString
CkRsa_get_EncodingMode $myRsa $ckStr
set strVal [CkRsa_get_encodingMode $myRsa]
CkRsa_put_EncodingMode $myRsa $strVal

Encoding mode to be used in methods ending in "ENC", such as EncryptStringENC. Valid EncodingModes are "base64", "hex", "url", or "quoted-printable" (or "qp"). Encryption methods ending in "ENC" will return encrypted data as a string encoded according to this property's value. Decryption methods ending in "ENC" accept an encoded string as specified by this property. The string is first decoded and then decrypted. The default value is "base64".

This property also applies to the "ENC" methods for creating and verifying digital signatures.

More Information and Examples
top
LastErrorHtml
string
# ckStr is a CkString
CkRsa_get_LastErrorHtml $myRsa $ckStr
set strVal [CkRsa_get_lastErrorHtml $myRsa]

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

top
LastErrorText
string
# ckStr is a CkString
CkRsa_get_LastErrorText $myRsa $ckStr
set strVal [CkRsa_get_lastErrorText $myRsa]

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

top
LastErrorXml
string
# ckStr is a CkString
CkRsa_get_LastErrorXml $myRsa $ckStr
set strVal [CkRsa_get_lastErrorXml $myRsa]

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

top
LastMethodSuccess
boolean 1/0
set boolVal [CkRsa_get_LastMethodSuccess $myRsa]
CkRsa_put_LastMethodSuccess $myRsa $boolVal

Indicate whether the last method call succeeded or failed. A value of 1 indicates success, a value of 0 indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

  • Any method that returns a string.
  • Any method returning a Chilkat object, binary bytes, or a date/time.
  • Any method returning a standard boolean status value where success = 1 and failure = 0.
  • Any method returning an integer where failure is defined by a return value less than zero.

Note: Methods that do not fit the above requirements will always set this property equal to 1. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

top
LittleEndian
boolean 1/0
set boolVal [CkRsa_get_LittleEndian $myRsa]
CkRsa_put_LittleEndian $myRsa $boolVal

The default value is 0, which means that signatures and encrypted output will be created using the big endian byte ordering. A value of 1 will produce little-endian output, which is what Microsoft's Crypto API produces.

Important: Prior to v9.5.0.49, this property behaved the opposite as it should for encryption. When updating from an older version of Chilkat to v9.5.0.49 or greater, the following change is required:

  • If the application did NOT explicity set the LittleEndian property, then no change is required for encryption/decryption. If signatures were being created or verified, then explicitly set this property to 1.
  • If the application explicitly set this property, then reverse the setting ONLY if doing encryption/decryption. No changes are required if doing signature creation/verification.

top
NoUnpad
boolean 1/0
set boolVal [CkRsa_get_NoUnpad $myRsa]
CkRsa_put_NoUnpad $myRsa $boolVal

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

top
NumBits
integer
set intVal [CkRsa_get_NumBits $myRsa]

The number of bits of the key generated or imported into this RSA encryption object. Keys ranging in size from 384 bits to 4096 bits can be generated by calling GenerateKey. A public or private key may be imported by calling ImportPublicKey or ImportPrivateKey. A key must be available either via GenerateKey or import before any of the encrypt/decrypt methods may be called.

top
OaepHash
string
# ckStr is a CkString
CkRsa_get_OaepHash $myRsa $ckStr
set strVal [CkRsa_get_oaepHash $myRsa]
CkRsa_put_OaepHash $myRsa $strVal
Introduced in version 9.5.0.48

Selects the hash algorithm for use within OAEP padding. The valid choices are "sha1", "sha256", "sha384", "sha512", "md2", "md5", "haval", "ripemd128", "ripemd160","ripemd256", or "ripemd320". The default is "sha1".

top
OaepLabel
string
# ckStr is a CkString
CkRsa_get_OaepLabel $myRsa $ckStr
set strVal [CkRsa_get_oaepLabel $myRsa]
CkRsa_put_OaepLabel $myRsa $strVal
Introduced in version 9.5.0.95

The optional RSA encryption OAEP label. This property is the hex representation of the OAEP label bytes to be used when encrypting with OAEP padding. In virtually all cases, it is left empty (the label is 0 bytes in length). Only set this property if you have a specific need. Otherwise, leave it empty.

top
OaepMgfHash
string
# ckStr is a CkString
CkRsa_get_OaepMgfHash $myRsa $ckStr
set strVal [CkRsa_get_oaepMgfHash $myRsa]
CkRsa_put_OaepMgfHash $myRsa $strVal
Introduced in version 9.5.0.71

Selects the MGF (mask generation) hash algorithm for use within OAEP padding. The valid choices are "sha1", "sha256", "sha384", "sha512", "md2", "md5", "haval", "ripemd128", "ripemd160","ripemd256", or "ripemd320". The default is "sha1".

top
OaepPadding
boolean 1/0
set boolVal [CkRsa_get_OaepPadding $myRsa]
CkRsa_put_OaepPadding $myRsa $boolVal

Controls whether Optimal Asymmetric Encryption Padding (OAEP) is used for the padding scheme (for encrypting/decrypting). If set to 0, PKCS1 v1.5 padding is used. If set to 1, PKCS1 v2.0 (OAEP) padding is used.

Important: The OAEP padding algorithm uses randomly generated bytes. Therefore, the RSA result will be different each time, even if all of the other inputs are identical. For example, if you RSA encrypt or sign the same data using the same key 100 times, the output will appear different each time, but they are all valid.

When creating digital signatures, this property controls whether RSA-PSS or PKCS1 v1.5 is used. If 1, then the RSA-PSS signature scheme is used. The default value of this property is 0.

More Information and Examples
top
PssSaltLen
integer
set intVal [CkRsa_get_PssSaltLen $myRsa]
CkRsa_put_PssSaltLen $myRsa $intVal
Introduced in version 9.5.0.80

Selects the PSS salt length when RSASSA-PSS padding is selected for signatures. The default value is -1 to indicate that the length of the hash function should be used. For example, if the hash function is SHA256, then the PSS salt length will be 32 bytes. Can be optionally set to a value such as 20 if a specific salt length is required. This property should normally remain at the default value.

top
UncommonOptions
string
# ckStr is a CkString
CkRsa_get_UncommonOptions $myRsa $ckStr
set strVal [CkRsa_get_uncommonOptions $myRsa]
CkRsa_put_UncommonOptions $myRsa $strVal
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
Utf8
boolean 1/0
set boolVal [CkRsa_get_Utf8 $myRsa]
CkRsa_put_Utf8 $myRsa $boolVal

When set to 1, all "const char *" arguments are interpreted as utf-8 strings. If set to 0 (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to 1, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to 0, all "const char *" return values are ANSI strings.

top
VerboseLogging
boolean 1/0
set boolVal [CkRsa_get_VerboseLogging $myRsa]
CkRsa_put_VerboseLogging $myRsa $boolVal

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
string
# ckStr is a CkString
CkRsa_get_Version $myRsa $ckStr
set strVal [CkRsa_get_version $myRsa]

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

More Information and Examples
top

Methods

DecryptBd
# bd is a CkBinData
# usePrivateKey is a boolean
set status [CkRsa_DecryptBd $bd $usePrivateKey]
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 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
# inData is a CkByteData
# usePrivateKey is a boolean
# outData is a CkByteData (output)
set status [CkRsa_DecryptBytes $inData $usePrivateKey $outData]

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 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
DecryptBytesENC
# str is a string
# bUsePrivateKey is a boolean
# outData is a CkByteData (output)
set status [CkRsa_DecryptBytesENC $str $bUsePrivateKey $outData]

Same as DecryptBytes, except the input is an encoded string. The encoding is specified by the EncodingMode property, which can have values such as "base64", "hex", "quoted-printable", "url", etc.

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

Returns 1 for success, 0 for failure.

top
DecryptString
# encBytes is a CkByteData
# usePrivateKey is a boolean
# outStr is a CkString (output)
set status [CkRsa_DecryptString $encBytes $usePrivateKey $outStr]
set retStr [CkRsa_decryptString $myRsa $encBytes $usePrivateKey]

Decrypts encrypted string data and returns an unencrypted string. usePrivateKey should be set to 1 if the private key is to be used for decrypting. Otherwise it should be set to 0 if the public key is to be used. The Charset property controls how the component interprets the decrypted string. Depending on the programming language, strings are returned to the application as Unicode, utf-8, or ANSI. Internal to DecryptString, the decrypted string is automatically converted from the charset specified by the Charset property to the encoding required by the calling programming language.

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

Returns 1 for success, 0 for failure.

top
DecryptStringENC
# str is a string
# usePrivateKey is a boolean
# outStr is a CkString (output)
set status [CkRsa_DecryptStringENC $str $usePrivateKey $outStr]
set retStr [CkRsa_decryptStringENC $myRsa $str $usePrivateKey]

Same as DecryptString, except the input is an encoded string. The encoding is specified by the EncodingMode property, which can have values such as "base64", "hex", "quoted-printable", "url", etc.

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

Returns 1 for success, 0 for failure.

top
EncryptBd
# bd is a CkBinData
# usePrivateKey is a boolean
set status [CkRsa_EncryptBd $bd $usePrivateKey]
Introduced in version 9.5.0.76

RSA encrypts the contents of bd. usePrivateKey should be set to 1 if the private key is to be used for encrypting. Otherwise it should be set to 0 if the public key is to be used for encrypting.

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

Note: Except for special situations, the public key should always be used for encrypting, and the private key for decrypting. This makes sense because an encrypted message is sent to a recipient, and the recipient is the only one in possession of the private key, and therefore the only one that can decrypt and read the message.

Returns 1 for success, 0 for failure.

top
EncryptBytes
# binaryData is a CkByteData
# usePrivateKey is a boolean
# outData is a CkByteData (output)
set status [CkRsa_EncryptBytes $binaryData $usePrivateKey $outData]

Encrypts byte data using the RSA encryption algorithm. usePrivateKey should be set to 1 if the private key is to be used for encrypting. Otherwise it should be set to 0 if the public key is to be used for encrypting.

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

Note: Except for special situations, the public key should always be used for encrypting, and the private key for decrypting. This makes sense because an encrypted message is sent to a recipient, and the recipient is the only one in possession of the private key, and therefore the only one that can decrypt and read the message.

Returns 1 for success, 0 for failure.

top
EncryptBytesENC
# data is a CkByteData
# bUsePrivateKey is a boolean
# outStr is a CkString (output)
set status [CkRsa_EncryptBytesENC $data $bUsePrivateKey $outStr]
set retStr [CkRsa_encryptBytesENC $myRsa $data $bUsePrivateKey]

Same as EncryptBytes, except the output is an encoded string. The encoding is specified by the EncodingMode property, which can have values such as "base64", "hex", "quoted-printable", "url", etc.

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

Note: Except for special situations, the public key should always be used for encrypting, and the private key for decrypting. This makes sense because an encrypted message is sent to a recipient, and the recipient is the only one in possession of the private key, and therefore the only one that can decrypt and read the message.

Returns 1 for success, 0 for failure.

top
EncryptString
# stringToEncrypt is a string
# usePrivateKey is a boolean
# outData is a CkByteData (output)
set status [CkRsa_EncryptString $stringToEncrypt $usePrivateKey $outData]

Encrypts a string using the RSA encryption algorithm. usePrivateKey should be set to 1 if the private key is to be used for encrypting. Otherwise it should be set to 0 if the public key is to be used for encrypting. The string is first converted (if necessary) to the character encoding specified by the Charset property before encrypting. The encrypted bytes are returned.

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

Note: Except for special situations, the public key should always be used for encrypting, and the private key for decrypting. This makes sense because an encrypted message is sent to a recipient, and the recipient is the only one in possession of the private key, and therefore the only one that can decrypt and read the message.

Returns 1 for success, 0 for failure.

More Information and Examples
top
EncryptStringENC
# str is a string
# bUsePrivateKey is a boolean
# outStr is a CkString (output)
set status [CkRsa_EncryptStringENC $str $bUsePrivateKey $outStr]
set retStr [CkRsa_encryptStringENC $myRsa $str $bUsePrivateKey]

Same as EncryptString, except the output is an encoded string. The encoding is specified by the EncodingMode property, which can have values such as "base64", "hex", "quoted-printable", "url", etc.

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

Note: Except for special situations, the public key should always be used for encrypting, and the private key for decrypting. This makes sense because an encrypted message is sent to a recipient, and the recipient is the only one in possession of the private key, and therefore the only one that can decrypt and read the message.

Returns 1 for success, 0 for failure.

top
ExportPrivateKey
# outStr is a CkString (output)
set status [CkRsa_ExportPrivateKey $outStr]
set retStr [CkRsa_exportPrivateKey $myRsa]

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 1 for success, 0 for failure.

top
ExportPrivateKeyObj
# returns a CkPrivateKey
set ret_privateKey [CkRsa_ExportPrivateKeyObj]
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 NULL on failure

More Information and Examples
top
ExportPublicKey
# outStr is a CkString (output)
set status [CkRsa_ExportPublicKey $outStr]
set retStr [CkRsa_exportPublicKey $myRsa]

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 1 for success, 0 for failure.

top
ExportPublicKeyObj
# returns a CkPublicKey
set ret_publicKey [CkRsa_ExportPublicKeyObj]
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 NULL on failure

More Information and Examples
top
GenerateKey
# numBits is an integer
set status [CkRsa_GenerateKey $numBits]

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: Prior to version 9.5.0.49, the max key size was 4096 bits. Generating an 8192-bit RSA key takes a considerable amount of time and CPU processing power. 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.

More Information and Examples
top
ImportPrivateKey
# xmlKey is a string
set status [CkRsa_ImportPrivateKey $xmlKey]

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
# key is a CkPrivateKey
set status [CkRsa_ImportPrivateKeyObj $key]
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
# xmlKey is a string
set status [CkRsa_ImportPublicKey $xmlKey]

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
# key is a CkPublicKey
set status [CkRsa_ImportPublicKeyObj $key]
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
# bd is a CkBinData
set status [CkRsa_OpenSslSignBd $bd]
Introduced in version 9.5.0.77

Duplicates OpenSSL's rsautl utility for creating RSA signatures. The contents of bd are signed. If successful, the result is that bd contains the RSA signature that itself contains (embeds) the original data.

Returns 1 for success, 0 for failure.

top
OpenSslSignBytes
# data is a CkByteData
# outBytes is a CkByteData (output)
set status [CkRsa_OpenSslSignBytes $data $outData]

Duplicates OpenSSL's rsautl utility for creating RSA signatures. Input data consists of binary bytes, and returns the signature bytes.

Returns 1 for success, 0 for failure.

top
OpenSslSignBytesENC
# data is a CkByteData
# outStr is a CkString (output)
set status [CkRsa_OpenSslSignBytesENC $data $outStr]
set retStr [CkRsa_openSslSignBytesENC $myRsa $data]

Duplicates OpenSSL's rsautl utility for creating RSA signatures. Input data consists of binary bytes, and returns the signature as a string encoded according to the EncodingMode property (base64, hex, etc.).

Returns 1 for success, 0 for failure.

top
OpenSslSignString
# str is a string
# outBytes is a CkByteData (output)
set status [CkRsa_OpenSslSignString $str $outData]

Duplicates OpenSSL's rsautl utility for creating RSA signatures. Input data is a string, and returns the signature bytes.

Returns 1 for success, 0 for failure.

top
OpenSslSignStringENC
# str is a string
# outStr is a CkString (output)
set status [CkRsa_OpenSslSignStringENC $str $outStr]
set retStr [CkRsa_openSslSignStringENC $myRsa $str]

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

Returns 1 for success, 0 for failure.

top
OpenSslVerifyBd
# bd is a CkBinData
set status [CkRsa_OpenSslVerifyBd $bd]
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
# signature is a CkByteData
# outBytes is a CkByteData (output)
set status [CkRsa_OpenSslVerifyBytes $signature $outData]

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 1 for success, 0 for failure.

top
OpenSslVerifyBytesENC
# str is a string
# outBytes is a CkByteData (output)
set status [CkRsa_OpenSslVerifyBytesENC $str $outData]

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 1 for success, 0 for failure.

top
OpenSslVerifyString
# data is a CkByteData
# outStr is a CkString (output)
set status [CkRsa_OpenSslVerifyString $data $outStr]
set retStr [CkRsa_openSslVerifyString $myRsa $data]

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 1 for success, 0 for failure.

top
OpenSslVerifyStringENC
# str is a string
# outStr is a CkString (output)
set status [CkRsa_OpenSslVerifyStringENC $str $outStr]
set retStr [CkRsa_openSslVerifyStringENC $myRsa $str]

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 1 for success, 0 for failure.

top
SetX509Cert
# cert is a CkCert
# usePrivateKey is a boolean
set status [CkRsa_SetX509Cert $cert $usePrivateKey]
Introduced in version 9.5.0.73

Provides the private or public key indirectly through a certificate. This method is especially useful on Windows computers where the private key is installed as non-exportable (such as on a hardware token).

Returns 1 for success, 0 for failure.

top
SignBd
# bdData is a CkBinData
# hashAlgorithm is a string
# bdSig is a CkBinData
set retBool [CkRsa_SignBd $bdData $hashAlgorithm $bdSig]
Introduced in version 9.5.0.77

Creates an RSA digital signature by hashing the contents of bdData and then signing the hash. The hash algorithm is specified by hashAlgorithm, which may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The resulting signature is returned in bdSig.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0. (The LittleEndian property should also be set to 0 to match Amazon web services, such as CloudFront.)

A private key is required to create digital signatures.

More Information and Examples
top
SignBytes
# binaryData is a CkByteData
# hashAlgorithm is a string
# outData is a CkByteData (output)
set status [CkRsa_SignBytes $binaryData $hashAlgorithm $outData]

Creates an RSA digital signature by hashing binaryData and then signing the hash. The hash algorithm is specified by hashAlgorithm, which may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1".

Important: If trying to match OpenSSL results, set the LittleEndian property = 0. (The LittleEndian property should also be set to 0 to match Amazon web services, such as CloudFront.)

A private key is required to create a digital signature.

An error is indicated when a byte array of 0 length is returned.

Returns 1 for success, 0 for failure.

top
SignBytesENC
# binaryData is a CkByteData
# hashAlgorithm is a string
# outStr is a CkString (output)
set status [CkRsa_SignBytesENC $binaryData $hashAlgorithm $outStr]
set retStr [CkRsa_signBytesENC $myRsa $binaryData $hashAlgorithm]

Creates an RSA digital signature by hashing binaryData and then signing the hash. The hash algorithm is specified by hashAlgorithm, which may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1". The digital signature is returned as an encoded string, where the encoding is specified by the EncodingMode property.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0. (The LittleEndian property should also be set to 0 to match Amazon web services, such as CloudFront.)

A private key is required to create a digital signature.

An error is indicated when null reference is returned.

Returns 1 for success, 0 for failure.

top
SignHash
# hashBytes is a CkByteData
# hashAlg is a string
# outBytes is a CkByteData (output)
set status [CkRsa_SignHash $hashBytes $hashAlg $outData]

The same as the SignBytes method, except the hash to be signed is passed directly.

Returns 1 for success, 0 for failure.

top
SignHashENC
# encodedHash is a string
# hashAlg is a string
# outStr is a CkString (output)
set status [CkRsa_SignHashENC $encodedHash $hashAlg $outStr]
set retStr [CkRsa_signHashENC $myRsa $encodedHash $hashAlg]

The same as SignBytesENC except the hash is passed directly.

Returns 1 for success, 0 for failure.

top
SignString
# strToBeHashed is a string
# hashAlgorithm is a string
# outData is a CkByteData (output)
set status [CkRsa_SignString $strToBeHashed $hashAlgorithm $outData]

Creates an RSA digital signature by hashing strToBeHashed and then signing the hash. The hash algorithm is specified by hashAlgorithm, which may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1".

Important: If trying to match OpenSSL results, set the LittleEndian property = 0. (The LittleEndian property should also be set to 0 to match Amazon web services, such as CloudFront.)

A private key is required to create a digital signature.

An error is indicated when a byte array of 0 length is returned.

Returns 1 for success, 0 for failure.

top
SignStringENC
# strToBeHashed is a string
# hashAlgorithm is a string
# outStr is a CkString (output)
set status [CkRsa_SignStringENC $strToBeHashed $hashAlgorithm $outStr]
set retStr [CkRsa_signStringENC $myRsa $strToBeHashed $hashAlgorithm]

Creates an RSA digital signature by hashing strToBeHashed and then signing the hash. The hash algorithm is specified by hashAlgorithm, which may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1". The digital signature is returned as an encoded string, where the encoding is specified by the EncodingMode property.

Important: If trying to match OpenSSL results, set the LittleEndian property = 0. (The LittleEndian property should also be set to 0 to match Amazon web services, such as CloudFront.)

A private key is required to create a digital signature.

An error is indicated when null reference is returned.

Returns 1 for success, 0 for failure.

top
SnkToXml
# filename is a string
# outStr is a CkString (output)
set status [CkRsa_SnkToXml $filename $outStr]
set retStr [CkRsa_snkToXml $myRsa $filename]

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

Returns 1 for success, 0 for failure.

top
VerifyBd
# bdData is a CkBinData
# hashAlgorithm is a string
# bdSig is a CkBinData
set status [CkRsa_VerifyBd $bdData $hashAlgorithm $bdSig]
Introduced in version 9.5.0.77

Verifies an RSA digital signature. Returns 1 if the signature in bdSig is valid an confirms that the original data in bdData has not been modified. The hashAlgorithm may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512".

Returns 1 for success, 0 for failure.

More Information and Examples
top
VerifyBytes
# originalData is a CkByteData
# hashAlgorithm is a string
# signatureBytes is a CkByteData
set retBool [CkRsa_VerifyBytes $originalData $hashAlgorithm $signatureBytes]

Verifies an RSA digital signature. Returns 1 if the signature is valid for the originalData. The hashAlgorithm may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1".

top
VerifyBytesENC
# originalData is a CkByteData
# hashAlgorithm is a string
# encodedSig is a string
set retBool [CkRsa_VerifyBytesENC $originalData $hashAlgorithm $encodedSig]

Verifies an RSA digital signature. Returns 1 if the signature is valid for the originalData. The hashAlgorithm may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1".

The encodedSig is a digital signature encoded according to the EncodingMode property (i.e. base64, hex, etc.).

top
VerifyHash
# hashBytes is a CkByteData
# hashAlg is a string
# sigBytes is a CkByteData
set retBool [CkRsa_VerifyHash $hashBytes $hashAlg $sigBytes]

The same as VerifyBytes except the hash of the original data is passed directly.

top
VerifyHashENC
# encodedHash is a string
# hashAlg is a string
# encodedSig is a string
set retBool [CkRsa_VerifyHashENC $encodedHash $hashAlg $encodedSig]

The same as VerifyBytesENC except the hash of the original data is passed directly.

More Information and Examples
top
VerifyPrivateKey
# xml is a string
set status [CkRsa_VerifyPrivateKey $xml]

Returns 1 if the XML contains a valid RSA private key. Otherwise returns 0.

Returns 1 for success, 0 for failure.

top
VerifyString
# originalString is a string
# hashAlgorithm is a string
# binarySig is a CkByteData
set retBool [CkRsa_VerifyString $originalString $hashAlgorithm $binarySig]

Verifies an RSA digital signature. Returns 1 if the signature is valid for the originalString. The hashAlgorithm may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1".

top
VerifyStringENC
# originalString is a string
# hashAlgorithm is a string
# encodedSig is a string
set retBool [CkRsa_VerifyStringENC $originalString $hashAlgorithm $encodedSig]

Verifies an RSA digital signature. Returns 1 if the signature is valid for the originalString. The hashAlgorithm may be "SHA-1", "MD5", "MD2", "SHA-256", "SHA-384", or "SHA-512". The recommended hash algorithm is "SHA-1".

The encodedSig is a digital signature encoded according to the EncodingMode property (i.e. base64, hex, etc.).

More Information and Examples
top