1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // RDV4 flash constants
17 //-----------------------------------------------------------------------------
25 // 256kb divided into 4k sectors.
27 // 0x3F000 - 1 4kb sector = signature
28 // 0x3E000 - 1 4kb sector = settings
29 // 0x3D000 - 1 4kb sector = default T55XX keys dictionary
30 // 0x3B000 - 1 4kb sector = default ICLASS keys dictionary
31 // 0x38000 - 3 4kb sectors = default MFC keys dictionary
33 #ifndef FLASH_MEM_BLOCK_SIZE
34 # define FLASH_MEM_BLOCK_SIZE 256
37 #ifndef FLASH_MEM_MAX_SIZE
38 # define FLASH_MEM_MAX_SIZE 0x40000 // (262144)
40 #ifndef FLASH_MEM_MAX_SIZE_P
41 # define FLASH_MEM_MAX_SIZE_P(p64k) (1024 * 64 * (p64k))
44 #ifndef FLASH_MEM_MAX_4K_SECTOR
45 # define FLASH_MEM_MAX_4K_SECTOR 0x3F000
47 #ifndef FLASH_MEM_MAX_4K_SECTOR_P
48 # define FLASH_MEM_MAX_4K_SECTOR_P(p64k) (FLASH_MEM_MAX_SIZE_P(p64k) - 4096)
51 #ifndef FLASH_MEM_ID_LEN
52 # define FLASH_MEM_ID_LEN 8
55 #ifndef FLASH_MEM_SIGNATURE_LEN
56 # define FLASH_MEM_SIGNATURE_LEN 128
59 #ifndef FLASH_MEM_SIGNATURE_OFFSET
60 // -1 for historical compatibility with already released Proxmark3 RDV4.0 devices
61 # define FLASH_MEM_SIGNATURE_OFFSET (FLASH_MEM_MAX_SIZE - FLASH_MEM_SIGNATURE_LEN - 1)
63 #ifndef FLASH_MEM_SIGNATURE_OFFSET_P
64 # define FLASH_MEM_SIGNATURE_OFFSET_P(p64k) (FLASH_MEM_MAX_SIZE_P(p64k) - FLASH_MEM_SIGNATURE_LEN - 1)
67 #ifndef T55XX_CONFIG_LEN
68 # define T55XX_CONFIG_LEN sizeof( t55xx_configurations_t )
71 #ifndef T55XX_CONFIG_OFFSET
72 # define T55XX_CONFIG_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x2000)
74 #ifndef T55XX_CONFIG_OFFSET_P
75 # define T55XX_CONFIG_OFFSET_P(p64k) (FLASH_MEM_MAX_4K_SECTOR_P(p64k) - 0x2000)
78 // Reserved space for T55XX PWD = 4 kb
79 #ifndef DEFAULT_T55XX_KEYS_OFFSET
80 # define DEFAULT_T55XX_KEYS_LEN (0x1000)
81 # define DEFAULT_T55XX_KEYS_OFFSET (T55XX_CONFIG_OFFSET - DEFAULT_T55XX_KEYS_LEN)
82 # define DEFAULT_T55XX_KEYS_MAX ((DEFAULT_T55XX_KEYS_LEN - 2) / 4)
84 #ifndef DEFAULT_T55XX_KEYS_OFFSET_P
85 # define DEFAULT_T55XX_KEYS_OFFSET_P(p64k) (T55XX_CONFIG_OFFSET_P(p64k) - DEFAULT_T55XX_KEYS_LEN)
88 // Reserved space for iClass keys = 4 kb
89 #ifndef DEFAULT_ICLASS_KEYS_OFFSET
90 # define DEFAULT_ICLASS_KEYS_LEN (0x1000)
91 # define DEFAULT_ICLASS_KEYS_OFFSET (DEFAULT_T55XX_KEYS_OFFSET - DEFAULT_ICLASS_KEYS_LEN)
92 # define DEFAULT_ICLASS_KEYS_MAX ((DEFAULT_ICLASS_KEYS_LEN - 2) / 8)
94 #ifndef DEFAULT_ICLASS_KEYS_OFFSET_P
95 # define DEFAULT_ICLASS_KEYS_OFFSET_P(p64k) (DEFAULT_T55XX_KEYS_OFFSET_P(p64k) - DEFAULT_ICLASS_KEYS_LEN)
98 // Reserved space for MIFARE Keys = 12 kb
99 #ifndef DEFAULT_MF_KEYS_OFFSET
100 # define DEFAULT_MF_KEYS_LEN (0x3000)
101 # define DEFAULT_MF_KEYS_OFFSET (DEFAULT_ICLASS_KEYS_OFFSET - DEFAULT_MF_KEYS_LEN)
102 # define DEFAULT_MF_KEYS_MAX ((DEFAULT_MF_KEYS_LEN - 2) / 6)
104 #ifndef DEFAULT_MF_KEYS_OFFSET_P
105 # define DEFAULT_MF_KEYS_OFFSET_P(p64k) (DEFAULT_ICLASS_KEYS_OFFSET_P(p64k) - DEFAULT_MF_KEYS_LEN)
108 // RDV40, validation structure to help identifying that client/firmware is talking with RDV40
111 uint8_t flashid
[FLASH_MEM_ID_LEN
];
112 uint8_t signature
[FLASH_MEM_SIGNATURE_LEN
];
113 } PACKED rdv40_validation_t
;
116 #endif // __PMFLASH_H