mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
[FL-3835] Ultralight C authentication with des key (#3720)
* Update api_symbols.csv * Ultralight C 3des implementation added * Access check for Ultralight cards is now splitted into 2 functions one for ULC card and another for common * Ultralight C authentication command handlers added * Update api_symbols.csv and api_symbols.csv * Length added to ultralight encrypt function * New structure for storing 3des key added * Reseting of 3des_key added * des_context init/deinit added to poller * New poller step for ultralight c auth added * Added ultralight c des key to application * Renamed felica unlock scenes to more generic des auth scenes, because they are now used also for ultralight c * Show different menus for different ultralight card types * Update api_symbols.csv and api_symbols.csv * Some macro defines added * Different amount of pages will be now read for ultralight C and others * New unit test for ultralight C * Some comments and macro replacements * New function added to api * Now all data read checks mfulC separately * Adjusted listener to handle missing 3des_key properly * Now poller populates 3des_key after reading with auth to card data * Nfc: rename _3des_key to tdes_key * Bump API Symbols * Mute PVS Warnings Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <lib/nfc/protocols/iso14443_3a/iso14443_3a.h>
|
||||
#include <mbedtls/include/mbedtls/des.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -37,7 +38,15 @@ extern "C" {
|
||||
#define MF_ULTRALIGHT_TEARING_FLAG_NUM (3)
|
||||
#define MF_ULTRALIGHT_AUTH_PASSWORD_SIZE (4)
|
||||
#define MF_ULTRALIGHT_AUTH_PACK_SIZE (2)
|
||||
#define MF_ULTRALIGHT_AUTH_RESPONSE_SIZE (9)
|
||||
|
||||
#define MF_ULTRALIGHT_C_AUTH_RESPONSE_SIZE (9)
|
||||
#define MF_ULTRALIGHT_C_AUTH_DES_KEY_SIZE (16)
|
||||
#define MF_ULTRALIGHT_C_AUTH_DATA_SIZE (MF_ULTRALIGHT_C_AUTH_DES_KEY_SIZE)
|
||||
#define MF_ULTRALIGHT_C_AUTH_IV_BLOCK_SIZE (8)
|
||||
#define MF_ULTRALIGHT_C_AUTH_RND_BLOCK_SIZE (8)
|
||||
#define MF_ULTRALIGHT_C_AUTH_RND_A_BLOCK_OFFSET (0)
|
||||
#define MF_ULTRALIGHT_C_AUTH_RND_B_BLOCK_OFFSET (8)
|
||||
#define MF_ULTRALIGHT_C_ENCRYPTED_PACK_SIZE (MF_ULTRALIGHT_C_AUTH_DATA_SIZE + 1)
|
||||
|
||||
typedef enum {
|
||||
MfUltralightErrorNone,
|
||||
@@ -119,6 +128,10 @@ typedef struct {
|
||||
uint8_t data[MF_ULTRALIGHT_AUTH_PASSWORD_SIZE];
|
||||
} MfUltralightAuthPassword;
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[MF_ULTRALIGHT_C_AUTH_DES_KEY_SIZE];
|
||||
} MfUltralightC3DesAuthKey;
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[MF_ULTRALIGHT_AUTH_PACK_SIZE];
|
||||
} MfUltralightAuthPack;
|
||||
@@ -226,6 +239,28 @@ bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data);
|
||||
|
||||
bool mf_ultralight_is_counter_configured(const MfUltralightData* data);
|
||||
|
||||
void mf_ultralight_3des_shift_data(uint8_t* const arr);
|
||||
|
||||
bool mf_ultralight_3des_key_valid(const MfUltralightData* data);
|
||||
|
||||
const uint8_t* mf_ultralight_3des_get_key(const MfUltralightData* data);
|
||||
|
||||
void mf_ultralight_3des_encrypt(
|
||||
mbedtls_des3_context* ctx,
|
||||
const uint8_t* ck,
|
||||
const uint8_t* iv,
|
||||
const uint8_t* input,
|
||||
const uint8_t length,
|
||||
uint8_t* out);
|
||||
|
||||
void mf_ultralight_3des_decrypt(
|
||||
mbedtls_des3_context* ctx,
|
||||
const uint8_t* ck,
|
||||
const uint8_t* iv,
|
||||
const uint8_t* input,
|
||||
const uint8_t length,
|
||||
uint8_t* out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user