Skip to content
GitLab
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
172f645d
Verified
Commit
172f645d
authored
Nov 03, 2022
by
Ingo Klöcker
Committed by
Ingo Klöcker
Nov 03, 2022
Browse files
Add helper to check if two UserID objects represent the same user ID
GnuPG-bug-id: 6265
parent
014e3c7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/utils/keys.cpp
View file @
172f645d
...
...
@@ -141,3 +141,22 @@ bool Kleo::userIDBelongsToKey(const GpgME::UserID &userID, const GpgME::Key &key
{
return
!
qstricmp
(
userID
.
parent
().
primaryFingerprint
(),
key
.
primaryFingerprint
());
}
static
time_t
creationDate
(
const
GpgME
::
UserID
&
uid
)
{
// returns the date of the first self-signature
for
(
unsigned
int
i
=
0
,
numSignatures
=
uid
.
numSignatures
();
i
<
numSignatures
;
++
i
)
{
const
auto
sig
=
uid
.
signature
(
i
);
if
(
Kleo
::
isSelfSignature
(
sig
))
{
return
sig
.
creationTime
();
}
}
return
0
;
}
bool
Kleo
::
userIDsAreEqual
(
const
GpgME
::
UserID
&
lhs
,
const
GpgME
::
UserID
&
rhs
)
{
return
(
qstrcmp
(
lhs
.
parent
().
primaryFingerprint
(),
rhs
.
parent
().
primaryFingerprint
())
==
0
&&
qstrcmp
(
lhs
.
id
(),
rhs
.
id
())
==
0
&&
creationDate
(
lhs
)
==
creationDate
(
rhs
));
}
src/utils/keys.h
View file @
172f645d
...
...
@@ -110,4 +110,13 @@ inline auto userIDBelongsToKey(const GpgME::Key &key)
};
}
/**
* Returns true, if the two user IDs \p lhs and \p rhs are equal.
*
* Equality means that both user IDs belong to the same key, contain identical
* text, and have the same creation date (i.e. the creation date of the first
* self-signature is the same).
*/
bool
userIDsAreEqual
(
const
GpgME
::
UserID
&
lhs
,
const
GpgME
::
UserID
&
rhs
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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