@@ -620,61 +620,46 @@ def test_prim_implicit_tagging
620620 encode_test B ( %w{ 80 01 01 } ) , int
621621 int2 = OpenSSL ::ASN1 ::Integer . new ( 1 , 1 , :IMPLICIT , :APPLICATION )
622622 encode_test B ( %w{ 41 01 01 } ) , int2
623- #decoded = OpenSSL::ASN1.decode(int2.to_der)
624- # <:APPLICATION> expected but was <:UNIVERSAL>
625- #assert_equal :APPLICATION, decoded.tag_class
626- # <1> expected but was <2>
627- #assert_equal 1, decoded.tag
628- # <"\x01"> expected but was <#<OpenSSL::BN 1>>
629- #assert_equal B(%w{ 01 }), decoded.value
630-
631- # Special behavior: Encoding universal types with non-default 'tag'
632- # attribute and nil tagging method.
633- #int3 = OpenSSL::ASN1::Integer.new(1, 1)
634- # <"\x01\x01\x01"> expected but was <"\x02\x01\x01">
635- #encode_test B(%w{ 01 01 01 }), int3
623+ decoded = OpenSSL ::ASN1 . decode ( int2 . to_der )
624+ assert_equal :APPLICATION , decoded . tag_class
625+ assert_equal 1 , decoded . tag
626+ assert_equal B ( %w{ 01 } ) , decoded . value
627+
628+ # Special behavior: Encoding universal types with non-default 'tag' attribute and nil tagging method.
629+ int3 = OpenSSL ::ASN1 ::Integer . new ( 1 , 1 )
630+ encode_test B ( %w{ 01 01 01 } ) , int3
636631 end
637632
638633 def test_cons_explicit_tagging
639- #content = [ OpenSSL::ASN1::PrintableString.new('abc') ]
640- #seq = OpenSSL::ASN1::Sequence.new(content, 2, :EXPLICIT)
641- # TODO: Import Issue
642- # RuntimeError: No message available
643- #encode_test B(%w{ A2 07 30 05 13 03 61 62 63 }), seq
644- #seq2 = OpenSSL::ASN1::Sequence.new(content, 3, :EXPLICIT, :APPLICATION)
645- # RuntimeError: No message available
646- #encode_test B(%w{ 63 07 30 05 13 03 61 62 63 }), seq2
647-
648- #content3 = [ OpenSSL::ASN1::PrintableString.new('abc'),
649- # OpenSSL::ASN1::EndOfContent.new() ]
650- #seq3 = OpenSSL::ASN1::Sequence.new(content3, 2, :EXPLICIT)
651- #seq3.indefinite_length = true
652- # RuntimeError: No message available
653- #encode_test B(%w{ A2 80 30 80 13 03 61 62 63 00 00 00 00 }), seq3
634+ content = [ OpenSSL ::ASN1 ::PrintableString . new ( 'abc' ) ]
635+ seq = OpenSSL ::ASN1 ::Sequence . new ( content , 2 , :EXPLICIT )
636+ encode_test B ( %w{ A2 07 30 05 13 03 61 62 63 } ) , seq
637+ seq2 = OpenSSL ::ASN1 ::Sequence . new ( content , 3 , :EXPLICIT , :APPLICATION )
638+ encode_test B ( %w{ 63 07 30 05 13 03 61 62 63 } ) , seq2
639+
640+ content3 = [ OpenSSL ::ASN1 ::PrintableString . new ( 'abc' ) ,
641+ OpenSSL ::ASN1 ::EndOfContent . new ( ) ]
642+ seq3 = OpenSSL ::ASN1 ::Sequence . new ( content3 , 2 , :EXPLICIT )
643+ seq3 . indefinite_length = true
644+ encode_test B ( %w{ A2 80 30 80 13 03 61 62 63 00 00 00 00 } ) , seq3
654645 end
655646
656647 def test_cons_implicit_tagging
657- #content = [ OpenSSL::ASN1::Null.new(nil) ]
658- #seq = OpenSSL::ASN1::Sequence.new(content, 1, :IMPLICIT)
659- # TODO: Import Issue
660- # <"\xA1\x02\x05\x00"> expected but was <"0\x02\x05\x00">
661- #encode_test B(%w{ A1 02 05 00 }), seq
662- #seq2 = OpenSSL::ASN1::Sequence.new(content, 1, :IMPLICIT, :APPLICATION)
663- # <"a\x02\x05\x00"> expected but was <"0\x02\x05\x00">
664- #encode_test B(%w{ 61 02 05 00 }), seq2
665-
666- #content3 = [ OpenSSL::ASN1::Null.new(nil),
667- # OpenSSL::ASN1::EndOfContent.new() ]
668- #seq3 = OpenSSL::ASN1::Sequence.new(content3, 1, :IMPLICIT)
669- #seq3.indefinite_length = true
670- # <"\xA1\x80\x05\x00\x00\x00"> expected but was <"0\x80\x05\x00\x00\x00">
671- #encode_test B(%w{ A1 80 05 00 00 00 }), seq3
672-
673- # Special behavior: Encoding universal types with non-default 'tag'
674- # attribute and nil tagging method.
675- #seq4 = OpenSSL::ASN1::Sequence.new([], 1)
676- # <"!\x00"> expected but was <"0\x00">
677- #encode_test B(%w{ 21 00 }), seq4
648+ content = [ OpenSSL ::ASN1 ::Null . new ( nil ) ]
649+ seq = OpenSSL ::ASN1 ::Sequence . new ( content , 1 , :IMPLICIT )
650+ encode_test B ( %w{ A1 02 05 00 } ) , seq
651+ seq2 = OpenSSL ::ASN1 ::Sequence . new ( content , 1 , :IMPLICIT , :APPLICATION )
652+ encode_test B ( %w{ 61 02 05 00 } ) , seq2
653+
654+ content3 = [ OpenSSL ::ASN1 ::Null . new ( nil ) ,
655+ OpenSSL ::ASN1 ::EndOfContent . new ( ) ]
656+ seq3 = OpenSSL ::ASN1 ::Sequence . new ( content3 , 1 , :IMPLICIT )
657+ seq3 . indefinite_length = true
658+ encode_test B ( %w{ A1 80 05 00 00 00 } ) , seq3
659+
660+ # Special behavior: Encoding universal types with non-default 'tag' attribute and nil tagging method.
661+ seq4 = OpenSSL ::ASN1 ::Sequence . new ( [ ] , 1 )
662+ encode_test B ( %w{ 21 00 } ) , seq4
678663 end
679664
680665 def test_octet_string_constructed_tagging
0 commit comments