mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
nfc: Enable MFUL sync poller to be provided with passwords (#4050)
* nfc: Enable MFUL sync poller to be provided with passwords * Sync targret api versions Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -262,7 +262,7 @@ static void mf_ultralight_reader_test(const char* path) {
|
|||||||
nfc_listener_start(mfu_listener, NULL, NULL);
|
nfc_listener_start(mfu_listener, NULL, NULL);
|
||||||
|
|
||||||
MfUltralightData* mfu_data = mf_ultralight_alloc();
|
MfUltralightData* mfu_data = mf_ultralight_alloc();
|
||||||
MfUltralightError error = mf_ultralight_poller_sync_read_card(poller, mfu_data);
|
MfUltralightError error = mf_ultralight_poller_sync_read_card(poller, mfu_data, NULL);
|
||||||
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
||||||
|
|
||||||
nfc_listener_stop(mfu_listener);
|
nfc_listener_stop(mfu_listener);
|
||||||
@@ -315,7 +315,7 @@ MU_TEST(ntag_213_locked_reader) {
|
|||||||
nfc_listener_start(mfu_listener, NULL, NULL);
|
nfc_listener_start(mfu_listener, NULL, NULL);
|
||||||
|
|
||||||
MfUltralightData* mfu_data = mf_ultralight_alloc();
|
MfUltralightData* mfu_data = mf_ultralight_alloc();
|
||||||
MfUltralightError error = mf_ultralight_poller_sync_read_card(poller, mfu_data);
|
MfUltralightError error = mf_ultralight_poller_sync_read_card(poller, mfu_data, NULL);
|
||||||
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
||||||
|
|
||||||
nfc_listener_stop(mfu_listener);
|
nfc_listener_stop(mfu_listener);
|
||||||
@@ -353,7 +353,7 @@ static void mf_ultralight_write(void) {
|
|||||||
MfUltralightData* mfu_data = mf_ultralight_alloc();
|
MfUltralightData* mfu_data = mf_ultralight_alloc();
|
||||||
|
|
||||||
// Initial read
|
// Initial read
|
||||||
MfUltralightError error = mf_ultralight_poller_sync_read_card(poller, mfu_data);
|
MfUltralightError error = mf_ultralight_poller_sync_read_card(poller, mfu_data, NULL);
|
||||||
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
||||||
|
|
||||||
mu_assert(
|
mu_assert(
|
||||||
@@ -371,7 +371,7 @@ static void mf_ultralight_write(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verification read
|
// Verification read
|
||||||
error = mf_ultralight_poller_sync_read_card(poller, mfu_data);
|
error = mf_ultralight_poller_sync_read_card(poller, mfu_data, NULL);
|
||||||
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
mu_assert(error == MfUltralightErrorNone, "mf_ultralight_poller_sync_read_card() failed");
|
||||||
|
|
||||||
nfc_listener_stop(mfu_listener);
|
nfc_listener_stop(mfu_listener);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ typedef struct {
|
|||||||
FuriThreadId thread_id;
|
FuriThreadId thread_id;
|
||||||
MfUltralightError error;
|
MfUltralightError error;
|
||||||
MfUltralightPollerContextData data;
|
MfUltralightPollerContextData data;
|
||||||
|
const MfUltralightPollerAuthContext* auth_context;
|
||||||
} MfUltralightPollerContext;
|
} MfUltralightPollerContext;
|
||||||
|
|
||||||
typedef MfUltralightError (*MfUltralightPollerCmdHandler)(
|
typedef MfUltralightError (*MfUltralightPollerCmdHandler)(
|
||||||
@@ -250,12 +251,17 @@ static NfcCommand mf_ultralight_poller_read_callback(NfcGenericEvent event, void
|
|||||||
poller_context->error = mfu_event->data->error;
|
poller_context->error = mfu_event->data->error;
|
||||||
command = NfcCommandStop;
|
command = NfcCommandStop;
|
||||||
} else if(mfu_event->type == MfUltralightPollerEventTypeAuthRequest) {
|
} else if(mfu_event->type == MfUltralightPollerEventTypeAuthRequest) {
|
||||||
mfu_event->data->auth_context.skip_auth = true;
|
if(poller_context->auth_context != NULL) {
|
||||||
if(mf_ultralight_support_feature(
|
mfu_event->data->auth_context = *poller_context->auth_context;
|
||||||
mfu_poller->feature_set, MfUltralightFeatureSupportAuthenticate)) {
|
} else {
|
||||||
mfu_event->data->auth_context.skip_auth = false;
|
mfu_event->data->auth_context.skip_auth = true;
|
||||||
memset(
|
if(mfu_poller->data->type == MfUltralightTypeMfulC) {
|
||||||
mfu_poller->auth_context.tdes_key.data, 0x00, MF_ULTRALIGHT_C_AUTH_DES_KEY_SIZE);
|
mfu_event->data->auth_context.skip_auth = false;
|
||||||
|
memset(
|
||||||
|
mfu_poller->auth_context.tdes_key.data,
|
||||||
|
0x00,
|
||||||
|
MF_ULTRALIGHT_C_AUTH_DES_KEY_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,13 +272,17 @@ static NfcCommand mf_ultralight_poller_read_callback(NfcGenericEvent event, void
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
MfUltralightError mf_ultralight_poller_sync_read_card(Nfc* nfc, MfUltralightData* data) {
|
MfUltralightError mf_ultralight_poller_sync_read_card(
|
||||||
|
Nfc* nfc,
|
||||||
|
MfUltralightData* data,
|
||||||
|
const MfUltralightPollerAuthContext* auth_context) {
|
||||||
furi_check(nfc);
|
furi_check(nfc);
|
||||||
furi_check(data);
|
furi_check(data);
|
||||||
|
|
||||||
MfUltralightPollerContext poller_context = {};
|
MfUltralightPollerContext poller_context = {};
|
||||||
poller_context.thread_id = furi_thread_get_current_id();
|
poller_context.thread_id = furi_thread_get_current_id();
|
||||||
poller_context.data.data = mf_ultralight_alloc();
|
poller_context.data.data = mf_ultralight_alloc();
|
||||||
|
poller_context.auth_context = auth_context;
|
||||||
|
|
||||||
NfcPoller* poller = nfc_poller_alloc(nfc, NfcProtocolMfUltralight);
|
NfcPoller* poller = nfc_poller_alloc(nfc, NfcProtocolMfUltralight);
|
||||||
nfc_poller_start(poller, mf_ultralight_poller_read_callback, &poller_context);
|
nfc_poller_start(poller, mf_ultralight_poller_read_callback, &poller_context);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "mf_ultralight.h"
|
#include "mf_ultralight.h"
|
||||||
|
#include "mf_ultralight_poller.h"
|
||||||
#include <nfc/nfc.h>
|
#include <nfc/nfc.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -27,7 +28,10 @@ MfUltralightError mf_ultralight_poller_sync_read_tearing_flag(
|
|||||||
uint8_t flag_num,
|
uint8_t flag_num,
|
||||||
MfUltralightTearingFlag* data);
|
MfUltralightTearingFlag* data);
|
||||||
|
|
||||||
MfUltralightError mf_ultralight_poller_sync_read_card(Nfc* nfc, MfUltralightData* data);
|
MfUltralightError mf_ultralight_poller_sync_read_card(
|
||||||
|
Nfc* nfc,
|
||||||
|
MfUltralightData* data,
|
||||||
|
const MfUltralightPollerAuthContext* auth_context);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
entry,status,name,type,params
|
entry,status,name,type,params
|
||||||
Version,+,79.3,,
|
Version,+,80.1,,
|
||||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||||
Header,+,applications/services/cli/cli.h,,
|
Header,+,applications/services/cli/cli.h,,
|
||||||
|
|||||||
|
@@ -1,5 +1,5 @@
|
|||||||
entry,status,name,type,params
|
entry,status,name,type,params
|
||||||
Version,+,79.3,,
|
Version,+,80.1,,
|
||||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||||
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
|
||||||
@@ -2681,7 +2681,7 @@ Function,+,mf_ultralight_poller_read_page_from_sector,MfUltralightError,"MfUltra
|
|||||||
Function,+,mf_ultralight_poller_read_signature,MfUltralightError,"MfUltralightPoller*, MfUltralightSignature*"
|
Function,+,mf_ultralight_poller_read_signature,MfUltralightError,"MfUltralightPoller*, MfUltralightSignature*"
|
||||||
Function,+,mf_ultralight_poller_read_tearing_flag,MfUltralightError,"MfUltralightPoller*, uint8_t, MfUltralightTearingFlag*"
|
Function,+,mf_ultralight_poller_read_tearing_flag,MfUltralightError,"MfUltralightPoller*, uint8_t, MfUltralightTearingFlag*"
|
||||||
Function,+,mf_ultralight_poller_read_version,MfUltralightError,"MfUltralightPoller*, MfUltralightVersion*"
|
Function,+,mf_ultralight_poller_read_version,MfUltralightError,"MfUltralightPoller*, MfUltralightVersion*"
|
||||||
Function,+,mf_ultralight_poller_sync_read_card,MfUltralightError,"Nfc*, MfUltralightData*"
|
Function,+,mf_ultralight_poller_sync_read_card,MfUltralightError,"Nfc*, MfUltralightData*, const MfUltralightPollerAuthContext*"
|
||||||
Function,+,mf_ultralight_poller_sync_read_counter,MfUltralightError,"Nfc*, uint8_t, MfUltralightCounter*"
|
Function,+,mf_ultralight_poller_sync_read_counter,MfUltralightError,"Nfc*, uint8_t, MfUltralightCounter*"
|
||||||
Function,+,mf_ultralight_poller_sync_read_page,MfUltralightError,"Nfc*, uint16_t, MfUltralightPage*"
|
Function,+,mf_ultralight_poller_sync_read_page,MfUltralightError,"Nfc*, uint16_t, MfUltralightPage*"
|
||||||
Function,+,mf_ultralight_poller_sync_read_signature,MfUltralightError,"Nfc*, MfUltralightSignature*"
|
Function,+,mf_ultralight_poller_sync_read_signature,MfUltralightError,"Nfc*, MfUltralightSignature*"
|
||||||
|
|||||||
|
Reference in New Issue
Block a user