@@ -12,6 +12,7 @@ public void TestMinStringLengthEncode() {
1212 var oid = new Asn1ObjectIdentifier ( "0.0" ) ;
1313 Assert . AreEqual ( "0.0" , oid . Value . Value ) ;
1414 String encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
15+ // must be 06 01 00
1516 Assert . AreEqual ( "BgEA" , encodedB64 ) ;
1617 }
1718 [ TestMethod , Description ( "Test if at least two arcs are required." ) ]
@@ -20,20 +21,66 @@ public void TestMinStringLengthDecode() {
2021 var oid = new Asn1ObjectIdentifier ( rawData ) ;
2122 Assert . AreEqual ( "0.0" , oid . Value . Value ) ;
2223 String encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
24+ // must be 06 01 00
2325 Assert . AreEqual ( "BgEA" , encodedB64 ) ;
2426 }
2527 [ TestMethod , Description ( "Test if single arc encoding fails." ) ]
2628 [ ExpectedException ( typeof ( InvalidDataException ) ) ]
2729 public void TestSingleArcEncodeFail ( ) {
2830 new Asn1ObjectIdentifier ( "0" ) ;
2931 }
30- [ TestMethod , Description ( "Test if 2nd arc under 'ITU ' root node encoded up to 39." ) ]
32+ [ TestMethod , Description ( "Test if 2nd arc under 'itu-t ' root node encoded up to 39." ) ]
3133 public void TestItuRootArcConstraintsPass ( ) {
32- new Asn1ObjectIdentifier ( "1 .39" ) ;
34+ new Asn1ObjectIdentifier ( "0 .39" ) ;
3335 }
34- [ TestMethod , Description ( "Test if 2nd arc under 'ITU ' root node >39 fails." ) ]
36+ [ TestMethod , Description ( "Test if 2nd arc under 'itu-t ' root node >39 fails." ) ]
3537 [ ExpectedException ( typeof ( InvalidDataException ) ) ]
3638 public void TestItuRootArcConstraintsFail ( ) {
39+ new Asn1ObjectIdentifier ( "0.40" ) ;
40+ }
41+ [ TestMethod , Description ( "Test if 2nd arc under 'iso' root node encoded up to 39." ) ]
42+ public void TestIsoRootArcConstraintsPass ( ) {
43+ new Asn1ObjectIdentifier ( "1.39" ) ;
44+ }
45+ [ TestMethod , Description ( "Test if 2nd arc under 'iso' root node >39 fails." ) ]
46+ [ ExpectedException ( typeof ( InvalidDataException ) ) ]
47+ public void TestIsoRootArcConstraintsFail ( ) {
3748 new Asn1ObjectIdentifier ( "1.40" ) ;
3849 }
50+ [ TestMethod , Description ( "Test if 2nd arc under 'joint-iso-itu-t' root do not impose 2nd arc limits." ) ]
51+ public void TestJointIsoItuRootArcPass ( ) {
52+ new Asn1ObjectIdentifier ( "2.40" ) ;
53+ }
54+ [ TestMethod , Description ( "Test if first first two arcs can span multiple bytes if first byte >= 128" ) ]
55+ public void TestLargeTopArcs ( ) {
56+ var oid = new Asn1ObjectIdentifier ( "2.999" ) ;
57+ String encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
58+ // must be 06 02 88 37
59+ Assert . AreEqual ( "BgKINw==" , encodedB64 ) ;
60+
61+ oid = new Asn1ObjectIdentifier ( "2.999.3" ) ;
62+ encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
63+ // must be 06 03 88 37 03
64+ Assert . AreEqual ( "BgOINwM=" , encodedB64 ) ;
65+
66+ oid = new Asn1ObjectIdentifier ( "2.251.9.121" ) ;
67+ encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
68+ // must be 06 04 82 4B 09 79
69+ Assert . AreEqual ( "BgSCSwl5" , encodedB64 ) ;
70+
71+ oid = new Asn1ObjectIdentifier ( "2.999.1234" ) ;
72+ encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
73+ // must be 06 04 88 37 89 52
74+ Assert . AreEqual ( "BgSIN4lS" , encodedB64 ) ;
75+
76+ oid = new Asn1ObjectIdentifier ( "2.176.9.121" ) ;
77+ encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
78+ // must be 06 04 82 00 09 79
79+ Assert . AreEqual ( "BgSCAAl5" , encodedB64 ) ;
80+
81+ oid = new Asn1ObjectIdentifier ( "2.81.0.9.121" ) ;
82+ encodedB64 = Convert . ToBase64String ( oid . GetRawData ( ) ) ;
83+ // must be 06 04 79 00 09 79
84+ Assert . AreEqual ( "BgWBIQAJeQ==" , encodedB64 ) ;
85+ }
3986}
0 commit comments