picopass_i.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. #include "picopass.h"
  3. #include "picopass_worker.h"
  4. #include "picopass_device.h"
  5. #include "rfal_picopass.h"
  6. #include <furi.h>
  7. #include <gui/gui.h>
  8. #include <gui/view_dispatcher.h>
  9. #include <gui/scene_manager.h>
  10. #include <notification/notification_messages.h>
  11. #include <gui/modules/submenu.h>
  12. #include <gui/modules/popup.h>
  13. #include <gui/modules/loading.h>
  14. #include <gui/modules/text_input.h>
  15. #include <gui/modules/byte_input.h>
  16. #include <gui/modules/widget.h>
  17. #include <input/input.h>
  18. #include "scenes/picopass_scene.h"
  19. #include "views/dict_attack.h"
  20. #include "views/loclass.h"
  21. #include <storage/storage.h>
  22. #include <lib/toolbox/path.h>
  23. #include <picopass_icons.h>
  24. #define PICOPASS_TEXT_STORE_SIZE 128
  25. #define LOCLASS_NUM_CSNS 9
  26. // Collect 2 MACs per CSN to account for keyroll modes
  27. #define LOCLASS_MACS_TO_COLLECT (LOCLASS_NUM_CSNS * 2)
  28. enum PicopassCustomEvent {
  29. // Reserve first 100 events for button types and indexes, starting from 0
  30. PicopassCustomEventReserved = 100,
  31. PicopassCustomEventViewExit,
  32. PicopassCustomEventWorkerExit,
  33. PicopassCustomEventByteInputDone,
  34. PicopassCustomEventTextInputDone,
  35. PicopassCustomEventDictAttackSkip,
  36. };
  37. typedef enum {
  38. EventTypeTick,
  39. EventTypeKey,
  40. } EventType;
  41. struct Picopass {
  42. PicopassWorker* worker;
  43. ViewDispatcher* view_dispatcher;
  44. Gui* gui;
  45. NotificationApp* notifications;
  46. SceneManager* scene_manager;
  47. PicopassDevice* dev;
  48. char text_store[PICOPASS_TEXT_STORE_SIZE + 1];
  49. FuriString* text_box_store;
  50. uint8_t byte_input_store[RFAL_PICOPASS_BLOCK_LEN];
  51. // Common Views
  52. Submenu* submenu;
  53. Popup* popup;
  54. Loading* loading;
  55. TextInput* text_input;
  56. ByteInput* byte_input;
  57. Widget* widget;
  58. DictAttack* dict_attack;
  59. Loclass* loclass;
  60. };
  61. typedef enum {
  62. PicopassViewMenu,
  63. PicopassViewPopup,
  64. PicopassViewLoading,
  65. PicopassViewTextInput,
  66. PicopassViewByteInput,
  67. PicopassViewWidget,
  68. PicopassViewDictAttack,
  69. PicopassViewLoclass,
  70. } PicopassView;
  71. Picopass* picopass_alloc();
  72. void picopass_text_store_set(Picopass* picopass, const char* text, ...);
  73. void picopass_text_store_clear(Picopass* picopass);
  74. void picopass_blink_start(Picopass* picopass);
  75. void picopass_blink_emulate_start(Picopass* picopass);
  76. void picopass_blink_stop(Picopass* picopass);
  77. void picopass_show_loading_popup(void* context, bool show);
  78. /** Check if memory is set to pattern
  79. *
  80. * @warning zero size will return false
  81. *
  82. * @param[in] data Pointer to the byte array
  83. * @param[in] pattern The pattern
  84. * @param[in] size The byte array size
  85. *
  86. * @return True if memory is set to pattern, false otherwise
  87. */
  88. bool picopass_is_memset(const uint8_t* data, const uint8_t pattern, size_t size);