mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Add options dialog, not done yet...
unfy hashAlgo handling (hashBox)
This commit is contained in:
parent
4a441557f7
commit
b0b9cd1d00
@ -1,3 +1,4 @@
|
||||
* Add options dialog
|
||||
* make cert, crl and key details copy&paste able
|
||||
* fix background color of clicklabels
|
||||
Bug [ 1704699 ]
|
||||
|
||||
@ -153,31 +153,22 @@ pki_crl *db_crl::newItem(pki_x509 *cert)
|
||||
a1time time;
|
||||
pki_crl *crl = NULL;
|
||||
Ui::NewCrl ui;
|
||||
const EVP_MD *dgst;
|
||||
const EVP_MD *algolist[] = { EVP_md2(), EVP_md5(), EVP_sha1()
|
||||
#ifdef HAS_SHA256
|
||||
,EVP_sha256(), EVP_sha512()
|
||||
#endif
|
||||
};
|
||||
|
||||
x509v3ext e;
|
||||
X509V3_CTX ext_ctx;
|
||||
X509V3_set_ctx(&ext_ctx, cert->getCert() , NULL, NULL, NULL, 0);
|
||||
X509V3_set_ctx_nodb((&ext_ctx));
|
||||
QDialog *dlg = new QDialog(mainwin);
|
||||
|
||||
ui.setupUi(dlg);
|
||||
ui.image->setPixmap(*MainWindow::revImg);
|
||||
#ifdef HAS_SHA256
|
||||
ui.hashAlgo->addItem(tr("SHA 256"));
|
||||
ui.hashAlgo->addItem(tr("SHA 512"));
|
||||
ui.hashAlgo->setCurrentIndex(3);
|
||||
#endif
|
||||
ui.lastUpdate->setDate(time.now());
|
||||
ui.nextUpdate->setDate(time.now(cert->getCrlDays() *60*60*24));
|
||||
|
||||
if (cert->getRefKey()->getType() == EVP_PKEY_DSA)
|
||||
ui.hashAlgo->setEnabled(false);
|
||||
ui.hashAlgo->setDsa(true);
|
||||
else
|
||||
ui.hashAlgo->setEnabled(true);
|
||||
ui.hashAlgo->setDsa(false);
|
||||
|
||||
if (cert->hasExtension(NID_subject_alt_name))
|
||||
ui.subAltName->setEnabled(true);
|
||||
@ -212,12 +203,8 @@ pki_crl *db_crl::newItem(pki_x509 *cert)
|
||||
crl->setLastUpdate(ui.lastUpdate->getDate());
|
||||
crl->setNextUpdate(ui.nextUpdate->getDate());
|
||||
cert->setCrlExpiry(ui.nextUpdate->getDate());
|
||||
if (cert->getRefKey()->getType() == EVP_PKEY_DSA)
|
||||
dgst = EVP_dss1();
|
||||
else
|
||||
dgst = algolist[ui.hashAlgo->currentIndex()];
|
||||
|
||||
crl->sign(cert->getRefKey(), dgst);
|
||||
crl->sign(cert->getRefKey(), ui.hashAlgo->currentHash());
|
||||
mainwin->certs->updatePKI(cert);
|
||||
insert(crl);
|
||||
}
|
||||
|
||||
38
lib/db_crl.h
38
lib/db_crl.h
@ -17,25 +17,25 @@
|
||||
|
||||
class db_crl: public db_base
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QPixmap *crlicon;
|
||||
db_x509 *certs;
|
||||
public:
|
||||
db_crl(QString db, MainWindow *mw);
|
||||
pki_base *newPKI();
|
||||
void revokeCerts(pki_crl *crl);
|
||||
void inToCont(pki_base *pki);
|
||||
pki_base *insert(pki_base *item);
|
||||
pki_crl *newItem(pki_x509 *cert);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
void removeSigner(pki_base *signer);
|
||||
public slots:
|
||||
void store();
|
||||
void load();
|
||||
void showPki(pki_base *pki);
|
||||
signals:
|
||||
void updateCertView();
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QPixmap *crlicon;
|
||||
db_x509 *certs;
|
||||
public:
|
||||
db_crl(QString db, MainWindow *mw);
|
||||
pki_base *newPKI();
|
||||
void revokeCerts(pki_crl *crl);
|
||||
void inToCont(pki_base *pki);
|
||||
pki_base *insert(pki_base *item);
|
||||
pki_crl *newItem(pki_x509 *cert);
|
||||
void showContextMenu(QContextMenuEvent *e, const QModelIndex &index);
|
||||
void removeSigner(pki_base *signer);
|
||||
public slots:
|
||||
void store();
|
||||
void load();
|
||||
void showPki(pki_base *pki);
|
||||
signals:
|
||||
void updateCertView();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "db.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc<2)
|
||||
|
||||
@ -515,9 +515,7 @@ void db_x509::newCert(NewX509 *dlg)
|
||||
for (int i=0; i<m; i++)
|
||||
cert->addV3ext(ne[i]);
|
||||
|
||||
const EVP_MD *hashAlgo = dlg->getHashAlgo();
|
||||
if (signkey->getType() == EVP_PKEY_DSA)
|
||||
hashAlgo = EVP_dss1();
|
||||
const EVP_MD *hashAlgo = dlg->hashAlgo->currentHash();
|
||||
#ifdef WG_QA_SERIAL
|
||||
if (dlg->selfQASignRB->isChecked()) {
|
||||
// sign the request intermediately in order to finally fill
|
||||
|
||||
@ -62,17 +62,14 @@ void db_x509req::newItem(pki_temp *temp)
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const EVP_MD *hashAlgo = dlg->getHashAlgo();
|
||||
pki_key *key = dlg->getSelectedKey();
|
||||
x509name xn = dlg->getX509name();
|
||||
req = new pki_x509req();
|
||||
|
||||
req->setIntName(dlg->description->text());
|
||||
if (key->getType() == EVP_PKEY_DSA)
|
||||
hashAlgo = EVP_dss1();
|
||||
|
||||
dlg->initCtx(NULL, NULL, req);
|
||||
req->createReq(key, xn, hashAlgo, dlg->getAllExt());
|
||||
req->createReq(key, xn, dlg->hashAlgo->currentHash(), dlg->getAllExt());
|
||||
insert(req);
|
||||
}
|
||||
catch (errorEx &err) {
|
||||
|
||||
23
ui/NewCrl.ui
23
ui/NewCrl.ui
@ -143,23 +143,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="hashAlgo" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>MD 2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>MD 5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>SHA 1</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="hashBox" name="hashAlgo" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -245,6 +229,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>hashBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>widgets/hashBox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Validity</class>
|
||||
<extends>QWidget</extends>
|
||||
|
||||
@ -280,23 +280,7 @@ If this list is disabled, you only can create a self-signed certificate.</string
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="hashAlgo" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>MD 2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>MD 5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>SHA 1</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="hashBox" name="hashAlgo" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -1491,6 +1475,11 @@ email:my@other.address, RID:1.2.3.4, DNS: ns.server.tld</string>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>hashBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>widgets/hashBox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Validity</class>
|
||||
<extends>QWidget</extends>
|
||||
|
||||
234
ui/Options.ui
Normal file
234
ui/Options.ui
Normal file
@ -0,0 +1,234 @@
|
||||
<ui version="4.0" >
|
||||
<class>Options</class>
|
||||
<widget class="QDialog" name="Options" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>362</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="TextLabel1" >
|
||||
<property name="font" >
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
<underline>false</underline>
|
||||
<strikeout>false</strikeout>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:14pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">XCA Options</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Mandatory subject entries</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="extDNobj" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="extDNlist" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="extDNadd" >
|
||||
<property name="text" >
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="extDNdel" >
|
||||
<property name="text" >
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox" >
|
||||
<property name="text" >
|
||||
<string>Allow multiple use of keys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Default hash algorithm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="hashBox" name="hashAlgo" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton" >
|
||||
<property name="text" >
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton" >
|
||||
<property name="text" >
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>hashBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>widgets/hashBox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>hashAlgo</tabstop>
|
||||
<tabstop>okButton</tabstop>
|
||||
<tabstop>cancelButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>okButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Options</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>224</x>
|
||||
<y>332</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>96</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cancelButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Options</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>305</x>
|
||||
<y>332</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>179</x>
|
||||
<y>282</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@ -78,6 +78,12 @@ void MainWindow::init_database()
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
if (!mydb.find(setting, "default_hash")) {
|
||||
if ((p = (char *)mydb.load(NULL))) {
|
||||
hashBox::setDefault(p);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
} catch (errorEx &err) {
|
||||
Error(err);
|
||||
return;
|
||||
|
||||
@ -7,8 +7,11 @@
|
||||
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Options.h"
|
||||
#include "lib/load_obj.h"
|
||||
#include "lib/pass_info.h"
|
||||
#include "ui_Options.h"
|
||||
#include "widgets/hashBox.h"
|
||||
#include <qapplication.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qmessagebox.h>
|
||||
@ -31,6 +34,8 @@ void MainWindow::init_menu()
|
||||
acList += file->addAction(tr("&Undelete items"), this,
|
||||
SLOT(undelete()), Qt::CTRL+Qt::Key_U );
|
||||
file->addSeparator();
|
||||
file->addAction(tr("Options"), this, SLOT(setOptions()) );
|
||||
file->addSeparator();
|
||||
file->addAction(tr("E&xit"), qApp, SLOT(quit()), Qt::ALT+Qt::Key_F4 );
|
||||
|
||||
import = menuBar()->addMenu(tr("&Import"));
|
||||
@ -51,6 +56,7 @@ void MainWindow::init_menu()
|
||||
import->addAction(tr("PEM file"), this,
|
||||
SLOT(loadPem()) );
|
||||
|
||||
|
||||
help = menuBar()->addMenu(tr("&Help") );
|
||||
help->addAction(tr("&Content"), this, SLOT(help()), Qt::Key_F1 );
|
||||
help->addAction(tr("&About"), this, SLOT(about()) );
|
||||
@ -125,3 +131,22 @@ void MainWindow::import_dbdump()
|
||||
Error(err);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setOptions()
|
||||
{
|
||||
Options *opt = new Options(this);
|
||||
|
||||
if (!opt->exec())
|
||||
return;
|
||||
|
||||
QString alg = opt->hashAlgo->currentHashName();
|
||||
db mydb(dbfile);
|
||||
mydb.set((const unsigned char *)CCHAR(alg), alg.length()+1, 1,
|
||||
setting, "default_hash");
|
||||
hashBox::setDefault(alg);
|
||||
|
||||
QString mandatory = opt->getDnString();
|
||||
printf("DNString = %s\n", CCHAR(mandatory));
|
||||
mydb.set((const unsigned char *)CCHAR(mandatory), mandatory.length()+1, 1,
|
||||
setting, "mandatory_dn");
|
||||
}
|
||||
|
||||
@ -87,6 +87,7 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
void loadPem();
|
||||
|
||||
private slots:
|
||||
void setOptions();
|
||||
void on_keyView_doubleClicked(const QModelIndex &m);
|
||||
void on_reqView_doubleClicked(const QModelIndex &m);
|
||||
void on_certView_doubleClicked(const QModelIndex &m);
|
||||
|
||||
@ -5,7 +5,7 @@ endif
|
||||
|
||||
MOC_NAMES=MainWindow KeyDetail clicklabel XcaTreeView ExportKey NewX509 \
|
||||
validity v3ext ReqDetail distname CertDetail CertExtend ExportCert \
|
||||
ImportMulti CrlDetail ExportDer
|
||||
ImportMulti CrlDetail ExportDer hashBox Options
|
||||
|
||||
NAMES=$(MOC_NAMES) NewX509_ext MW_menu MW_help MW_database
|
||||
NAMES=$(MOC_NAMES) NewX509_ext MW_help MW_database
|
||||
|
||||
@ -57,12 +57,6 @@ NewX509::NewX509(QWidget *parent)
|
||||
serialNr->setValidator( new QRegExpValidator(QRegExp("[0-9a-fA-F]*"), this));
|
||||
QStringList strings;
|
||||
|
||||
hashAlgo->setCurrentIndex(2);
|
||||
#ifdef HAS_SHA256
|
||||
hashAlgo->addItem(tr("SHA 256"));
|
||||
hashAlgo->addItem(tr("SHA 512"));
|
||||
hashAlgo->setCurrentIndex(3);
|
||||
#endif
|
||||
// are there any useable private keys ?
|
||||
strings = MainWindow::keys->get0PrivateDesc();
|
||||
keyList->insertItems(0, strings);
|
||||
@ -339,10 +333,8 @@ void NewX509::on_reqList_currentIndexChanged(const QString &)
|
||||
|
||||
void NewX509::switchHashAlgo()
|
||||
{
|
||||
static int h_index = 0;
|
||||
pki_key *key;
|
||||
pki_x509super *sig;
|
||||
bool disable;
|
||||
|
||||
if (foreignSignRB->isChecked())
|
||||
sig = getSelectedSigner();
|
||||
@ -352,22 +344,10 @@ void NewX509::switchHashAlgo()
|
||||
sig = NULL;
|
||||
|
||||
key = sig ? sig->getRefKey() : getSelectedKey();
|
||||
disable = (key && key->getType() == EVP_PKEY_DSA) ? true : false;
|
||||
|
||||
if (disable) {
|
||||
if (hashAlgo->isEnabled()) {
|
||||
/* backup */
|
||||
h_index = hashAlgo->currentIndex();
|
||||
hashAlgo->setCurrentIndex(2);
|
||||
hashAlgo->setDisabled(true);
|
||||
}
|
||||
} else {
|
||||
if (!hashAlgo->isEnabled()) {
|
||||
/* restore */
|
||||
hashAlgo->setCurrentIndex(h_index);
|
||||
hashAlgo->setDisabled(false);
|
||||
}
|
||||
}
|
||||
if (key && key->getType() == EVP_PKEY_DSA)
|
||||
hashAlgo->setDsa(true);
|
||||
else
|
||||
hashAlgo->setDsa(false);
|
||||
}
|
||||
|
||||
void NewX509::toggleOkBut()
|
||||
@ -587,16 +567,6 @@ void NewX509::on_extDNdel_clicked()
|
||||
extDNlist->removeRow(extDNlist->currentRow());
|
||||
}
|
||||
|
||||
const EVP_MD *NewX509::getHashAlgo()
|
||||
{
|
||||
const EVP_MD *ha[] = { EVP_md2(), EVP_md5(), EVP_sha1()
|
||||
#ifdef HAS_SHA256
|
||||
, EVP_sha256(), EVP_sha512()
|
||||
#endif
|
||||
};
|
||||
return ha[hashAlgo->currentIndex()];
|
||||
}
|
||||
|
||||
void NewX509::on_applyTime_clicked()
|
||||
{
|
||||
applyTD(this, validNumber->text().toInt(), validRange->currentIndex(),
|
||||
|
||||
@ -77,7 +77,6 @@ class NewX509: public QDialog, public Ui::NewX509
|
||||
x509v3ext getCertPol();
|
||||
extList getNetscapeExt();
|
||||
extList getAllExt();
|
||||
const EVP_MD *getHashAlgo();
|
||||
void initCtx(pki_x509 *subj, pki_x509 *iss, pki_x509req *req);
|
||||
void setBasicConstraints(const x509v3ext &e);
|
||||
void setExt(const x509v3ext &ext);
|
||||
|
||||
40
widgets/Options.cpp
Normal file
40
widgets/Options.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/* vi: set sw=4 ts=4:
|
||||
*
|
||||
* Copyright (C) 2001 - 2007 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "Options.h"
|
||||
#include <openssl/objects.h>
|
||||
|
||||
Options::Options(QWidget *parent)
|
||||
:QDialog(parent)
|
||||
{
|
||||
NIDlist dn_nid = *MainWindow::dn_nid;
|
||||
setWindowTitle(tr(XCA_TITLE));
|
||||
setupUi(this);
|
||||
|
||||
for (int i=0; i < dn_nid.count(); i++)
|
||||
extDNobj->addItem(OBJ_nid2ln(dn_nid[i]));
|
||||
}
|
||||
|
||||
void Options::on_extDNadd_clicked()
|
||||
{
|
||||
extDNlist->insertItem(0, extDNobj->currentText());
|
||||
}
|
||||
void Options::on_extDNdel_clicked()
|
||||
{
|
||||
extDNlist->takeItem(extDNlist->currentRow());
|
||||
}
|
||||
|
||||
QString Options::getDnString()
|
||||
{
|
||||
QStringList dn;
|
||||
for (int j=0; j<extDNlist->count(); j++) {
|
||||
int nid;
|
||||
nid = OBJ_ln2nid(CCHAR(extDNlist->item(j)->text()));
|
||||
dn << QString(OBJ_nid2sn(nid));
|
||||
}
|
||||
return dn.join(",");
|
||||
}
|
||||
27
widgets/Options.h
Normal file
27
widgets/Options.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* vi: set sw=4 ts=4:
|
||||
*
|
||||
* Copyright (C) 2001 - 2007 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef OPTIONS_H
|
||||
#define OPTIONS_H
|
||||
|
||||
#include "ui_Options.h"
|
||||
#include <qdialog.h>
|
||||
#include "lib/base.h"
|
||||
#include "widgets/MainWindow.h"
|
||||
|
||||
class Options: public QDialog, public Ui::Options
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Options(QWidget *parent);
|
||||
public slots:
|
||||
void on_extDNadd_clicked();
|
||||
void on_extDNdel_clicked();
|
||||
QString getDnString();
|
||||
};
|
||||
|
||||
#endif
|
||||
88
widgets/hashBox.cpp
Normal file
88
widgets/hashBox.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/* vi: set sw=4 ts=4:
|
||||
*
|
||||
* Copyright (C) 2001 - 2007 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "hashBox.h"
|
||||
#include "lib/base.h"
|
||||
|
||||
#define DSA_INDEX 2
|
||||
|
||||
#ifdef HAS_SHA256
|
||||
int hashBox::default_md = 3; /* SHA256 */
|
||||
#else
|
||||
int hashBox::default_md = 2; /* SHA1 */
|
||||
#endif
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
const EVP_MD *md;
|
||||
} hashalgos[] = {
|
||||
{ "MD 2", EVP_md2() },
|
||||
{ "MD 5", EVP_md5() },
|
||||
{ "SHA 1", EVP_sha1() },
|
||||
#ifdef HAS_SHA256
|
||||
{ "SHA 256", EVP_sha256() },
|
||||
{ "SHA 512", EVP_sha512() },
|
||||
#endif
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
hashBox::hashBox(QWidget *parent)
|
||||
:QComboBox(parent)
|
||||
{
|
||||
for (int i=0; hashalgos[i].name; i++)
|
||||
addItem(QString(hashalgos[i].name));
|
||||
setDefaultHash();
|
||||
backup = default_md;
|
||||
}
|
||||
|
||||
void hashBox::setDsa(bool new_dsa)
|
||||
{
|
||||
if (dsa == new_dsa)
|
||||
return;
|
||||
dsa = new_dsa;
|
||||
if (dsa) {
|
||||
backup = currentIndex();
|
||||
setCurrentIndex(DSA_INDEX);
|
||||
setDisabled(true);
|
||||
} else {
|
||||
setCurrentIndex(backup);
|
||||
setDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
const EVP_MD *hashBox::currentHash()
|
||||
{
|
||||
if (dsa)
|
||||
return EVP_dss1();
|
||||
return hashalgos[currentIndex()].md;
|
||||
}
|
||||
|
||||
QString hashBox::currentHashName()
|
||||
{
|
||||
return QString(hashalgos[currentIndex()].name);
|
||||
}
|
||||
|
||||
void hashBox::setDefaultHash()
|
||||
{
|
||||
setCurrentIndex(default_md);
|
||||
}
|
||||
|
||||
void hashBox::setCurrentAsDefault()
|
||||
{
|
||||
default_md = currentIndex();
|
||||
}
|
||||
|
||||
void hashBox::setDefault(QString def)
|
||||
{
|
||||
for (int i=0; hashalgos[i].name; i++) {
|
||||
if (QString(hashalgos[i].name) == def) {
|
||||
default_md = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
widgets/hashBox.h
Normal file
31
widgets/hashBox.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* vi: set sw=4 ts=4:
|
||||
*
|
||||
* Copyright (C) 2001 - 2007 Christian Hohnstaedt.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef HASH_BOX_H
|
||||
#define HASH_BOX_H
|
||||
|
||||
#include <qcombobox.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
class hashBox: public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
static int default_md;
|
||||
int backup;
|
||||
bool dsa;
|
||||
public:
|
||||
hashBox(QWidget *parent);
|
||||
void setDsa(bool dsa);
|
||||
const EVP_MD *currentHash();
|
||||
QString currentHashName();
|
||||
void setCurrentAsDefault();
|
||||
void setDefaultHash();
|
||||
static void setDefault(QString def);
|
||||
};
|
||||
|
||||
#endif
|
||||
5
xca.pro
5
xca.pro
@ -49,10 +49,12 @@ HEADERS += lib/asn1int.h \
|
||||
widgets/ExportCert.h \
|
||||
widgets/ExportDer.h \
|
||||
widgets/ExportKey.h \
|
||||
widgets/hashBox.h \
|
||||
widgets/ImportMulti.h \
|
||||
widgets/KeyDetail.h \
|
||||
widgets/MainWindow.h \
|
||||
widgets/NewX509.h \
|
||||
widgets/Options.h \
|
||||
widgets/ReqDetail.h \
|
||||
widgets/v3ext.h \
|
||||
widgets/validity.h \
|
||||
@ -73,6 +75,7 @@ FORMS += ui/About.ui \
|
||||
ui/NewCrl.ui \
|
||||
ui/NewKey.ui \
|
||||
ui/NewX509.ui \
|
||||
ui/Options.ui \
|
||||
ui/PassRead.ui \
|
||||
ui/PassWrite.ui \
|
||||
ui/ReqDetail.ui \
|
||||
@ -114,6 +117,7 @@ SOURCES += lib/asn1int.cpp \
|
||||
widgets/ExportCert.cpp \
|
||||
widgets/ExportDer.cpp \
|
||||
widgets/ExportKey.cpp \
|
||||
widgets/hashBox.cpp \
|
||||
widgets/ImportMulti.cpp \
|
||||
widgets/KeyDetail.cpp \
|
||||
widgets/MainWindow.cpp \
|
||||
@ -122,6 +126,7 @@ SOURCES += lib/asn1int.cpp \
|
||||
widgets/MW_menu.cpp \
|
||||
widgets/NewX509.cpp \
|
||||
widgets/NewX509_ext.cpp \
|
||||
Widgets/Options.cpp \
|
||||
widgets/ReqDetail.cpp \
|
||||
widgets/v3ext.cpp \
|
||||
widgets/validity.cpp \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user