2005-01-01 02:44:28 +00:00
|
|
|
/*
|
|
|
|
* qca_cert.h - Qt Cryptographic Architecture
|
|
|
|
* Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
|
|
|
|
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QCA_CERT_H
|
|
|
|
#define QCA_CERT_H
|
|
|
|
|
2005-02-27 01:12:26 +00:00
|
|
|
#include <QMap>
|
2005-03-04 21:50:57 +00:00
|
|
|
#include <QDateTime>
|
2005-01-01 02:44:28 +00:00
|
|
|
#include "qca_core.h"
|
2005-01-25 13:01:45 +00:00
|
|
|
#include "qca_publickey.h"
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
namespace QCA
|
|
|
|
{
|
2005-03-28 07:11:58 +00:00
|
|
|
class CertificateCollection;
|
|
|
|
|
2005-01-18 09:59:10 +00:00
|
|
|
/**
|
|
|
|
Certificate Request Format
|
|
|
|
*/
|
2005-01-17 22:12:21 +00:00
|
|
|
enum CertificateRequestFormat
|
|
|
|
{
|
2005-02-25 06:51:06 +00:00
|
|
|
PKCS10, ///< standard PKCS#10 format
|
|
|
|
SPKAC ///< Signed Public Key and Challenge (Netscape) format
|
2005-01-17 22:12:21 +00:00
|
|
|
};
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Certificate information types
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
enum CertificateInfoType
|
2005-02-24 08:39:08 +00:00
|
|
|
{
|
2005-05-10 12:24:23 +00:00
|
|
|
CommonName, ///< The common name (eg person)
|
|
|
|
Email, ///< Email address
|
|
|
|
Organization, ///< An organisation (eg company)
|
|
|
|
OrganizationalUnit, ///< An part of an organisation (eg a division or branch)
|
|
|
|
Locality, ///< The locality (eg a shire, or part of a state)
|
|
|
|
State, ///< The state within the country
|
|
|
|
Country, ///< The country
|
|
|
|
URI,
|
2005-02-25 06:51:06 +00:00
|
|
|
DNS,
|
2005-03-04 21:50:57 +00:00
|
|
|
IPAddress,
|
2005-02-25 06:51:06 +00:00
|
|
|
XMPP
|
2005-02-24 08:39:08 +00:00
|
|
|
};
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Certificate constraints
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
enum ConstraintType
|
2005-02-24 08:39:08 +00:00
|
|
|
{
|
|
|
|
// basic
|
2005-02-25 06:51:06 +00:00
|
|
|
DigitalSignature,
|
|
|
|
NonRepudiation,
|
|
|
|
KeyEncipherment,
|
|
|
|
DataEncipherment,
|
|
|
|
KeyAgreement,
|
|
|
|
KeyCertificateSign,
|
|
|
|
CRLSign,
|
|
|
|
EncipherOnly,
|
|
|
|
DecipherOnly,
|
2005-02-24 08:39:08 +00:00
|
|
|
|
|
|
|
// extended
|
2005-02-25 06:51:06 +00:00
|
|
|
ServerAuth,
|
|
|
|
ClientAuth,
|
|
|
|
CodeSigning,
|
|
|
|
EmailProtection,
|
2005-03-13 08:48:36 +00:00
|
|
|
IPSecEndSystem,
|
|
|
|
IPSecTunnel,
|
|
|
|
IPSecUser,
|
2005-02-25 06:51:06 +00:00
|
|
|
TimeStamping,
|
|
|
|
OCSPSigning
|
2005-02-24 08:39:08 +00:00
|
|
|
};
|
|
|
|
|
2005-03-28 07:11:58 +00:00
|
|
|
/**
|
|
|
|
Specify the intended usage of a certificate
|
|
|
|
*/
|
|
|
|
enum UsageMode
|
|
|
|
{
|
|
|
|
UsageAny = 0x00, ///< Any application, or unspecified
|
|
|
|
UsageTLSServer = 0x01, ///< server side of a TLS or SSL connection
|
|
|
|
UsageTLSClient = 0x02, ///< client side of a TLS or SSL connection
|
|
|
|
UsageCodeSigning = 0x04, ///< code signing certificate
|
|
|
|
UsageEmailProtection = 0x08, ///< email (S/MIME) certificate
|
|
|
|
UsageTimeStamping = 0x10, ///< time stamping certificate
|
|
|
|
UsageCRLSigning = 0x20 ///< certificate revocation list signing certificate
|
|
|
|
};
|
|
|
|
|
2005-01-25 13:01:45 +00:00
|
|
|
/**
|
|
|
|
The validity (or otherwise) of a certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
enum Validity
|
2005-01-25 13:01:45 +00:00
|
|
|
{
|
2005-02-25 06:51:06 +00:00
|
|
|
ValidityGood, ///< The certificate is valid
|
|
|
|
ErrorRejected, ///< The root CA rejected the certificate purpose
|
|
|
|
ErrorUntrusted, ///< The certificate is not trusted
|
|
|
|
ErrorSignatureFailed, ///< The signature does not match
|
|
|
|
ErrorInvalidCA, ///< The Certificate Authority is invalid
|
|
|
|
ErrorInvalidPurpose, ///< The purpose does not match the intended usage
|
|
|
|
ErrorSelfSigned, ///< The certificate is self-signed, and is not found in the list of trusted certificates
|
|
|
|
ErrorRevoked, ///< The certificate has been revoked
|
|
|
|
ErrorPathLengthExceeded, ///< The path length from the root CA to this certificate is too long
|
|
|
|
ErrorExpired, ///< The certificate has expired
|
|
|
|
ErrorExpiredCA, ///< The Certificate Authority has expired
|
|
|
|
ErrorValidityUnknown ///< Validity is unknown
|
2005-01-25 13:01:45 +00:00
|
|
|
};
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Certificate properties type
|
|
|
|
*/
|
2005-04-05 08:50:28 +00:00
|
|
|
typedef QMultiMap<CertificateInfoType, QString> CertificateInfo;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
2005-05-01 07:36:31 +00:00
|
|
|
%Certificate constraints type
|
2005-04-27 12:03:12 +00:00
|
|
|
*/
|
2005-02-27 01:12:26 +00:00
|
|
|
typedef QList<ConstraintType> Constraints;
|
2005-01-25 13:01:45 +00:00
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
2005-05-10 12:24:23 +00:00
|
|
|
\class CertificateOptions qca_cert.h QtCrypto
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
%Certificate options
|
|
|
|
|
|
|
|
\note In SPKAC mode, all options are ignored except for challenge
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
class QCA_EXPORT CertificateOptions
|
|
|
|
{
|
|
|
|
public:
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Create a Certificate options set
|
|
|
|
|
|
|
|
\param format the format to create the certificate request in
|
|
|
|
*/
|
|
|
|
CertificateOptions(CertificateRequestFormat format = PKCS10);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Standard copy constructor
|
|
|
|
|
|
|
|
\param from the Certificate Options to copy into this object
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
CertificateOptions(const CertificateOptions &from);
|
|
|
|
~CertificateOptions();
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Standard assignment operator
|
|
|
|
|
|
|
|
\param from the Certificate Options to copy into this object
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
CertificateOptions & operator=(const CertificateOptions &from);
|
2005-01-17 22:12:21 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
test the format type for this certificate
|
|
|
|
*/
|
2005-01-17 22:12:21 +00:00
|
|
|
CertificateRequestFormat format() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Specify the format for this certificate
|
|
|
|
|
|
|
|
\param f the format to use
|
|
|
|
*/
|
2005-01-17 22:12:21 +00:00
|
|
|
void setFormat(CertificateRequestFormat f);
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Test if the certificate options object is valid
|
|
|
|
|
|
|
|
\return true if the certificate options object is valid
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
bool isValid() const;
|
|
|
|
|
2005-02-25 06:51:06 +00:00
|
|
|
QString challenge() const; // request
|
|
|
|
CertificateInfo info() const; // request or create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
list the constraints on this certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
Constraints constraints() const; // request or create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
list the policies on this certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
QStringList policies() const; // request or create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
test if the certificate options include the certificate being a
|
|
|
|
certificate authority
|
|
|
|
|
|
|
|
\sa setAsCA
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
bool isCA() const; // request or create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
return the path limit on this certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
int pathLimit() const; // request or create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The serial number for the certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
QBigInteger serialNumber() const; // create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
the first time the certificate will be valid
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
QDateTime notValidBefore() const; // create
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
the last time the certificate is valid
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
QDateTime notValidAfter() const; // create
|
2005-01-14 06:36:12 +00:00
|
|
|
|
|
|
|
void setChallenge(const QString &s);
|
2005-02-25 06:51:06 +00:00
|
|
|
void setInfo(const CertificateInfo &info);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
set the constraints on the certificate
|
|
|
|
|
|
|
|
\param constraints the constraints to be used for the certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
void setConstraints(const Constraints &constraints);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
set the policies on the certificate
|
|
|
|
|
|
|
|
\param policies the policies to be used for the certificate
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
void setPolicies(const QStringList &policies);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
set the certificate options to include the certificate being
|
|
|
|
a certificate authority
|
|
|
|
|
|
|
|
\param pathLimit the number of intermediate certificates allowable
|
|
|
|
*/
|
2005-03-13 08:48:36 +00:00
|
|
|
void setAsCA(int pathLimit = 8); // value from Botan
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the serial number property on this certificate
|
|
|
|
|
|
|
|
\param i the serial number to use
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
void setSerialNumber(const QBigInteger &i);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the validity period for the certificate
|
|
|
|
|
|
|
|
\param start the first time this certificate becomes valid
|
|
|
|
\param end the last time this certificate is valid
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
void setValidityPeriod(const QDateTime &start, const QDateTime &end);
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private *d;
|
2005-01-14 06:36:12 +00:00
|
|
|
};
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
2005-05-10 12:24:23 +00:00
|
|
|
\class Certificate qca_cert.h QtCrypto
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
Public Key (X.509) certificate
|
|
|
|
|
|
|
|
This class contains one X.509 certificate
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT Certificate : public Algorithm
|
|
|
|
{
|
|
|
|
public:
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Create an empty Certificate
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
Certificate();
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a Certificate from a PEM encoded file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required)
|
|
|
|
of the file that contains the PEM encoded certificate
|
|
|
|
*/
|
2005-02-25 04:36:27 +00:00
|
|
|
Certificate(const QString &fileName);
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a Certificate with specified options and a specified private key
|
|
|
|
|
|
|
|
\param opts the options to use
|
|
|
|
\param key the private key for this certificate
|
|
|
|
\param provider the provider to use to create this key, if a particular provider is required
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
Certificate(const CertificateOptions &opts, const PrivateKey &key, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Test if the certificate is empty (null)
|
|
|
|
\return true if the certificate is null
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isNull() const;
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
The earliest date that the certificate is valid
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QDateTime notValidBefore() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The latest date that the certificate is valid
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QDateTime notValidAfter() const;
|
|
|
|
|
2005-05-01 07:36:31 +00:00
|
|
|
/**
|
|
|
|
Properties of the subject of the certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
CertificateInfo subjectInfo() const;
|
2005-05-01 07:36:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Properties of the issuer of the certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
CertificateInfo issuerInfo() const;
|
2005-05-01 07:36:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The constraints that apply to this certificate
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
Constraints constraints() const;
|
2005-05-05 10:27:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The policies that apply to this certificate
|
|
|
|
|
|
|
|
Policies are specified as strings containing OIDs
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
QStringList policies() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-05-05 10:27:16 +00:00
|
|
|
/**
|
|
|
|
The common name of the subject of the certificate
|
|
|
|
|
|
|
|
Common names are normally the name of a person, company or organisation
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QString commonName() const;
|
2005-05-05 10:27:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The serial number of the certificate
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger serialNumber() const;
|
2005-05-05 10:27:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The public key associated with the subject of the certificate
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
PublicKey subjectPublicKey() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test if the Certificate is valid as a Certificate Authority
|
|
|
|
|
|
|
|
\return true if the Certificate is valid as a Certificate Authority
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isCA() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test if the Certificate is self-signed
|
|
|
|
|
|
|
|
\return true if the certificate is self-signed
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isSelfSigned() const;
|
2005-05-05 10:27:16 +00:00
|
|
|
|
2005-02-24 08:39:08 +00:00
|
|
|
int pathLimit() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The signature on the certificate
|
|
|
|
*/
|
2005-03-05 04:18:05 +00:00
|
|
|
QSecureArray signature() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The signature algorithm used for the signature on this certificate
|
|
|
|
*/
|
2005-02-24 21:14:03 +00:00
|
|
|
SignatureAlgorithm signatureAlgorithm() const;
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-05 10:27:16 +00:00
|
|
|
/**
|
|
|
|
The key identifier associated with the subject
|
|
|
|
*/
|
2005-04-04 03:20:20 +00:00
|
|
|
QByteArray subjectKeyId() const;
|
2005-05-05 10:27:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The key identifier associated with the issuer
|
|
|
|
*/
|
2005-04-04 03:20:20 +00:00
|
|
|
QByteArray issuerKeyId() const;
|
2005-05-05 10:27:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Check the validity of a certificate
|
|
|
|
|
|
|
|
\param trusted a collection of trusted certificates
|
|
|
|
\param untrusted a collection of additional certificates, not necessarily trusted
|
|
|
|
\param u the use required for the certificate
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
Validity validate(const CertificateCollection &trusted, const CertificateCollection &untrusted, UsageMode u = UsageAny) const;
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Export the Certificate into a DER format
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QSecureArray toDER() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Export the Certificate into a PEM format
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QString toPEM() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Export the Certificate into PEM format in a file
|
|
|
|
|
|
|
|
\param fileName the name of the file to use
|
|
|
|
*/
|
2005-02-25 04:36:27 +00:00
|
|
|
bool toPEMFile(const QString &fileName) const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import the certificate from DER
|
|
|
|
|
|
|
|
\param a the array containing the certificate in DER format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the Certificate corresponding to the certificate in the provided array
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static Certificate fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import the certificate from PEM format
|
|
|
|
|
|
|
|
\param s the string containing the certificate in PEM format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the Certificate corresponding to the certificate in the provided string
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static Certificate fromPEM(const QString &s, ConvertResult *result = 0, const QString &provider = QString());
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import the certificate from a file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required) of the file containing the certificate in PEM format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the Certificate corresponding to the certificate in the provided string
|
|
|
|
*/
|
2005-02-25 04:36:27 +00:00
|
|
|
static Certificate fromPEMFile(const QString &fileName, ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
bool matchesHostname(const QString &host) const;
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Test for equality of two certificates
|
|
|
|
|
|
|
|
\return true if the two certificates are the same
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool operator==(const Certificate &a) const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test for inequality of two certificates
|
|
|
|
|
|
|
|
\return true if the two certificates are not the same
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool operator!=(const Certificate &a) const;
|
|
|
|
};
|
|
|
|
|
2005-02-27 01:12:26 +00:00
|
|
|
class QCA_EXPORT CertificateChain : public QList<Certificate>
|
2005-01-14 06:36:12 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CertificateChain();
|
|
|
|
CertificateChain(const Certificate &primary);
|
|
|
|
|
|
|
|
const Certificate & primary() const;
|
|
|
|
};
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
2005-05-10 12:24:23 +00:00
|
|
|
\class CertificateRequest qca_cert.h QtCrypto
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
Certificate Request
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
class QCA_EXPORT CertificateRequest : public Algorithm
|
|
|
|
{
|
|
|
|
public:
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Create an empty certificate request
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
CertificateRequest();
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a certificate request based on the contents of a file
|
|
|
|
|
|
|
|
\param fileName the file (and path, if necessary) containing a PEM encoded certificate request
|
|
|
|
*/
|
2005-02-25 04:36:27 +00:00
|
|
|
CertificateRequest(const QString &fileName);
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Create a certificate request based on specified options
|
|
|
|
|
|
|
|
\param opts the options to use in the certificate request
|
|
|
|
\param key the private key that matches the certificate being requested
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
*/
|
|
|
|
CertificateRequest(const CertificateOptions &opts, const PrivateKey &key, const QString &provider = QString());
|
|
|
|
/**
|
|
|
|
test if the certificate request is empty
|
|
|
|
|
|
|
|
\return true if the certificate request is empty, otherwise false
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
bool isNull() const;
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Test if the certificate request can use a specified format
|
|
|
|
|
|
|
|
\param f the format to test for
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return true if the certificate request can use the specified format
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
static bool canUseFormat(CertificateRequestFormat f, const QString &provider = QString());
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
the format that this Certificate request is in
|
|
|
|
*/
|
2005-01-17 22:12:21 +00:00
|
|
|
CertificateRequestFormat format() const;
|
2005-02-24 08:39:08 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Information on the subject of the certificate being requested
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
CertificateInfo subjectInfo() const; // PKCS#10 only
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The constraints that apply to this certificate request
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
Constraints constraints() const; // PKCS#10 only
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The policies that apply to this certificate request
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
QStringList policies() const; // PKCS#10 only
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The public key belonging to the issuer
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
PublicKey subjectPublicKey() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test if this Certificate Request is for a Certificate Authority certificate
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
bool isCA() const; // PKCS#10 only
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The path limit for the certificate in this Certificate Request
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
int pathLimit() const; // PKCS#10 only
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The challenge associated with this certificate request
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
QString challenge() const;
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The signature on this certificate request
|
|
|
|
*/
|
2005-03-05 04:18:05 +00:00
|
|
|
QSecureArray signature() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The algorithm used to make the signature on this certificate request
|
|
|
|
*/
|
2005-02-24 21:14:03 +00:00
|
|
|
SignatureAlgorithm signatureAlgorithm() const;
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Export the Certificate Request into a DER format
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
QSecureArray toDER() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Export the Certificate Request into a PEM format
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
QString toPEM() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Export the Certificate into PEM format in a file
|
|
|
|
|
|
|
|
\param fileName the name of the file to use
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-25 04:36:27 +00:00
|
|
|
bool toPEMFile(const QString &fileName) const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import the certificate request from DER
|
|
|
|
|
|
|
|
\param a the array containing the certificate request in DER format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CertificateRequest corresponding to the certificate request in the provided array
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static CertificateRequest fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import the certificate request from PEM format
|
|
|
|
|
|
|
|
\param s the string containing the certificate request in PEM format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CertificateRequest corresponding to the certificate request in the provided string
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static CertificateRequest fromPEM(const QString &s, ConvertResult *result = 0, const QString &provider = QString());
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Import the certificate request from a file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required) of the file containing the certificate request in PEM format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CertificateRequest corresponding to the certificate request in the provided string
|
|
|
|
|
|
|
|
\note this only applies to PKCS#10 format certificate requests
|
|
|
|
*/
|
2005-02-25 04:36:27 +00:00
|
|
|
static CertificateRequest fromPEMFile(const QString &fileName, ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-17 22:12:21 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Export the CertificateRequest to a string
|
|
|
|
|
|
|
|
\return the string corresponding to the certificate request
|
|
|
|
|
|
|
|
\note this only applies to SPKAC format certificate requests
|
|
|
|
*/
|
2005-01-17 22:12:21 +00:00
|
|
|
QString toString() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import the CertificateRequest from a string
|
|
|
|
|
|
|
|
\param s the string containing to the certificate request
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CertificateRequest corresponding to the certificate request in the provided string
|
|
|
|
|
|
|
|
\note this only applies to SPKAC format certificate requests
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static CertificateRequest fromString(const QString &s, ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-14 06:36:12 +00:00
|
|
|
};
|
|
|
|
|
2005-05-01 07:36:31 +00:00
|
|
|
/**
|
2005-05-10 12:24:23 +00:00
|
|
|
\class CRLEntry qca_cert.h QtCrypto
|
|
|
|
|
2005-05-01 07:36:31 +00:00
|
|
|
Part of a CRL representing a single certificate
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
class QCA_EXPORT CRLEntry
|
|
|
|
{
|
|
|
|
public:
|
2005-05-05 10:27:16 +00:00
|
|
|
/**
|
|
|
|
The reason why the certificate has been revoked
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
enum Reason
|
|
|
|
{
|
2005-05-05 10:27:16 +00:00
|
|
|
Unspecified, ///< reason is unknown
|
|
|
|
KeyCompromise, ///< private key has been compromised
|
|
|
|
CACompromise, ///< certificate authority has been compromised
|
2005-02-24 08:39:08 +00:00
|
|
|
AffiliationChanged,
|
2005-05-05 10:27:16 +00:00
|
|
|
Superceded, ///< certificate has been superceded
|
2005-02-24 08:39:08 +00:00
|
|
|
CessationOfOperation,
|
|
|
|
CertificateHold,
|
|
|
|
RemoveFromCRL,
|
|
|
|
PrivilegeWithdrawn,
|
|
|
|
AACompromise
|
|
|
|
};
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
create an empty CRL entry
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
CRLEntry();
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
create a CRL entry
|
|
|
|
|
|
|
|
\param c the certificate to revoke
|
|
|
|
\param r the reason that the certificate is being revoked
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
CRLEntry(const Certificate &c, Reason r = Unspecified);
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The serial number of the certificate that is the subject of this CRL entry
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
QBigInteger serialNumber() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The time this CRL entry was created
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
QDateTime time() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
the reason that this CRL entry was created
|
|
|
|
|
|
|
|
Alternatively, you might like to think of this as the reason that the
|
|
|
|
subject certificate has been revoked
|
|
|
|
*/
|
2005-01-14 06:36:12 +00:00
|
|
|
Reason reason() const;
|
2005-03-04 21:50:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QBigInteger _serial;
|
|
|
|
QDateTime _time;
|
|
|
|
Reason _reason;
|
2005-01-14 06:36:12 +00:00
|
|
|
};
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
2005-05-10 12:24:23 +00:00
|
|
|
\class CRL qca_cert.h QtCrypto
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
Certificate Revocation List
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT CRL : public Algorithm
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CRL();
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Test if the CRL is empty
|
|
|
|
|
|
|
|
\return true if the CRL is entry, otherwise return false
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isNull() const;
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Information on the issuer of the CRL
|
|
|
|
*/
|
2005-02-25 06:51:06 +00:00
|
|
|
CertificateInfo issuerInfo() const;
|
2005-02-24 08:39:08 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The CRL serial number
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
int number() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
the time that this CRL became (or becomes) valid
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QDateTime thisUpdate() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
the time that this CRL will be obsoleted
|
|
|
|
|
|
|
|
you should obtain an updated CRL at this time
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QDateTime nextUpdate() const;
|
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
a list of the revoked certificates in this CRL
|
|
|
|
*/
|
2005-02-27 01:12:26 +00:00
|
|
|
QList<CRLEntry> revoked() const;
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The signature on this CRL
|
|
|
|
*/
|
2005-03-05 04:18:05 +00:00
|
|
|
QSecureArray signature() const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The signature algorithm used for the signature on this CRL
|
|
|
|
*/
|
2005-02-24 21:14:03 +00:00
|
|
|
SignatureAlgorithm signatureAlgorithm() const;
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
The key identification of the CRL issuer
|
|
|
|
*/
|
2005-04-04 03:20:20 +00:00
|
|
|
QByteArray issuerKeyId() const;
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
|
|
|
Export the Certificate Revocation List (CRL) in DER format
|
|
|
|
|
|
|
|
\return an array containing the CRL in DER format
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QSecureArray toDER() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Export the Certificate Revocation List (CRL) in PEM format
|
|
|
|
|
|
|
|
\return a string containing the CRL in PEM format
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QString toPEM() const;
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import a DER encoded Certificate Revocation List (CRL)
|
|
|
|
|
|
|
|
\param a the array containing the CRL in DER format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CRL corresponding to the contents of the array
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static CRL fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
2005-04-27 12:03:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Import a PEM encoded %Certificate Revocation List (CRL)
|
|
|
|
|
|
|
|
\param s the string containing the CRL in PEM format
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CRL corresponding to the contents of the string
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
static CRL fromPEM(const QString &s, ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
};
|
|
|
|
|
2005-04-27 12:03:12 +00:00
|
|
|
/**
|
2005-05-10 12:24:23 +00:00
|
|
|
\class CertificateCollection qca_cert.h QtCrypto
|
|
|
|
|
2005-05-01 07:36:31 +00:00
|
|
|
Bundle of Certificates and CRLs
|
2005-04-27 12:03:12 +00:00
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
class CertificateCollection
|
2005-01-01 02:44:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Create an empty Certificate / CRL collection
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
CertificateCollection();
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Standard copy constructor
|
|
|
|
|
|
|
|
\param from the CertificateCollection to copy from
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
CertificateCollection(const CertificateCollection &from);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
2005-03-28 07:11:58 +00:00
|
|
|
~CertificateCollection();
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Standard assignment operator
|
|
|
|
|
|
|
|
\param from the CertificateCollection to copy from
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
CertificateCollection & operator=(const CertificateCollection &from);
|
2005-03-13 08:48:36 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Append a Certificate to this collection
|
|
|
|
|
|
|
|
\param cert the Certificate to add to this CertificateCollection
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
void addCertificate(const Certificate &cert);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Append a CRL to this collection
|
|
|
|
|
|
|
|
\param crl the certificate revokation list to add to this CertificateCollection
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
void addCRL(const CRL &crl);
|
|
|
|
|
2005-05-01 07:36:31 +00:00
|
|
|
/**
|
|
|
|
The Certificates in this collection
|
|
|
|
*/
|
2005-02-27 01:12:26 +00:00
|
|
|
QList<Certificate> certificates() const;
|
2005-05-01 07:36:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The CRLs in this collection
|
|
|
|
*/
|
2005-02-27 01:12:26 +00:00
|
|
|
QList<CRL> crls() const;
|
2005-01-17 00:24:39 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
Add another CertificateCollection to this collection
|
|
|
|
|
|
|
|
\param other the CertificateCollection to add to this collection
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
void append(const CertificateCollection &other);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Add another CertificateCollection to this collection
|
|
|
|
|
|
|
|
\param other the CertificateCollection to add to this collection
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
CertificateCollection operator+(const CertificateCollection &other) const;
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Add another CertificateCollection to this collection
|
|
|
|
|
|
|
|
\param other the CertificateCollection to add to this collection
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
CertificateCollection & operator+=(const CertificateCollection &other);
|
|
|
|
|
2005-01-17 00:24:39 +00:00
|
|
|
// import / export
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
test if the CertificateCollection can be imported and exported to PKCS#7 format
|
|
|
|
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return true if the CertificateCollection can be imported and exported to PKCS#7 format
|
|
|
|
*/
|
2005-02-24 08:39:08 +00:00
|
|
|
static bool canUsePKCS7(const QString &provider = QString());
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
export the CertificateCollection to a plain text file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required) to write the contents of the CertificateCollection to
|
|
|
|
|
|
|
|
\return true if the export succeeded, otherwise false
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
bool toFlatTextFile(const QString &fileName);
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
export the CertificateCollection to a PKCS#7 file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required) to write the contents of the CertificateCollection to
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return true if the export succeeded, otherwise false
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
bool toPKCS7File(const QString &fileName, const QString &provider = QString());
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
import a CertificateCollection from a text file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required) to read the certificate collection from
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CertificateCollection corresponding to the contents of the file specified in fileName
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
static CertificateCollection fromFlatTextFile(const QString &fileName, ConvertResult *result = 0, const QString &provider = QString());
|
2005-05-10 12:24:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
import a CertificateCollection from a PKCS#7 file
|
|
|
|
|
|
|
|
\param fileName the name (and path, if required) to read the certificate collection from
|
|
|
|
\param result a pointer to a ConvertResult, which if not-null will be set to the conversion status
|
|
|
|
\param provider the provider to use, if a specific provider is required
|
|
|
|
|
|
|
|
\return the CertificateCollection corresponding to the contents of the file specified in fileName
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
static CertificateCollection fromPKCS7File(const QString &fileName, ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
QSharedDataPointer<Private> d;
|
2005-01-01 02:44:28 +00:00
|
|
|
};
|
2005-01-14 06:36:12 +00:00
|
|
|
|
2005-05-10 12:24:23 +00:00
|
|
|
/**
|
|
|
|
\class CertificateAuthority qca_cert.h QtCrypto
|
|
|
|
*/
|
2005-03-04 23:54:03 +00:00
|
|
|
class QCA_EXPORT CertificateAuthority : public Algorithm
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CertificateAuthority(const Certificate &cert, const PrivateKey &key, const QString &provider);
|
|
|
|
|
|
|
|
Certificate certificate() const;
|
|
|
|
|
|
|
|
Certificate signRequest(const CertificateRequest &req, const QDateTime ¬ValidAfter) const;
|
|
|
|
Certificate createCertificate(const PublicKey &key, const CertificateOptions &opts) const;
|
|
|
|
CRL createCRL(const QDateTime &nextUpdate) const;
|
|
|
|
CRL updateCRL(const CRL &crl, const QList<CRLEntry> &entries, const QDateTime &nextUpdate) const;
|
|
|
|
};
|
|
|
|
|
2005-03-28 07:11:58 +00:00
|
|
|
// holds a certificate chain and an associated private key
|
|
|
|
class QCA_EXPORT KeyBundle
|
2005-01-14 06:36:12 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-03-28 07:11:58 +00:00
|
|
|
KeyBundle();
|
|
|
|
KeyBundle(const QString &fileName, const QSecureArray &passphrase);
|
|
|
|
KeyBundle(const KeyBundle &from);
|
|
|
|
~KeyBundle();
|
|
|
|
KeyBundle & operator=(const KeyBundle &from);
|
2005-01-14 06:36:12 +00:00
|
|
|
|
|
|
|
bool isNull() const;
|
|
|
|
|
2005-03-05 01:10:14 +00:00
|
|
|
QString name() const;
|
2005-01-14 06:36:12 +00:00
|
|
|
CertificateChain certificateChain() const;
|
|
|
|
PrivateKey privateKey() const;
|
2005-03-05 01:10:14 +00:00
|
|
|
void setName(const QString &s);
|
2005-01-14 06:36:12 +00:00
|
|
|
void setCertificateChainAndKey(const CertificateChain &c, const PrivateKey &key);
|
|
|
|
|
|
|
|
// import / export
|
2005-03-05 01:10:14 +00:00
|
|
|
QByteArray toArray(const QSecureArray &passphrase, const QString &provider = QString()) const;
|
|
|
|
bool toFile(const QString &fileName, const QSecureArray &passphrase, const QString &provider = QString()) const;
|
2005-03-28 07:11:58 +00:00
|
|
|
static KeyBundle fromArray(const QByteArray &a, const QSecureArray &passphrase, ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static KeyBundle fromFile(const QString &fileName, const QSecureArray &passphrase, ConvertResult *result = 0, const QString &provider = QString());
|
2005-03-05 01:10:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
2005-03-28 07:11:58 +00:00
|
|
|
QSharedDataPointer<Private> d;
|
|
|
|
};
|
|
|
|
|
|
|
|
// PGPKey can either reference an item in a real PGP keyring or can
|
|
|
|
// be made by calling a "from" function. Note that with the latter
|
|
|
|
// method, the key is of no use besides being informational. The
|
|
|
|
// key must be in a keyring (inKeyring() == true) to actually do
|
|
|
|
// crypto with it.
|
|
|
|
class QCA_EXPORT PGPKey : public Algorithm
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PGPKey();
|
|
|
|
PGPKey(const QString &fileName);
|
|
|
|
PGPKey(const PGPKey &from);
|
|
|
|
~PGPKey();
|
|
|
|
PGPKey & operator=(const PGPKey &from);
|
|
|
|
|
|
|
|
bool isNull() const;
|
|
|
|
|
|
|
|
QString keyId() const;
|
|
|
|
QString primaryUserId() const;
|
|
|
|
QStringList userIds() const;
|
|
|
|
|
2005-05-13 04:31:13 +00:00
|
|
|
bool isSecret() const;
|
2005-03-28 07:11:58 +00:00
|
|
|
QDateTime creationDate() const;
|
|
|
|
QDateTime expirationDate() const;
|
|
|
|
QString fingerprint() const;
|
|
|
|
|
|
|
|
bool inKeyring() const;
|
|
|
|
bool isTrusted() const;
|
|
|
|
|
|
|
|
// import / export
|
|
|
|
QSecureArray toArray() const;
|
|
|
|
QString toString() const;
|
|
|
|
bool toFile(const QString &fileName) const;
|
|
|
|
static PGPKey fromArray(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static PGPKey fromString(const QString &s, ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static PGPKey fromFile(const QString &fileName, ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-14 06:36:12 +00:00
|
|
|
};
|
2005-01-01 02:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|