Module: KRB5::Mixin::Packer

Included in:
Entry, Keytab, Principal
Defined in:
lib/krb5/mixin/packer.rb

Instance Method Summary collapse

Instance Method Details

#pack_bytes(data) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/krb5/mixin/packer.rb', line 19

def pack_bytes(data)
  @bytes ||= []

  if data.is_a?(Array)
    @bytes += data
  elsif data.is_a?(String)
    @bytes << data
  end
end

#pack_data(data) ⇒ String

Generic method to pack Kerberos data

data ::=

length (16 bits)
value (length bytes)

See: web.mit.edu/kerberos/krb5-1.16/doc/formats/keytab_file_format.html

Returns:

  • (String)


14
15
16
17
# File 'lib/krb5/mixin/packer.rb', line 14

def pack_data(data)
  pack_int16(data.length)
  pack_bytes(data)
end

#pack_int16(data) ⇒ Object



35
36
37
38
39
# File 'lib/krb5/mixin/packer.rb', line 35

def pack_int16(data)
  @bytes ||= []

  @bytes << [data].pack('s>')
end

#pack_int32(data) ⇒ Object



41
42
43
44
45
# File 'lib/krb5/mixin/packer.rb', line 41

def pack_int32(data)
  @bytes ||= []

  @bytes << [data].pack('l>')
end

#pack_int8(data) ⇒ Object



29
30
31
32
33
# File 'lib/krb5/mixin/packer.rb', line 29

def pack_int8(data)
  @bytes ||= []

  @bytes << [data].pack('c')
end