| 84 | Q_DECLARE_METATYPE(keyListItem); |
| 85 | |
| 86 | NewKey::NewKey(QWidget *parent, const QString &name) |
| 87 | :QDialog(parent ? parent : mainwin) |
| 88 | { |
| 89 | static const QList<int> sizeList = { 1024, 2048, 4096, 8192 }; |
| 90 | slotidList p11_slots; |
| 91 | QList<keyListItem> keytypes; |
| 92 | |
| 93 | setupUi(this); |
| 94 | setWindowTitle(XCA_TITLE); |
| 95 | image->setPixmap(QPixmap(":keyImg")); |
| 96 | mainwin->helpdlg->register_ctxhelp_button(this, "keygen"); |
| 97 | |
| 98 | if (!name.isEmpty()) |
| 99 | keyDesc->setText(name); |
| 100 | |
| 101 | keyLength->setEditable(true); |
| 102 | foreach (int size, sizeList) |
| 103 | keyLength->addItem(QString("%1 bit").arg(size)); |
| 104 | |
| 105 | foreach (const keytype t, keytype::types()) |
| 106 | keytypes << keyListItem(t); |
| 107 | |
| 108 | updateCurves(); |
| 109 | keyLength->setEditText(QString("%1 bit").arg(keyjob::defaultjob.size)); |
| 110 | keyDesc->setFocus(); |
| 111 | if (pkcs11::libraries.loaded()) try { |
| 112 | pkcs11 p11; |
| 113 | p11_slots = p11.getSlotList(); |
| 114 | |
| 115 | foreach(slotid slot, p11_slots) { |
| 116 | QList<CK_MECHANISM_TYPE> ml = p11.mechanismList(slot); |
| 117 | foreach(keytype t, keytype::types()) |
| 118 | if (ml.contains(t.mech)) |
| 119 | keytypes << keyListItem(&p11, slot, |
| 120 | t.mech); |
| 121 | } |
| 122 | } catch (errorEx &) { |
| 123 | p11_slots.clear(); |
| 124 | } |
| 125 | for (int i=0; i<keytypes.count(); i++) { |
| 126 | QVariant q; |
| 127 | q.setValue(keytypes[i]); |
| 128 | keyType->addItem(keytypes[i].printname, q); |
| 129 | if (!keytypes[i].card && |
| 130 | keytypes[i].type() == keyjob::defaultjob.ktype.type) |
| 131 | { |
| 132 | keyType->setCurrentIndex(i); |
| 133 | } |
| 134 | } |
| 135 | buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create")); |
| 136 | } |
| 137 | |
| 138 | void NewKey::addCurveBoxCurves(const QList<builtin_curve> &curves) |
| 139 | { |
nothing calls this directly
no test coverage detected