asn1.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ASN1: module {
  2. PATH: con "/dis/lib/asn1.dis";
  3. # Tag classes
  4. Universal : con 0;
  5. Application : con 16r40;
  6. Context : con 16r80;
  7. Private : con 16rC0;
  8. # Universal tags
  9. BOOLEAN : con 1;
  10. INTEGER : con 2;
  11. BIT_STRING : con 3;
  12. OCTET_STRING : con 4;
  13. NULL : con 5;
  14. OBJECT_ID: con 6;
  15. ObjectDescriptor : con 7;
  16. EXTERNAL : con 8;
  17. REAL : con 9;
  18. ENUMERATED : con 10;
  19. EMBEDDED_PDV : con 11;
  20. SEQUENCE : con 16; # also SEQUENCE OF
  21. SET : con 17; # also SET OF
  22. NumericString : con 18;
  23. PrintableString : con 19;
  24. TeletexString : con 20;
  25. VideotexString : con 21;
  26. IA5String : con 22;
  27. UTCTime : con 23;
  28. GeneralizedTime : con 24;
  29. GraphicString : con 25;
  30. VisibleString : con 26;
  31. GeneralString : con 27;
  32. UniversalString : con 28;
  33. BMPString : con 30;
  34. Elem: adt {
  35. tag: Tag;
  36. val: ref Value;
  37. is_seq: fn(e: self ref Elem) : (int, list of ref Elem);
  38. is_set: fn(e: self ref Elem) : (int, list of ref Elem);
  39. is_int: fn(e: self ref Elem) : (int, int);
  40. is_bigint: fn(e: self ref Elem) : (int, array of byte);
  41. is_bitstring: fn(e: self ref Elem) : (int, int, array of byte);
  42. is_octetstring: fn(e: self ref Elem) : (int, array of byte);
  43. is_oid: fn(e: self ref Elem) : (int, ref Oid);
  44. is_string: fn(e: self ref Elem) : (int, string);
  45. is_time: fn(e: self ref Elem) : (int, string);
  46. tostring: fn(e: self ref Elem) : string;
  47. };
  48. Tag: adt {
  49. class: int;
  50. num: int;
  51. constr: int; # ignored by encode()
  52. tostring: fn(t: self Tag) : string;
  53. };
  54. Value: adt {
  55. pick {
  56. Bool or Int =>
  57. v: int;
  58. Octets or BigInt or Real or Other =>
  59. # BigInt: integer too big for limbo int
  60. # Real: we don't care to decode these
  61. # since they are hardly ever used
  62. bytes: array of byte;
  63. BitString =>
  64. # pack into bytes, with perhaps some
  65. # unused bits in last byte
  66. unusedbits: int;
  67. bits: array of byte;
  68. Null or EOC =>
  69. dummy: int;
  70. ObjId =>
  71. id: ref Oid;
  72. String =>
  73. s: string;
  74. Seq or Set =>
  75. l: list of ref Elem;
  76. }
  77. tostring : fn(v: self ref Value) : string;
  78. };
  79. Oid: adt {
  80. nums: array of int;
  81. tostring: fn(o: self ref Oid) : string;
  82. };
  83. init: fn();
  84. decode: fn(a: array of byte) : (string, ref Elem);
  85. decode_seq: fn(a: array of byte) : (string, list of ref Elem);
  86. decode_value: fn(a: array of byte, kind, constr: int) : (string, ref Value);
  87. encode: fn(e: ref Elem) : (string, array of byte);
  88. oid_lookup: fn(o: ref Oid, tab: array of Oid) : int;
  89. print_elem: fn(e: ref Elem);
  90. };