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
02b63bb5
Commit
02b63bb5
authored
Dec 08, 2020
by
Ingo Klöcker
Browse files
Replace card-specific logic with info about signing/encryption key
GnuPG-bug-id: 5125, 5126
parent
d2bf514e
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/commands/createopenpgpkeyfromcardkeyscommand.cpp
View file @
02b63bb5
...
...
@@ -91,26 +91,21 @@ CreateOpenPGPKeyFromCardKeysCommand::Private::~Private()
void
CreateOpenPGPKeyFromCardKeysCommand
::
Private
::
start
()
{
const
auto
card
=
ReaderStatus
::
instance
()
->
getCard
(
serialNumber
(),
appName
);
if
(
!
card
)
{
error
(
i18n
(
"Failed to find the smartcard with the serial number: %1"
,
QString
::
fromStdString
(
serialNumber
())));
if
(
appName
!=
OpenPGPCard
::
AppName
&&
appName
!=
PIVCard
::
AppName
)
{
qCWarning
(
KLEOPATRA_LOG
)
<<
"CreateOpenPGPKeyFromCardKeysCommand does not support card application"
<<
QString
::
fromStdString
(
appName
);
finished
();
return
;
}
Key
signingKey
;
if
(
card
->
appName
()
==
OpenPGPCard
::
AppName
)
{
const
auto
pgpCard
=
std
::
dynamic_pointer_cast
<
OpenPGPCard
>
(
card
);
signingKey
=
KeyCache
::
instance
()
->
findByKeyIDOrFingerprint
(
pgpCard
->
sigFpr
());
}
else
if
(
appName
==
PIVCard
::
AppName
)
{
const
auto
pivCard
=
std
::
dynamic_pointer_cast
<
PIVCard
>
(
card
);
signingKey
=
KeyCache
::
instance
()
->
findSubkeyByKeyGrip
(
pivCard
->
keyGrip
(
PIVCard
::
digitalSignatureKeyRef
()),
OpenPGP
).
parent
();
}
else
{
qCWarning
(
KLEOPATRA_LOG
)
<<
"CreateOpenPGPKeyFromCardKeysCommand does not support card application"
<<
QString
::
fromStdString
(
appName
);
const
auto
card
=
ReaderStatus
::
instance
()
->
getCard
(
serialNumber
(),
appName
);
if
(
!
card
)
{
error
(
i18n
(
"Failed to find the smartcard with the serial number: %1"
,
QString
::
fromStdString
(
serialNumber
())));
finished
();
return
;
}
const
auto
signingKeyGrip
=
card
->
keyInfo
(
card
->
signingKeyRef
()).
grip
;
const
Key
signingKey
=
KeyCache
::
instance
()
->
findSubkeyByKeyGrip
(
signingKeyGrip
,
OpenPGP
).
parent
();
if
(
!
signingKey
.
isNull
())
{
const
QString
message
=
i18nc
(
"@info"
,
"<p>There is already an OpenPGP key corresponding to the signing key on this card:</p><p>%1</p>"
...
...
src/smartcard/card.cpp
View file @
02b63bb5
...
...
@@ -131,6 +131,11 @@ std::string Card::signingKeyRef() const
return
mSigningKeyRef
;
}
bool
Card
::
hasSigningKey
()
const
{
return
!
keyInfo
(
mSigningKeyRef
).
grip
.
empty
();
}
void
Card
::
setEncryptionKeyRef
(
const
std
::
string
&
keyRef
)
{
mEncryptionKeyRef
=
keyRef
;
...
...
@@ -141,6 +146,11 @@ std::string Card::encryptionKeyRef() const
return
mEncryptionKeyRef
;
}
bool
Card
::
hasEncryptionKey
()
const
{
return
!
keyInfo
(
mEncryptionKeyRef
).
grip
.
empty
();
}
std
::
vector
<
Card
::
PinState
>
Card
::
pinStates
()
const
{
return
mPinStates
;
...
...
src/smartcard/card.h
View file @
02b63bb5
...
...
@@ -78,9 +78,11 @@ public:
void
setSigningKeyRef
(
const
std
::
string
&
keyRef
);
std
::
string
signingKeyRef
()
const
;
bool
hasSigningKey
()
const
;
void
setEncryptionKeyRef
(
const
std
::
string
&
keyRef
);
std
::
string
encryptionKeyRef
()
const
;
bool
hasEncryptionKey
()
const
;
std
::
vector
<
PinState
>
pinStates
()
const
;
void
setPinStates
(
const
std
::
vector
<
PinState
>
&
pinStates
);
...
...
src/view/pgpcardwidget.cpp
View file @
02b63bb5
...
...
@@ -240,7 +240,7 @@ void PGPCardWidget::setCard(const OpenPGPCard *card)
updateKey
(
mAuthKey
,
card
->
authFpr
());
mCardIsEmpty
=
card
->
authFpr
().
empty
()
&&
card
->
sigFpr
().
empty
()
&&
card
->
encFpr
().
empty
();
mKeyForCardKeysButton
->
setEnabled
(
!
mCardIsEmpty
);
mKeyForCardKeysButton
->
setEnabled
(
card
->
hasSigningKey
()
&&
card
->
hasEncryptionKey
()
);
}
void
PGPCardWidget
::
doChangePin
(
const
std
::
string
&
keyRef
)
...
...
src/view/pivcardwidget.cpp
View file @
02b63bb5
...
...
@@ -228,9 +228,7 @@ void PIVCardWidget::setCard(const PIVCard *card)
updateKeyWidgets
(
PIVCard
::
digitalSignatureKeyRef
(),
card
);
updateKeyWidgets
(
PIVCard
::
keyManagementKeyRef
(),
card
);
const
bool
signingKeyAvailable
=
!
card
->
keyGrip
(
PIVCard
::
digitalSignatureKeyRef
()).
empty
();
const
bool
encryptionKeyAvailable
=
!
card
->
keyGrip
(
PIVCard
::
keyManagementKeyRef
()).
empty
();
mKeyForCardKeysButton
->
setEnabled
(
signingKeyAvailable
&&
encryptionKeyAvailable
);
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