Class: SshTresor::SSHEncoding::Reader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_tresor/ssh_encoding.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Sequential reader for SSH wire values.

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Reader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Reader.

Parameters:

  • data (String)

    binary SSH wire data.



37
38
39
40
# File 'lib/ssh_tresor/ssh_encoding.rb', line 37

def initialize(data)
  @data = data.b
  @offset = 0
end

Instance Method Details

#byteInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns next byte value.

Returns:

  • (Integer)

    next byte value.



43
44
45
# File 'lib/ssh_tresor/ssh_encoding.rb', line 43

def byte
  read(1).getbyte(0)
end

#eof?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether the reader consumed all input.

Returns:

  • (Boolean)

    whether the reader consumed all input.



59
60
61
# File 'lib/ssh_tresor/ssh_encoding.rb', line 59

def eof?
  @offset == @data.bytesize
end

#stringString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns next SSH length-prefixed string.

Returns:

  • (String)

    next SSH length-prefixed string.



53
54
55
56
# File 'lib/ssh_tresor/ssh_encoding.rb', line 53

def string
  length = uint32
  read(length)
end

#uint32Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns next unsigned 32-bit integer.

Returns:

  • (Integer)

    next unsigned 32-bit integer.



48
49
50
# File 'lib/ssh_tresor/ssh_encoding.rb', line 48

def uint32
  read(4).unpack1("N")
end