nested.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #include <storage/storage.h>
  6. #include <stream/stream.h>
  7. #include <stream/buffered_file_stream.h>
  8. typedef enum {
  9. MifareNestedNonceNoTag,
  10. MifareNestedNonce,
  11. MifareNestedNonceStatic
  12. } MifareNestedNonceType;
  13. MifareNestedNonceType nested_check_nonce_type(FuriHalNfcTxRxContext* tx_rx);
  14. struct nonce_info_static {
  15. uint32_t cuid;
  16. uint32_t target_nt[2];
  17. uint32_t target_ks[2];
  18. bool full;
  19. };
  20. struct nonce_info_hard {
  21. uint32_t cuid;
  22. bool static_encrypted;
  23. bool full;
  24. };
  25. struct nonce_info {
  26. uint32_t cuid;
  27. uint32_t target_nt[2];
  28. uint32_t target_ks[2];
  29. uint8_t parity[2][4];
  30. bool full;
  31. };
  32. struct distance_info {
  33. uint32_t min_prng;
  34. uint32_t max_prng;
  35. uint32_t mid_prng;
  36. };
  37. struct nonce_info_static nested_static_nonce_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. struct nonce_info nested_attack(
  45. FuriHalNfcTxRxContext* tx_rx,
  46. uint8_t blockNo,
  47. uint8_t keyType,
  48. uint8_t targetBlockNo,
  49. uint8_t targetKeyType,
  50. uint64_t ui64Key,
  51. uint32_t distance,
  52. uint32_t delay);
  53. struct nonce_info_hard hard_nested_collect_nonces(
  54. FuriHalNfcTxRxContext* tx_rx,
  55. uint8_t blockNo,
  56. uint8_t keyType,
  57. uint8_t targetBlockNo,
  58. uint8_t targetKeyType,
  59. uint64_t ui64Key,
  60. uint32_t* found,
  61. Stream* file_stream);
  62. uint32_t nested_calibrate_distance(
  63. FuriHalNfcTxRxContext* tx_rx,
  64. uint8_t blockNo,
  65. uint8_t keyType,
  66. uint64_t ui64Key,
  67. uint32_t delay,
  68. bool full);
  69. struct distance_info nested_calibrate_distance_info(
  70. FuriHalNfcTxRxContext* tx_rx,
  71. uint8_t blockNo,
  72. uint8_t keyType,
  73. uint64_t ui64Key);
  74. typedef enum {
  75. NestedCheckKeyNoTag,
  76. NestedCheckKeyValid,
  77. NestedCheckKeyInvalid,
  78. } NestedCheckKeyResult;
  79. NestedCheckKeyResult nested_check_key(
  80. FuriHalNfcTxRxContext* tx_rx,
  81. uint8_t blockNo,
  82. uint8_t keyType,
  83. uint64_t ui64Key);
  84. void nested_get_data();
  85. bool mifare_classic_authex(
  86. Crypto1* crypto,
  87. FuriHalNfcTxRxContext* tx_rx,
  88. uint32_t uid,
  89. uint32_t blockNo,
  90. uint32_t keyType,
  91. uint64_t ui64Key,
  92. bool isNested,
  93. uint32_t* ntptr);
  94. void nfc_activate();
  95. void nfc_deactivate();