Skip to content

OpenSSL::ASN1::BitString#to_der fails to respect unused_bits #323

Closed
@segiddins

Description

@segiddins
#!/usr/bin/env ruby

puts RUBY_ENGINE

require "rubygems"
require "openssl"
require "base64"

asn = "\x00\x04".b
asn.prepend "\x03#{asn.bytesize.chr}"
pp asn
bs = OpenSSL::ASN1.decode(asn)
pp bs
pp bs.to_der

raise unless bs.to_der == asn

on mri

"\x03\x02\x00\x04"
#<OpenSSL::ASN1::BitString:0x000000011eac7758
 @indefinite_length=false,
 @tag=3,
 @tag_class=:UNIVERSAL,
 @tagging=nil,
 @unused_bits=0,
 @value="\x04">
"\x03\x02\x00\x04"

on jruby

"\u0003\u0002\u0000\u0004"
#<OpenSSL::ASN1::BitString:0xdbda472
 @indefinite_length=false,
 @tag=3,
 @tag_class=:UNIVERSAL,
 @tagging=nil,
 @unused_bits=0,
 @value="\x04">
"\x03\x02\x02\x04"
RuntimeError: No current exception
  <main> at Untitled 3.rb:16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions