ExamplesAccountKey.cs 938 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using ACMESharp.Crypto.JOSE;
  3. using ACMESharp.Crypto.JOSE.Impl;
  4. namespace PRSServer
  5. {
  6. public class ExamplesAccountKey
  7. {
  8. public string KeyType { get; set; }
  9. public string KeyExport { get; set; }
  10. public IJwsTool GenerateTool()
  11. {
  12. if (KeyType.StartsWith("ES"))
  13. {
  14. var tool = new ESJwsTool();
  15. tool.HashSize = int.Parse(KeyType.Substring(2));
  16. tool.Init();
  17. tool.Import(KeyExport);
  18. return tool;
  19. }
  20. if (KeyType.StartsWith("RS"))
  21. {
  22. var tool = new RSJwsTool();
  23. tool.HashSize = int.Parse(KeyType.Substring(2));
  24. tool.Init();
  25. tool.Import(KeyExport);
  26. return tool;
  27. }
  28. throw new Exception($"Unknown or unsupported KeyType [{KeyType}]");
  29. }
  30. }
  31. }