diff options
author | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-23 01:01:49 +0000 |
---|---|---|
committer | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-23 01:01:49 +0000 |
commit | 5b3dd70232ae9dc6b67001921374120ab168376e (patch) | |
tree | cdc3f65feea040853ff4a27b553fb5a91ed3f974 /test/openssl | |
parent | 1cb6879c824994df47fde9efcc3b542d5a349f70 (diff) |
* ext/openssl/ossl_asn1.c: Do not parse zero-tagged values as EOC. Do
not let current length become negative for infinite length constructed
values. Support constructed values of length zero. Added tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl')
-rw-r--r-- | test/openssl/test_asn1.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb index 0122e0fdcb..31fd2c3251 100644 --- a/test/openssl/test_asn1.rb +++ b/test/openssl/test_asn1.rb @@ -266,6 +266,31 @@ class OpenSSL::TestASN1 < Test::Unit::TestCase end end + def test_parse_empty_sequence + expected = %w{ A0 07 30 02 30 00 02 01 00 } + raw = [expected.join('')].pack('H*') + asn1 = OpenSSL::ASN1.decode(raw) + assert_equal(raw, asn1.to_der) + assert_equal(2, asn1.value.size) + seq = asn1.value[0] + assert_equal(1, seq.value.size) + inner_seq = seq.value[0] + assert_equal(0, inner_seq.value.size) + end + + def test_parse_tagged_0_infinite + expected = %w{ 30 80 02 01 01 80 01 02 00 00 } + raw = [expected.join('')].pack('H*') + asn1 = OpenSSL::ASN1.decode(raw) + assert_equal(3, asn1.value.size) + int = asn1.value[0] + assert_universal(OpenSSL::ASN1::INTEGER, int) + tagged = asn1.value[1] + assert_equal(0, tagged.tag) + assert_universal(OpenSSL::ASN1::EOC, asn1.value[2]) + assert_equal(raw, asn1.to_der) + end + def test_seq_infinite_length begin content = [ OpenSSL::ASN1::Null.new(nil), |