Skip to content

Commit beef4d2

Browse files
committed
Refactor: unify Auth/AuthMfulC choice in read_signature handler
1 parent fc95ec2 commit beef4d2

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

lib/nfc/protocols/mf_ultralight/mf_ultralight_poller.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,31 +305,34 @@ static NfcCommand mf_ultralight_poller_handler_get_feature_set(MfUltralightPolle
305305
}
306306

307307
static NfcCommand mf_ultralight_poller_handler_read_signature(MfUltralightPoller* instance) {
308-
MfUltralightPollerState next_state = MfUltralightPollerStateAuth;
308+
bool signature_read_ok = false;
309+
309310
if(mf_ultralight_support_feature(
310311
instance->feature_set, MfUltralightFeatureSupportReadSignature)) {
311312
FURI_LOG_D(TAG, "Reading signature");
312313
instance->error =
313314
mf_ultralight_poller_read_signature(instance, &instance->data->signature);
314-
if(instance->error != MfUltralightErrorNone) {
315+
if(instance->error == MfUltralightErrorNone) {
316+
signature_read_ok = true;
317+
} else {
315318
FURI_LOG_D(TAG, "Read signature failed, continuing without signature");
316319
memset(
317320
instance->data->signature.data,
318321
0,
319322
sizeof(instance->data->signature.data));
320-
/* Signature is optional; continue read so pages and other data can be read */
321-
if(mf_ultralight_support_feature(
322-
instance->feature_set, MfUltralightFeatureSupportAuthenticate)) {
323-
next_state = MfUltralightPollerStateAuthMfulC;
324-
}
325-
/* else next_state remains Auth */
326323
}
327324
} else {
328325
FURI_LOG_D(TAG, "Skip reading signature");
329-
if(mf_ultralight_support_feature(
330-
instance->feature_set, MfUltralightFeatureSupportAuthenticate)) {
331-
next_state = MfUltralightPollerStateAuthMfulC;
332-
}
326+
}
327+
328+
MfUltralightPollerState next_state;
329+
if(signature_read_ok) {
330+
next_state = MfUltralightPollerStateAuth;
331+
} else if(mf_ultralight_support_feature(
332+
instance->feature_set, MfUltralightFeatureSupportAuthenticate)) {
333+
next_state = MfUltralightPollerStateAuthMfulC;
334+
} else {
335+
next_state = MfUltralightPollerStateAuth;
333336
}
334337
instance->state = next_state;
335338

0 commit comments

Comments
 (0)