mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 06:50:21 +00:00
3224401479
* 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>
59 lines
1.7 KiB
C
59 lines
1.7 KiB
C
#include "mf_ultralight_auth.h"
|
|
|
|
#include <furi.h>
|
|
#include <mbedtls/sha1.h>
|
|
|
|
MfUltralightAuth* mf_ultralight_auth_alloc(void) {
|
|
MfUltralightAuth* instance = malloc(sizeof(MfUltralightAuth));
|
|
|
|
return instance;
|
|
}
|
|
|
|
void mf_ultralight_auth_free(MfUltralightAuth* instance) {
|
|
furi_assert(instance);
|
|
|
|
free(instance);
|
|
}
|
|
|
|
void mf_ultralight_auth_reset(MfUltralightAuth* instance) {
|
|
furi_assert(instance);
|
|
|
|
instance->type = MfUltralightAuthTypeNone;
|
|
memset(&instance->password, 0, sizeof(MfUltralightAuthPassword));
|
|
memset(&instance->tdes_key, 0, sizeof(MfUltralightC3DesAuthKey));
|
|
memset(&instance->pack, 0, sizeof(MfUltralightAuthPack));
|
|
}
|
|
|
|
bool mf_ultralight_generate_amiibo_pass(MfUltralightAuth* instance, uint8_t* uid, uint16_t uid_len) {
|
|
furi_assert(instance);
|
|
furi_assert(uid);
|
|
|
|
bool generated = false;
|
|
if(uid_len == 7) {
|
|
instance->password.data[0] = uid[1] ^ uid[3] ^ 0xAA;
|
|
instance->password.data[1] = uid[2] ^ uid[4] ^ 0x55;
|
|
instance->password.data[2] = uid[3] ^ uid[5] ^ 0xAA;
|
|
instance->password.data[3] = uid[4] ^ uid[6] ^ 0x55;
|
|
generated = true;
|
|
}
|
|
|
|
return generated;
|
|
}
|
|
|
|
bool mf_ultralight_generate_xiaomi_pass(MfUltralightAuth* instance, uint8_t* uid, uint16_t uid_len) {
|
|
furi_assert(instance);
|
|
furi_assert(uid);
|
|
|
|
uint8_t hash[20];
|
|
bool generated = false;
|
|
if(uid_len == 7) {
|
|
mbedtls_sha1(uid, uid_len, hash);
|
|
instance->password.data[0] = (hash[hash[0] % 20]);
|
|
instance->password.data[1] = (hash[(hash[0] + 5) % 20]);
|
|
instance->password.data[2] = (hash[(hash[0] + 13) % 20]);
|
|
instance->password.data[3] = (hash[(hash[0] + 17) % 20]);
|
|
generated = true;
|
|
}
|
|
|
|
return generated;
|
|
}
|