diff --git a/KeyDetail.ui b/KeyDetail.ui
index a7cd2be8..6ef0d0e1 100644
--- a/KeyDetail.ui
+++ b/KeyDetail.ui
@@ -11,8 +11,8 @@
0
0
- 558
- 387
+ 600
+ 447
@@ -557,14 +557,25 @@
- QMultiLineEdit
+ QLabel
name
keyModulus
- wrapPolicy
- Anywhere
+ frameShape
+ Panel
+
+
+ frameShadow
+ Sunken
+
+
+ alignment
+ WordBreak|AlignVCenter|AlignLeft
+
+
+ wordwrap
diff --git a/MainWindowKeys.cpp b/MainWindowKeys.cpp
index be6e1c2d..a777fb3a 100644
--- a/MainWindowKeys.cpp
+++ b/MainWindowKeys.cpp
@@ -155,18 +155,22 @@ bool MainWindow::showDetailsKey(pki_key *key, bool import)
delete detDlg;
return false;
}
- string ndesc = detDlg->keyDesc->text().latin1();
bool ret = detDlg->exec();
+ string ndesc = detDlg->keyDesc->text().latin1();
delete detDlg;
+ CERR(ndesc << " " << key->getDescription());
if ( ret && ndesc != key->getDescription()) {
+ MARK
try {
keys->renamePKI(key, ndesc);
+ MARK
}
catch (errorEx &err) {
Error(err);
}
return true;
}
+ MARK
return false;
}
diff --git a/lib/db_key.cpp b/lib/db_key.cpp
index b82a4c29..26c73e1f 100644
--- a/lib/db_key.cpp
+++ b/lib/db_key.cpp
@@ -111,8 +111,8 @@ void db_key::inToCont(pki_base *pki)
void db_key::updateViewPKI(pki_base *pki)
{
CERR("updateViewPKI()");
- db_base::updateViewPKI(pki);
if (! pki) return;
+ db_base::updateViewPKI(pki);
int pixnum = 0;
QListViewItem *current = (QListViewItem *)pki->getPointer();
if (!current) return;
diff --git a/lib/pki_base.cpp b/lib/pki_base.cpp
index 9ddeb535..70f19c16 100644
--- a/lib/pki_base.cpp
+++ b/lib/pki_base.cpp
@@ -57,6 +57,7 @@ pki_base::pki_base(const string d)
error = "";
desc = d;
className = "pki_base";
+ pointer=NULL;
}
pki_base::pki_base()
@@ -64,6 +65,7 @@ pki_base::pki_base()
error = "";
desc = "";
className = "pki_base";
+ pointer=NULL;
}
pki_base::~pki_base(void)
diff --git a/lib/pki_base.h b/lib/pki_base.h
index f8213334..4cfe9a9c 100644
--- a/lib/pki_base.h
+++ b/lib/pki_base.h
@@ -67,10 +67,10 @@ class pki_base
string desc;
string error;
string className;
+ void *pointer;
void openssl_error(const string myerr = "");
void fopen_error(const string fname);
bool ign_openssl_error();
- void *pointer;
int intToData(unsigned char **p, const int val);
int intFromData(unsigned char **p);
int boolToData(unsigned char **p, const bool val);
diff --git a/lib/pki_key.cpp b/lib/pki_key.cpp
index 12ee707a..6f3d4308 100644
--- a/lib/pki_key.cpp
+++ b/lib/pki_key.cpp
@@ -53,9 +53,17 @@
char pki_key::passwd[40]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+void pki_key::init()
+{
+ ucount = 0;
+ className = "pki_key";
+}
+
pki_key::pki_key(const string d, void (*cb)(int, int,void *),void *prog, int bits = 1024, int type): pki_base(d)
{
+ init();
key = EVP_PKEY_new();
+ openssl_error();
key->type = type;
if (type == EVP_PKEY_RSA) {
RSA *rsakey;
@@ -63,45 +71,42 @@ pki_key::pki_key(const string d, void (*cb)(int, int,void *),void *prog, int bit
if (rsakey) EVP_PKEY_set1_RSA(key, rsakey);
}
openssl_error();
- ucount=0;
- className = "pki_key";
}
pki_key::pki_key(const pki_key *pk)
:pki_base(pk->desc)
{
+ init();
key = EVP_PKEY_new();
+ openssl_error();
key->type = pk->key->type;
if (key->type == EVP_PKEY_RSA) {
key->pkey.rsa=((RSA *)ASN1_dup( (int (*)())i2d_RSAPrivateKey, (char *(*)())d2i_RSAPrivateKey,(char *)pk->key->pkey.rsa));
}
// TODO add DSA support.....
openssl_error();
- ucount=0;
- className = "pki_key";
}
pki_key::pki_key(const string d, int type )
:pki_base(d)
{
+ init();
key = EVP_PKEY_new();
key->type = type;
openssl_error();
- ucount=0;
- className = "pki_key";
}
pki_key::pki_key(EVP_PKEY *pkey)
:pki_base("")
{
+ init();
key = pkey;
- ucount=0;
- className = "pki_key";
}
pki_key::pki_key(const string fname, pem_password_cb *cb, int type )
:pki_base(fname)
{
+ init();
PASS_INFO p;
string title = XCA_TITLE;
string description = "Please enter the password to decrypt the RSA key.";
@@ -158,8 +163,6 @@ pki_key::pki_key(const string fname, pem_password_cb *cb, int type )
else fopen_error(fname);
CERR("end of loading");
fclose(fp);
- ucount=0;
- className = "pki_key";
}
diff --git a/lib/pki_key.h b/lib/pki_key.h
index 25bc22d0..40f09745 100644
--- a/lib/pki_key.h
+++ b/lib/pki_key.h
@@ -105,6 +105,7 @@ class pki_key: public pki_base
pki_key(const string d, int type=EVP_PKEY_RSA);
pki_key(EVP_PKEY *pkey);
+ void init();
void fromData(unsigned char *p, int size);
unsigned char *toData(int *size);
bool compare(pki_base *ref);
diff --git a/lib/pki_x509.cpp b/lib/pki_x509.cpp
index 2f41af54..88d4df1e 100644
--- a/lib/pki_x509.cpp
+++ b/lib/pki_x509.cpp
@@ -100,9 +100,9 @@ pki_x509::pki_x509(string d,pki_key *clientKey, pki_x509req *req, pki_x509 *sign
pki_x509::pki_x509(X509 *c) : pki_base()
{
+ init();
cert = c;
openssl_error();
- init();
}
pki_x509::pki_x509(const pki_x509 *crt)
@@ -134,7 +134,6 @@ pki_x509::pki_x509(const string fname)
{
FILE *fp = fopen(fname.c_str(),"r");
init();
- cert = NULL;
if (fp != NULL) {
cert = PEM_read_X509(fp, NULL, NULL, NULL);
if (!cert) {
@@ -186,6 +185,7 @@ void pki_x509::init()
crlDays = 30;
lastCrl = NULL;
className="pki_x509";
+ cert=NULL;
}
@@ -214,7 +214,7 @@ bool pki_x509::canSign()
if (pkey->isPubKey()) return false;
bc = (BASIC_CONSTRAINTS *)X509_get_ext_d2i(cert, NID_basic_constraints, &crit, NULL);
openssl_error();
- if (!bc) return false;
+ if (!bc) return true;
if (!bc->ca) return false;
return true;
}
diff --git a/lib/pki_x509req.cpp b/lib/pki_x509req.cpp
index 9df91b24..0fa013f5 100644
--- a/lib/pki_x509req.cpp
+++ b/lib/pki_x509req.cpp
@@ -52,6 +52,13 @@
#include "pki_x509req.h"
+void pki_x509req::init()
+{
+ request = NULL;
+ privkey = NULL;
+ className = "pki_x509req";
+}
+
pki_x509req::pki_x509req(pki_key *key, const string cn,
const string c, const string l,
@@ -60,6 +67,7 @@ pki_x509req::pki_x509req(pki_key *key, const string cn,
const string d, const string challenge)
:pki_base( d )
{
+ init();
request = X509_REQ_new();
openssl_error();
if (key == NULL) {
@@ -100,23 +108,22 @@ pki_x509req::pki_x509req(pki_key *key, const string cn,
openssl_error();
privkey = key;
key->incUcount();
- className="pki_x509req";
}
pki_x509req::pki_x509req() : pki_base()
{
+ init();
request = X509_REQ_new();
openssl_error();
- privkey = NULL;
- className="pki_x509req";
}
pki_x509req::~pki_x509req()
{
- X509_REQ_free(request);
+ if (request)
+ X509_REQ_free(request);
openssl_error();
if (privkey)
privkey->decUcount();
@@ -125,7 +132,7 @@ pki_x509req::~pki_x509req()
pki_x509req::pki_x509req(const string fname)
{
- request = NULL;
+ init();
FILE *fp = fopen(fname.c_str(),"r");
if (fp != NULL) {
request = PEM_read_X509_REQ(fp, NULL, NULL, NULL);
@@ -148,8 +155,6 @@ pki_x509req::pki_x509req(const string fname)
}
else fopen_error(fname);
fclose(fp);
- privkey = NULL;
- className="pki_x509req";
}
diff --git a/lib/pki_x509req.h b/lib/pki_x509req.h
index af23caba..71c71940 100644
--- a/lib/pki_x509req.h
+++ b/lib/pki_x509req.h
@@ -71,6 +71,7 @@ class pki_x509req : public pki_base
pki_x509req();
pki_x509req(const string fname);
~pki_x509req();
+ void init();
virtual void fromData(unsigned char *p, int size);
virtual unsigned char *toData(int *size);
virtual bool compare(pki_base *refreq);