support for pathlen of 0

This commit is contained in:
Christian Hohnstaedt 2009-12-06 17:50:06 +01:00
parent f54c7fd4d7
commit e293eb1f4f
8 changed files with 26 additions and 19 deletions

View File

@ -65,7 +65,7 @@ a1int &a1int::set(long l)
QString a1int::toHex() const
{
QString r = "--";
QString r;
if (in->length == 0) {
return r;
}
@ -79,7 +79,7 @@ QString a1int::toHex() const
QString a1int::toDec() const
{
QString r = "--";
QString r;
if (in->length == 0) {
return r;
}

View File

@ -57,7 +57,7 @@ pki_temp::pki_temp(const QString d)
:pki_base(d)
{
class_name = "pki_temp";
dataVersion=5;
dataVersion=6;
pkiType=tmpl;
cols=2;
@ -81,7 +81,7 @@ pki_temp::pki_temp(const QString d)
subKey=false;
authKey=false;
validMidn=false;
pathLen=0;
pathLen="";
validN=365;
validM=0;
keyUse=0;
@ -184,7 +184,7 @@ extList pki_temp::fromCert(pki_x509super *cert_or_req)
bcCrit = el[i].getCritical();
ca = (bc->ca ? 0 : 1) +1;
a1int pl(bc->pathlen);
pathLen = pl.getLong();
pathLen = pl.toDec();
BASIC_CONSTRAINTS_free(bc);
}
el.removeAt(i);
@ -279,7 +279,13 @@ void pki_temp::fromData(const unsigned char *p, int size, int version)
subKey=db::boolFromData(&p1);
authKey=db::boolFromData(&p1);
ca =db:: intFromData(&p1);
pathLen=db::intFromData(&p1);
if (version > 5) {
pathLen=db::stringFromData(&p1);
} else {
pathLen=QString::number(db::intFromData(&p1));
if (pathLen == "0")
pathLen = "";
}
validN =db::intFromData(&p1);
validM =db::intFromData(&p1);
keyUse=db::intFromData(&p1);
@ -329,7 +335,7 @@ unsigned char *pki_temp::toData(int *size)
db::boolToData(&p1, subKey);
db::boolToData(&p1, authKey);
db::intToData(&p1, ca);
db::intToData(&p1, pathLen);
db::stringToData(&p1, pathLen);
db::intToData(&p1, validN);
db::intToData(&p1, validM);
db::intToData(&p1, keyUse);
@ -363,7 +369,7 @@ void pki_temp::writeDefault(const QString fname)
void pki_temp::writeTemp(QString fname)
{
int size = 0;
unsigned char *p, buf[2*sizeof(int)], *p1=buf;
unsigned char *p, buf[2*sizeof(uint32_t)], *p1=buf;
FILE *fp = fopen(QString2filename(fname),"w");
if (fp == NULL) {
@ -373,7 +379,7 @@ void pki_temp::writeTemp(QString fname)
p = toData(&size);
db::intToData(&p1, size);
db::intToData(&p1, dataVersion);
fwrite(buf, 2*sizeof(int), 1, fp);
fwrite(buf, 2*sizeof(uint32_t), 1, fp);
fwrite(p, 1, size, fp);
OPENSSL_free(p);
fclose(fp);
@ -433,7 +439,7 @@ pki_temp::~pki_temp()
int pki_temp::dataSize()
{
int s = 8 * sizeof(int) + 9 * sizeof(char) +
int s = 5 * sizeof(uint32_t) + 7 * sizeof(char) +
xname.derSize() + (
subAltName.length() +
issAltName.length() +
@ -449,7 +455,8 @@ int pki_temp::dataSize()
nsSslServerName.length() +
adv_ext.length() +
eKeyUse.length() +
13 ) * sizeof(char);
pathLen.length() +
16 ) * sizeof(char);
return s;
}
@ -499,7 +506,9 @@ void pki_temp::oldFromData(unsigned char *p, int size )
if (version >= 2) {
ca = intFromData(&p1);
}
pathLen= intFromData(&p1);
pathLen = QString::number(db::intFromData(&p1));
if (pathLen == "0")
pathLen = "";
validN = intFromData(&p1);
validM = intFromData(&p1);
keyUse=intFromData(&p1);

View File

@ -23,10 +23,10 @@ class pki_temp: public pki_base
QString subAltName, issAltName, crlDist, authInfAcc, certPol;
QString nsComment, nsBaseUrl, nsRevocationUrl,
nsCARevocationUrl, nsRenewalUrl, nsCaPolicyUrl,
nsSslServerName, destination, adv_ext, eKeyUse;
nsSslServerName, destination, adv_ext, eKeyUse, pathLen;
bool bcCrit, keyUseCrit, eKeyUseCrit, subKey, authKey,
validMidn, noWellDefined;
int nsCertType, pathLen, keyUse, ca;
int nsCertType, keyUse, ca;
int validN, validM;
// methods

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -323,9 +323,7 @@ void NewX509::fromTemplate(pki_temp *temp)
validNumber->setText(QString::number(temp->validN));
validRange->setCurrentIndex(temp->validM);
midnightCB->setChecked(temp->validMidn);
if (temp->pathLen) {
basicPath->setText(QString::number(temp->pathLen));
}
basicPath->setText(temp->pathLen);
nconf_data->document()->setPlainText(temp->adv_ext);
noWellDefinedExpDate->setChecked(temp->noWellDefined);
notBefore->setNow();
@ -358,7 +356,7 @@ void NewX509::toTemplate(pki_temp *temp)
temp->eKeyUse = lb2QString(ekeyUsage);
temp->validN = validNumber->text().toInt();
temp->validM = validRange->currentIndex();
temp->pathLen = basicPath->text().toInt();
temp->pathLen = basicPath->text();
temp->validMidn = midnightCB->isChecked();
if (nconf_data->isReadOnly()) {
temp->adv_ext = v3ext_backup;

View File

@ -27,7 +27,7 @@ x509v3ext NewX509::getBasicConstraints()
cont << "critical";
cont << ca[basicCA->currentIndex()];
if (!basicPath->text().isEmpty())
cont << (QString)"pathlen:" + basicPath->text();
cont << QString("pathlen:") + basicPath->text();
ext.create(NID_basic_constraints, cont.join(", "), &ext_ctx);
}
return ext;