Module: Net::BER::BERParser
- Included in:
- IO, OpenSSL::SSL::SSLSocket, String, StringIO
- Defined in:
- lib/net/ber/ber_parser.rb
Overview
Implements Basic Encoding Rules parsing to be mixed into types as needed.
Constant Summary collapse
- BuiltinSyntax =
The universal, built-in ASN.1 BER syntax.
Net::BER.compile_syntax(:universal => universal, :context_specific => context)
Instance Method Summary collapse
-
#read_ber(syntax = nil) {|id, content_length| ... } ⇒ Object
Reads a BER object from the including object.
Instance Method Details
#read_ber(syntax = nil) {|id, content_length| ... } ⇒ Object
Reads a BER object from the including object. Requires that #getbyte is implemented on the including object and that it returns a Fixnum value. Also requires #read(bytes) to work.
Yields the object type ‘id` and the data `content_length` if a block is given. This is namely to support instrumentation.
This does not work with non-blocking I/O.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/net/ber/ber_parser.rb', line 164 def read_ber(syntax = nil) # TODO: clean this up so it works properly with partial packets coming # from streams that don't block when we ask for more data (like # StringIOs). At it is, this can throw TypeErrors and other nasties. id = getbyte or return nil # don't trash this value, we'll use it later content_length = read_ber_length yield id, content_length if block_given? if -1 == content_length raise Net::BER::BerError, "Indeterminite BER content length not implemented." else data = read(content_length) end parse_ber_object(syntax, id, data) end |