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
b3dcee27
Verified
Commit
b3dcee27
authored
Oct 18, 2022
by
Ingo Klöcker
Committed by
Ingo Klöcker
Oct 19, 2022
Browse files
Add simple struct for information on algorithms
GnuPG-bug-id: 4429
parent
9f72d2d7
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
b3dcee27
...
...
@@ -391,6 +391,7 @@ set(_kleopatra_SRCS
selftest/libkleopatrarccheck.h
selftest/selftest.cpp
selftest/selftest.h
smartcard/algorithminfo.h
smartcard/card.cpp
smartcard/card.h
smartcard/deviceinfowatcher.cpp
...
...
src/commands/pivgeneratecardkeycommand.cpp
View file @
b3dcee27
...
...
@@ -11,6 +11,7 @@
#include
"cardcommand_p.h"
#include
"smartcard/algorithminfo.h"
#include
"smartcard/pivcard.h"
#include
"smartcard/readerstatus.h"
...
...
src/dialogs/gencardkeydialog.cpp
View file @
b3dcee27
...
...
@@ -9,6 +9,7 @@
#include
"gencardkeydialog.h"
#include
"smartcard/algorithminfo.h"
#include
"utils/qt-cxx20-compat.h"
#include
"utils/userinfo.h"
...
...
@@ -117,7 +118,7 @@ public:
q
->
accept
();
}
void
setSupportedAlgorithms
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
QString
>
>
&
algorithms
,
const
std
::
string
&
defaultAlgo
)
void
setSupportedAlgorithms
(
const
std
::
vector
<
SmartCard
::
AlgorithmInfo
>
&
algorithms
,
const
std
::
string
&
defaultAlgo
)
{
if
(
!
mAlgorithmCombo
)
{
qCWarning
(
KLEOPATRA_LOG
)
<<
"GenCardKeyDialog::setSupportedAlgorithms() called, but algorithm no required key attribute"
;
...
...
@@ -125,8 +126,8 @@ public:
}
mAlgorithmCombo
->
clear
();
for
(
auto
algorithm
:
algorithms
)
{
mAlgorithmCombo
->
addItem
(
algorithm
.
second
,
QByteArray
::
fromStdString
(
algorithm
.
first
));
for
(
const
auto
&
algorithm
:
algorithms
)
{
mAlgorithmCombo
->
addItem
(
algorithm
.
displayName
,
QByteArray
::
fromStdString
(
algorithm
.
id
));
}
mAlgorithmCombo
->
setCurrentIndex
(
mAlgorithmCombo
->
findData
(
QByteArray
::
fromStdString
(
defaultAlgo
)));
}
...
...
@@ -160,7 +161,7 @@ GenCardKeyDialog::GenCardKeyDialog(KeyAttributes requiredAttributes, QWidget *pa
{
}
void
GenCardKeyDialog
::
setSupportedAlgorithms
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
QString
>
>
&
algorithms
,
const
std
::
string
&
defaultAlgo
)
void
GenCardKeyDialog
::
setSupportedAlgorithms
(
const
std
::
vector
<
SmartCard
::
AlgorithmInfo
>
&
algorithms
,
const
std
::
string
&
defaultAlgo
)
{
d
->
setSupportedAlgorithms
(
algorithms
,
defaultAlgo
);
}
...
...
src/dialogs/gencardkeydialog.h
View file @
b3dcee27
...
...
@@ -17,6 +17,11 @@
namespace
Kleo
{
namespace
SmartCard
{
struct
AlgorithmInfo
;
}
class
GenCardKeyDialog
:
public
QDialog
{
Q_OBJECT
...
...
@@ -49,7 +54,7 @@ public:
KeyParams
getKeyParams
()
const
;
void
setSupportedAlgorithms
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
QString
>
>
&
algorithms
,
const
std
::
string
&
defaultAlgo
);
void
setSupportedAlgorithms
(
const
std
::
vector
<
SmartCard
::
AlgorithmInfo
>
&
algorithms
,
const
std
::
string
&
defaultAlgo
);
private:
class
Private
;
...
...
src/smartcard/algorithminfo.h
0 → 100644
View file @
b3dcee27
/* smartcard/algorithminfo.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include
<string>
class
QString
;
namespace
Kleo
{
namespace
SmartCard
{
struct
AlgorithmInfo
{
std
::
string
id
;
QString
displayName
;
};
}
// namespace SmartCard
}
// namespace Kleo
src/smartcard/pivcard.cpp
View file @
b3dcee27
...
...
@@ -9,6 +9,7 @@
#include
"pivcard.h"
#include
"algorithminfo.h"
#include
"keypairinfo.h"
#include
<KLocalizedString>
...
...
@@ -91,7 +92,7 @@ QString PIVCard::keyDisplayName(const std::string &keyRef)
}
// static
std
::
vector
<
std
::
pair
<
std
::
string
,
QString
>
>
PIVCard
::
supportedAlgorithms
(
const
std
::
string
&
keyRef
)
std
::
vector
<
AlgorithmInfo
>
PIVCard
::
supportedAlgorithms
(
const
std
::
string
&
keyRef
)
{
if
(
keyRef
==
PIVCard
::
keyManagementKeyRef
())
{
return
{
...
...
src/smartcard/pivcard.h
View file @
b3dcee27
...
...
@@ -14,6 +14,7 @@ namespace Kleo
{
namespace
SmartCard
{
struct
AlgorithmInfo
;
struct
KeyPairInfo
;
/** Class to work with PIV smartcards or compatible tokens */
...
...
@@ -34,7 +35,7 @@ public:
static
const
std
::
vector
<
KeyPairInfo
>
&
supportedKeys
();
static
QString
keyDisplayName
(
const
std
::
string
&
keyRef
);
static
std
::
vector
<
std
::
pair
<
std
::
string
,
QString
>
>
supportedAlgorithms
(
const
std
::
string
&
keyRef
);
static
std
::
vector
<
AlgorithmInfo
>
supportedAlgorithms
(
const
std
::
string
&
keyRef
);
std
::
string
keyAlgorithm
(
const
std
::
string
&
keyRef
)
const
;
void
setKeyAlgorithm
(
const
std
::
string
&
keyRef
,
const
std
::
string
&
algorithm
);
...
...
src/view/pgpcardwidget.cpp
View file @
b3dcee27
...
...
@@ -18,6 +18,7 @@
#include
"commands/createcsrforcardkeycommand.h"
#include
"commands/createopenpgpkeyfromcardkeyscommand.h"
#include
"smartcard/algorithminfo.h"
#include
"smartcard/openpgpcard.h"
#include
"smartcard/readerstatus.h"
...
...
@@ -357,7 +358,7 @@ void PGPCardWidget::genkeyRequested()
}
auto
dlg
=
new
GenCardKeyDialog
(
GenCardKeyDialog
::
AllKeyAttributes
,
this
);
std
::
vector
<
std
::
pair
<
std
::
string
,
QString
>
>
algos
=
{
std
::
vector
<
AlgorithmInfo
>
algos
=
{
{
"1024"
,
QStringLiteral
(
"RSA 1024"
)
},
{
"2048"
,
QStringLiteral
(
"RSA 2048"
)
},
{
"3072"
,
QStringLiteral
(
"RSA 3072"
)
}
...
...
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