From 47b5913636f39d7ca1713e399be4337a3e09040e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Fri, 19 Feb 1999 15:33:09 +0100 Subject: [PATCH] Added classes asn1_boolean and asn1_enumerated. Rev: lib/modules/Standards.pmod/ASN1.pmod/Types.pmod:1.4 --- .../Standards.pmod/ASN1.pmod/Types.pmod | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/modules/Standards.pmod/ASN1.pmod/Types.pmod b/lib/modules/Standards.pmod/ASN1.pmod/Types.pmod index c968d425ed..8a05bf213c 100644 --- a/lib/modules/Standards.pmod/ASN1.pmod/Types.pmod +++ b/lib/modules/Standards.pmod/ASN1.pmod/Types.pmod @@ -189,9 +189,8 @@ class asn1_string } } -#if 0 - // FIXME: What is the DER-encoding of TRUE??? +// According to Jan Petrous, the LDAP spec says that 0xff is right. class asn1_boolean { @@ -203,14 +202,23 @@ class asn1_boolean object init(int x) { value = x; return this_object(); } - string der_encode() {} - object decode_primitive() {} - string debug_string + string der_encode() { return build_der(value ? "\377" : "\0"); } + object decode_primitive(string contents) + { + if (strlen(contents) != 1) + { + WERROR("asn1_boolean->decode_primitive: Bad length.\n"); + return 0; + } + record_der(contents); + value = contents[0]; + return this_object(); + } + string debug_string() { return value ? "TRUE" : "FALSE"; } } -#endif // All integers are represented as bignums, for simplicity class asn1_integer @@ -261,6 +269,12 @@ class asn1_integer } } +class asn1_enumerated +{ + inherit asn1_integer; + constant tag = 10; + constant type_name ="ENUMERATED"; +} class asn1_bit_string { -- GitLab