File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
main/java/org/bouncycastle/asn1
test/java/org/bouncycastle/asn1/test Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 77import java .util .concurrent .ConcurrentMap ;
88
99import org .bouncycastle .util .Arrays ;
10+ import org .bouncycastle .util .Properties ;
1011
1112public class ASN1RelativeOID
1213 extends ASN1Primitive
@@ -254,7 +255,12 @@ static boolean isValidContents(byte[] contents)
254255 for (int i = 0 ; i < contents .length ; ++i )
255256 {
256257 if (subIDStart && (contents [i ] & 0xff ) == 0x80 )
257- return false ;
258+ {
259+ if (!Properties .isOverrideSet ("org.bouncycastle.asn1.allow_wrong_oid_enc" ))
260+ {
261+ return false ;
262+ }
263+ }
258264
259265 subIDStart = (contents [i ] & 0x80 ) == 0 ;
260266 }
Original file line number Diff line number Diff line change 11package org .bouncycastle .asn1 .test ;
22
33import org .bouncycastle .asn1 .ASN1ObjectIdentifier ;
4+ import org .bouncycastle .util .encoders .Hex ;
45import org .bouncycastle .util .test .SimpleTest ;
56import org .bouncycastle .util .test .TestResult ;
67
@@ -24,7 +25,24 @@ public void performTest()
2425 {
2526 isEquals ("invalid OID contents" , e .getMessage ());
2627 }
27-
28+
29+ byte [] faultyOID = Hex .decode ("06092A864886FC6B048000" );
30+ try
31+ {
32+ ASN1ObjectIdentifier .getInstance (faultyOID );
33+ fail ("no exception" );
34+ }
35+ catch (Exception e )
36+ {
37+ isEquals ("failed to construct object identifier from byte[]: invalid OID contents" , e .getMessage ());
38+ }
39+
40+ System .setProperty ("org.bouncycastle.asn1.allow_wrong_oid_enc" , "true" );
41+ String oid = ASN1ObjectIdentifier .getInstance (faultyOID ).getId ();
42+
43+ System .clearProperty ("org.bouncycastle.asn1.allow_wrong_oid_enc" );
44+ isEquals ("1.2.840.114283.4.0" , oid );
45+
2846 // exercise the object cache
2947 for (int i = 0 ; i < 100 ; i ++)
3048 {
You can’t perform that action at this time.
0 commit comments