Class: MIFARE::DESFire::KEY_SETTING

Inherits:
Struct
  • Object
show all
Defined in:
lib/mifare/des_fire.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKEY_SETTING

Returns a new instance of KEY_SETTING.



89
90
91
92
93
94
95
96
# File 'lib/mifare/des_fire.rb', line 89

def initialize(*)
  super
  self.privileged_key = 0 if self.privileged_key.nil?
  self.masterkey_changeable = true if self.masterkey_changeable.nil?
  self.file_management_without_auth = true if self.file_management_without_auth.nil?
  self.file_configurable_without_auth = true if self.file_configurable_without_auth.nil?
  self.key_setting_changeable = true if self.key_setting_changeable.nil?
end

Instance Attribute Details

#file_configurable_without_authObject

Returns the value of attribute file_configurable_without_auth

Returns:

  • (Object)

    the current value of file_configurable_without_auth



73
74
75
# File 'lib/mifare/des_fire.rb', line 73

def file_configurable_without_auth
  @file_configurable_without_auth
end

#file_management_without_authObject

Returns the value of attribute file_management_without_auth

Returns:

  • (Object)

    the current value of file_management_without_auth



73
74
75
# File 'lib/mifare/des_fire.rb', line 73

def file_management_without_auth
  @file_management_without_auth
end

#key_setting_changeableObject

Returns the value of attribute key_setting_changeable

Returns:

  • (Object)

    the current value of key_setting_changeable



73
74
75
# File 'lib/mifare/des_fire.rb', line 73

def key_setting_changeable
  @key_setting_changeable
end

#masterkey_changeableObject

Returns the value of attribute masterkey_changeable

Returns:

  • (Object)

    the current value of masterkey_changeable



73
74
75
# File 'lib/mifare/des_fire.rb', line 73

def masterkey_changeable
  @masterkey_changeable
end

#privileged_keyObject

Returns the value of attribute privileged_key

Returns:

  • (Object)

    the current value of privileged_key



73
74
75
# File 'lib/mifare/des_fire.rb', line 73

def privileged_key
  @privileged_key
end

Class Method Details

.import(byte) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/mifare/des_fire.rb', line 98

def self.import(byte)
  self.new(
    (byte >> 4) & 0x0F,
    byte & 0x01 != 0,
    byte & 0x02 != 0,
    byte & 0x04 != 0,
    byte & 0x08 != 0
  )
end

Instance Method Details

#exportObject



108
109
110
111
112
113
114
115
# File 'lib/mifare/des_fire.rb', line 108

def export
  output = (self.privileged_key << 4)
  output |= 0x01 if self.masterkey_changeable
  output |= 0x02 if self.file_management_without_auth
  output |= 0x04 if self.file_configurable_without_auth
  output |= 0x08 if self.key_setting_changeable
  output
end