Class: RASN1::Types::ObjectId
- Defined in:
- lib/rasn1/types/object_id.rb
Overview
ASN.1 Object ID
An OBJECT ID provides unique identifiers.
Object Id are shown as numbered dotted strings, like 0.1.2.1256.1. First number is in range [0-2], the second in range [0-39]. Others are not limited.
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
derstring.
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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rasn1/types/object_id.rb', line 31 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 |