1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Never name a variable errno

This commit is contained in:
Uwe L. Korn
2014-06-30 17:17:14 +01:00
parent 1109f0bafb
commit dd0672ae82
9 changed files with 116 additions and 116 deletions

View File

@@ -62,7 +62,7 @@ CertificateBuilder::CertificateBuilder()
: d(new CertificateBuilderPrivate) : d(new CertificateBuilderPrivate)
{ {
ensure_gnutls_init(); ensure_gnutls_init();
d->errno = gnutls_x509_crt_init(&d->crt); d->errnumber = gnutls_x509_crt_init(&d->crt);
} }
/*! /*!
@@ -81,7 +81,7 @@ CertificateBuilder::~CertificateBuilder()
*/ */
int CertificateBuilder::error() const int CertificateBuilder::error() const
{ {
return d->errno; return d->errnumber;
} }
/*! /*!
@@ -90,7 +90,7 @@ int CertificateBuilder::error() const
*/ */
QString CertificateBuilder::errorString() const QString CertificateBuilder::errorString() const
{ {
return QString::fromUtf8(gnutls_strerror(d->errno)); return QString::fromUtf8(gnutls_strerror(d->errnumber));
} }
/*! /*!
@@ -98,8 +98,8 @@ QString CertificateBuilder::errorString() const
*/ */
bool CertificateBuilder::setRequest(const CertificateRequest &crq) bool CertificateBuilder::setRequest(const CertificateRequest &crq)
{ {
d->errno = gnutls_x509_crt_set_crq(d->crt, crq.d->crq); d->errnumber = gnutls_x509_crt_set_crq(d->crt, crq.d->crq);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -107,8 +107,8 @@ bool CertificateBuilder::setRequest(const CertificateRequest &crq)
*/ */
bool CertificateBuilder::setVersion(int version) bool CertificateBuilder::setVersion(int version)
{ {
d->errno = gnutls_x509_crt_set_version(d->crt, version); d->errnumber = gnutls_x509_crt_set_version(d->crt, version);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -117,8 +117,8 @@ bool CertificateBuilder::setVersion(int version)
*/ */
bool CertificateBuilder::setSerial(const QByteArray &serial) bool CertificateBuilder::setSerial(const QByteArray &serial)
{ {
d->errno = gnutls_x509_crt_set_serial(d->crt, serial.constData(), serial.size()); d->errnumber = gnutls_x509_crt_set_serial(d->crt, serial.constData(), serial.size());
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -126,8 +126,8 @@ bool CertificateBuilder::setSerial(const QByteArray &serial)
*/ */
bool CertificateBuilder::setActivationTime(const QDateTime &date) bool CertificateBuilder::setActivationTime(const QDateTime &date)
{ {
d->errno = gnutls_x509_crt_set_activation_time(d->crt, date.toTime_t()); d->errnumber = gnutls_x509_crt_set_activation_time(d->crt, date.toTime_t());
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -135,8 +135,8 @@ bool CertificateBuilder::setActivationTime(const QDateTime &date)
*/ */
bool CertificateBuilder::setExpirationTime(const QDateTime &date) bool CertificateBuilder::setExpirationTime(const QDateTime &date)
{ {
d->errno = gnutls_x509_crt_set_expiration_time(d->crt, date.toTime_t()); d->errnumber = gnutls_x509_crt_set_expiration_time(d->crt, date.toTime_t());
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -147,8 +147,8 @@ bool CertificateBuilder::setExpirationTime(const QDateTime &date)
*/ */
bool CertificateBuilder::copyRequestExtensions(const CertificateRequest &crq) bool CertificateBuilder::copyRequestExtensions(const CertificateRequest &crq)
{ {
d->errno = gnutls_x509_crt_set_crq_extensions(d->crt, crq.d->crq); d->errnumber = gnutls_x509_crt_set_crq_extensions(d->crt, crq.d->crq);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -159,8 +159,8 @@ bool CertificateBuilder::copyRequestExtensions(const CertificateRequest &crq)
*/ */
bool CertificateBuilder::setBasicConstraints(bool ca, int pathLength) bool CertificateBuilder::setBasicConstraints(bool ca, int pathLength)
{ {
d->errno = gnutls_x509_crt_set_basic_constraints (d->crt, ca, pathLength); d->errnumber = gnutls_x509_crt_set_basic_constraints (d->crt, ca, pathLength);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -214,8 +214,8 @@ bool CertificateBuilder::addKeyPurpose(KeyPurpose purpose, bool critical)
*/ */
bool CertificateBuilder::addKeyPurpose(const QByteArray &oid, bool critical) bool CertificateBuilder::addKeyPurpose(const QByteArray &oid, bool critical)
{ {
d->errno = gnutls_x509_crt_set_key_purpose_oid(d->crt, oid.constData(), critical); d->errnumber = gnutls_x509_crt_set_key_purpose_oid(d->crt, oid.constData(), critical);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -244,8 +244,8 @@ bool CertificateBuilder::setKeyUsage(KeyUsageFlags usages)
if (usages & UsageDecipherOnly) if (usages & UsageDecipherOnly)
usage |= GNUTLS_KEY_DECIPHER_ONLY; usage |= GNUTLS_KEY_DECIPHER_ONLY;
d->errno = gnutls_x509_crt_set_key_usage(d->crt, usage); d->errnumber = gnutls_x509_crt_set_key_usage(d->crt, usage);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -257,12 +257,12 @@ bool CertificateBuilder::addSubjectKeyIdentifier()
QByteArray ba(128, 0); // Normally 20 bytes (SHA1) QByteArray ba(128, 0); // Normally 20 bytes (SHA1)
size_t size = ba.size(); size_t size = ba.size();
d->errno = gnutls_x509_crt_get_key_id(d->crt, 0, reinterpret_cast<unsigned char *>(ba.data()), &size); d->errnumber = gnutls_x509_crt_get_key_id(d->crt, 0, reinterpret_cast<unsigned char *>(ba.data()), &size);
if (GNUTLS_E_SUCCESS != d->errno) if (GNUTLS_E_SUCCESS != d->errnumber)
return false; return false;
d->errno = gnutls_x509_crt_set_subject_key_id (d->crt, ba.constData(), size); d->errnumber = gnutls_x509_crt_set_subject_key_id (d->crt, ba.constData(), size);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -272,30 +272,30 @@ bool CertificateBuilder::addSubjectKeyIdentifier()
*/ */
bool CertificateBuilder::addAuthorityKeyIdentifier(const QSslCertificate &qcacert) bool CertificateBuilder::addAuthorityKeyIdentifier(const QSslCertificate &qcacert)
{ {
gnutls_x509_crt_t cacrt = qsslcert_to_crt(qcacert, &d->errno); gnutls_x509_crt_t cacrt = qsslcert_to_crt(qcacert, &d->errnumber);
if (GNUTLS_E_SUCCESS != d->errno) if (GNUTLS_E_SUCCESS != d->errnumber)
return false; return false;
QByteArray ba(128, 0); // Normally 20 bytes (SHA1) QByteArray ba(128, 0); // Normally 20 bytes (SHA1)
size_t size = ba.size(); size_t size = ba.size();
// Try using the subject keyid // Try using the subject keyid
d->errno = gnutls_x509_crt_get_subject_key_id(cacrt, reinterpret_cast<unsigned char *>(ba.data()), &size, NULL); d->errnumber = gnutls_x509_crt_get_subject_key_id(cacrt, reinterpret_cast<unsigned char *>(ba.data()), &size, NULL);
// Or fallback to creating it // Or fallback to creating it
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
d->errno = gnutls_x509_crt_get_key_id(cacrt, 0, reinterpret_cast<unsigned char *>(ba.data()), &size); d->errnumber = gnutls_x509_crt_get_key_id(cacrt, 0, reinterpret_cast<unsigned char *>(ba.data()), &size);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_crt_deinit(cacrt); gnutls_x509_crt_deinit(cacrt);
return false; return false;
} }
} }
gnutls_x509_crt_deinit(cacrt); gnutls_x509_crt_deinit(cacrt);
d->errno = gnutls_x509_crt_set_authority_key_id(d->crt, reinterpret_cast<const unsigned char *>(ba.constData()), size); d->errnumber = gnutls_x509_crt_set_authority_key_id(d->crt, reinterpret_cast<const unsigned char *>(ba.constData()), size);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -304,29 +304,29 @@ bool CertificateBuilder::addAuthorityKeyIdentifier(const QSslCertificate &qcacer
*/ */
QSslCertificate CertificateBuilder::signedCertificate(const QSslKey &qkey) QSslCertificate CertificateBuilder::signedCertificate(const QSslKey &qkey)
{ {
gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errno); gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errnumber);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return QSslCertificate(); return QSslCertificate();
}; };
gnutls_privkey_t abstractKey; gnutls_privkey_t abstractKey;
d->errno = gnutls_privkey_init(&abstractKey); d->errnumber = gnutls_privkey_init(&abstractKey);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return QSslCertificate(); return QSslCertificate();
} }
gnutls_privkey_import_x509(abstractKey, key, GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE); gnutls_privkey_import_x509(abstractKey, key, GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE);
d->errno = gnutls_x509_crt_privkey_sign(d->crt, d->crt, abstractKey, GNUTLS_DIG_SHA1, 0); d->errnumber = gnutls_x509_crt_privkey_sign(d->crt, d->crt, abstractKey, GNUTLS_DIG_SHA1, 0);
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
if (GNUTLS_E_SUCCESS != d->errno) if (GNUTLS_E_SUCCESS != d->errnumber)
return QSslCertificate(); return QSslCertificate();
return crt_to_qsslcert(d->crt, &d->errno); return crt_to_qsslcert(d->crt, &d->errnumber);
} }
/*! /*!
@@ -338,15 +338,15 @@ QSslCertificate CertificateBuilder::signedCertificate(const QSslCertificate &qca
// //
// Extract the CA key // Extract the CA key
// //
gnutls_x509_privkey_t key = qsslkey_to_key(qcakey, &d->errno); gnutls_x509_privkey_t key = qsslkey_to_key(qcakey, &d->errnumber);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return QSslCertificate(); return QSslCertificate();
}; };
gnutls_privkey_t abstractKey; gnutls_privkey_t abstractKey;
d->errno = gnutls_privkey_init(&abstractKey); d->errnumber = gnutls_privkey_init(&abstractKey);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return QSslCertificate(); return QSslCertificate();
} }
@@ -356,8 +356,8 @@ QSslCertificate CertificateBuilder::signedCertificate(const QSslCertificate &qca
// //
// Extract the CA cert // Extract the CA cert
// //
gnutls_x509_crt_t cacrt = qsslcert_to_crt(qcacert, &d->errno); gnutls_x509_crt_t cacrt = qsslcert_to_crt(qcacert, &d->errnumber);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return QSslCertificate(); return QSslCertificate();
} }
@@ -365,15 +365,15 @@ QSslCertificate CertificateBuilder::signedCertificate(const QSslCertificate &qca
// //
// Sign the cert // Sign the cert
// //
d->errno = gnutls_x509_crt_privkey_sign(d->crt, cacrt, abstractKey, GNUTLS_DIG_SHA1, 0); d->errnumber = gnutls_x509_crt_privkey_sign(d->crt, cacrt, abstractKey, GNUTLS_DIG_SHA1, 0);
gnutls_x509_crt_deinit(cacrt); gnutls_x509_crt_deinit(cacrt);
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
if (GNUTLS_E_SUCCESS != d->errno) if (GNUTLS_E_SUCCESS != d->errnumber)
return QSslCertificate(); return QSslCertificate();
return crt_to_qsslcert(d->crt, &d->errno); return crt_to_qsslcert(d->crt, &d->errnumber);
} }
QT_END_NAMESPACE_CERTIFICATE QT_END_NAMESPACE_CERTIFICATE

View File

@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE_CERTIFICATE
struct CertificateBuilderPrivate struct CertificateBuilderPrivate
{ {
int errno; int errnumber;
gnutls_x509_crt_t crt; gnutls_x509_crt_t crt;
}; };

View File

@@ -57,14 +57,14 @@ QT_BEGIN_NAMESPACE_CERTIFICATE
\internal \internal
Convert a crq to a PEM or DER encoded QByteArray. Convert a crq to a PEM or DER encoded QByteArray.
*/ */
static QByteArray request_to_bytearray(gnutls_x509_crq_t crq, gnutls_x509_crt_fmt_t format, int *errno) static QByteArray request_to_bytearray(gnutls_x509_crq_t crq, gnutls_x509_crt_fmt_t format, int *errnumber)
{ {
QByteArray ba(4096, 0); QByteArray ba(4096, 0);
size_t size = ba.size(); size_t size = ba.size();
*errno = gnutls_x509_crq_export(crq, format, ba.data(), &size); *errnumber = gnutls_x509_crq_export(crq, format, ba.data(), &size);
if (GNUTLS_E_SUCCESS != *errno) if (GNUTLS_E_SUCCESS != *errnumber)
return QByteArray(); return QByteArray();
ba.resize(size); // size has now been updated ba.resize(size); // size has now been updated
@@ -77,7 +77,7 @@ CertificateRequestPrivate::CertificateRequestPrivate()
ensure_gnutls_init(); ensure_gnutls_init();
gnutls_x509_crq_init(&crq); gnutls_x509_crq_init(&crq);
errno = GNUTLS_E_SUCCESS; errnumber = GNUTLS_E_SUCCESS;
} }
CertificateRequestPrivate::~CertificateRequestPrivate() CertificateRequestPrivate::~CertificateRequestPrivate()
@@ -114,8 +114,8 @@ CertificateRequest::CertificateRequest(QIODevice *io, QSsl::EncodingFormat forma
buffer.data = (unsigned char *)(buf.data()); buffer.data = (unsigned char *)(buf.data());
buffer.size = buf.size(); buffer.size = buf.size();
d->errno = gnutls_x509_crq_import(d->crq, &buffer, (QSsl::Pem == format) ? GNUTLS_X509_FMT_PEM : GNUTLS_X509_FMT_DER); d->errnumber = gnutls_x509_crq_import(d->crq, &buffer, (QSsl::Pem == format) ? GNUTLS_X509_FMT_PEM : GNUTLS_X509_FMT_DER);
if (GNUTLS_E_SUCCESS == d->errno) if (GNUTLS_E_SUCCESS == d->errnumber)
d->null = false; d->null = false;
} }
@@ -141,7 +141,7 @@ bool CertificateRequest::isNull() const
*/ */
int CertificateRequest::error() const int CertificateRequest::error() const
{ {
return d->errno; return d->errnumber;
} }
/*! /*!
@@ -150,7 +150,7 @@ int CertificateRequest::error() const
*/ */
QString CertificateRequest::errorString() const QString CertificateRequest::errorString() const
{ {
return QString::fromUtf8(gnutls_strerror(d->errno)); return QString::fromUtf8(gnutls_strerror(d->errnumber));
} }
/*! /*!
@@ -174,14 +174,14 @@ QList<QByteArray> CertificateRequest::nameEntryAttributes()
QByteArray buffer(1024, 0); QByteArray buffer(1024, 0);
size_t size = buffer.size(); size_t size = buffer.size();
d->errno = gnutls_x509_crq_get_dn_oid(d->crq, index, buffer.data(), &size); d->errnumber = gnutls_x509_crq_get_dn_oid(d->crq, index, buffer.data(), &size);
if (GNUTLS_E_SUCCESS == d->errno) { if (GNUTLS_E_SUCCESS == d->errnumber) {
buffer.resize(size); buffer.resize(size);
result << buffer; result << buffer;
} }
index++; index++;
} while(GNUTLS_E_SUCCESS == d->errno); } while(GNUTLS_E_SUCCESS == d->errnumber);
return result; return result;
} }
@@ -208,13 +208,13 @@ QStringList CertificateRequest::nameEntryInfo(const QByteArray &oid)
QByteArray buffer(1024, 0); QByteArray buffer(1024, 0);
size_t size = buffer.size(); size_t size = buffer.size();
d->errno = gnutls_x509_crq_get_dn_by_oid(d->crq, oid.constData(), index, false, buffer.data(), &size); d->errnumber = gnutls_x509_crq_get_dn_by_oid(d->crq, oid.constData(), index, false, buffer.data(), &size);
if (GNUTLS_E_SUCCESS == d->errno) if (GNUTLS_E_SUCCESS == d->errnumber)
result << QString::fromUtf8(buffer); result << QString::fromUtf8(buffer);
index++; index++;
} while(GNUTLS_E_SUCCESS == d->errno); } while(GNUTLS_E_SUCCESS == d->errnumber);
return result; return result;
} }
@@ -224,7 +224,7 @@ QStringList CertificateRequest::nameEntryInfo(const QByteArray &oid)
*/ */
QByteArray CertificateRequest::toPem() QByteArray CertificateRequest::toPem()
{ {
return request_to_bytearray(d->crq, GNUTLS_X509_FMT_PEM, &d->errno); return request_to_bytearray(d->crq, GNUTLS_X509_FMT_PEM, &d->errnumber);
} }
/*! /*!
@@ -232,7 +232,7 @@ QByteArray CertificateRequest::toPem()
*/ */
QByteArray CertificateRequest::toDer() QByteArray CertificateRequest::toDer()
{ {
return request_to_bytearray(d->crq, GNUTLS_X509_FMT_DER, &d->errno); return request_to_bytearray(d->crq, GNUTLS_X509_FMT_DER, &d->errnumber);
} }
/*! /*!
@@ -241,9 +241,9 @@ QByteArray CertificateRequest::toDer()
QString CertificateRequest::toText() QString CertificateRequest::toText()
{ {
gnutls_datum_t datum; gnutls_datum_t datum;
d->errno = gnutls_x509_crq_print(d->crq, GNUTLS_CRT_PRINT_FULL, &datum); d->errnumber = gnutls_x509_crq_print(d->crq, GNUTLS_CRT_PRINT_FULL, &datum);
if (GNUTLS_E_SUCCESS != d->errno) if (GNUTLS_E_SUCCESS != d->errnumber)
return QString(); return QString();
QString result = QString::fromUtf8(reinterpret_cast<const char *>(datum.data), datum.size); QString result = QString::fromUtf8(reinterpret_cast<const char *>(datum.data), datum.size);

View File

@@ -53,7 +53,7 @@ public:
~CertificateRequestPrivate(); ~CertificateRequestPrivate();
bool null; bool null;
int errno; int errnumber;
gnutls_x509_crq_t crq; gnutls_x509_crq_t crq;
}; };

View File

@@ -60,7 +60,7 @@ CertificateRequestBuilder::CertificateRequestBuilder()
ensure_gnutls_init(); ensure_gnutls_init();
gnutls_x509_crq_init(&d->crq); gnutls_x509_crq_init(&d->crq);
d->errno = GNUTLS_E_SUCCESS; d->errnumber = GNUTLS_E_SUCCESS;
} }
/*! /*!
@@ -79,7 +79,7 @@ CertificateRequestBuilder::~CertificateRequestBuilder()
*/ */
int CertificateRequestBuilder::error() const int CertificateRequestBuilder::error() const
{ {
return d->errno; return d->errnumber;
} }
/*! /*!
@@ -88,7 +88,7 @@ int CertificateRequestBuilder::error() const
*/ */
QString CertificateRequestBuilder::errorString() const QString CertificateRequestBuilder::errorString() const
{ {
return QString::fromUtf8(gnutls_strerror(d->errno)); return QString::fromUtf8(gnutls_strerror(d->errnumber));
} }
/*! /*!
@@ -97,8 +97,8 @@ QString CertificateRequestBuilder::errorString() const
*/ */
bool CertificateRequestBuilder::setVersion(int version) bool CertificateRequestBuilder::setVersion(int version)
{ {
d->errno = gnutls_x509_crq_set_version(d->crq, version); d->errnumber = gnutls_x509_crq_set_version(d->crq, version);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -108,7 +108,7 @@ int CertificateRequestBuilder::version() const
{ {
int ver = gnutls_x509_crq_get_version(d->crq); int ver = gnutls_x509_crq_get_version(d->crq);
if (ver < 0) if (ver < 0)
d->errno = ver; d->errnumber = ver;
return ver; return ver;
} }
@@ -117,17 +117,17 @@ int CertificateRequestBuilder::version() const
*/ */
bool CertificateRequestBuilder::setKey(const QSslKey &qkey) bool CertificateRequestBuilder::setKey(const QSslKey &qkey)
{ {
gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errno); gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errnumber);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return false; return false;
}; };
d->errno = gnutls_x509_crq_set_key(d->crq, key); d->errnumber = gnutls_x509_crq_set_key(d->crq, key);
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
/*! /*!
@@ -143,14 +143,14 @@ QList<QByteArray> CertificateRequestBuilder::nameEntryAttributes()
QByteArray buffer(1024, 0); QByteArray buffer(1024, 0);
size_t size = buffer.size(); size_t size = buffer.size();
d->errno = gnutls_x509_crq_get_dn_oid(d->crq, index, buffer.data(), &size); d->errnumber = gnutls_x509_crq_get_dn_oid(d->crq, index, buffer.data(), &size);
if (GNUTLS_E_SUCCESS == d->errno) { if (GNUTLS_E_SUCCESS == d->errnumber) {
buffer.resize(size); buffer.resize(size);
result << buffer; result << buffer;
} }
index++; index++;
} while(GNUTLS_E_SUCCESS == d->errno); } while(GNUTLS_E_SUCCESS == d->errnumber);
return result; return result;
} }
@@ -177,13 +177,13 @@ QStringList CertificateRequestBuilder::nameEntryInfo(const QByteArray &oid)
QByteArray buffer(1024, 0); QByteArray buffer(1024, 0);
size_t size = buffer.size(); size_t size = buffer.size();
d->errno = gnutls_x509_crq_get_dn_by_oid(d->crq, oid.constData(), index, false, buffer.data(), &size); d->errnumber = gnutls_x509_crq_get_dn_by_oid(d->crq, oid.constData(), index, false, buffer.data(), &size);
if (GNUTLS_E_SUCCESS == d->errno) if (GNUTLS_E_SUCCESS == d->errnumber)
result << QString::fromUtf8(buffer); result << QString::fromUtf8(buffer);
index++; index++;
} while(GNUTLS_E_SUCCESS == d->errno); } while(GNUTLS_E_SUCCESS == d->errnumber);
return result; return result;
} }
@@ -213,9 +213,9 @@ bool CertificateRequestBuilder::addNameEntry(Certificate::EntryType type, const
*/ */
bool CertificateRequestBuilder::addNameEntry(const QByteArray &oid, const QByteArray &value, bool raw) bool CertificateRequestBuilder::addNameEntry(const QByteArray &oid, const QByteArray &value, bool raw)
{ {
d->errno = gnutls_x509_crq_set_dn_by_oid(d->crq, oid.constData(), raw, d->errnumber = gnutls_x509_crq_set_dn_by_oid(d->crq, oid.constData(), raw,
value.constData(), qstrlen(value.constData())); value.constData(), qstrlen(value.constData()));
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
@@ -223,16 +223,16 @@ bool CertificateRequestBuilder::addSubjectAlternativeNameEntry(QSsl::Alternative
{ {
gnutls_x509_subject_alt_name_t type = qssl_altnameentrytype_to_altname(qtype); gnutls_x509_subject_alt_name_t type = qssl_altnameentrytype_to_altname(qtype);
d->errno = gnutls_x509_crq_set_subject_alt_name(d->crq, type, value.constData(), value.size(), GNUTLS_FSAN_APPEND); d->errnumber = gnutls_x509_crq_set_subject_alt_name(d->crq, type, value.constData(), value.size(), GNUTLS_FSAN_APPEND);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
#else #else
bool CertificateRequestBuilder::addSubjectAlternativeNameEntry(QSsl::AlternateNameEntryType qtype, const QByteArray &value) bool CertificateRequestBuilder::addSubjectAlternativeNameEntry(QSsl::AlternateNameEntryType qtype, const QByteArray &value)
{ {
gnutls_x509_subject_alt_name_t type = qssl_altnameentrytype_to_altname(qtype); gnutls_x509_subject_alt_name_t type = qssl_altnameentrytype_to_altname(qtype);
d->errno = gnutls_x509_crq_set_subject_alt_name(d->crq, type, value.constData(), value.size(), GNUTLS_FSAN_APPEND); d->errnumber = gnutls_x509_crq_set_subject_alt_name(d->crq, type, value.constData(), value.size(), GNUTLS_FSAN_APPEND);
return GNUTLS_E_SUCCESS == d->errno; return GNUTLS_E_SUCCESS == d->errnumber;
} }
#endif #endif
@@ -243,16 +243,16 @@ CertificateRequest CertificateRequestBuilder::signedRequest(const QSslKey &qkey)
{ {
CertificateRequest result; CertificateRequest result;
gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errno); gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errnumber);
if (GNUTLS_E_SUCCESS != d->errno) { if (GNUTLS_E_SUCCESS != d->errnumber) {
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
return result; return result;
}; };
d->errno = gnutls_x509_crq_sign2(d->crq, key, GNUTLS_DIG_SHA1, 0); d->errnumber = gnutls_x509_crq_sign2(d->crq, key, GNUTLS_DIG_SHA1, 0);
gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(key);
if (GNUTLS_E_SUCCESS != d->errno) if (GNUTLS_E_SUCCESS != d->errnumber)
return result; return result;
gnutls_x509_crq_t crqsave = result.d->crq; gnutls_x509_crq_t crqsave = result.d->crq;

View File

@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE_CERTIFICATE
struct CertificateRequestBuilderPrivate struct CertificateRequestBuilderPrivate
{ {
int errno; int errnumber;
gnutls_x509_crq_t crq; gnutls_x509_crq_t crq;
}; };

View File

@@ -66,8 +66,8 @@ QByteArray RandomGenerator::getPositiveBytes(int size)
{ {
QByteArray result(size, 0); QByteArray result(size, 0);
int errno = gnutls_rnd(GNUTLS_RND_RANDOM, result.data(), size); int errnumber = gnutls_rnd(GNUTLS_RND_RANDOM, result.data(), size);
if (GNUTLS_E_SUCCESS != errno) if (GNUTLS_E_SUCCESS != errnumber)
return QByteArray(); return QByteArray();
// Clear the top bit to ensure the number is positive // Clear the top bit to ensure the number is positive

View File

@@ -94,12 +94,12 @@ QByteArray entrytype_to_oid(Certificate::EntryType type)
return oid; return oid;
} }
gnutls_x509_privkey_t qsslkey_to_key(const QSslKey &qkey, int *errno) gnutls_x509_privkey_t qsslkey_to_key(const QSslKey &qkey, int *errnumber)
{ {
gnutls_x509_privkey_t key; gnutls_x509_privkey_t key;
*errno = gnutls_x509_privkey_init(&key); *errnumber = gnutls_x509_privkey_init(&key);
if (GNUTLS_E_SUCCESS != *errno) if (GNUTLS_E_SUCCESS != *errnumber)
return 0; return 0;
QByteArray buf(qkey.toPem()); QByteArray buf(qkey.toPem());
@@ -109,16 +109,16 @@ gnutls_x509_privkey_t qsslkey_to_key(const QSslKey &qkey, int *errno)
buffer.data = (unsigned char *)(buf.data()); buffer.data = (unsigned char *)(buf.data());
buffer.size = buf.size(); buffer.size = buf.size();
*errno = gnutls_x509_privkey_import(key, &buffer, GNUTLS_X509_FMT_PEM); *errnumber = gnutls_x509_privkey_import(key, &buffer, GNUTLS_X509_FMT_PEM);
return key; return key;
} }
gnutls_x509_crt_t qsslcert_to_crt(const QSslCertificate &qcert, int *errno) gnutls_x509_crt_t qsslcert_to_crt(const QSslCertificate &qcert, int *errnumber)
{ {
gnutls_x509_crt_t cert; gnutls_x509_crt_t cert;
*errno = gnutls_x509_crt_init(&cert); *errnumber = gnutls_x509_crt_init(&cert);
if (GNUTLS_E_SUCCESS != *errno) if (GNUTLS_E_SUCCESS != *errnumber)
return 0; return 0;
QByteArray buf(qcert.toPem()); QByteArray buf(qcert.toPem());
@@ -129,29 +129,29 @@ gnutls_x509_crt_t qsslcert_to_crt(const QSslCertificate &qcert, int *errno)
buffer.size = buf.size(); buffer.size = buf.size();
// Import the cert // Import the cert
*errno = gnutls_x509_crt_import(cert, &buffer, GNUTLS_X509_FMT_PEM); *errnumber = gnutls_x509_crt_import(cert, &buffer, GNUTLS_X509_FMT_PEM);
return cert; return cert;
} }
QSslCertificate crt_to_qsslcert(gnutls_x509_crt_t crt, int *errno) QSslCertificate crt_to_qsslcert(gnutls_x509_crt_t crt, int *errnumber)
{ {
QByteArray ba(4096, 0); QByteArray ba(4096, 0);
size_t size = ba.size(); size_t size = ba.size();
*errno = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, ba.data(), &size); *errnumber = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, ba.data(), &size);
if (GNUTLS_E_SUCCESS != *errno) if (GNUTLS_E_SUCCESS != *errnumber)
return QSslCertificate(); return QSslCertificate();
return QSslCertificate(ba); return QSslCertificate(ba);
} }
QSslKey key_to_qsslkey(gnutls_x509_privkey_t key, QSsl::KeyAlgorithm algo, int *errno) QSslKey key_to_qsslkey(gnutls_x509_privkey_t key, QSsl::KeyAlgorithm algo, int *errnumber)
{ {
QByteArray ba(4096, 0); QByteArray ba(4096, 0);
size_t size = ba.size(); size_t size = ba.size();
*errno = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, ba.data(), &size); *errnumber = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, ba.data(), &size);
if (GNUTLS_E_SUCCESS != *errno) if (GNUTLS_E_SUCCESS != *errnumber)
return QSslKey(); return QSslKey();
return QSslKey(ba, algo); return QSslKey(ba, algo);

View File

@@ -56,11 +56,11 @@ void ensure_gnutls_init();
QByteArray entrytype_to_oid(Certificate::EntryType type); QByteArray entrytype_to_oid(Certificate::EntryType type);
gnutls_x509_privkey_t qsslkey_to_key(const QSslKey &qkey, int *errno); gnutls_x509_privkey_t qsslkey_to_key(const QSslKey &qkey, int *errnumber);
gnutls_x509_crt_t qsslcert_to_crt(const QSslCertificate &qcert, int *errno); gnutls_x509_crt_t qsslcert_to_crt(const QSslCertificate &qcert, int *errnumber);
QSslCertificate crt_to_qsslcert(gnutls_x509_crt_t crt, int *errno); QSslCertificate crt_to_qsslcert(gnutls_x509_crt_t crt, int *errnumber);
QSslKey key_to_qsslkey(gnutls_x509_privkey_t key, QSsl::KeyAlgorithm algo, int *errno); QSslKey key_to_qsslkey(gnutls_x509_privkey_t key, QSsl::KeyAlgorithm algo, int *errnumber);
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
gnutls_x509_subject_alt_name_t qssl_altnameentrytype_to_altname(QSsl::AlternativeNameEntryType qtype); gnutls_x509_subject_alt_name_t qssl_altnameentrytype_to_altname(QSsl::AlternativeNameEntryType qtype);