Commit 0d3c6b40 authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid

Use GooString for publicKey, cert_serial, cert_der

parent 11955443
......@@ -16,32 +16,23 @@
#include <stdlib.h>
X509CertificateInfo::PublicKeyInfo::PublicKeyInfo() :
publicKey(nullptr),
publicKeyType(OTHERKEY),
publicKeyStrength(0)
{
}
X509CertificateInfo::PublicKeyInfo::~PublicKeyInfo()
{
delete publicKey;
}
X509CertificateInfo::PublicKeyInfo::PublicKeyInfo(X509CertificateInfo::PublicKeyInfo &&other)
{
publicKey = other.publicKey;
publicKey = std::move(other.publicKey);
publicKeyType = other.publicKeyType;
publicKeyStrength = other.publicKeyStrength;
other.publicKey = nullptr;
}
X509CertificateInfo::PublicKeyInfo &X509CertificateInfo::PublicKeyInfo::operator=(X509CertificateInfo::PublicKeyInfo &&other)
{
delete publicKey;
publicKey = other.publicKey;
publicKey = std::move(other.publicKey);
publicKeyType = other.publicKeyType;
publicKeyStrength = other.publicKeyStrength;
other.publicKey = nullptr;
return *this;
}
......@@ -91,19 +82,13 @@ X509CertificateInfo::EntityInfo &X509CertificateInfo::EntityInfo::operator=(X509
}
X509CertificateInfo::X509CertificateInfo() :
cert_serial(nullptr),
cert_der(nullptr),
ku_extensions(KU_NONE),
cert_version(-1),
is_self_signed(false)
{
}
X509CertificateInfo::~X509CertificateInfo()
{
delete cert_serial;
delete cert_der;
}
X509CertificateInfo::~X509CertificateInfo() = default;
int X509CertificateInfo::getVersion() const
{
......@@ -112,7 +97,7 @@ int X509CertificateInfo::getVersion() const
const GooString &X509CertificateInfo::getSerialNumber() const
{
return *cert_serial;
return cert_serial;
}
const X509CertificateInfo::EntityInfo &X509CertificateInfo::getIssuerInfo() const
......@@ -142,7 +127,7 @@ unsigned int X509CertificateInfo::getKeyUsageExtensions() const
const GooString &X509CertificateInfo::getCertificateDER() const
{
return *cert_der;
return cert_der;
}
bool X509CertificateInfo::getIsSelfSigned() const
......@@ -155,10 +140,9 @@ void X509CertificateInfo::setVersion(int version)
cert_version = version;
}
void X509CertificateInfo::setSerialNumber(GooString *serialNumber)
void X509CertificateInfo::setSerialNumber(const GooString &serialNumber)
{
delete cert_serial;
cert_serial = serialNumber;
cert_serial.Set(&serialNumber);
}
void X509CertificateInfo::setIssuerInfo(EntityInfo &&issuerInfo)
......@@ -186,10 +170,9 @@ void X509CertificateInfo::setKeyUsageExtensions(unsigned int keyUsages)
ku_extensions = keyUsages;
}
void X509CertificateInfo::setCertificateDER(GooString *certDer)
void X509CertificateInfo::setCertificateDER(const GooString &certDer)
{
delete cert_der;
cert_der = certDer;
cert_der.Set(&certDer);
}
void X509CertificateInfo::setIsSelfSigned(bool isSelfSigned)
......
......@@ -13,6 +13,7 @@
#ifndef CERTIFICATEINFO_H
#define CERTIFICATEINFO_H
#include <memory>
#include <time.h>
#include "goo/GooString.h"
......@@ -44,7 +45,6 @@ public:
struct PublicKeyInfo {
PublicKeyInfo();
~PublicKeyInfo();
PublicKeyInfo(PublicKeyInfo &&);
PublicKeyInfo &operator=(PublicKeyInfo &&);
......@@ -52,7 +52,7 @@ public:
PublicKeyInfo(const PublicKeyInfo &) = delete;
PublicKeyInfo &operator=(const PublicKeyInfo &) = delete;
GooString *publicKey;
GooString publicKey;
PublicKeyType publicKeyType;
unsigned int publicKeyStrength; // in bits
};
......@@ -93,13 +93,13 @@ public:
/* SETTERS */
void setVersion(int);
void setSerialNumber(GooString *);
void setSerialNumber(const GooString &);
void setIssuerInfo(EntityInfo &&);
void setValidity(Validity);
void setSubjectInfo(EntityInfo &&);
void setPublicKeyInfo(PublicKeyInfo &&);
void setKeyUsageExtensions(unsigned int);
void setCertificateDER(GooString *);
void setCertificateDER(const GooString &);
void setIsSelfSigned(bool);
private:
......@@ -110,8 +110,8 @@ private:
EntityInfo subject_info;
PublicKeyInfo public_key_info;
Validity cert_validity;
GooString *cert_serial;
GooString *cert_der;
GooString cert_serial;
GooString cert_der;
unsigned int ku_extensions;
int cert_version;
bool is_self_signed;
......
......@@ -116,10 +116,10 @@ X509CertificateInfo::EntityInfo SignatureHandler::getEntityInfo(CERTName *entity
return info;
}
static GooString *SECItemToGooString(const SECItem &secItem)
static GooString SECItemToGooString(const SECItem &secItem)
{
// TODO do we need to handle secItem.type;
return new GooString((const char *)secItem.data, secItem.len);
return GooString((const char *)secItem.data, secItem.len);
}
X509CertificateInfo *SignatureHandler::getCertificateInfo() const
......
......@@ -969,7 +969,7 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime& v
certPriv->validity_end = QDateTime::fromTime_t(certValidity.notAfter, Qt::UTC);
const X509CertificateInfo::PublicKeyInfo &pkInfo = ci->getPublicKeyInfo();
certPriv->public_key = QByteArray(pkInfo.publicKey->c_str(), pkInfo.publicKey->getLength());
certPriv->public_key = QByteArray(pkInfo.publicKey.c_str(), pkInfo.publicKey.getLength());
certPriv->public_key_type = static_cast<int>(pkInfo.publicKeyType);
certPriv->public_key_strength = pkInfo.publicKeyStrength;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment