Skip to content

Commit dead363

Browse files
forcing .chr conversion to binary encoding
it's US-ASCII for integers < 128
1 parent 3f28457 commit dead363

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/openssl/asn1.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def der_value
306306

307307
return "\x00" if @value.empty?
308308

309-
@unused_bits.chr << super
309+
@unused_bits.chr.force_encoding(Encoding::BINARY) << super
310310
end
311311
end
312312

@@ -356,7 +356,7 @@ def der_value
356356
dot_index = value.index(".")
357357

358358
if dot_index == value.size - 1
359-
return (value.to_i * 40).chr
359+
return (value.to_i * 40).chr.force_encoding(Encoding::BINARY)
360360
else
361361
codes = [value.byteslice(0..dot_index-1).to_i * 40]
362362
end
@@ -436,7 +436,7 @@ def put_object(constructed, indefinite_length, length, tag, tag_class)
436436
i |= (xclass & 0xc0) # PRIVATE
437437

438438
if tag < 31
439-
str = (i | tag).chr
439+
str = (i | tag).chr.force_encoding(Encoding::BINARY)
440440

441441
else
442442
str = [i | 0x1f, tag].pack("Cw")
@@ -453,7 +453,7 @@ def put_object(constructed, indefinite_length, length, tag, tag_class)
453453

454454
def put_length(length)
455455
if length < 0x80
456-
length.chr
456+
length.chr.force_encoding(Encoding::BINARY)
457457
else
458458
data = integer_to_octets(length)
459459
data.unshift(data.size | 0x80)

0 commit comments

Comments
 (0)