mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Extend #383: tag insecure PFX/PKCS#12 algorithms
Show the insecure algorithms with the postfix (insecure) in the dropdown menu. Since the "insecure" is translateable, put the algorithm NID into the data field of the combo-box entry to reliably find the correct entry by NID instead of text.
This commit is contained in:
parent
10e8385c69
commit
e72ffb1445
@ -207,6 +207,14 @@ QString encAlgo::name() const
|
||||
return QString(encAlgo_nid == NID_undef ? "" : OBJ_nid2sn(encAlgo_nid));
|
||||
}
|
||||
|
||||
QString encAlgo::displayName() const
|
||||
{
|
||||
QString n = name();
|
||||
if (legacy())
|
||||
n += QString(" (%1)").arg(QObject::tr("insecure"));
|
||||
return n;
|
||||
}
|
||||
|
||||
int encAlgo::getEncAlgoNid() const
|
||||
{
|
||||
return encAlgo_nid;
|
||||
|
||||
@ -28,6 +28,7 @@ class encAlgo
|
||||
encAlgo& operator=(const encAlgo &d) = default;
|
||||
|
||||
QString name() const;
|
||||
QString displayName() const;
|
||||
int getEncAlgoNid() const;
|
||||
bool legacy() const
|
||||
{
|
||||
|
||||
@ -16,34 +16,34 @@ pkcs12EncBox::pkcs12EncBox(QWidget *parent)
|
||||
|
||||
const encAlgo pkcs12EncBox::current() const
|
||||
{
|
||||
return encAlgo(currentText());
|
||||
return encAlgo(currentData().toInt());
|
||||
}
|
||||
|
||||
void pkcs12EncBox::setCurrent(const encAlgo &md)
|
||||
{
|
||||
int idx = findText(md.name());
|
||||
int idx = findData(QVariant(md.getEncAlgoNid()));
|
||||
if (idx != -1) {
|
||||
setCurrentIndex(idx);
|
||||
wanted_encAlgo = "";
|
||||
wanted_encAlgo = NID_undef;
|
||||
} else {
|
||||
wanted_encAlgo = md.name();
|
||||
wanted_encAlgo = md.getEncAlgoNid();
|
||||
}
|
||||
}
|
||||
|
||||
void pkcs12EncBox::setupEncAlgos(QList<int> nids)
|
||||
{
|
||||
QString md = currentText();
|
||||
int md = currentData().toInt();
|
||||
|
||||
if (!wanted_encAlgo.isEmpty())
|
||||
if (wanted_encAlgo != NID_undef)
|
||||
md = wanted_encAlgo;
|
||||
clear();
|
||||
foreach(int nid, encAlgo::all_encAlgos) {
|
||||
if (nids.contains(nid))
|
||||
addItem(encAlgo(nid).name());
|
||||
addItem(encAlgo(nid).displayName(), QVariant(nid));
|
||||
}
|
||||
setEnabled(count() > 0);
|
||||
setDefaultEncAlgo();
|
||||
if (!md.isEmpty())
|
||||
if (md != NID_undef)
|
||||
setCurrent(encAlgo(md));
|
||||
else
|
||||
setDefaultEncAlgo();
|
||||
|
||||
@ -14,8 +14,10 @@
|
||||
class pkcs12EncBox: public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QString wanted_encAlgo{};
|
||||
int wanted_encAlgo{};
|
||||
|
||||
public:
|
||||
pkcs12EncBox(QWidget *parent);
|
||||
const encAlgo current() const;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user