mfrc522 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec95f072c266803e40c9178fba2435c8f113d5ab
4
- data.tar.gz: 98eb6c503409371dcb7e25f7e61f02494c5c13b4
3
+ metadata.gz: 75d391fefaa44340237f219a9292de10b030f321
4
+ data.tar.gz: 9574c355eb6ccb2abb83930e064b0fe73cd52900
5
5
  SHA512:
6
- metadata.gz: 23304b26becaed10dc250a013bc5a098894e9ce03f688986ca9fd403897bdf4472603aba2f7bc216bb26732a70c515c5f302c656e559a4fc2e6e51f5a8ec68a3
7
- data.tar.gz: b8afd661c9ed6e8e898716e5c91bbfee19d373bb1287822f12fa8f42890d42e1cce1fc844312e312a52724a1f97ca58c5a53ad85215e12ac7931e12cd797cf88
6
+ metadata.gz: 0d46681cb3ad8bd8fa0b02e9c11c946d90e67e8eb7426da22242d5f3360cd7309b573b00285d0067c057ea98f805dd5d214f305ddd7987c76ca3ed0e92617dea
7
+ data.tar.gz: e814a5f7d9e10675d19f4f69d2d6e5de7c6ee95ec73085adf65ac990329b10b7341529c97b34c6608138d1869e1836fa7465f36dd7ed053c81fa2479f05b67b9
@@ -156,7 +156,7 @@ class ISO144434 < PICC
156
156
 
157
157
  fsci = t0 & 0x0F # PICC buffer size integer
158
158
  y1 = (t0 >> 4) & 0x07 # Optional frame(TA, TB, TC) indicator
159
- @fsc = FSCI_to_FSC[fsci] # Convert buffer size integer to bytes
159
+ @fsc = FSCI_to_FSC.fetch(fsci) # Convert buffer size integer to bytes
160
160
  dr = 0 # default baud rate 106kBd
161
161
  ds = 0
162
162
 
@@ -115,7 +115,7 @@ module Mifare
115
115
  linear_record_file: 0x03, cyclic_record_file: 0x04
116
116
  }
117
117
 
118
- FILE_ENCRYPTION = {plain: 0x00, mac: 0x01, encrypt: 0x03}
118
+ FILE_COMMUNICATION = {plain: 0x00, mac: 0x01, encrypt: 0x03}
119
119
 
120
120
  # value 0x00 ~ 0x0D are key numbers, 0x0E grants free access, 0x0F always denies access
121
121
  FILE_PERMISSION = Struct.new(:read_access, :write_access, :read_write_access, :change_access) do
@@ -134,7 +134,7 @@ module Mifare
134
134
 
135
135
  FILE_SETTING = Struct.new(
136
136
  :type,
137
- :encryption,
137
+ :communication,
138
138
  :permission,
139
139
  # Data file only
140
140
  :size,
@@ -381,7 +381,7 @@ module Mifare
381
381
  same_key = (key_number == @authed)
382
382
 
383
383
  # Only Master Key can change its key type
384
- key_number |= KEY_TYPE[new_key.cipher_suite] if @selected_app == 0
384
+ key_number |= KEY_TYPE.fetch(new_key.cipher_suite) if @selected_app == 0
385
385
 
386
386
  # XOR new key if we're using different one
387
387
  unless same_key
@@ -435,7 +435,7 @@ module Mifare
435
435
 
436
436
  file_setting = FILE_SETTING.new
437
437
  file_setting.type = FILE_TYPE.key(received_data.shift)
438
- file_setting.encryption = FILE_ENCRYPTION.key(received_data.shift)
438
+ file_setting.communication = FILE_COMMUNICATION.key(received_data.shift)
439
439
  file_setting.permission = FILE_PERMISSION.new.import(received_data.shift(2).to_uint)
440
440
 
441
441
  case file_setting.type
@@ -457,7 +457,7 @@ module Mifare
457
457
 
458
458
  def change_file_setting(id, file_setting)
459
459
  buffer = []
460
- buffer.append_uint(FILE_ENCRYPTION[file_setting.encryption], 1)
460
+ buffer.append_uint(FILE_COMMUNICATION.fetch(file_setting.communication), 1)
461
461
  buffer.append_uint(file_setting.permission.to_uint, 2)
462
462
 
463
463
  transceive(cmd: CMD_CHANGE_FILE_SETTING, plain_data: id, data: buffer, tx: :encrypt, rx: :cmac, expect: ST_SUCCESS)
@@ -465,7 +465,7 @@ module Mifare
465
465
 
466
466
  def create_file(id, file_setting)
467
467
  buffer = [id]
468
- buffer.append_uint(FILE_ENCRYPTION[file_setting.encryption], 1)
468
+ buffer.append_uint(FILE_COMMUNICATION.fetch(file_setting.communication), 1)
469
469
  buffer.append_uint(file_setting.permission.to_uint, 2)
470
470
 
471
471
  case file_setting.type
@@ -493,12 +493,12 @@ module Mifare
493
493
  def read_file(id, cmd, data, length)
494
494
  file_setting = get_file_setting(id)
495
495
  length *= file_setting.record_size if file_setting.record_size
496
- transceive(cmd: cmd, data: data, tx: :cmac, rx: convert_file_encryption(file_setting.encryption), expect: ST_SUCCESS, receive_all: true, receive_length: length)
496
+ transceive(cmd: cmd, data: data, tx: :cmac, rx: convert_file_communication(file_setting.communication), expect: ST_SUCCESS, receive_all: true, receive_length: length)
497
497
  end
498
498
 
499
499
  def write_file(id, cmd, plain_data, data)
500
500
  file_setting = get_file_setting(id)
501
- transceive(cmd: cmd, plain_data: plain_data, data: data, tx: convert_file_encryption(file_setting.encryption), rx: :cmac, expect: ST_SUCCESS)
501
+ transceive(cmd: cmd, plain_data: plain_data, data: data, tx: convert_file_communication(file_setting.communication), rx: :cmac, expect: ST_SUCCESS)
502
502
  end
503
503
 
504
504
  def read_data(id, offset, length)
@@ -624,8 +624,8 @@ module Mifare
624
624
  end
625
625
  end
626
626
 
627
- def convert_file_encryption(encryption)
628
- case encryption
627
+ def convert_file_communication(communication)
628
+ case communication
629
629
  when :plain
630
630
  :cmac
631
631
  when :mac
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mfrc522
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - atitan