DSAKeyValue.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // DSAKeyValue.cs - DSA KeyValue implementation for XML Signature
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. using System.Security.Cryptography;
  10. using System.Text;
  11. using System.Xml;
  12. namespace System.Security.Cryptography.Xml {
  13. public class DSAKeyValue : KeyInfoClause {
  14. private DSA dsa;
  15. public DSAKeyValue ()
  16. {
  17. dsa = (DSA)DSA.Create ();
  18. }
  19. public DSAKeyValue (DSA key)
  20. {
  21. dsa = key;
  22. }
  23. public DSA Key
  24. {
  25. get { return dsa; }
  26. set { dsa = value; }
  27. }
  28. public override XmlElement GetXml ()
  29. {
  30. XmlDocument document = new XmlDocument ();
  31. XmlElement xel = document.CreateElement (XmlSignature.ElementNames.KeyValue, XmlSignature.NamespaceURI);
  32. xel.SetAttribute ("xmlns", XmlSignature.NamespaceURI);
  33. xel.InnerXml = dsa.ToXmlString (false);
  34. return xel;
  35. }
  36. public override void LoadXml (XmlElement value)
  37. {
  38. if (value == null)
  39. throw new ArgumentNullException ();
  40. if ((value.LocalName != XmlSignature.ElementNames.KeyValue) || (value.NamespaceURI != XmlSignature.NamespaceURI))
  41. throw new CryptographicException ("value");
  42. dsa.FromXmlString (value.InnerXml);
  43. }
  44. }
  45. }