unit Chilkat.PrivateKey;

{
  Pascal wrapper for Chilkat PrivateKey.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TPrivateKey wraps CkPrivateKey via the C bridge layer. }
  TPrivateKey = class(TChilkatBase)
  private
    FOnAbortCheck: TChilkatAbortCheckEvent;
    FOnPercentDone: TChilkatPercentDoneEvent;
    FOnProgressInfo: TChilkatProgressInfoEvent;
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
    function  GetBitLength: Integer;
    function  GetKeyType: string;
    function  GetPkcs8EncryptAlg: string;
    procedure SetPkcs8EncryptAlg(AValue: string);
    function  GetUncommonOptions: string;
    procedure SetUncommonOptions(AValue: string);
    procedure SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
    procedure SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
    procedure SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;
    property BitLength: Integer read GetBitLength;
    property KeyType: string read GetKeyType;
    property Pkcs8EncryptAlg: string read GetPkcs8EncryptAlg write SetPkcs8EncryptAlg;
    property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;

    { Event callbacks.  Return True from OnAbortCheck / OnPercentDone
      to abort the running method.  Callbacks are invoked on the
      thread that called the Chilkat method.  The HeartbeatMs
      property controls the AbortCheck frequency. }
    property OnAbortCheck: TChilkatAbortCheckEvent read FOnAbortCheck write SetOnAbortCheck;
    property OnPercentDone: TChilkatPercentDoneEvent read FOnPercentDone write SetOnPercentDone;
    property OnProgressInfo: TChilkatProgressInfoEvent read FOnProgressInfo write SetOnProgressInfo;

    function  GetPkcs1ENC(const encoding: string): string;
    function  GetPkcs8ENC(const encoding: string): string;
    function  GetPkcs8EncryptedENC(const encoding: string; const password: string): string;
    function  GetPkcs8EncryptedPem(const password: string): string;
    function  GetPkcs8Pem: string;
    function  GetXml: string;
    function  LoadEncryptedPem(const pemStr: string; const password: string): Boolean;
    function  LoadEncryptedPemFile(const path: string; const password: string): Boolean;
    function  LoadPem(const str: string): Boolean;
    function  LoadPemFile(const path: string): Boolean;
    function  LoadPkcs8EncryptedFile(const path: string; const password: string): Boolean;
    function  LoadPkcs8File(const path: string): Boolean;
    function  LoadPvkFile(const path: string; const password: string): Boolean;
    function  LoadXml(const xml: string): Boolean;
    function  LoadXmlFile(const path: string): Boolean;
    function  SavePkcs8EncryptedFile(const password: string; const path: string): Boolean;
    function  SavePkcs8EncryptedPemFile(const password: string; const path: string): Boolean;
    function  SavePkcs8File(const path: string): Boolean;
    function  SavePkcs8PemFile(const path: string): Boolean;
    function  SaveXmlFile(const path: string): Boolean;
    function  GetPkcs1Pem: string;
    function  LoadPkcs1File(const path: string): Boolean;
    function  SavePkcs1File(const path: string): Boolean;
    function  SavePemFile(const path: string): Boolean;
    function  GetJwk: string;
    function  LoadJwk(const jsonStr: string): Boolean;
    function  GetJwkThumbprint(const hashAlg: string): string;
    function  LoadAnyFormat(privKeyData: TChilkatBase; const password: string): Boolean;
    function  LoadEd25519(const privKey: string; const pubKey: string): Boolean;
    function  LoadAnyFormatFile(const path: string; const password: string): Boolean;
    function  GetRawHex(pubKey: TChilkatBase): string;
    function  UploadToCloud(jsonIn: TChilkatBase; jsonOut: TChilkatBase): Boolean;
    function  ToPublicKey(pubKey: TChilkatBase): Boolean;
    function  GetPkcsBd(pkcs1: Boolean; const password: string; bd: TChilkatBase): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkPrivateKey_Create  = function(): Pointer; cdecl;
  TCkPrivateKey_Dispose = procedure(handle: Pointer); cdecl;
  TCkBridgeAbortCheckCb   = function(userData: Pointer): Integer; cdecl;
  TCkBridgePercentDoneCb  = function(pctDone: Integer; userData: Pointer): Integer; cdecl;
  TCkBridgeProgressInfoCb = procedure(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
  TCkPrivateKey_SetAbortCheckCallback   = procedure(handle: Pointer; cb: TCkBridgeAbortCheckCb; userData: Pointer); cdecl;
  TCkPrivateKey_SetPercentDoneCallback  = procedure(handle: Pointer; cb: TCkBridgePercentDoneCb; userData: Pointer); cdecl;
  TCkPrivateKey_SetProgressInfoCallback = procedure(handle: Pointer; cb: TCkBridgeProgressInfoCb; userData: Pointer); cdecl;
  TCkPrivateKey_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkPrivateKey_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkPrivateKey_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkPrivateKey_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkPrivateKey_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkPrivateKey_get_BitLength = function(handle: Pointer): Integer; cdecl;
  TCkPrivateKey_get_KeyType = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_get_Pkcs8EncryptAlg = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_put_Pkcs8EncryptAlg = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkPrivateKey_get_UncommonOptions = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_put_UncommonOptions = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkPrivateKey_GetPkcs1ENC = function(handle: Pointer; encoding: PAnsiChar): PAnsiChar; cdecl;
  TCkPrivateKey_GetPkcs8ENC = function(handle: Pointer; encoding: PAnsiChar): PAnsiChar; cdecl;
  TCkPrivateKey_GetPkcs8EncryptedENC = function(handle: Pointer; encoding: PAnsiChar; password: PAnsiChar): PAnsiChar; cdecl;
  TCkPrivateKey_GetPkcs8EncryptedPem = function(handle: Pointer; password: PAnsiChar): PAnsiChar; cdecl;
  TCkPrivateKey_GetPkcs8Pem = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_GetXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_LoadEncryptedPem = function(handle: Pointer; pemStr: PAnsiChar; password: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadEncryptedPemFile = function(handle: Pointer; path: PAnsiChar; password: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadPem = function(handle: Pointer; str: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadPemFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadPkcs8EncryptedFile = function(handle: Pointer; path: PAnsiChar; password: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadPkcs8File = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadPvkFile = function(handle: Pointer; path: PAnsiChar; password: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadXml = function(handle: Pointer; xml: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadXmlFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SavePkcs8EncryptedFile = function(handle: Pointer; password: PAnsiChar; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SavePkcs8EncryptedPemFile = function(handle: Pointer; password: PAnsiChar; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SavePkcs8File = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SavePkcs8PemFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SaveXmlFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_GetPkcs1Pem = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_LoadPkcs1File = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SavePkcs1File = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_SavePemFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_GetJwk = function(handle: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_LoadJwk = function(handle: Pointer; jsonStr: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_GetJwkThumbprint = function(handle: Pointer; hashAlg: PAnsiChar): PAnsiChar; cdecl;
  TCkPrivateKey_LoadAnyFormat = function(handle: Pointer; privKeyData: Pointer; password: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadEd25519 = function(handle: Pointer; privKey: PAnsiChar; pubKey: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_LoadAnyFormatFile = function(handle: Pointer; path: PAnsiChar; password: PAnsiChar): LongBool; cdecl;
  TCkPrivateKey_GetRawHex = function(handle: Pointer; pubKey: Pointer): PAnsiChar; cdecl;
  TCkPrivateKey_UploadToCloud = function(handle: Pointer; jsonIn: Pointer; jsonOut: Pointer): LongBool; cdecl;
  TCkPrivateKey_ToPublicKey = function(handle: Pointer; pubKey: Pointer): LongBool; cdecl;
  TCkPrivateKey_GetPkcsBd = function(handle: Pointer; pkcs1: LongBool; password: PAnsiChar; bd: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkPrivateKey_Create:  TCkPrivateKey_Create  = nil;
  CkPrivateKey_Dispose: TCkPrivateKey_Dispose = nil;
  CkPrivateKey_SetAbortCheckCallback:   TCkPrivateKey_SetAbortCheckCallback   = nil;
  CkPrivateKey_SetPercentDoneCallback:  TCkPrivateKey_SetPercentDoneCallback  = nil;
  CkPrivateKey_SetProgressInfoCallback: TCkPrivateKey_SetProgressInfoCallback = nil;
  CkPrivateKey_get_LastErrorHtml: TCkPrivateKey_get_LastErrorHtml = nil;
  CkPrivateKey_get_LastErrorText: TCkPrivateKey_get_LastErrorText = nil;
  CkPrivateKey_get_LastErrorXml: TCkPrivateKey_get_LastErrorXml = nil;
  CkPrivateKey_get_Version: TCkPrivateKey_get_Version = nil;
  CkPrivateKey_get_DebugLogFilePath: TCkPrivateKey_get_DebugLogFilePath = nil;
  CkPrivateKey_put_DebugLogFilePath: TCkPrivateKey_put_DebugLogFilePath = nil;
  CkPrivateKey_get_VerboseLogging: TCkPrivateKey_get_VerboseLogging = nil;
  CkPrivateKey_put_VerboseLogging: TCkPrivateKey_put_VerboseLogging = nil;
  CkPrivateKey_get_LastMethodSuccess: TCkPrivateKey_get_LastMethodSuccess = nil;
  CkPrivateKey_put_LastMethodSuccess: TCkPrivateKey_put_LastMethodSuccess = nil;
  CkPrivateKey_get_BitLength: TCkPrivateKey_get_BitLength = nil;
  CkPrivateKey_get_KeyType: TCkPrivateKey_get_KeyType = nil;
  CkPrivateKey_get_Pkcs8EncryptAlg: TCkPrivateKey_get_Pkcs8EncryptAlg = nil;
  CkPrivateKey_put_Pkcs8EncryptAlg: TCkPrivateKey_put_Pkcs8EncryptAlg = nil;
  CkPrivateKey_get_UncommonOptions: TCkPrivateKey_get_UncommonOptions = nil;
  CkPrivateKey_put_UncommonOptions: TCkPrivateKey_put_UncommonOptions = nil;
  CkPrivateKey_GetPkcs1ENC: TCkPrivateKey_GetPkcs1ENC = nil;
  CkPrivateKey_GetPkcs8ENC: TCkPrivateKey_GetPkcs8ENC = nil;
  CkPrivateKey_GetPkcs8EncryptedENC: TCkPrivateKey_GetPkcs8EncryptedENC = nil;
  CkPrivateKey_GetPkcs8EncryptedPem: TCkPrivateKey_GetPkcs8EncryptedPem = nil;
  CkPrivateKey_GetPkcs8Pem: TCkPrivateKey_GetPkcs8Pem = nil;
  CkPrivateKey_GetXml: TCkPrivateKey_GetXml = nil;
  CkPrivateKey_LoadEncryptedPem: TCkPrivateKey_LoadEncryptedPem = nil;
  CkPrivateKey_LoadEncryptedPemFile: TCkPrivateKey_LoadEncryptedPemFile = nil;
  CkPrivateKey_LoadPem: TCkPrivateKey_LoadPem = nil;
  CkPrivateKey_LoadPemFile: TCkPrivateKey_LoadPemFile = nil;
  CkPrivateKey_LoadPkcs8EncryptedFile: TCkPrivateKey_LoadPkcs8EncryptedFile = nil;
  CkPrivateKey_LoadPkcs8File: TCkPrivateKey_LoadPkcs8File = nil;
  CkPrivateKey_LoadPvkFile: TCkPrivateKey_LoadPvkFile = nil;
  CkPrivateKey_LoadXml: TCkPrivateKey_LoadXml = nil;
  CkPrivateKey_LoadXmlFile: TCkPrivateKey_LoadXmlFile = nil;
  CkPrivateKey_SavePkcs8EncryptedFile: TCkPrivateKey_SavePkcs8EncryptedFile = nil;
  CkPrivateKey_SavePkcs8EncryptedPemFile: TCkPrivateKey_SavePkcs8EncryptedPemFile = nil;
  CkPrivateKey_SavePkcs8File: TCkPrivateKey_SavePkcs8File = nil;
  CkPrivateKey_SavePkcs8PemFile: TCkPrivateKey_SavePkcs8PemFile = nil;
  CkPrivateKey_SaveXmlFile: TCkPrivateKey_SaveXmlFile = nil;
  CkPrivateKey_GetPkcs1Pem: TCkPrivateKey_GetPkcs1Pem = nil;
  CkPrivateKey_LoadPkcs1File: TCkPrivateKey_LoadPkcs1File = nil;
  CkPrivateKey_SavePkcs1File: TCkPrivateKey_SavePkcs1File = nil;
  CkPrivateKey_SavePemFile: TCkPrivateKey_SavePemFile = nil;
  CkPrivateKey_GetJwk: TCkPrivateKey_GetJwk = nil;
  CkPrivateKey_LoadJwk: TCkPrivateKey_LoadJwk = nil;
  CkPrivateKey_GetJwkThumbprint: TCkPrivateKey_GetJwkThumbprint = nil;
  CkPrivateKey_LoadAnyFormat: TCkPrivateKey_LoadAnyFormat = nil;
  CkPrivateKey_LoadEd25519: TCkPrivateKey_LoadEd25519 = nil;
  CkPrivateKey_LoadAnyFormatFile: TCkPrivateKey_LoadAnyFormatFile = nil;
  CkPrivateKey_GetRawHex: TCkPrivateKey_GetRawHex = nil;
  CkPrivateKey_UploadToCloud: TCkPrivateKey_UploadToCloud = nil;
  CkPrivateKey_ToPublicKey: TCkPrivateKey_ToPublicKey = nil;
  CkPrivateKey_GetPkcsBd: TCkPrivateKey_GetPkcsBd = nil;

constructor TPrivateKey.Create;
begin
  inherited Create;
  FHandle := CkPrivateKey_Create();
end;

destructor TPrivateKey.Destroy;
begin
  if FHandle <> nil then
    CkPrivateKey_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

{ ---- Event callback thunks ---- }
{ Standalone cdecl functions registered with the C bridge.  The bridge
  passes back the userData pointer, which carries the Pascal object
  instance.  A non-zero return value aborts the running method. }

function TPrivateKey_AbortCheckThunk(userData: Pointer): Integer; cdecl;
var
  obj: TPrivateKey;
begin
  Result := 0;
  obj := TPrivateKey(userData);
  if Assigned(obj) and Assigned(obj.FOnAbortCheck) then
    if obj.FOnAbortCheck(obj) then Result := 1;
end;

function TPrivateKey_PercentDoneThunk(pctDone: Integer; userData: Pointer): Integer; cdecl;
var
  obj: TPrivateKey;
begin
  Result := 0;
  obj := TPrivateKey(userData);
  if Assigned(obj) and Assigned(obj.FOnPercentDone) then
    if obj.FOnPercentDone(obj, pctDone) then Result := 1;
end;

procedure TPrivateKey_ProgressInfoThunk(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
var
  obj: TPrivateKey;
begin
  obj := TPrivateKey(userData);
  if Assigned(obj) and Assigned(obj.FOnProgressInfo) then
    obj.FOnProgressInfo(obj, CkToStr(name), CkToStr(value));
end;

procedure TPrivateKey.SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
begin
  FOnAbortCheck := AValue;
  if Assigned(AValue) then
    CkPrivateKey_SetAbortCheckCallback(FHandle, @TPrivateKey_AbortCheckThunk, Self)
  else
    CkPrivateKey_SetAbortCheckCallback(FHandle, nil, nil);
end;

procedure TPrivateKey.SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
begin
  FOnPercentDone := AValue;
  if Assigned(AValue) then
    CkPrivateKey_SetPercentDoneCallback(FHandle, @TPrivateKey_PercentDoneThunk, Self)
  else
    CkPrivateKey_SetPercentDoneCallback(FHandle, nil, nil);
end;

procedure TPrivateKey.SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
begin
  FOnProgressInfo := AValue;
  if Assigned(AValue) then
    CkPrivateKey_SetProgressInfoCallback(FHandle, @TPrivateKey_ProgressInfoThunk, Self)
  else
    CkPrivateKey_SetProgressInfoCallback(FHandle, nil, nil);
end;

function TPrivateKey.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkPrivateKey_get_LastErrorHtml(FHandle));
end;

function TPrivateKey.GetLastErrorText: string;
begin
  Result := CkToStr(CkPrivateKey_get_LastErrorText(FHandle));
end;

function TPrivateKey.GetLastErrorXml: string;
begin
  Result := CkToStr(CkPrivateKey_get_LastErrorXml(FHandle));
end;

function TPrivateKey.GetVersion: string;
begin
  Result := CkToStr(CkPrivateKey_get_Version(FHandle));
end;

function TPrivateKey.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkPrivateKey_get_DebugLogFilePath(FHandle));
end;

procedure TPrivateKey.SetDebugLogFilePath(AValue: string);
begin
  CkPrivateKey_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TPrivateKey.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkPrivateKey_get_VerboseLogging(FHandle));
end;

procedure TPrivateKey.SetVerboseLogging(AValue: Boolean);
begin
  CkPrivateKey_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TPrivateKey.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkPrivateKey_get_LastMethodSuccess(FHandle));
end;

procedure TPrivateKey.SetLastMethodSuccess(AValue: Boolean);
begin
  CkPrivateKey_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TPrivateKey.GetBitLength: Integer;
begin
  Result := CkPrivateKey_get_BitLength(FHandle);
end;

function TPrivateKey.GetKeyType: string;
begin
  Result := CkToStr(CkPrivateKey_get_KeyType(FHandle));
end;

function TPrivateKey.GetPkcs8EncryptAlg: string;
begin
  Result := CkToStr(CkPrivateKey_get_Pkcs8EncryptAlg(FHandle));
end;

procedure TPrivateKey.SetPkcs8EncryptAlg(AValue: string);
begin
  CkPrivateKey_put_Pkcs8EncryptAlg(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TPrivateKey.GetUncommonOptions: string;
begin
  Result := CkToStr(CkPrivateKey_get_UncommonOptions(FHandle));
end;

procedure TPrivateKey.SetUncommonOptions(AValue: string);
begin
  CkPrivateKey_put_UncommonOptions(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TPrivateKey.GetPkcs1ENC(const encoding: string): string;
begin
  Result := CkToStr(CkPrivateKey_GetPkcs1ENC(FHandle, PAnsiChar(StrToCk(encoding))));
end;

function TPrivateKey.GetPkcs8ENC(const encoding: string): string;
begin
  Result := CkToStr(CkPrivateKey_GetPkcs8ENC(FHandle, PAnsiChar(StrToCk(encoding))));
end;

function TPrivateKey.GetPkcs8EncryptedENC(const encoding: string; const password: string): string;
begin
  Result := CkToStr(CkPrivateKey_GetPkcs8EncryptedENC(FHandle, PAnsiChar(StrToCk(encoding)), PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.GetPkcs8EncryptedPem(const password: string): string;
begin
  Result := CkToStr(CkPrivateKey_GetPkcs8EncryptedPem(FHandle, PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.GetPkcs8Pem: string;
begin
  Result := CkToStr(CkPrivateKey_GetPkcs8Pem(FHandle));
end;

function TPrivateKey.GetXml: string;
begin
  Result := CkToStr(CkPrivateKey_GetXml(FHandle));
end;

function TPrivateKey.LoadEncryptedPem(const pemStr: string; const password: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadEncryptedPem(FHandle, PAnsiChar(StrToCk(pemStr)), PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.LoadEncryptedPemFile(const path: string; const password: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadEncryptedPemFile(FHandle, PAnsiChar(StrToCk(path)), PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.LoadPem(const str: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadPem(FHandle, PAnsiChar(StrToCk(str))));
end;

function TPrivateKey.LoadPemFile(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadPemFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.LoadPkcs8EncryptedFile(const path: string; const password: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadPkcs8EncryptedFile(FHandle, PAnsiChar(StrToCk(path)), PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.LoadPkcs8File(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadPkcs8File(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.LoadPvkFile(const path: string; const password: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadPvkFile(FHandle, PAnsiChar(StrToCk(path)), PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.LoadXml(const xml: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadXml(FHandle, PAnsiChar(StrToCk(xml))));
end;

function TPrivateKey.LoadXmlFile(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadXmlFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SavePkcs8EncryptedFile(const password: string; const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SavePkcs8EncryptedFile(FHandle, PAnsiChar(StrToCk(password)), PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SavePkcs8EncryptedPemFile(const password: string; const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SavePkcs8EncryptedPemFile(FHandle, PAnsiChar(StrToCk(password)), PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SavePkcs8File(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SavePkcs8File(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SavePkcs8PemFile(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SavePkcs8PemFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SaveXmlFile(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SaveXmlFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.GetPkcs1Pem: string;
begin
  Result := CkToStr(CkPrivateKey_GetPkcs1Pem(FHandle));
end;

function TPrivateKey.LoadPkcs1File(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadPkcs1File(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SavePkcs1File(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SavePkcs1File(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.SavePemFile(const path: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_SavePemFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TPrivateKey.GetJwk: string;
begin
  Result := CkToStr(CkPrivateKey_GetJwk(FHandle));
end;

function TPrivateKey.LoadJwk(const jsonStr: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadJwk(FHandle, PAnsiChar(StrToCk(jsonStr))));
end;

function TPrivateKey.GetJwkThumbprint(const hashAlg: string): string;
begin
  Result := CkToStr(CkPrivateKey_GetJwkThumbprint(FHandle, PAnsiChar(StrToCk(hashAlg))));
end;

function TPrivateKey.LoadAnyFormat(privKeyData: TChilkatBase; const password: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadAnyFormat(FHandle, privKeyData.Handle, PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.LoadEd25519(const privKey: string; const pubKey: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadEd25519(FHandle, PAnsiChar(StrToCk(privKey)), PAnsiChar(StrToCk(pubKey))));
end;

function TPrivateKey.LoadAnyFormatFile(const path: string; const password: string): Boolean;
begin
  Result := Boolean(CkPrivateKey_LoadAnyFormatFile(FHandle, PAnsiChar(StrToCk(path)), PAnsiChar(StrToCk(password))));
end;

function TPrivateKey.GetRawHex(pubKey: TChilkatBase): string;
begin
  Result := CkToStr(CkPrivateKey_GetRawHex(FHandle, pubKey.Handle));
end;

function TPrivateKey.UploadToCloud(jsonIn: TChilkatBase; jsonOut: TChilkatBase): Boolean;
begin
  Result := Boolean(CkPrivateKey_UploadToCloud(FHandle, jsonIn.Handle, jsonOut.Handle));
end;

function TPrivateKey.ToPublicKey(pubKey: TChilkatBase): Boolean;
begin
  Result := Boolean(CkPrivateKey_ToPublicKey(FHandle, pubKey.Handle));
end;

function TPrivateKey.GetPkcsBd(pkcs1: Boolean; const password: string; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkPrivateKey_GetPkcsBd(FHandle, LongBool(pkcs1), PAnsiChar(StrToCk(password)), bd.Handle));
end;

initialization
  Chilkat_GetProcedureAddress(CkPrivateKey_Create,  'CkPrivateKey_Create');
  Chilkat_GetProcedureAddress(CkPrivateKey_Dispose, 'CkPrivateKey_Dispose');
  Chilkat_GetProcedureAddress(CkPrivateKey_SetAbortCheckCallback, 'CkPrivateKey_SetAbortCheckCallback');
  Chilkat_GetProcedureAddress(CkPrivateKey_SetPercentDoneCallback, 'CkPrivateKey_SetPercentDoneCallback');
  Chilkat_GetProcedureAddress(CkPrivateKey_SetProgressInfoCallback, 'CkPrivateKey_SetProgressInfoCallback');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_LastErrorHtml, 'CkPrivateKey_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_LastErrorText, 'CkPrivateKey_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_LastErrorXml, 'CkPrivateKey_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_Version, 'CkPrivateKey_get_Version');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_DebugLogFilePath, 'CkPrivateKey_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkPrivateKey_put_DebugLogFilePath, 'CkPrivateKey_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_VerboseLogging, 'CkPrivateKey_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkPrivateKey_put_VerboseLogging, 'CkPrivateKey_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_LastMethodSuccess, 'CkPrivateKey_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkPrivateKey_put_LastMethodSuccess, 'CkPrivateKey_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_BitLength, 'CkPrivateKey_get_BitLength');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_KeyType, 'CkPrivateKey_get_KeyType');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_Pkcs8EncryptAlg, 'CkPrivateKey_get_Pkcs8EncryptAlg');
  Chilkat_GetProcedureAddress(CkPrivateKey_put_Pkcs8EncryptAlg, 'CkPrivateKey_put_Pkcs8EncryptAlg');
  Chilkat_GetProcedureAddress(CkPrivateKey_get_UncommonOptions, 'CkPrivateKey_get_UncommonOptions');
  Chilkat_GetProcedureAddress(CkPrivateKey_put_UncommonOptions, 'CkPrivateKey_put_UncommonOptions');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcs1ENC, 'CkPrivateKey_GetPkcs1ENC');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcs8ENC, 'CkPrivateKey_GetPkcs8ENC');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcs8EncryptedENC, 'CkPrivateKey_GetPkcs8EncryptedENC');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcs8EncryptedPem, 'CkPrivateKey_GetPkcs8EncryptedPem');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcs8Pem, 'CkPrivateKey_GetPkcs8Pem');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetXml, 'CkPrivateKey_GetXml');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadEncryptedPem, 'CkPrivateKey_LoadEncryptedPem');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadEncryptedPemFile, 'CkPrivateKey_LoadEncryptedPemFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadPem, 'CkPrivateKey_LoadPem');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadPemFile, 'CkPrivateKey_LoadPemFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadPkcs8EncryptedFile, 'CkPrivateKey_LoadPkcs8EncryptedFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadPkcs8File, 'CkPrivateKey_LoadPkcs8File');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadPvkFile, 'CkPrivateKey_LoadPvkFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadXml, 'CkPrivateKey_LoadXml');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadXmlFile, 'CkPrivateKey_LoadXmlFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_SavePkcs8EncryptedFile, 'CkPrivateKey_SavePkcs8EncryptedFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_SavePkcs8EncryptedPemFile, 'CkPrivateKey_SavePkcs8EncryptedPemFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_SavePkcs8File, 'CkPrivateKey_SavePkcs8File');
  Chilkat_GetProcedureAddress(CkPrivateKey_SavePkcs8PemFile, 'CkPrivateKey_SavePkcs8PemFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_SaveXmlFile, 'CkPrivateKey_SaveXmlFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcs1Pem, 'CkPrivateKey_GetPkcs1Pem');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadPkcs1File, 'CkPrivateKey_LoadPkcs1File');
  Chilkat_GetProcedureAddress(CkPrivateKey_SavePkcs1File, 'CkPrivateKey_SavePkcs1File');
  Chilkat_GetProcedureAddress(CkPrivateKey_SavePemFile, 'CkPrivateKey_SavePemFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetJwk, 'CkPrivateKey_GetJwk');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadJwk, 'CkPrivateKey_LoadJwk');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetJwkThumbprint, 'CkPrivateKey_GetJwkThumbprint');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadAnyFormat, 'CkPrivateKey_LoadAnyFormat');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadEd25519, 'CkPrivateKey_LoadEd25519');
  Chilkat_GetProcedureAddress(CkPrivateKey_LoadAnyFormatFile, 'CkPrivateKey_LoadAnyFormatFile');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetRawHex, 'CkPrivateKey_GetRawHex');
  Chilkat_GetProcedureAddress(CkPrivateKey_UploadToCloud, 'CkPrivateKey_UploadToCloud');
  Chilkat_GetProcedureAddress(CkPrivateKey_ToPublicKey, 'CkPrivateKey_ToPublicKey');
  Chilkat_GetProcedureAddress(CkPrivateKey_GetPkcsBd, 'CkPrivateKey_GetPkcsBd');

end.
