@@ -1341,7 +1341,20 @@ boolean isEOC() {
1341
1341
boolean isImplicitTagging () { return true ; }
1342
1342
1343
1343
int getTag (final ThreadContext context ) {
1344
- return RubyNumeric .fix2int (callMethod (context , "tag" ));
1344
+ return RubyNumeric .fix2int (getInstanceVariable ("@tag" ));
1345
+ }
1346
+
1347
+ int getTagClass (final ThreadContext context ) {
1348
+ IRubyObject tag_class = getInstanceVariable ("@tag_class" );
1349
+ if (tag_class instanceof RubySymbol ) {
1350
+ if ("APPLICATION" .equals (tag_class .toString ())) {
1351
+ return BERTags .APPLICATION ;
1352
+ }
1353
+ if ("CONTEXT_SPECIFIC" .equals (tag_class .toString ())) {
1354
+ return BERTags .CONTEXT_SPECIFIC ;
1355
+ }
1356
+ }
1357
+ return BERTags .UNIVERSAL ; // 0
1345
1358
}
1346
1359
1347
1360
ASN1Encodable toASN1 (final ThreadContext context ) {
@@ -1775,8 +1788,7 @@ private boolean isInfiniteLength() {
1775
1788
@ Override
1776
1789
boolean isExplicitTagging () {
1777
1790
IRubyObject tagging = getInstanceVariable ("@tagging" );
1778
- if ( tagging .isNil () ) return true ;
1779
- return "EXPLICIT" .equals ( tagging .toString () );
1791
+ return tagging .isNil () || "EXPLICIT" .equals ( tagging .toString () );
1780
1792
}
1781
1793
1782
1794
@ Override
@@ -1830,22 +1842,21 @@ byte[] toDER(final ThreadContext context) throws IOException {
1830
1842
if ( isSequence () ) {
1831
1843
return sequenceToDER (context );
1832
1844
}
1833
- else if ( isSet () ) {
1845
+ if ( isSet () ) {
1834
1846
return setToDER (context );
1835
1847
}
1836
- else { // "raw" Constructive
1837
- switch ( getTag (context ) ) {
1838
- case OCTET_STRING :
1839
- return octetStringToDER (context );
1840
- case BIT_STRING :
1841
- return bitStringToDER (context );
1842
- case SEQUENCE :
1843
- return sequenceToDER (context );
1844
- case SET :
1845
- return setToDER (context );
1846
- }
1847
- throw new UnsupportedOperationException ( this .inspect ().toString () );
1848
+ // "raw" Constructive
1849
+ switch ( getTag (context ) ) {
1850
+ case OCTET_STRING :
1851
+ return octetStringToDER (context );
1852
+ case BIT_STRING :
1853
+ return bitStringToDER (context );
1854
+ case SEQUENCE :
1855
+ return sequenceToDER (context );
1856
+ case SET :
1857
+ return setToDER (context );
1848
1858
}
1859
+ throw new UnsupportedOperationException ( this .inspect ().toString () );
1849
1860
}
1850
1861
1851
1862
return super .toDER (context );
0 commit comments