#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using json = nlohmann::json; static const std::string base32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; class TOTPGenGUI : public wxApp { public: virtual bool OnInit(); }; class TOTPGen : public wxFrame { public: TOTPGen(); private: wxPanel *MainWindow; wxBoxSizer *MainSizer; wxBoxSizer *SelectSizer; wxBoxSizer *TextSizer; wxBoxSizer *ButtonSizer_Upper; wxBoxSizer *ButtonSizer_Middle; wxBoxSizer *ButtonSizer_Lower; wxComboBox *SecretChooser; void ReloadSelections(void); void SelectSecret(wxCommandEvent& event); wxStaticText *TOTPField; void ResizeTextToFit(wxStaticText *text_field); wxTimer *CountdownTimer; wxGauge *CountdownGauge; void UpdateStatus(wxTimerEvent& event); wxButton *AddButton; void AddSecret(wxCommandEvent& event); bool IsBase32(std::string& str); wxButton *DeleteButton; void DeleteSecret(wxCommandEvent& event); wxButton *CopyButton; void CopyText(wxCommandEvent& event); wxButton *QuitButton; void OnExit(wxCommandEvent& event); std::string Passphrase; wxButton *SecurityButton; void InitDB(wxCommandEvent& event); void SetPassword(wxCommandEvent& event); void Unlock(wxCommandEvent& event); json KeyDB; wxString SecretDB_File; void InitAES(const char *passphrase, unsigned char *salt, unsigned char *key, unsigned char *iv); bool DecryptDB(void); bool EncryptDB(const std::string& secret_str); std::string Secret; std::string TOTP; bool GenTOTP(const std::string& secret_str); };