nested.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include <lib/nfc/protocols/nfc_util.h>
  3. #include <lib/nfc/protocols/mifare_classic.h>
  4. #include <lib/nfc/protocols/crypto1.h>
  5. typedef enum {
  6. MifareNestedNonceNoTag,
  7. MifareNestedNonce,
  8. MifareNestedNonceStatic
  9. } MifareNestedNonceType;
  10. MifareNestedNonceType nested_check_nonce_type(FuriHalNfcTxRxContext* tx_rx);
  11. struct nonce_info_static {
  12. uint32_t cuid;
  13. uint32_t target_nt[2];
  14. uint32_t target_ks[2];
  15. bool full;
  16. };
  17. struct nonce_info {
  18. uint32_t cuid;
  19. uint32_t target_nt[2];
  20. uint32_t target_ks[2];
  21. uint8_t parity[2][4];
  22. bool full;
  23. };
  24. struct distance_info {
  25. uint32_t min_prng;
  26. uint32_t max_prng;
  27. uint32_t mid_prng;
  28. uint32_t invalid; // How many PRNG values <> mid_prng +- 100
  29. };
  30. struct nonce_info_static nested_static_nonce_attack(
  31. FuriHalNfcTxRxContext* tx_rx,
  32. uint8_t blockNo,
  33. uint8_t keyType,
  34. uint8_t targetBlockNo,
  35. uint8_t targetKeyType,
  36. uint64_t ui64Key);
  37. struct nonce_info nested_attack(
  38. FuriHalNfcTxRxContext* tx_rx,
  39. uint8_t blockNo,
  40. uint8_t keyType,
  41. uint8_t targetBlockNo,
  42. uint8_t targetKeyType,
  43. uint64_t ui64Key,
  44. uint32_t distance,
  45. uint32_t delay);
  46. uint32_t nested_calibrate_distance(
  47. FuriHalNfcTxRxContext* tx_rx,
  48. uint8_t blockNo,
  49. uint8_t keyType,
  50. uint64_t ui64Key,
  51. uint32_t delay,
  52. bool full);
  53. struct distance_info nested_calibrate_distance_info(
  54. FuriHalNfcTxRxContext* tx_rx,
  55. uint8_t blockNo,
  56. uint8_t keyType,
  57. uint64_t ui64Key);
  58. typedef enum {
  59. NestedCheckKeyNoTag,
  60. NestedCheckKeyValid,
  61. NestedCheckKeyInvalid,
  62. } NestedCheckKeyResult;
  63. NestedCheckKeyResult nested_check_key(
  64. FuriHalNfcTxRxContext* tx_rx,
  65. uint8_t blockNo,
  66. uint8_t keyType,
  67. uint64_t ui64Key);
  68. void nested_get_data();
  69. bool mifare_classic_authex(
  70. Crypto1* crypto,
  71. FuriHalNfcTxRxContext* tx_rx,
  72. uint32_t uid,
  73. uint32_t blockNo,
  74. uint32_t keyType,
  75. uint64_t ui64Key,
  76. bool isNested,
  77. uint32_t* ntptr);
  78. void nfc_activate();
  79. void nfc_deactivate();