PublicKey.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // PublicKey.cs - System.Security.Cryptography.PublicKey
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. #if NET_1_2
  10. using System;
  11. namespace System.Security.Cryptography.X509Certificates {
  12. // Note: Match the definition of framework version 1.2.3400.0 on http://longhorn.msdn.microsoft.com
  13. public sealed class PublicKey {
  14. private AsymmetricAlgorithm _key;
  15. private AsnEncodedData _keyValue;
  16. private AsnEncodedData _params;
  17. private Oid _oid;
  18. internal PublicKey (Mono.Security.X509.X509Certificate certificate)
  19. {
  20. if (certificate.KeyAlgorithm == "1.2.840.113549.1.1.1") {
  21. _key = certificate.RSA;
  22. }
  23. else {
  24. _key = certificate.DSA;
  25. }
  26. _oid = new Oid (certificate.KeyAlgorithm);
  27. _keyValue = new AsnEncodedData (_oid, certificate.PublicKey);
  28. _params = new AsnEncodedData (_oid, certificate.KeyAlgorithmParameters);
  29. }
  30. // properties
  31. public AsnEncodedData EncodedKeyValue {
  32. get { return _keyValue; }
  33. }
  34. public AsnEncodedData EncodedParameters {
  35. get { return _params; }
  36. }
  37. public AsymmetricAlgorithm Key {
  38. get { return _key; }
  39. }
  40. public Oid Oid {
  41. get { return _oid; }
  42. }
  43. }
  44. }
  45. #endif