@@ -1341,7 +1341,20 @@ boolean isEOC() {
13411341 boolean isImplicitTagging () { return true ; }
13421342
13431343 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
13451358 }
13461359
13471360 ASN1Encodable toASN1 (final ThreadContext context ) {
@@ -1775,8 +1788,7 @@ private boolean isInfiniteLength() {
17751788 @ Override
17761789 boolean isExplicitTagging () {
17771790 IRubyObject tagging = getInstanceVariable ("@tagging" );
1778- if ( tagging .isNil () ) return true ;
1779- return "EXPLICIT" .equals ( tagging .toString () );
1791+ return tagging .isNil () || "EXPLICIT" .equals ( tagging .toString () );
17801792 }
17811793
17821794 @ Override
@@ -1830,22 +1842,21 @@ byte[] toDER(final ThreadContext context) throws IOException {
18301842 if ( isSequence () ) {
18311843 return sequenceToDER (context );
18321844 }
1833- else if ( isSet () ) {
1845+ if ( isSet () ) {
18341846 return setToDER (context );
18351847 }
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 );
18481858 }
1859+ throw new UnsupportedOperationException ( this .inspect ().toString () );
18491860 }
18501861
18511862 return super .toDER (context );
0 commit comments