aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_asn1.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-01-14 19:48:00 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-07-23 13:32:35 +0900
commite61502fb82084937160f4ffa0bda89f4c6788d6d (patch)
treeadb1bc19efdb595e77820a8708ce240df98b389b /test/test_asn1.rb
parent7df19c3f287940fca3bc8df0f2418e5c7199261e (diff)
downloadruby-openssl-e61502fb82084937160f4ffa0bda89f4c6788d6d.tar.gz
asn1: check for illegal 'unused_bits' value of BitString
Invalid values such as nil or values not in the range 0 to 7 are silently coerced into the valid range. This behavior is confusing and hides user bugs. Raise an exception instead if an illegal value is specified.
Diffstat (limited to 'test/test_asn1.rb')
-rw-r--r--test/test_asn1.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/test_asn1.rb b/test/test_asn1.rb
index a18e8dd8..e98b9202 100644
--- a/test/test_asn1.rb
+++ b/test/test_asn1.rb
@@ -271,6 +271,11 @@ class OpenSSL::TestASN1 < OpenSSL::TestCase
# assert_raise(OpenSSL::ASN1::ASN1Error) {
# OpenSSL::ASN1.decode(B(%w{ 03 01 04 }))
# }
+ assert_raise(OpenSSL::ASN1::ASN1Error) {
+ obj = OpenSSL::ASN1::BitString.new(B(%w{ FF FF }))
+ obj.unused_bits = 8
+ obj.to_der
+ }
end
def test_string_basic