ClpKeyEncoder.pas 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. { *********************************************************************************** }
  2. { * CryptoLib Library * }
  3. { * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
  4. { * Github Repository <https://github.com/Xor-el> * }
  5. { * Distributed under the MIT software license, see the accompanying file LICENSE * }
  6. { * or visit http://www.opensource.org/licenses/mit-license.php. * }
  7. { * Acknowledgements: * }
  8. { * * }
  9. { * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
  10. { * development of this library * }
  11. { * ******************************************************************************* * }
  12. (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
  13. unit ClpKeyEncoder;
  14. {$I ..\Include\CryptoLib.inc}
  15. interface
  16. uses
  17. ClpIAsymmetricKeyParameter,
  18. ClpIECParameters,
  19. ClpIKeyEncoder,
  20. ClpCryptoLibTypes;
  21. type
  22. TKeyEncoder = class(TInterfacedObject, IKeyEncoder)
  23. strict private
  24. var
  25. FUsePointCompression: Boolean;
  26. public
  27. constructor Create(usePointCompression: Boolean);
  28. function GetEncoded(const keyParameter: IAsymmetricKeyParameter)
  29. : TCryptoLibByteArray;
  30. end;
  31. implementation
  32. { TKeyEncoder }
  33. constructor TKeyEncoder.Create(usePointCompression: Boolean);
  34. begin
  35. Inherited Create();
  36. FUsePointCompression := usePointCompression;
  37. end;
  38. function TKeyEncoder.GetEncoded(const keyParameter: IAsymmetricKeyParameter)
  39. : TCryptoLibByteArray;
  40. begin
  41. Result := (keyParameter as IECPublicKeyParameters)
  42. .Q.GetEncoded(FUsePointCompression);
  43. end;
  44. end.