diff --git a/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in b/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in index bdb74206213b1abfb91bfdb3679e8c693668ab7c..149739dad43ad434c3f14998354fbb311b3bafe8 100644 --- a/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in +++ b/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in @@ -27,26 +27,70 @@ test_decode("010100","FALSE") test_decode("010101","TRUE") test_eval_error(Standards.ASN1.Decode.simple_der_decode("\1\0")) -test_decode("0500","NULL") - test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("090380fb05"-" "))->debug_string(),"REAL 0.15625") test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("090390fe0a"-" "))->debug_string(),"REAL 0.15625") test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("0903acfe05"-" "))->debug_string(),"REAL 0.15625") dnl -dnl Tests from ITU-T Rec.X690 (07/2002) -dnl (originally from A Layman's Guide to a Subset of ASN.1, BER, and -dnl DER) +dnl --- START tests from +dnl A Layman's Guide to a Subset of ASN.1, BER, and DER) dnl dnl 5.4 test_decode("03 04 06 6e 5d c0", "BIT STRING (18) 11011100101110111") test_decode("03 04 06 6e 5d e0", "BIT STRING (18) 11011100101110111") test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("03 81 04 06 6e 5d c0"-" "))->debug_string(), "BIT STRING (18) 11011100101110111") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("23 09 03 03 00 6e 5d 03 02 06 c0"-" "))->debug_string(), "BIT STRING (18) 11011100101110111") + +dnl 5.6 +test_decode("16 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d", + "Types.IA5String(\"test1@rsa.com\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("16 81 0d 74 65 73 74 31 40 72 73 61 2e 63 6f 6d"-" "))->debug_string(), "Types.IA5String(\"test1@rsa.com\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("36 13 16 05 74 65 73 74 31 16 01 40 16 07 72 73 61 2e 63 6f 6d"-" "))->debug_string(), "Types.IA5String(\"test1@rsa.com\")") + +dnl 5.6 +test_decode("02 01 00", "INTEGER (1) 0") +test_decode("02 01 7f", "INTEGER (7) 127") +test_decode("02 02 00 80", "INTEGER (8) 128") +test_decode("02 02 01 00", "INTEGER (9) 256") +test_decode("02 01 80", "INTEGER (8) -128") +test_decode("02 02 ff 7f", "INTEGER (8) -129") + +dnl 5.8 +test_decoce("05 00", "NULL") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("05 81 00"-" "))->debug_string(), "NULL") +test_eq( Types.Null()->get_der(), "\5\0" ) + +dnl 5.9 +test_decode("06 06 2a 86 48 86 f7 0d", "IDENTIFIER 1.2.840.113549") +test_eq(Types.Identifier(1,2,840,113549)->get_der(), + String.hex2string("06062a864886f70d")) +dnl 5.10 +test_decode("04 08 01 23 45 67 89 ab cd ef", "Types.OctetString(\"\\1#Eg\\211\\253\\315\\357\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("04 81 08 01 23 45 67 89 ab cd ef"-" "))->debug_string(), "Types.OctetString(\"\\1#Eg\\211\\253\\315\\357\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("24 0c 04 04 01 23 45 67 04 04 89 ab cd ef"-" "))->debug_string(), "Types.OctetString(\"\\1#Eg\\211\\253\\315\\357\")") -dnl �8.8 -test_eq( Types.Null()->get_der(), "\5\0" ) +dnl 5.11 +test_decode("13 0b 54 65 73 74 20 55 73 65 72 20 31", "Types.PrintableString(\"Test User 1\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("13 81 0b 54 65 73 74 20 55 73 65 72 20 31"-" "))->debug_string(), "Types.PrintableString(\"Test User 1\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("33 0f 13 05 54 65 73 74 20 13 06 55 73 65 72 20 31"-" "))->debug_string(), "Types.PrintableString(\"Test User 1\")") + +dnl 5.16 +dnl FIXME: T61 is not encoded +dnl test_decode("14 0f 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73", "Types.TeletexString(\"cl\\351s publiques\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("14 81 0f 63 6c c2 65 73 20 70 75 62 6c 69 71 75 65 73"-" "))->debug_string(), "Types.TeletexString(\"cl\\351s publiques\")") +test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("34 15 14 05 63 6c c2 65 73 14 01 20 14 09 70 75 62 6c 69 71 75 65 73"-" "))->debug_string(), "Types.TeletexString(\"cl\\351s publiques\")") + +dnl 5.17 +test_decode("17 0d 39 31 30 35 30 36 32 33 34 35 34 30 5a", "Types.UTC(\"910506234540Z\")") +dnl FIXME: Should time be normalized? +dnl test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string("17 11 39 31 30 35 30 36 31 36 34 35 34 30 2D 30 37 30 30"-" "))->debug_string(), "Types.UTC(\"910506234540Z\")") + +dnl +dnl --- END tests from +dnl A Layman's Guide to a Subset of ASN.1, BER, and DER) +dnl dnl �8.9 test_any([[ @@ -63,18 +107,6 @@ test_eq( Types.VisibleString("Jones")->get_der(), "\32\5Jones" ) test_eq( Types.BitString()->set_from_ascii("011011100101110111")->get_der(), String.hex2string("0304066e5dc0") ) -test_eq( Types.IA5String("test1@rsa.com")->get_der(), - String.hex2string("160d7465737431407273612e636f6d") ) - -test_eq( Types.Integer(0)->get_der(), String.hex2string("020100") ) -test_eq( Types.Integer(127)->get_der(), String.hex2string("02017f") ) -test_eq( Types.Integer(128)->get_der(), String.hex2string("02020080") ) -test_eq( Types.Integer(256)->get_der(), String.hex2string("02020100") ) -test_eq( Types.Integer(-128)->get_der(), String.hex2string("020180") ) -test_eq( Types.Integer(-129)->get_der(), String.hex2string("0202ff7f") ) - -test_eq(Types.Identifier(1,2,840,113549)->get_der(), - String.hex2string("06062a864886f70d")) test_eq(Types.OctetString(String.hex2string("0123456789abcdef"))->get_der(), String.hex2string("04080123456789abcdef") )