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
d2bf514e
Commit
d2bf514e
authored
Dec 08, 2020
by
Ingo Klöcker
Browse files
Fetch and store IDs of signing key and encryption key for card
GnuPG-bug-id: 5125, 5126, 5128
parent
3ca64c75
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/smartcard/card.cpp
View file @
d2bf514e
...
...
@@ -121,6 +121,26 @@ QString Card::cardHolder() const
return
mCardHolder
;
}
void
Card
::
setSigningKeyRef
(
const
std
::
string
&
keyRef
)
{
mSigningKeyRef
=
keyRef
;
}
std
::
string
Card
::
signingKeyRef
()
const
{
return
mSigningKeyRef
;
}
void
Card
::
setEncryptionKeyRef
(
const
std
::
string
&
keyRef
)
{
mEncryptionKeyRef
=
keyRef
;
}
std
::
string
Card
::
encryptionKeyRef
()
const
{
return
mEncryptionKeyRef
;
}
std
::
vector
<
Card
::
PinState
>
Card
::
pinStates
()
const
{
return
mPinStates
;
...
...
src/smartcard/card.h
View file @
d2bf514e
...
...
@@ -76,6 +76,12 @@ public:
QString
cardHolder
()
const
;
void
setSigningKeyRef
(
const
std
::
string
&
keyRef
);
std
::
string
signingKeyRef
()
const
;
void
setEncryptionKeyRef
(
const
std
::
string
&
keyRef
);
std
::
string
encryptionKeyRef
()
const
;
std
::
vector
<
PinState
>
pinStates
()
const
;
void
setPinStates
(
const
std
::
vector
<
PinState
>
&
pinStates
);
...
...
@@ -110,6 +116,8 @@ private:
std
::
string
mCardType
;
int
mCardVersion
=
-
1
;
QString
mCardHolder
;
std
::
string
mSigningKeyRef
;
std
::
string
mEncryptionKeyRef
;
std
::
vector
<
PinState
>
mPinStates
;
QString
mErrMsg
;
std
::
vector
<
KeyPairInfo
>
mKeyInfos
;
...
...
src/smartcard/readerstatus.cpp
View file @
d2bf514e
...
...
@@ -234,6 +234,21 @@ static const std::string scd_getattr_status(std::shared_ptr<Context> &gpgAgent,
return
gpgagent_status
(
gpgAgent
,
cmd
.
c_str
(),
err
);
}
static
const
std
::
string
getAttribute
(
std
::
shared_ptr
<
Context
>
&
gpgAgent
,
const
char
*
attribute
,
const
char
*
versionHint
)
{
Error
err
;
const
auto
result
=
scd_getattr_status
(
gpgAgent
,
attribute
,
err
);
if
(
err
)
{
if
(
err
.
code
()
==
GPG_ERR_INV_NAME
)
{
qCDebug
(
KLEOPATRA_LOG
)
<<
"Querying for attribute"
<<
attribute
<<
"not yet supported; needs GnuPG"
<<
versionHint
;
}
else
{
qCWarning
(
KLEOPATRA_LOG
)
<<
"Running SCD GETATTR "
<<
attribute
<<
" failed:"
<<
err
;
}
return
std
::
string
();
}
return
result
;
}
static
std
::
vector
<
CardApp
>
getCardsAndApps
(
std
::
shared_ptr
<
Context
>
&
gpgAgent
,
Error
&
err
)
{
std
::
vector
<
CardApp
>
result
;
...
...
@@ -608,6 +623,9 @@ static std::shared_ptr<Card> get_card_status(const std::string &serialNumber, co
ci
->
setSerialNumber
(
serialNumber
);
ci
->
setSigningKeyRef
(
getAttribute
(
gpg_agent
,
"$SIGNKEYID"
,
"2.2.18"
));
ci
->
setEncryptionKeyRef
(
getAttribute
(
gpg_agent
,
"$ENCRKEYID"
,
"2.2.18"
));
// Handle different card types
if
(
appName
==
NetKeyCard
::
AppName
)
{
qCDebug
(
KLEOPATRA_LOG
)
<<
"get_card_status: found Netkey card"
<<
ci
->
serialNumber
().
c_str
()
<<
"end"
;
...
...
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