void PasswordSafeDialog::on_ButtonSendpassword_clicked() { QString MsgText; int ret_s32; if (true == ui->radioKeyboard->isChecked()) { OwnSleep::msleep(delaySendTextInMs); ret_s32 = cryptostick->passwordSafeSendSlotDataViaHID(UsedSlot, PWS_SEND_PASSWORD); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't send password chars via HID")); return; } } if (true == ui->radioCutUPaste->isChecked()) { ret_s32 = cryptostick->getPasswordSafeSlotPassword(UsedSlot); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't get password")); return; } clipboard->setText((char *)cryptostick->passwordSafePassword); } }
void PasswordDialog::on_buttonBox_accepted() { int n; // unsigned char password[50]; QByteArray passwordString; if (false == ui->checkBox_PasswordMatrix->isChecked()) { // Send normal password password[0] = 'P'; // For normal password // Check the password length passwordString = ui->lineEdit->text().toLatin1(); n = passwordString.size(); if (30 <= n) { csApplet()->warningBox(tr("Your PIN is too long! Use not more than 30 characters.")); done(FALSE); return; } if (6 > n) { csApplet()->warningBox(tr("Your PIN is too short. Use at least 6 characters.")); done(FALSE); return; } if ((0 == strcmp(passwordString, "123456")) || (0 == strcmp(passwordString, "12345678"))) { csApplet()->warningBox(tr("Warning: Default PIN is used.\nPlease change the PIN.")); } memset(&password[1], 0, 49); memcpy(&password[1], passwordString.data(), n); } else { if (NULL != cryptostick) { // Get matrix password MatrixPasswordDialog dialog(this); dialog.setModal(TRUE); dialog.cryptostick = cryptostick; dialog.PasswordLen = 19; dialog.SetupInterfaceFlag = false; dialog.InitSecurePasswordDialog(); if (false == dialog.exec()) { done(FALSE); return; } // Copy the matrix password password[0] = 'M'; // For matrix password dialog.CopyMatrixPassword((char *)&password[1], 49); } } }
void PasswordSafeDialog::on_ButtonSendPW_LN_clicked() { QString MsgText; int ret_s32; if (true == ui->radioKeyboard->isChecked()) { OwnSleep::msleep(delaySendTextInMs); ret_s32 = cryptostick->passwordSafeSendSlotDataViaHID(UsedSlot, PWS_SEND_LOGINNAME); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't send loginname via keyboard")); return; } ret_s32 = cryptostick->passwordSafeSendSlotDataViaHID(UsedSlot, PWS_SEND_TAB); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't send CR via keyboard")); return; } ret_s32 = cryptostick->passwordSafeSendSlotDataViaHID(UsedSlot, PWS_SEND_PASSWORD); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't send password via keyboard")); return; } } if (true == ui->radioCutUPaste->isChecked()) { ret_s32 = cryptostick->getPasswordSafeSlotLoginName(UsedSlot); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't get password")); return; } MsgText.append((char *)cryptostick->passwordSafeLoginName); MsgText.append((char)9); // ascii code for tab character ret_s32 = cryptostick->getPasswordSafeSlotPassword(UsedSlot); if (ERR_NO_ERROR != ret_s32) { csApplet()->warningBox(tr("Can't get password")); return; } MsgText.append((char *)cryptostick->passwordSafePassword); clipboard->setText(MsgText); } }
bool Authentication::authenticate(){ bool authenticationSuccess = false; if (isAuthenticated()){ authenticationSuccess = true; markAuthenticated(); return authenticationSuccess; } QString password; do { const auto pinType = type==ADMIN? PinType::ADMIN_PIN : PinType::USER_PIN; PinDialog dialog(pinType); int ok = dialog.exec(); if (ok != QDialog::Accepted) { return authenticationSuccess; } auto password = dialog.getPassword(); tempPassword = generateTemporaryPassword(); try{ switch (pinType){ case PinType::USER_PIN: nm::instance()->user_authenticate(password.c_str(), tempPassword.constData()); break; case PinType::ADMIN_PIN: nm::instance()->first_authenticate(password.c_str(), tempPassword.constData()); break; default: break; } markAuthenticated(); authenticationSuccess = true; return authenticationSuccess; } catch (CommandFailedException &e){ if (!e.reason_wrong_password()) throw; csApplet()->warningBox(tr("Wrong PIN. Please try again.")); } } while (true); return authenticationSuccess; }
void Stick20ResponseTask::ShowIconMessage(const QString msg) { QString title = QString("Nitrokey App"); int timeout = 3000; #ifdef HAVE_LIBAPPINDICATOR if (isUnity()) { if (!notify_init("example")) return; NotifyNotification *notf; notf = notify_notification_new(title.toUtf8().data(), msg.toUtf8().data(), NULL); notify_notification_show(notf, NULL); notify_uninit(); } else #endif // HAVE_LIBAPPINDICATOR { if (TRUE == trayIcon->supportsMessages()) { trayIcon->showMessage(title, msg, QSystemTrayIcon::Information, timeout); } else csApplet()->messageBox(msg); } }
void PasswordDialog::UI_deviceNotInitialized() const { csApplet()->warningBox(tr("Device is not yet initialized. Please try again later.")); }
void Stick20ResponseTask::checkStick20Status() { QString OutputText; Counter_u32++; retStick20Respone = stick20Response->getResponse(cryptostick); if (0 == retStick20Respone) { if (-1 == ActiveCommand) { ActiveCommand = stick20Response->HID_Stick20Status_st.LastCommand_u8; } switch (stick20Response->HID_Stick20Status_st.Status_u8) { case OUTPUT_CMD_STICK20_STATUS_IDLE: break; case OUTPUT_CMD_STICK20_STATUS_OK: EndFlag = TRUE; break; case OUTPUT_CMD_STICK20_STATUS_BUSY: break; case OUTPUT_CMD_STICK20_STATUS_WRONG_PASSWORD: switch (ActiveCommand) { csApplet()->warningBox(tr("Wrong password")); } EndFlag = TRUE; break; case OUTPUT_CMD_STICK20_STATUS_BUSY_PROGRESSBAR: break; case OUTPUT_CMD_STICK20_STATUS_PASSWORD_MATRIX_READY: EndFlag = TRUE; break; case OUTPUT_CMD_STICK20_STATUS_NO_USER_PASSWORD_UNLOCK: EndFlag = TRUE; break; case OUTPUT_CMD_STICK20_STATUS_SMARTCARD_ERROR: EndFlag = TRUE; break; case OUTPUT_CMD_STICK20_STATUS_SECURITY_BIT_ACTIVE: EndFlag = TRUE; break; default: break; } if (TRUE == FlagNoStopWhenStatusOK) { switch (stick20Response->HID_Stick20Status_st.Status_u8) { case OUTPUT_CMD_STICK20_STATUS_OK: done(TRUE); ResultValue = TRUE; break; case OUTPUT_CMD_STICK20_STATUS_IDLE: case OUTPUT_CMD_STICK20_STATUS_BUSY: case OUTPUT_CMD_STICK20_STATUS_BUSY_PROGRESSBAR: case OUTPUT_CMD_STICK20_STATUS_PASSWORD_MATRIX_READY: // Do nothing, wait for next hid info break; case OUTPUT_CMD_STICK20_STATUS_WRONG_PASSWORD: done(FALSE); ResultValue = FALSE; switch (ActiveCommand) { case STICK20_CMD_SEND_CLEAR_STICK_KEYS_NOT_INITIATED: case STICK20_CMD_SEND_LOCK_STICK_HARDWARE: case STICK20_CMD_EXPORT_FIRMWARE_TO_FILE: case STICK20_CMD_GENERATE_NEW_KEYS: case STICK20_CMD_FILL_SD_CARD_WITH_RANDOM_CHARS: if (0 < HID_Stick20Configuration_st.AdminPwRetryCount) { HID_Stick20Configuration_st.AdminPwRetryCount--; } break; case STICK20_CMD_ENABLE_READONLY_UNCRYPTED_LUN: case STICK20_CMD_ENABLE_READWRITE_UNCRYPTED_LUN: case STICK20_CMD_ENABLE_CRYPTED_PARI: if (0 < HID_Stick20Configuration_st.UserPwRetryCount) { HID_Stick20Configuration_st.UserPwRetryCount--; } break; } break; case OUTPUT_CMD_STICK20_STATUS_NO_USER_PASSWORD_UNLOCK: done(FALSE); ResultValue = FALSE; break; case OUTPUT_CMD_STICK20_STATUS_SMARTCARD_ERROR: done(FALSE); ResultValue = FALSE; break; case OUTPUT_CMD_STICK20_STATUS_SECURITY_BIT_ACTIVE: done(FALSE); ResultValue = FALSE; break; } } if (OUTPUT_CMD_STICK20_STATUS_OK == stick20Response->HID_Stick20Status_st.Status_u8) { ResultValue = TRUE; switch (ActiveCommand) { case STICK20_CMD_ENABLE_CRYPTED_PARI: ShowIconMessage(tr("Encrypted volume unlocked successfully")); HID_Stick20Configuration_st.UserPwRetryCount = 3; break; case STICK20_CMD_DISABLE_CRYPTED_PARI: ShowIconMessage(tr("Encrypted volume locked successfully")); break; case STICK20_CMD_ENABLE_HIDDEN_CRYPTED_PARI: ShowIconMessage(tr("Hidden volume unlocked successfully")); break; case STICK20_CMD_DISABLE_HIDDEN_CRYPTED_PARI: ShowIconMessage(tr("Hidden volume locked successfully")); break; case STICK20_CMD_SEND_HIDDEN_VOLUME_SETUP: ShowIconMessage(tr("Hidden volume setup successfully")); break; case STICK20_CMD_ENABLE_READONLY_UNCRYPTED_LUN: ShowIconMessage(tr("Cleartext volume is in readonly mode")); HID_Stick20Configuration_st.UserPwRetryCount = 3; break; case STICK20_CMD_ENABLE_READWRITE_UNCRYPTED_LUN: ShowIconMessage(tr("Cleartext volume is in readwrite mode")); HID_Stick20Configuration_st.UserPwRetryCount = 3; break; case STICK20_CMD_SEND_CLEAR_STICK_KEYS_NOT_INITIATED: ShowIconMessage(tr("Warning disabled")); HID_Stick20Configuration_st.AdminPwRetryCount = 3; break; case STICK20_CMD_SEND_LOCK_STICK_HARDWARE: ShowIconMessage(tr("Firmware is locked")); HID_Stick20Configuration_st.AdminPwRetryCount = 3; break; case STICK20_CMD_EXPORT_FIRMWARE_TO_FILE: ShowIconMessage(tr("Firmware exported successfully")); HID_Stick20Configuration_st.AdminPwRetryCount = 3; break; case STICK20_CMD_GENERATE_NEW_KEYS: ShowIconMessage(tr("New keys generated successfully")); HID_Stick20Configuration_st.AdminPwRetryCount = 3; break; case STICK20_CMD_GET_DEVICE_STATUS: // showStick20Configuration (ret); break; case STICK20_CMD_FILL_SD_CARD_WITH_RANDOM_CHARS: HID_Stick20Configuration_st.AdminPwRetryCount = 3; { csApplet()->messageBox(tr("Storage successfully initialized with random data")); } done(TRUE); break; default: break; } } if (OUTPUT_CMD_STICK20_STATUS_WRONG_PASSWORD == stick20Response->HID_Stick20Status_st.Status_u8) { switch (ActiveCommand) { case STICK20_CMD_ENABLE_HIDDEN_CRYPTED_PARI: { csApplet()->warningBox(tr("Can't enable hidden volume")); } break; default: break; } } if (OUTPUT_CMD_STICK20_STATUS_NO_USER_PASSWORD_UNLOCK == stick20Response->HID_Stick20Status_st.Status_u8) { switch (ActiveCommand) { case STICK20_CMD_SEND_HIDDEN_VOLUME_SETUP: { // msgBox.setText("To setup the hidden volume, please // enable the encrypted volume to enable smartcard // access"); csApplet()->warningBox(tr("Please enable the encrypted volume first.")); } break; case STICK20_CMD_ENABLE_HIDDEN_CRYPTED_PARI: { csApplet()->messageBox(tr("Encrypted volume was not enabled, please " "enable the encrypted volume")); } break; default: break; } } if (OUTPUT_CMD_STICK20_STATUS_SMARTCARD_ERROR == stick20Response->HID_Stick20Status_st.Status_u8) { switch (ActiveCommand) { case STICK20_CMD_ENABLE_HIDDEN_CRYPTED_PARI: { csApplet()->warningBox(tr("Smartcard error, please retry the command")); } break; default: break; } } if (OUTPUT_CMD_STICK20_STATUS_SECURITY_BIT_ACTIVE == stick20Response->HID_Stick20Status_st.Status_u8) { switch (ActiveCommand) { case STICK20_CMD_ENABLE_FIRMWARE_UPDATE: { csApplet()->messageBox(tr("Security bit of the device is activated.\nFirmware update is " "not possible.")); } break; default: break; } } } }