File tree 1 file changed +13
-9
lines changed
1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -24,19 +24,23 @@ void ButtonInit(void)
24
24
25
25
static void ExecuteButtonAction (ButtonActionEnum ButtonAction )
26
26
{
27
- uint8_t UidBuffer [ CONFIGURATION_UID_SIZE_MAX ] ;
27
+ ConfigurationUidType UidBuffer ;
28
28
29
29
if (ButtonAction == BUTTON_ACTION_UID_RANDOM ) {
30
-
31
- /* iceman, 2018, this random functionality could be more localized to the current cardtype in use.
32
- ie. for Ultralight based cards with 7byte uid, skip manufacturing byte
33
- */
34
-
30
+ uint8_t startByte = 0 ;
35
31
ApplicationGetUid (UidBuffer );
36
32
37
- /* skip manufacturing byte UID0 */
38
- for (uint8_t i = 1 ; i < ActiveConfiguration .UidSize - 1 ; i ++ ) {
39
- UidBuffer [i ] = RandomGetByte ();
33
+ #ifdef CONFIG_MF_ULTRALIGHT_SUPPORT
34
+ // Make RANDOM keep 1st byte safe for Ultralight types
35
+ ConfigurationEnum ActiveConfigurationId = GlobalSettings .ActiveSettingPtr -> Configuration ;
36
+ if ( (ActiveConfigurationId == CONFIG_MF_ULTRALIGHT )
37
+ || (ActiveConfigurationId == CONFIG_MF_ULTRALIGHT_EV1_80B )
38
+ || (ActiveConfigurationId == CONFIG_MF_ULTRALIGHT_EV1_164B ) ) {
39
+ startByte = 1 ;
40
+ }
41
+ #endif
42
+ for ( ; startByte < ActiveConfiguration .UidSize ; startByte ++ ) {
43
+ UidBuffer [startByte ] = RandomGetByte ();
40
44
}
41
45
42
46
ApplicationSetUid (UidBuffer );
You can’t perform that action at this time.
0 commit comments