PrivateKey Delphi DLL Reference Documentation

PrivateKey

Current Version: 10.0.0

Contains an RSA, DSA, or ECC private key. Provides methods for importing and exporting to/from PEM, DER, PKCS8, PKCS1, PVK, and XML formats. Private keys can be imported/exported to both memory and files.

Create/Dispose

var
myObject: HCkPrivateKey;

begin
myObject := CkPrivateKey_Create();

// ...

CkPrivateKey_Dispose(myObject);
end;
function CkPrivateKey_Create: HCkPrivateKey; stdcall;

Creates an instance of the HCkPrivateKey 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 CkPrivateKey_Dispose(handle: HCkPrivateKey); stdcall;

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

Properties

BitLength
function CkPrivateKey_getBitLength(objHandle: HCkPrivateKey): Integer; stdcall;
Introduced in version 9.5.0.49

The bit length (strength) of the private key.

top
DebugLogFilePath
procedure CkPrivateKey_getDebugLogFilePath(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
procedure CkPrivateKey_putDebugLogFilePath(objHandle: HCkPrivateKey; newPropVal: PWideChar); stdcall;
function CkPrivateKey__debugLogFilePath(objHandle: HCkPrivateKey): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
KeyType
procedure CkPrivateKey_getKeyType(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
function CkPrivateKey__keyType(objHandle: HCkPrivateKey): PWideChar; stdcall;
Introduced in version 9.5.0.52

The type of private key. Can be "empty", "rsa", "dsa", "ecc" (i.e. ECDSA), or "ed25519".

See the notes about PWideChar memory ownership and validity.

top
LastErrorHtml
procedure CkPrivateKey_getLastErrorHtml(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
function CkPrivateKey__lastErrorHtml(objHandle: HCkPrivateKey): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastErrorText
procedure CkPrivateKey_getLastErrorText(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
function CkPrivateKey__lastErrorText(objHandle: HCkPrivateKey): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastErrorXml
procedure CkPrivateKey_getLastErrorXml(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
function CkPrivateKey__lastErrorXml(objHandle: HCkPrivateKey): PWideChar; stdcall;

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.

See the notes about PWideChar memory ownership and validity.

top
LastMethodSuccess
function CkPrivateKey_getLastMethodSuccess(objHandle: HCkPrivateKey): wordbool; stdcall;
procedure CkPrivateKey_putLastMethodSuccess(objHandle: HCkPrivateKey; newPropVal: wordbool); stdcall;

Indicate whether the last method call succeeded or failed. A value of True indicates success, a value of False 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 = True and failure = False.
  • 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 True. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

top
Pkcs8EncryptAlg
procedure CkPrivateKey_getPkcs8EncryptAlg(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
procedure CkPrivateKey_putPkcs8EncryptAlg(objHandle: HCkPrivateKey; newPropVal: PWideChar); stdcall;
function CkPrivateKey__pkcs8EncryptAlg(objHandle: HCkPrivateKey): PWideChar; stdcall;
Introduced in version 9.5.0.49

The encryption algorithm to be used when exporting the key to encrypted PKCS8. The default value is "3des". Possible choices also include "aes128", "aes192", and "aes256". All of the encryption algorithm choices use CBC mode.

See the notes about PWideChar memory ownership and validity.

top
UncommonOptions
procedure CkPrivateKey_getUncommonOptions(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
procedure CkPrivateKey_putUncommonOptions(objHandle: HCkPrivateKey; newPropVal: PWideChar); stdcall;
function CkPrivateKey__uncommonOptions(objHandle: HCkPrivateKey): PWideChar; stdcall;
Introduced in version 9.5.0.96

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 CkPrivateKey_getVerboseLogging(objHandle: HCkPrivateKey): wordbool; stdcall;
procedure CkPrivateKey_putVerboseLogging(objHandle: HCkPrivateKey; 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 CkPrivateKey_getVersion(objHandle: HCkPrivateKey; outPropVal: HCkString); stdcall;
function CkPrivateKey__version(objHandle: HCkPrivateKey): PWideChar; stdcall;

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

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top

Methods

GetJwk
function CkPrivateKey_GetJwk(objHandle: HCkPrivateKey;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getJwk(objHandle: HCkPrivateKey): PWideChar; stdcall;
Introduced in version 9.5.0.66

Gets the private key in JWK (JSON Web Key) format.

RSA keys have this JWK format:

         {"kty":"RSA",
          "n":"0vx7agoebGcQ ... JzKnqDKgw",
          "e":"AQAB",
          "d":"X4cTteJY_gn4F ... 4jfcKoAC8Q",
          "p":"83i-7IvMGXoMX ... vn7O0nVbfs",
          "q":"3dfOR9cuYq-0S ... 4vIcb6yelxk",
          "dp":"G4sPXkc6Ya9 ... 8YeiKkTiBj0",
          "dq":"s9lAH9fggBso ... w494Q_cgk",
          "qi":"GyM_p6JrXySi ... zTKhAVRU"}

ECC keys have this JWK format.

         {"kty":"EC",
          "crv":"P-256",
          "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
          "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
          "d":"870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE"}

Ed25519 keys (added in v9.5.0.83) have this JWK format.

         {"kty": "OKP",
         "crv": "Ed25519",
         "x": "SE2Kne5xt51z1eciMH2T2ftDQp96Gl6FhY6zSQujiP0",
         "d": "O-eRXewadF0sNyB0U9omcnt8Qg2ZmeK3WSXPYgqe570",
         "use": "sig"}

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetJwkThumbprint
function CkPrivateKey_GetJwkThumbprint(objHandle: HCkPrivateKey;
    hashAlg: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getJwkThumbprint(objHandle: HCkPrivateKey;
    hashAlg: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.66

Returns the JWK thumbprint for the private key. This is the thumbprint of the JSON Web Key (JWK) as per RFC 7638.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetPkcs1
function CkPrivateKey_GetPkcs1(objHandle: HCkPrivateKey;
    outBytes: HCkByteData): wordbool; stdcall;
Introduced in version 9.5.0.58

Gets the private key in unencrypted binary DER format, preferring PKCS1 if possible.

RSA keys are returned in PKCS1 ASN.1 DER format:

RSAPrivateKey ::= SEQUENCE {
    version           Version,
    modulus           INTEGER,  -- n
    publicExponent    INTEGER,  -- e
    privateExponent   INTEGER,  -- d
    prime1            INTEGER,  -- p
    prime2            INTEGER,  -- q
    exponent1         INTEGER,  -- d mod (p-1)
    exponent2         INTEGER,  -- d mod (q-1)
    coefficient       INTEGER,  -- (inverse of q) mod p
    otherPrimeInfos   OtherPrimeInfos OPTIONAL
}

DSA keys are returned in this ASN.1 DER format:

SEQUENCE(6 elem)
    INTEGER 0
    INTEGER(2048 bit) (p) 
    INTEGER(160 bit) (q) 
    INTEGER(2044 bit) (g) 
    INTEGER(2040 bit) (y - public key) 
    INTEGER(156 bit) (x - private key) 

ECC keys are returned in this ASN.1 DER format:

(from RFC 5915)
ECPrivateKey ::= SEQUENCE {
    version        INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
    privateKey     OCTET STRING,
    parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
    publicKey  [1] BIT STRING OPTIONAL (This is the ANSI X9.63 public key format.)

Returns True for success, False for failure.

top
GetPkcs1ENC
function CkPrivateKey_GetPkcs1ENC(objHandle: HCkPrivateKey;
    encoding: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getPkcs1ENC(objHandle: HCkPrivateKey;
    encoding: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.52

Gets the private key in unencrypted binary DER format, preferring PKCS1 if possible, and returns in an encoded string, as specified by the encoding argument.

RSA keys are returned in PKCS1 ASN.1 DER format:

RSAPrivateKey ::= SEQUENCE {
    version           Version,
    modulus           INTEGER,  -- n
    publicExponent    INTEGER,  -- e
    privateExponent   INTEGER,  -- d
    prime1            INTEGER,  -- p
    prime2            INTEGER,  -- q
    exponent1         INTEGER,  -- d mod (p-1)
    exponent2         INTEGER,  -- d mod (q-1)
    coefficient       INTEGER,  -- (inverse of q) mod p
    otherPrimeInfos   OtherPrimeInfos OPTIONAL
}

DSA keys are returned in this ASN.1 DER format:

SEQUENCE(6 elem)
    INTEGER 0
    INTEGER(2048 bit) (p) 
    INTEGER(160 bit) (q) 
    INTEGER(2044 bit) (g) 
    INTEGER(2040 bit) (y - public key) 
    INTEGER(156 bit) (x - private key) 

ECC keys are returned in this ASN.1 DER format:

(from RFC 5915)
ECPrivateKey ::= SEQUENCE {
    version        INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
    privateKey     OCTET STRING,
    parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
    publicKey  [1] BIT STRING OPTIONAL (This is the ANSI X9.63 public key format.)

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
GetPkcs1Pem
function CkPrivateKey_GetPkcs1Pem(objHandle: HCkPrivateKey;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getPkcs1Pem(objHandle: HCkPrivateKey): PWideChar; stdcall;
Introduced in version 9.5.0.58

Gets the private key in non-encrypted PEM format, preferring PKCS1 over PKCS8 if possible for the key type.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetPkcs8
function CkPrivateKey_GetPkcs8(objHandle: HCkPrivateKey;
    outData: HCkByteData): wordbool; stdcall;

Gets the private key in unencrypted PKCS8 format.

RSA keys are returned in PKCS8 ASN.1 DER format:

SEQUENCE                  // PrivateKeyInfo
+- INTEGER                // Version - 0 (v1998)
+- SEQUENCE               // AlgorithmIdentifier
   +- OID                 // 1.2.840.113549.1.1.1
   +- NULL                // Optional Parameters
+- OCTETSTRING            // PrivateKey
   +- SEQUENCE            // RSAPrivateKey
      +- INTEGER(0)       // Version - v1998(0)
      +- INTEGER(N)       // N
      +- INTEGER(E)       // E
      +- INTEGER(D)       // D
      +- INTEGER(P)       // P
      +- INTEGER(Q)       // Q
      +- INTEGER(DP)      // d mod p-1
      +- INTEGER(DQ)      // d mod q-1
      +- INTEGER(Inv Q)   // INV(q) mod p

DSA keys are returned in this ASN.1 DER format:

SEQUENCE                 // PrivateKeyInfo
+- INTEGER                 // Version
+- SEQUENCE              // AlgorithmIdentifier
    +- OID                       // 1.2.840.10040.4.1
    +- SEQUENCE           // DSS-Params (Optional Parameters)
	+- INTEGER(P)      // P
	+- INTEGER(Q)      // Q
	+- INTEGER(G)      // G
    +- OCTETSTRING             // PrivateKey
	+- INTEGER(X)      // DSAPrivateKey X

ECC keys are returned in this ASN.1 DER format:

(from RFC 5915)
ECPrivateKey ::= SEQUENCE {
    version        INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
    privateKey     OCTET STRING,
    parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
    publicKey  [1] BIT STRING OPTIONAL (This is the ANSI X9.63 public key format.)

Returns True for success, False for failure.

top
GetPkcs8ENC
function CkPrivateKey_GetPkcs8ENC(objHandle: HCkPrivateKey;
    encoding: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getPkcs8ENC(objHandle: HCkPrivateKey;
    encoding: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.52

Gets the private key in unencrypted PKCS8 format and returned in an encoded string, as specified by the encoding argument.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetPkcs8Encrypted
function CkPrivateKey_GetPkcs8Encrypted(objHandle: HCkPrivateKey;
    password: PWideChar;
    outBytes: HCkByteData): wordbool; stdcall;

Writes the private key to password-protected PKCS8 format. The Pkcs8EncryptAlg property controls the encryption algorithm used to encrypt.

Returns True for success, False for failure.

top
GetPkcs8EncryptedENC
function CkPrivateKey_GetPkcs8EncryptedENC(objHandle: HCkPrivateKey;
    encoding: PWideChar;
    password: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getPkcs8EncryptedENC(objHandle: HCkPrivateKey;
    encoding: PWideChar;
    password: PWideChar): PWideChar; stdcall;
Introduced in version 9.5.0.52

Writes the private key to password-protected PKCS8 format and returns as an encoded string as specified by the encoding argument. The Pkcs8EncryptAlg property controls the encryption algorithm used to encrypt.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
GetPkcs8EncryptedPem
function CkPrivateKey_GetPkcs8EncryptedPem(objHandle: HCkPrivateKey;
    password: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getPkcs8EncryptedPem(objHandle: HCkPrivateKey;
    password: PWideChar): PWideChar; stdcall;

Writes the private key to password-protected PKCS8 PEM format. The Pkcs8EncryptAlg property controls the encryption algorithm used to encrypt.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
GetPkcs8Pem
function CkPrivateKey_GetPkcs8Pem(objHandle: HCkPrivateKey;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getPkcs8Pem(objHandle: HCkPrivateKey): PWideChar; stdcall;

Gets the private key in PKCS8 PEM format.

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetPublicKey
function CkPrivateKey_GetPublicKey(objHandle: HCkPrivateKey): HCkPublicKey; stdcall;
Introduced in version 9.5.0.52

Returns the public key portion of the private key as a public key object.

Returns nil on failure

top
GetRawHex
function CkPrivateKey_GetRawHex(objHandle: HCkPrivateKey;
    pubKey: HCkStringBuilder;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getRawHex(objHandle: HCkPrivateKey;
    pubKey: HCkStringBuilder): PWideChar; stdcall;
Introduced in version 9.5.0.83

Returns the private key in raw hex format (lowercase). The public key is written to pubKey.

Ed25519 private and public keys are 32-byte each (64 chars in hex format).

The length of an EC key depends on the curve. The private key is a single hex string. The public key is a hex string composed of the "x" and "y" parts of the public key like this:

    04||HEX(x)||HEX(y)

Note: This method is only applicable to Ed25519 and ECDSA keys. An RSA key cannot be returned in such as simple raw format because it is composed of multiple parts (modulus, exponent, and more).

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

top
GetXml
function CkPrivateKey_GetXml(objHandle: HCkPrivateKey;
    outStr: HCkString): wordbool; stdcall;
function CkPrivateKey__getXml(objHandle: HCkPrivateKey): PWideChar; stdcall;

Returns the private key in XML format. The private key is returned unencrypted and the parts are base64 encoded.

RSA keys have this XML format:

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

DSA keys have this XML format:

<DSAKeyValue>
	<P>...</P>
	<Q>...</Q>
	<G>...</G>
	<Y>...</Y>
	<X>...</X>
</DSAKeyValue>

ECC keys have this XML format. The CURVE_NAME could be one of secp256r1, secp384r1, secp521r1, secp256k1 (or others as new curves are supported.)

<ECCKeyValue curve="CURVE_NAME">...</ECCKeyValue>

Returns True for success, False for failure.

See the notes about PWideChar memory ownership and validity.

More Information and Examples
top
LoadAnyFormat
function CkPrivateKey_LoadAnyFormat(objHandle: HCkPrivateKey;
    privKeyData: HCkBinData;
    password: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.75

Loads a private key from any format (PKCS1, PKCS8, PEM, JWK, PVK, etc.). The contents of the key (binary or text) is passed in privKeyData. The password is optional and should be specified if needed.

Returns True for success, False for failure.

top
LoadAnyFormatFile
function CkPrivateKey_LoadAnyFormatFile(objHandle: HCkPrivateKey;
    path: PWideChar;
    password: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.83

Loads a private key from a file in any format (PKCS1, PKCS8, PEM, JWK, PVK, etc.). The password is optional and should be specified if needed.

Returns True for success, False for failure.

top
LoadEd25519
function CkPrivateKey_LoadEd25519(objHandle: HCkPrivateKey;
    privKey: PWideChar;
    pubKey: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.83

Loads the private key object with an ed25519 key pair. The privKey is the 32-byte private key as a hex string. The pubKey is the 32-byte public key as a hex string. pubKey may be an empty string, in which case the public key is automatically computed from the private key.

Returns True for success, False for failure.

More Information and Examples
top
LoadEncryptedPem
function CkPrivateKey_LoadEncryptedPem(objHandle: HCkPrivateKey;
    pemStr: PWideChar;
    password: PWideChar): wordbool; stdcall;

Loads the private key from an in-memory encrypted PEM string. An encrypted PEM contains the private key in encrypted PKCS#8 format, where the data begins and ends with the following tags:

-----BEGIN ENCRYPTED PRIVATE KEY-----
BASE64 ENCODED DATA
-----END ENCRYPTED PRIVATE KEY-----

For those requiring a deeper understanding: The base64 data contains ASN.1 DER with the following structure:

EncryptedPrivateKeyInfo ::= SEQUENCE {
  encryptionAlgorithm  EncryptionAlgorithmIdentifier,
  encryptedData        EncryptedData
}

EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier

EncryptedData ::= OCTET STRING

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadEncryptedPemFile
function CkPrivateKey_LoadEncryptedPemFile(objHandle: HCkPrivateKey;
    path: PWideChar;
    password: PWideChar): wordbool; stdcall;

Loads a private key from an encrypted PEM file.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

More Information and Examples
top
LoadJwk
function CkPrivateKey_LoadJwk(objHandle: HCkPrivateKey;
    jsonStr: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.66

Loads a private key from an JWK (JSON Web Key) string.

RSA keys have this JWK format:

         {"kty":"RSA",
          "n":"0vx7agoebGcQ ... JzKnqDKgw",
          "e":"AQAB",
          "d":"X4cTteJY_gn4F ... 4jfcKoAC8Q",
          "p":"83i-7IvMGXoMX ... vn7O0nVbfs",
          "q":"3dfOR9cuYq-0S ... 4vIcb6yelxk",
          "dp":"G4sPXkc6Ya9 ... 8YeiKkTiBj0",
          "dq":"s9lAH9fggBso ... w494Q_cgk",
          "qi":"GyM_p6JrXySi ... zTKhAVRU"}

ECC keys have this JWK format.

         {"kty":"EC",
          "crv":"P-256",
          "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
          "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
          "d":"870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE"}

Ed25519 keys (added in v9.5.0.83) have this JWK format.

         {"kty": "OKP",
         "crv": "Ed25519",
         "x": "SE2Kne5xt51z1eciMH2T2ftDQp96Gl6FhY6zSQujiP0",
         "d": "O-eRXewadF0sNyB0U9omcnt8Qg2ZmeK3WSXPYgqe570",
         "use": "sig"}

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPem
function CkPrivateKey_LoadPem(objHandle: HCkPrivateKey;
    str: PWideChar): wordbool; stdcall;

Loads the private key from an in-memory PEM string. If the PEM contains an encrypted private key, then the LoadEncryptedPem method should instead be called. This method is for loading an unencrypted private key stored in PEM using PKCS#1 or PKCS#8.

A private key stored in PKCS#1 format begins and ends with the tags:

-----BEGIN RSA PRIVATE KEY-----
BASE64 ENCODED DATA
-----END RSA PRIVATE KEY-----

For those requiring a deeper understanding, the PKCS1 base64 contains ASN.1 in DER encoding with the following structure:

RSAPrivateKey ::= SEQUENCE {
  version           Version,
  modulus           INTEGER,  -- n
  publicExponent    INTEGER,  -- e
  privateExponent   INTEGER,  -- d
  prime1            INTEGER,  -- p
  prime2            INTEGER,  -- q
  exponent1         INTEGER,  -- d mod (p-1)
  exponent2         INTEGER,  -- d mod (q-1)
  coefficient       INTEGER,  -- (inverse of q) mod p
  otherPrimeInfos   OtherPrimeInfos OPTIONAL
}

A private key stored in PKCS#8 format begins and ends with the tags:

-----BEGIN PRIVATE KEY-----
BASE64 ENCODED DATA
-----END PRIVATE KEY-----

For those requiring a deeper understanding, the PKCS8 base64 contains ASN.1 in DER encoding with the following structure:

PrivateKeyInfo ::= SEQUENCE {
  version         Version,
  algorithm       AlgorithmIdentifier,
  PrivateKey      BIT STRING
}

AlgorithmIdentifier ::= SEQUENCE {
  algorithm       OBJECT IDENTIFIER,
  parameters      ANY DEFINED BY algorithm OPTIONAL
}

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPemFile
function CkPrivateKey_LoadPemFile(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;

Loads a private key from a PEM file.

Returns True for success, False for failure.

top
LoadPkcs1
function CkPrivateKey_LoadPkcs1(objHandle: HCkPrivateKey;
    data: HCkByteData): wordbool; stdcall;
Introduced in version 9.5.0.58

Loads an RSA, ECC, or DSA private key from binary DER.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPkcs1File
function CkPrivateKey_LoadPkcs1File(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Loads a private key from a PKCS1 file.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPkcs8
function CkPrivateKey_LoadPkcs8(objHandle: HCkPrivateKey;
    data: HCkByteData): wordbool; stdcall;

Loads a private key from in-memory PKCS8 byte data.

For those requiring a deeper understanding, the PKCS8 contains ASN.1 in DER encoding with the following structure:

PrivateKeyInfo ::= SEQUENCE {
  version         Version,
  algorithm       AlgorithmIdentifier,
  PrivateKey      BIT STRING
}

AlgorithmIdentifier ::= SEQUENCE {
  algorithm       OBJECT IDENTIFIER,
  parameters      ANY DEFINED BY algorithm OPTIONAL
}

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPkcs8Encrypted
function CkPrivateKey_LoadPkcs8Encrypted(objHandle: HCkPrivateKey;
    data: HCkByteData;
    password: PWideChar): wordbool; stdcall;

Loads a private key from in-memory password-protected PKCS8 byte data.

For those requiring a deeper understanding, the encrypted PKCS8 contains ASN.1 in DER encoding with the following structure:

EncryptedPrivateKeyInfo ::= SEQUENCE {
  encryptionAlgorithm  EncryptionAlgorithmIdentifier,
  encryptedData        EncryptedData
}

EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier

EncryptedData ::= OCTET STRING

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPkcs8EncryptedFile
function CkPrivateKey_LoadPkcs8EncryptedFile(objHandle: HCkPrivateKey;
    path: PWideChar;
    password: PWideChar): wordbool; stdcall;

Loads a private key from an encrypted PKCS8 file.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

More Information and Examples
top
LoadPkcs8File
function CkPrivateKey_LoadPkcs8File(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;

Loads a private key from a PKCS8 file.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPvk
function CkPrivateKey_LoadPvk(objHandle: HCkPrivateKey;
    data: HCkByteData;
    password: PWideChar): wordbool; stdcall;

Loads a private key from in-memory PVK byte data.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadPvkFile
function CkPrivateKey_LoadPvkFile(objHandle: HCkPrivateKey;
    path: PWideChar;
    password: PWideChar): wordbool; stdcall;

Loads a private key from a PVK format file.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadXml
function CkPrivateKey_LoadXml(objHandle: HCkPrivateKey;
    xml: PWideChar): wordbool; stdcall;

Loads a private key from an XML string.

RSA keys have this XML format:

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

DSA keys have this XML format:

<DSAKeyValue>
	<P>...</P>
	<Q>...</Q>
	<G>...</G>
	<Y>...</Y>
	<X>...</X>
</DSAKeyValue>

ECC keys have this XML format. The CURVE_NAME could be one of secp256r1, secp384r1, secp521r1, secp256k1 (or others as new curves are supported.)

<ECCKeyValue curve="CURVE_NAME">...</ECCKeyValue>

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
LoadXmlFile
function CkPrivateKey_LoadXmlFile(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;

Loads a private key from an XML file.

Note: Each of the private key Load* methods willl auto-recognize the content and will parse appropriately. The private key should be successfully loaded even when the wrong format data is passed to the wrong method.

Returns True for success, False for failure.

top
SavePemFile
function CkPrivateKey_SavePemFile(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Saves the private key to an unencrypted PKCS1 PEM format file.

Returns True for success, False for failure.

top
SavePkcs1File
function CkPrivateKey_SavePkcs1File(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;
Introduced in version 9.5.0.58

Saves the private key to an unencrypted binary PKCS1 format file.

Returns True for success, False for failure.

top
SavePkcs8EncryptedFile
function CkPrivateKey_SavePkcs8EncryptedFile(objHandle: HCkPrivateKey;
    password: PWideChar;
    path: PWideChar): wordbool; stdcall;

Saves the private key to a password-protected PKCS8 format file. The Pkcs8EncryptAlg property controls the encryption algorithm used to encrypt.

Returns True for success, False for failure.

top
SavePkcs8EncryptedPemFile
function CkPrivateKey_SavePkcs8EncryptedPemFile(objHandle: HCkPrivateKey;
    password: PWideChar;
    path: PWideChar): wordbool; stdcall;

Saves the private key to a password-protected PKCS8 PEM format file. The Pkcs8EncryptAlg property controls the encryption algorithm used to encrypt.

Returns True for success, False for failure.

top
SavePkcs8File
function CkPrivateKey_SavePkcs8File(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;

Saves the private key to an unencrypted binary PKCS8 format file.

Returns True for success, False for failure.

top
SavePkcs8PemFile
function CkPrivateKey_SavePkcs8PemFile(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;

Saves the private key to a PKCS8 PEM format file.

Returns True for success, False for failure.

top
SaveXmlFile
function CkPrivateKey_SaveXmlFile(objHandle: HCkPrivateKey;
    path: PWideChar): wordbool; stdcall;

Saves the private key to an XML file.

Returns True for success, False for failure.

top
UploadToCloud
function CkPrivateKey_UploadToCloud(objHandle: HCkPrivateKey;
    jsonIn: HCkJsonObject;
    jsonOut: HCkJsonObject): wordbool; stdcall;
Introduced in version 9.5.0.96

This is an open-ended method to accomodate uploading the private key to a cloud service, such as AWS KMS, or Azure Key Vault. For details, see the examples below.

Returns True for success, False for failure.

top
UploadToCloudAsync (1)
function CkPrivateKey_UploadToCloudAsync(objHandle: HCkPrivateKey;
    jsonIn: HCkJsonObject;
    jsonOut: HCkJsonObject): HCkTask; stdcall;
Introduced in version 9.5.0.96

Creates an asynchronous task to call the UploadToCloud method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top

Events

Chilkat supports event callbacks for the Delphi DLL starting in version 9.5.0.82.

AbortCheck
function MyAbortCheck(): Integer; cdecl;
Introduced in version 9.5.0.82

Provides the opportunity for a method call to be aborted. The AbortCheck event is fired periodically based on the value of the HeartbeatMs property. If HeartbeatMs is 0, then no AbortCheck events will fire. As an example, to fire 5 AbortCheck events per second, set the HeartbeatMs property equal to 200. Return True to abort; return False to continue (not abort)

More Information and Examples
top
PercentDone
function MyPercentDone(pctDone: Integer): Integer; cdecl;
Introduced in version 9.5.0.82

Provides the percentage completed for any method that involves network communications or time-consuming processing (assuming it is a method where a percentage completion can be measured). This event is only fired when it is possible to know a percentage completion, and when it makes sense to express the operation as a percentage completed. The pctDone argument will have a value from 1 to 100. For operations (Chilkat method calls) that complete very quickly, the number of PercentDone callbacks will vary, but the final callback should have a value of 100. For long running operations, no more than one callback per percentage point will occur (for example: 1, 2, 3, ... 98, 99, 100).

The PercentDone callback counts as an AbortCheck event. For method calls that complete quickly such that PercentDone events fire, it may be that AbortCheck events don't fire because the opportunity to abort is already provided in the PercentDone callback. For time consuming operations, where the amount of time between PercentDone callbacks are long, AbortCheck callbacks may be used to allow for the operation to be aborted in a more responsive manner.

Return True to abort; return False to continue (not abort)

More Information and Examples
top
ProgressInfo
procedure MyProgressInfo(name: PWideChar; value: PWideChar) cdecl;
Introduced in version 9.5.0.82

A general name/value event that provides information about what is happening during a method call. To find out what information is available, write code to handle this event and log the name/value pairs. Most are self-explanatory.

More Information and Examples
top
TaskCompleted
procedure MyTaskCompleted(task: HCkTask) cdecl;
Introduced in version 9.5.0.82

Called in the background thread when an asynchronous task completes.

top