Class: RASN1::Types::ObjectId
- Defined in:
- lib/rasn1/types/object_id.rb
Overview
ASN.1 Object ID
Constant Summary collapse
- ID =
ObjectId id value
6
Constants inherited from Primitive
Constants inherited from Base
Base::CLASSES, Base::CLASS_MASK, Base::INDEFINITE_LENGTH, Base::MULTI_OCTETS_ID
Instance Attribute Summary
Attributes inherited from Base
#asn1_class, #default, #name, #options
Instance Method Summary collapse
-
#der_to_value(der, ber: false) ⇒ void
Make object id value from
der
string.
Methods inherited from Base
#==, #can_build?, constrained?, #constructed?, #do_parse, #do_parse_explicit, #do_parse_explicit_with_tracing, #do_parse_with_tracing, encoded_type, #explicit?, #id, #implicit?, #initialize, #initialize_copy, #inspect, #optional?, parse, #parse!, #primitive?, #specific_initializer, start_tracing, stop_tracing, #tagged?, #to_der, #trace, #type, type, #value, #value=, #value?, #value_size, #void_value
Constructor Details
This class inherits a constructor from RASN1::Types::Base
Instance Method Details
#der_to_value(der, ber: false) ⇒ void
This method returns an undefined value.
Make object id value from der
string
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rasn1/types/object_id.rb', line 16 def der_to_value(der, ber: false) # rubocop:disable Lint/UnusedMethodArgument bytes = der.unpack('C*') ids = [] current_id = 0 bytes.each do |byte| current_id = (current_id << 7) | (byte & 0x7f) if byte.nobits?(0x80) ids << current_id current_id = 0 end end first_id = [2, ids.first / 40].min second_id = ids.first - first_id * 40 ids[0..0] = [first_id, second_id] @value = ids.join('.') end |