mfrc522 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/iso144434.rb +1 -1
- data/lib/mifare/des_fire.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d391fefaa44340237f219a9292de10b030f321
|
4
|
+
data.tar.gz: 9574c355eb6ccb2abb83930e064b0fe73cd52900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d46681cb3ad8bd8fa0b02e9c11c946d90e67e8eb7426da22242d5f3360cd7309b573b00285d0067c057ea98f805dd5d214f305ddd7987c76ca3ed0e92617dea
|
7
|
+
data.tar.gz: e814a5f7d9e10675d19f4f69d2d6e5de7c6ee95ec73085adf65ac990329b10b7341529c97b34c6608138d1869e1836fa7465f36dd7ed053c81fa2479f05b67b9
|
data/lib/iso144434.rb
CHANGED
@@ -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
|
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
|
|
data/lib/mifare/des_fire.rb
CHANGED
@@ -115,7 +115,7 @@ module Mifare
|
|
115
115
|
linear_record_file: 0x03, cyclic_record_file: 0x04
|
116
116
|
}
|
117
117
|
|
118
|
-
|
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
|
-
:
|
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
|
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.
|
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(
|
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(
|
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:
|
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:
|
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
|
628
|
-
case
|
627
|
+
def convert_file_communication(communication)
|
628
|
+
case communication
|
629
629
|
when :plain
|
630
630
|
:cmac
|
631
631
|
when :mac
|