Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
ced1ac37
Commit
ced1ac37
authored
Dec 09, 2020
by
Ingo Klöcker
Browse files
Offer creation of OpenPGP keys from card keys only if supported by gpg
GnuPG-bug-id: 5125, 5126, 5128
parent
5f6c5636
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/commands/createopenpgpkeyfromcardkeyscommand.cpp
View file @
ced1ac37
...
...
@@ -217,6 +217,12 @@ CreateOpenPGPKeyFromCardKeysCommand::~CreateOpenPGPKeyFromCardKeysCommand()
{
}
// static
bool
CreateOpenPGPKeyFromCardKeysCommand
::
isSupported
()
{
return
!
(
engineInfo
(
GpgEngine
).
engineVersion
()
<
"2.2.18"
);
}
void
CreateOpenPGPKeyFromCardKeysCommand
::
doStart
()
{
d
->
start
();
...
...
src/commands/createopenpgpkeyfromcardkeyscommand.h
View file @
ced1ac37
...
...
@@ -25,6 +25,8 @@ public:
explicit
CreateOpenPGPKeyFromCardKeysCommand
(
const
std
::
string
&
serialNumber
,
const
std
::
string
&
appName
,
QWidget
*
parent
=
nullptr
);
~
CreateOpenPGPKeyFromCardKeysCommand
()
override
;
static
bool
isSupported
();
private:
void
doStart
()
override
;
void
doCancel
()
override
;
...
...
src/view/netkeywidget.cpp
View file @
ced1ac37
...
...
@@ -44,7 +44,6 @@ NetKeyWidget::NetKeyWidget(QWidget *parent) :
mErrorLabel
(
new
QLabel
(
this
)),
mNullPinWidget
(
new
NullPinWidget
()),
mLearnKeysBtn
(
new
QPushButton
(
this
)),
mKeyForCardKeysButton
(
new
QPushButton
(
this
)),
mChangeNKSPINBtn
(
new
QPushButton
(
this
)),
mChangeSigGPINBtn
(
new
QPushButton
(
this
)),
mTreeView
(
new
KeyTreeView
(
this
)),
...
...
@@ -135,10 +134,13 @@ NetKeyWidget::NetKeyWidget(QWidget *parent) :
auto
actionLayout
=
new
QHBoxLayout
();
mKeyForCardKeysButton
->
setText
(
i18nc
(
"@action:button"
,
"Create OpenPGP Key"
));
mKeyForCardKeysButton
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Create an OpenPGP key for the keys stored on the card."
));
actionLayout
->
addWidget
(
mKeyForCardKeysButton
);
connect
(
mKeyForCardKeysButton
,
&
QPushButton
::
clicked
,
this
,
&
NetKeyWidget
::
createKeyFromCardKeys
);
if
(
CreateOpenPGPKeyFromCardKeysCommand
::
isSupported
())
{
mKeyForCardKeysButton
=
new
QPushButton
(
this
);
mKeyForCardKeysButton
->
setText
(
i18nc
(
"@action:button"
,
"Create OpenPGP Key"
));
mKeyForCardKeysButton
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Create an OpenPGP key for the keys stored on the card."
));
actionLayout
->
addWidget
(
mKeyForCardKeysButton
);
connect
(
mKeyForCardKeysButton
,
&
QPushButton
::
clicked
,
this
,
&
NetKeyWidget
::
createKeyFromCardKeys
);
}
mChangeNKSPINBtn
->
setText
(
i18nc
(
"NKS is an identifier for a type of keys on a NetKey card"
,
"Change NKS PIN"
));
mChangeSigGPINBtn
->
setText
(
i18nc
(
"SigG is an identifier for a type of keys on a NetKey card"
,
"Change SigG PIN"
));
...
...
src/view/netkeywidget.h
View file @
ced1ac37
...
...
@@ -47,17 +47,17 @@ private Q_SLOTS:
private:
std
::
string
mSerialNumber
;
QLabel
*
mSerialNumberLabel
,
*
mVersionLabel
,
*
mLearnKeysLabel
,
*
mErrorLabel
;
NullPinWidget
*
mNullPinWidget
;
QPushButton
*
mLearnKeysBtn
,
*
mKeyForCardKeysButton
,
*
mChangeNKSPINBtn
,
*
mChangeSigGPINBtn
;
KeyTreeView
*
mTreeView
;
QScrollArea
*
mArea
;
QLabel
*
mSerialNumberLabel
=
nullptr
,
*
mVersionLabel
=
nullptr
,
*
mLearnKeysLabel
=
nullptr
,
*
mErrorLabel
=
nullptr
;
NullPinWidget
*
mNullPinWidget
=
nullptr
;
QPushButton
*
mLearnKeysBtn
=
nullptr
,
*
mKeyForCardKeysButton
=
nullptr
,
*
mChangeNKSPINBtn
=
nullptr
,
*
mChangeSigGPINBtn
=
nullptr
;
KeyTreeView
*
mTreeView
=
nullptr
;
QScrollArea
*
mArea
=
nullptr
;
};
}
// namespace Kleo
...
...
src/view/pgpcardwidget.cpp
View file @
ced1ac37
...
...
@@ -105,7 +105,6 @@ PGPCardWidget::PGPCardWidget(QWidget *parent):
mEncryptionKey
(
new
QLabel
(
this
)),
mAuthKey
(
new
QLabel
(
this
)),
mUrlLabel
(
new
QLabel
(
this
)),
mKeyForCardKeysButton
(
new
QPushButton
(
this
)),
mCardIsEmpty
(
false
)
{
auto
grid
=
new
QGridLayout
;
...
...
@@ -202,10 +201,13 @@ PGPCardWidget::PGPCardWidget(QWidget *parent):
actionLayout
->
addWidget
(
resetCodeButton
);
connect
(
resetCodeButton
,
&
QPushButton
::
clicked
,
this
,
[
this
]
()
{
doChangePin
(
OpenPGPCard
::
resetCodeKeyRef
());
});
mKeyForCardKeysButton
->
setText
(
i18n
(
"Create OpenPGP Key"
));
mKeyForCardKeysButton
->
setToolTip
(
i18n
(
"Create an OpenPGP key for the keys stored on the card."
));
actionLayout
->
addWidget
(
mKeyForCardKeysButton
);
connect
(
mKeyForCardKeysButton
,
&
QPushButton
::
clicked
,
this
,
&
PGPCardWidget
::
createKeyFromCardKeys
);
if
(
CreateOpenPGPKeyFromCardKeysCommand
::
isSupported
())
{
mKeyForCardKeysButton
=
new
QPushButton
(
this
);
mKeyForCardKeysButton
->
setText
(
i18n
(
"Create OpenPGP Key"
));
mKeyForCardKeysButton
->
setToolTip
(
i18n
(
"Create an OpenPGP key for the keys stored on the card."
));
actionLayout
->
addWidget
(
mKeyForCardKeysButton
);
connect
(
mKeyForCardKeysButton
,
&
QPushButton
::
clicked
,
this
,
&
PGPCardWidget
::
createKeyFromCardKeys
);
}
actionLayout
->
addStretch
(
-
1
);
grid
->
addLayout
(
actionLayout
,
row
++
,
0
,
1
,
4
);
...
...
@@ -240,7 +242,9 @@ void PGPCardWidget::setCard(const OpenPGPCard *card)
updateKey
(
mAuthKey
,
card
->
authFpr
());
mCardIsEmpty
=
card
->
authFpr
().
empty
()
&&
card
->
sigFpr
().
empty
()
&&
card
->
encFpr
().
empty
();
mKeyForCardKeysButton
->
setEnabled
(
card
->
hasSigningKey
()
&&
card
->
hasEncryptionKey
());
if
(
mKeyForCardKeysButton
)
{
mKeyForCardKeysButton
->
setEnabled
(
card
->
hasSigningKey
()
&&
card
->
hasEncryptionKey
());
}
}
void
PGPCardWidget
::
doChangePin
(
const
std
::
string
&
keyRef
)
...
...
src/view/pivcardwidget.cpp
View file @
ced1ac37
...
...
@@ -78,7 +78,6 @@ PIVCardWidget::PIVCardWidget(QWidget *parent)
:
QWidget
(
parent
)
,
mSerialNumber
(
new
QLabel
(
this
))
,
mVersionLabel
(
new
QLabel
(
this
))
,
mKeyForCardKeysButton
(
new
QPushButton
(
this
))
{
// Set up the scroll area
auto
myLayout
=
new
QVBoxLayout
(
this
);
...
...
@@ -144,10 +143,13 @@ PIVCardWidget::PIVCardWidget(QWidget *parent)
auto
actionLayout
=
new
QHBoxLayout
;
mKeyForCardKeysButton
->
setText
(
i18nc
(
"@action:button"
,
"Create OpenPGP Key"
));
mKeyForCardKeysButton
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Create an OpenPGP key for the keys stored on the card."
));
actionLayout
->
addWidget
(
mKeyForCardKeysButton
);
connect
(
mKeyForCardKeysButton
,
&
QPushButton
::
clicked
,
this
,
&
PIVCardWidget
::
createKeyFromCardKeys
);
if
(
CreateOpenPGPKeyFromCardKeysCommand
::
isSupported
())
{
mKeyForCardKeysButton
=
new
QPushButton
(
this
);
mKeyForCardKeysButton
->
setText
(
i18nc
(
"@action:button"
,
"Create OpenPGP Key"
));
mKeyForCardKeysButton
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Create an OpenPGP key for the keys stored on the card."
));
actionLayout
->
addWidget
(
mKeyForCardKeysButton
);
connect
(
mKeyForCardKeysButton
,
&
QPushButton
::
clicked
,
this
,
&
PIVCardWidget
::
createKeyFromCardKeys
);
}
{
auto
button
=
new
QPushButton
(
i18nc
(
"@action:button"
,
"Change PIN"
));
...
...
@@ -228,7 +230,9 @@ void PIVCardWidget::setCard(const PIVCard *card)
updateKeyWidgets
(
PIVCard
::
digitalSignatureKeyRef
(),
card
);
updateKeyWidgets
(
PIVCard
::
keyManagementKeyRef
(),
card
);
mKeyForCardKeysButton
->
setEnabled
(
card
->
hasSigningKey
()
&&
card
->
hasEncryptionKey
());
if
(
mKeyForCardKeysButton
)
{
mKeyForCardKeysButton
->
setEnabled
(
card
->
hasSigningKey
()
&&
card
->
hasEncryptionKey
());
}
}
void
PIVCardWidget
::
updateKeyWidgets
(
const
std
::
string
&
keyRef
,
const
PIVCard
*
card
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment