File tree Expand file tree Collapse file tree 2 files changed +44
-8
lines changed
core/src/main/java/org/bouncycastle/asn1 Expand file tree Collapse file tree 2 files changed +44
-8
lines changed Original file line number Diff line number Diff line change @@ -166,11 +166,29 @@ public ASN1ObjectIdentifier branch(String branchID)
166166 {
167167 ASN1RelativeOID .checkIdentifier (branchID );
168168
169- byte [] branchContents = ASN1RelativeOID .parseIdentifier (branchID );
170- checkContentsLength (this .contents .length + branchContents .length );
169+ byte [] contents ;
170+ if (branchID .length () <= 2 )
171+ {
172+ checkContentsLength (this .contents .length + 1 );
173+ int subID = branchID .charAt (0 ) - '0' ;
174+ if (branchID .length () == 2 )
175+ {
176+ subID *= 10 ;
177+ subID += branchID .charAt (1 ) - '0' ;
178+ }
179+
180+ contents = Arrays .append (this .contents , (byte )subID );
181+ }
182+ else
183+ {
184+ byte [] branchContents = ASN1RelativeOID .parseIdentifier (branchID );
185+ checkContentsLength (this .contents .length + branchContents .length );
186+
187+ contents = Arrays .concatenate (this .contents , branchContents );
188+ }
171189
172- byte [] contents = Arrays . concatenate ( this . contents , branchContents );
173- String identifier = getId () + "." + branchID ;
190+ String rootID = getId ( );
191+ String identifier = rootID + "." + branchID ;
174192
175193 return new ASN1ObjectIdentifier (contents , identifier );
176194 }
Original file line number Diff line number Diff line change @@ -122,11 +122,29 @@ public ASN1RelativeOID branch(String branchID)
122122 {
123123 checkIdentifier (branchID );
124124
125- byte [] branchContents = parseIdentifier (branchID );
126- checkContentsLength (this .contents .length + branchContents .length );
125+ byte [] contents ;
126+ if (branchID .length () <= 2 )
127+ {
128+ checkContentsLength (this .contents .length + 1 );
129+ int subID = branchID .charAt (0 ) - '0' ;
130+ if (branchID .length () == 2 )
131+ {
132+ subID *= 10 ;
133+ subID += branchID .charAt (1 ) - '0' ;
134+ }
135+
136+ contents = Arrays .append (this .contents , (byte )subID );
137+ }
138+ else
139+ {
140+ byte [] branchContents = parseIdentifier (branchID );
141+ checkContentsLength (this .contents .length + branchContents .length );
142+
143+ contents = Arrays .concatenate (this .contents , branchContents );
144+ }
127145
128- byte [] contents = Arrays . concatenate ( this . contents , branchContents );
129- String identifier = getId () + "." + branchID ;
146+ String rootID = getId ( );
147+ String identifier = rootID + "." + branchID ;
130148
131149 return new ASN1RelativeOID (contents , identifier );
132150 }
You can’t perform that action at this time.
0 commit comments