AsnEncodedData.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // Oid.cs - System.Security.Cryptography.Oid
  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. using System.Text;
  12. namespace System.Security.Cryptography {
  13. // Note: Match the definition of framework version 1.2.3400.0 on http://longhorn.msdn.microsoft.com
  14. public sealed class AsnEncodedData {
  15. private Oid _oid;
  16. private byte[] _raw;
  17. // constructors
  18. public AsnEncodedData (string oid, byte[] rawData)
  19. : this (new Oid (oid), rawData) {}
  20. public AsnEncodedData (Oid oid, byte[] rawData)
  21. {
  22. // FIXME: compatibility with fx 1.2.3400.0
  23. if (oid == null)
  24. throw new NullReferenceException ();
  25. // throw new ArgumentNullException ("oid");
  26. if (rawData == null)
  27. throw new NullReferenceException ();
  28. // throw new ArgumentNullException ("rawData");
  29. _oid = oid;
  30. _raw = rawData;
  31. }
  32. public AsnEncodedData (AsnEncodedData asnEncodedData)
  33. {
  34. // FIXME: compatibility with fx 1.2.3400.0
  35. // if (asnEncodedData == null)
  36. // throw new ArgumentNullException ("asnEncodedData");
  37. _oid = new Oid (asnEncodedData._oid);
  38. _raw = asnEncodedData._raw;
  39. }
  40. // properties
  41. public byte[] RawData {
  42. get { return _raw; }
  43. }
  44. // methods
  45. public string Format (bool multiLine)
  46. {
  47. StringBuilder sb = new StringBuilder ();
  48. for (int i=0; i < _raw.Length; i++) {
  49. sb.Append (_raw [i].ToString ("x2"));
  50. if (i != _raw.Length - 1)
  51. sb.Append (" ");
  52. }
  53. return sb.ToString ();
  54. }
  55. }
  56. }
  57. #endif