Skip to content

Commit db1894a

Browse files
author
blackhedd
committed
Added Array#to_ber_oid.
1 parent 65b446c commit db1894a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/net/ber.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,16 @@ def to_ber_seq_internal code
472472
[code].pack('C') + s.length.to_ber_length_encoding + s
473473
end
474474

475+
def to_ber_oid
476+
ary = self.dup
477+
first = ary.shift
478+
raise Net::BER::BerError.new( "invalid OID" ) unless [0,1,2].include?(first)
479+
first = first * 40 + ary.shift
480+
ary.unshift first
481+
oid = ary.pack("w*")
482+
[6, oid.length].pack("CC") + oid
483+
end
484+
475485
end # class Array
476486

477487

0 commit comments

Comments
 (0)