ClpDsaKeyGenerationParameters.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 ClpDsaKeyGenerationParameters;
  14. {$I CryptoLib.inc}
  15. interface
  16. uses
  17. ClpBigInteger,
  18. ClpISecureRandom,
  19. ClpIDsaParameters,
  20. ClpIDsaKeyGenerationParameters,
  21. ClpKeyGenerationParameters;
  22. type
  23. TDsaKeyGenerationParameters = class sealed(TKeyGenerationParameters,
  24. IDsaKeyGenerationParameters)
  25. strict private
  26. var
  27. Fparameters: IDsaParameters;
  28. function GetParameters: IDsaParameters; inline;
  29. public
  30. constructor Create(const random: ISecureRandom;
  31. const parameters: IDsaParameters);
  32. property parameters: IDsaParameters read GetParameters;
  33. end;
  34. implementation
  35. { TDsaKeyGenerationParameters }
  36. constructor TDsaKeyGenerationParameters.Create(const random: ISecureRandom;
  37. const parameters: IDsaParameters);
  38. var
  39. P: TBigInteger;
  40. begin
  41. P := parameters.P;
  42. Inherited Create(random, P.BitLength - 1);
  43. Fparameters := parameters;
  44. end;
  45. function TDsaKeyGenerationParameters.GetParameters: IDsaParameters;
  46. begin
  47. result := Fparameters;
  48. end;
  49. end.