mfc-spec.txt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright (c) 2011 Anders Sundman <anders@4zm.org>
  2. #
  3. # This file is part of rkfterm.
  4. #
  5. # rkfterm is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # rkfterm is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with rkfterm. If not, see <http://www.gnu.org/licenses/>.
  17. # About the specification language:
  18. #
  19. # The primitive types in the specification language are Byte and Bit
  20. # and arrays of such. All other types need to be defined.
  21. #
  22. # Every specification must include the root type '.'
  23. # The root type is specified by its type name '.'
  24. . {
  25. Sector0 sector_0 # The types usesed here are defined below
  26. Sector1k[15] sectors_1k
  27. Sector4k[12] sectors_4k
  28. }
  29. # The type Sector_0 represents the first sector.
  30. Sector0 {
  31. { # This is an anonymous inner type. The type doesn't have a name.
  32. Byte[4] uid # Unique ID
  33. Byte cd # Check Byte; uid bytes xor:ed with cb should be 0
  34. Bit[4] - # Not used. Use '-' as a name in theese cases
  35. Bit[4] sak
  36. Byte[2] atqa
  37. Byte[8] manufacturer_data
  38. } block_0
  39. Block[2] blocks
  40. SectorTrailer trailer
  41. }
  42. Sector1k {
  43. Block[3] blocks
  44. SectorTrailer trailer
  45. }
  46. Sector4k {
  47. Block[15] blocks
  48. SectorTrailer trailer
  49. }
  50. Block {
  51. Byte[16] data
  52. }
  53. SectorTrailer {
  54. Byte[6] key_a
  55. ACL acl
  56. Byte[1] - # Undefined
  57. Byte[6] key_b
  58. }
  59. # See p.12 of Mifare MF1 IC S50 Functional Specification, rev. 4.0
  60. # _b suffixed bits are inverted versions of non suffixed counterparts
  61. ACL {
  62. Bit c2x3_b # bit 7
  63. Bit c2x2_b
  64. Bit c2x1_b
  65. Bit c2x0_b # bit 4
  66. Bit c1x3_b # bit 3
  67. Bit c1x2_b
  68. Bit c1x1_b
  69. Bit c1x0_b # bit 0
  70. Bit c1x3 # bit 7
  71. Bit c1x2
  72. Bit c1x1
  73. Bit c1x0 # bit 4
  74. Bit c3x3_b # bit 3
  75. Bit c3x2_b
  76. Bit c3x1_b
  77. Bit c3x0_b # bit 0
  78. Bit c3x3 # bit 7
  79. Bit c3x2
  80. Bit c3x1
  81. Bit c3x0 # bit 4
  82. Bit c2x3 # bit 3
  83. Bit c2x2
  84. Bit c2x1
  85. Bit c2x0 # bit 0
  86. }