From 9a17aa3f0668732fc778e3560d2f111182cb337b Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 24 Nov 2024 20:16:57 +0100 Subject: feat: improve info prompt at private key exporting --- src/ui/dialog/keypair_details/KeyPairOperaTab.cpp | 88 +++++++++++++---------- 1 file changed, 52 insertions(+), 36 deletions(-) (limited to 'src/ui/dialog/keypair_details/KeyPairOperaTab.cpp') diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp index ff796d6c..35e93faf 100644 --- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp +++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp @@ -184,9 +184,14 @@ void KeyPairOperaTab::CreateOperaMenu() { connect(export_shortest_secret_key, &QAction::triggered, this, &KeyPairOperaTab::slot_export_short_private_key); - if (Module::IsModuleActivate(kPaperKeyModuleID)) { - auto* export_secret_key_as_paper_key = - new QAction(tr("Export Secret Key As A Paper Key"), this); + secret_key_export_opera_menu_->addAction(export_full_secret_key); + secret_key_export_opera_menu_->addAction(export_shortest_secret_key); + + // only work with RSA + if (m_key_.GetKeyAlgo() == "RSA" && + Module::IsModuleActivate(kPaperKeyModuleID)) { + auto* export_secret_key_as_paper_key = new QAction( + tr("Export Secret Key As A Paper Key") + QString(" (BETA)"), this); connect(export_secret_key_as_paper_key, &QAction::triggered, this, &KeyPairOperaTab::slot_export_paper_key); if (!m_key_.IsPrivateKey()) { @@ -195,9 +200,6 @@ void KeyPairOperaTab::CreateOperaMenu() { secret_key_export_opera_menu_->addAction(export_secret_key_as_paper_key); } - secret_key_export_opera_menu_->addAction(export_full_secret_key); - secret_key_export_opera_menu_->addAction(export_shortest_secret_key); - rev_cert_opera_menu_ = new QMenu(this); auto* rev_cert_gen_action = @@ -248,18 +250,19 @@ void KeyPairOperaTab::slot_export_public_key() { } void KeyPairOperaTab::slot_export_short_private_key() { - // Show a information box with explanation about private key - int ret = QMessageBox::information( - this, tr("Exporting short private Key"), - "

" + tr("You are about to export your") + "" + - tr(" PRIVATE KEY ") + "!

\n" + - tr("This is NOT your Public Key, so DON'T give it away.") + "
" + - tr("Do you REALLY want to export your PRIVATE KEY in a Minimum " - "Size?") + - "
" + - tr("For OpenPGP keys it removes all signatures except for the latest " - "self-signatures."), - QMessageBox::Cancel | QMessageBox::Ok); + QString warning_message = + "

" + tr("WARNING: You are about to export your") + " " + + "" + tr("PRIVATE KEY") + "!

" + "

" + + tr("This is NOT your Public Key, so DO NOT share it with " + "anyone.") + + "

" + "

" + + tr("You are exporting a minimum size private key, which " + "removes all signatures except for the latest self-signatures.") + + "

" + "

" + tr("Do you REALLY want to proceed?") + "

"; + + int ret = QMessageBox::warning(this, tr("Exporting Short Private Key"), + warning_message, + QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked if (ret == QMessageBox::Ok) { @@ -298,13 +301,20 @@ void KeyPairOperaTab::slot_export_short_private_key() { void KeyPairOperaTab::slot_export_private_key() { // Show a information box with explanation about private key - int ret = QMessageBox::information( - this, tr("Exporting private Key"), - "

" + tr("You are about to export your") + "" + - tr(" PRIVATE KEY ") + "!

\n" + - tr("This is NOT your Public Key, so DON'T give it away.") + "
" + - tr("Do you REALLY want to export your PRIVATE KEY?"), - QMessageBox::Cancel | QMessageBox::Ok); + QString warning_message = + "

" + tr("WARNING: You are about to export your") + " " + + "" + tr("PRIVATE KEY") + "!

" + "

" + + tr("This operation will export your private key, including both " + "the main key and all subkeys, " + "into an external file. This key is extremely sensitive, and anyone " + "with access to it can impersonate you. " + "DO NOT share this file with anyone!") + + "

" + "

" + + tr("Are you ABSOLUTELY SURE you want to proceed?") + "

"; + + int ret = + QMessageBox::warning(this, tr("Exporting Private Key"), warning_message, + QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked if (ret == QMessageBox::Ok) { @@ -590,17 +600,23 @@ void KeyPairOperaTab::slot_import_revoke_cert() { void KeyPairOperaTab::slot_export_paper_key() { if (!Module::IsModuleActivate(kPaperKeyModuleID)) return; - int ret = QMessageBox::information( - this, tr("Exporting private key as a Paper key"), - "

" + tr("You are about to export your") + "" + - tr(" PRIVATE KEY ") + "!

\n" + - tr("This is NOT your Public Key, so DON'T give it away.") + "
" + - tr("A PaperKey is a human-readable printout of your private key, " - "which can be used to recover your key if you lose access to " - "your " - "digital copy. ") + - "
" + tr("Keep it in a safe place.") + "
" + - tr("Do you REALLY want to export your PRIVATE KEY?"), + QString warning_message = + "

" + tr("WARNING: You are about to export your") + " " + + "" + tr("PRIVATE KEY") + "!

" + "

" + + tr("This is NOT your Public Key, so DO NOT share it with " + "anyone.") + + "

" + "

" + + tr("A PaperKey is a human-readable printout of your private key, " + "which can be used to recover your key if you lose access to your " + "digital copy. ") + + "

" + "

" + + tr("Keep this paper copy in a safe and secure place, such as a fireproof " + "safe or a trusted vault.") + + "

" + "

" + + tr("Are you ABSOLUTELY SURE you want to proceed?") + "

"; + + int ret = QMessageBox::warning( + this, tr("Exporting Private Key as a PaperKey"), warning_message, QMessageBox::Cancel | QMessageBox::Ok); // export key, if ok was clicked -- cgit v1.2.3