Skip to content

Commit 22a944f

Browse files
committed
asn1: allow tag number to be >= 32 for universal tag class
There are actually high-tag universal types such as the time-of-day type.
1 parent a2b32a4 commit 22a944f

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

ext/openssl/ossl_asn1.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,6 @@ ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
661661
{
662662
if(!SYMBOL_P(tag_class))
663663
ossl_raise(eASN1Error, "invalid tag class");
664-
if (tag_class == sym_UNIVERSAL && NUM2INT(tag) > 31)
665-
ossl_raise(eASN1Error, "tag number for Universal too large");
666664
ossl_asn1_set_tag(self, tag);
667665
ossl_asn1_set_value(self, value);
668666
ossl_asn1_set_tag_class(self, tag_class);
@@ -1085,8 +1083,6 @@ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
10851083
}
10861084
if(!SYMBOL_P(tag_class))
10871085
ossl_raise(eASN1Error, "invalid tag class");
1088-
if (tagging == sym_IMPLICIT && NUM2INT(tag) > 31)
1089-
ossl_raise(eASN1Error, "tag number for Universal too large");
10901086
}
10911087
else{
10921088
tag = INT2NUM(default_tag);

test/test_asn1.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ def test_basic_asn1data
416416
encode_decode_test B(%w{ 41 00 }), OpenSSL::ASN1::ASN1Data.new(B(%w{}), 1, :APPLICATION)
417417
encode_decode_test B(%w{ 81 00 }), OpenSSL::ASN1::ASN1Data.new(B(%w{}), 1, :CONTEXT_SPECIFIC)
418418
encode_decode_test B(%w{ C1 00 }), OpenSSL::ASN1::ASN1Data.new(B(%w{}), 1, :PRIVATE)
419+
encode_decode_test B(%w{ 1F 20 00 }), OpenSSL::ASN1::ASN1Data.new(B(%w{}), 32, :UNIVERSAL)
420+
encode_decode_test B(%w{ 1F C0 20 00 }), OpenSSL::ASN1::ASN1Data.new(B(%w{}), 8224, :UNIVERSAL)
419421
encode_decode_test B(%w{ 41 02 AB CD }), OpenSSL::ASN1::ASN1Data.new(B(%w{ AB CD }), 1, :APPLICATION)
420422
encode_decode_test B(%w{ 41 81 80 } + %w{ AB CD } * 64), OpenSSL::ASN1::ASN1Data.new(B(%w{ AB CD } * 64), 1, :APPLICATION)
421423
encode_decode_test B(%w{ 41 82 01 00 } + %w{ AB CD } * 128), OpenSSL::ASN1::ASN1Data.new(B(%w{ AB CD } * 128), 1, :APPLICATION)

0 commit comments

Comments
 (0)