qca_publickey.h
Go to the documentation of this file.
/*
* qca_publickey.h - Qt Cryptographic Architecture
* Copyright (C) 2003-2007 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef QCA_PUBLICKEY_H
#define QCA_PUBLICKEY_H
#include "qca_core.h"
#include <QObject>
namespace QCA {
class PublicKey;
class PrivateKey;
class KeyGenerator;
class RSAPublicKey;
class RSAPrivateKey;
class DSAPublicKey;
class DSAPrivateKey;
class DHPublicKey;
class DHPrivateKey;
enum EncryptionAlgorithm
{
EME_PKCS1v15,
EME_PKCS1_OAEP,
EME_PKCS1v15_SSL,
EME_NO_PADDING
};
enum SignatureAlgorithm
{
SignatureUnknown,
EMSA1_SHA1,
EMSA3_SHA1,
EMSA3_MD5,
EMSA3_MD2,
EMSA3_RIPEMD160,
EMSA3_Raw,
EMSA3_SHA224,
EMSA3_SHA256,
EMSA3_SHA384,
EMSA3_SHA512
};
enum SignatureFormat
{
DefaultFormat,
IEEE_1363,
DERSequence
};
enum PBEAlgorithm
{
PBEDefault,
PBES2_DES_SHA1,
PBES2_TripleDES_SHA1,
PBES2_AES128_SHA1,
PBES2_AES192_SHA1,
PBES2_AES256_SHA1
};
enum ConvertResult
{
ConvertGood,
ErrorDecode,
ErrorPassphrase,
ErrorFile
};
enum DLGroupSet
{
DSA_512,
DSA_768,
DSA_1024,
IETF_768,
IETF_1024,
IETF_1536,
IETF_2048,
IETF_3072,
IETF_4096,
IETF_6144,
IETF_8192
};
QCA_EXPORT QByteArray emsa3Encode(const QString &hashName, const QByteArray &digest, int size = -1);
class QCA_EXPORT DLGroup
{
public:
DLGroup();
DLGroup(const BigInteger &p, const BigInteger &q, const BigInteger &g);
DLGroup(const BigInteger &p, const BigInteger &g);
DLGroup(const DLGroup &from);
~DLGroup();
DLGroup &operator=(const DLGroup &from);
static QList<DLGroupSet> supportedGroupSets(const QString &provider = QString());
bool isNull() const;
BigInteger p() const;
BigInteger q() const;
BigInteger g() const;
private:
class Private;
Private *d;
};
class QCA_EXPORT PKey : public Algorithm
{
public:
enum Type
{
RSA,
DSA,
DH
};
PKey();
PKey(const PKey &from);
~PKey() override;
PKey &operator=(const PKey &from);
static QList<Type> supportedTypes(const QString &provider = QString());
static QList<Type> supportedIOTypes(const QString &provider = QString());
bool isNull() const;
Type type() const;
int bitSize() const;
bool isRSA() const;
bool isDSA() const;
bool isDH() const;
bool isPublic() const;
bool isPrivate() const;
bool canExport() const;
bool canKeyAgree() const;
PublicKey toPublicKey() const;
PrivateKey toPrivateKey() const;
bool operator==(const PKey &a) const;
bool operator!=(const PKey &a) const;
protected:
PKey(const QString &type, const QString &provider);
void set(const PKey &k);
RSAPublicKey toRSAPublicKey() const;
RSAPrivateKey toRSAPrivateKey() const;
DSAPublicKey toDSAPublicKey() const;
DSAPrivateKey toDSAPrivateKey() const;
DHPublicKey toDHPublicKey() const;
DHPrivateKey toDHPrivateKey() const;
private:
void assignToPublic(PKey *dest) const;
void assignToPrivate(PKey *dest) const;
class Private;
Private *d;
};
class QCA_EXPORT PublicKey : public PKey
{
public:
PublicKey();
PublicKey(const PrivateKey &k);
PublicKey(const QString &fileName);
PublicKey(const PublicKey &from);
~PublicKey() override;
PublicKey &operator=(const PublicKey &from);
RSAPublicKey toRSA() const;
DSAPublicKey toDSA() const;
DHPublicKey toDH() const;
bool canEncrypt() const;
bool canDecrypt() const;
bool canVerify() const;
int maximumEncryptSize(EncryptionAlgorithm alg) const;
SecureArray encrypt(const SecureArray &a, EncryptionAlgorithm alg);
bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
void startVerify(SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
void update(const MemoryRegion &a);
bool validSignature(const QByteArray &sig);
bool verifyMessage(const MemoryRegion &a,
const QByteArray &sig,
SignatureAlgorithm alg,
SignatureFormat format = DefaultFormat);
QByteArray toDER() const;
QString toPEM() const;
bool toPEMFile(const QString &fileName) const;
static PublicKey fromDER(const QByteArray &a, ConvertResult *result = nullptr, const QString &provider = QString());
static PublicKey fromPEM(const QString &s, ConvertResult *result = nullptr, const QString &provider = QString());
static PublicKey
fromPEMFile(const QString &fileName, ConvertResult *result = nullptr, const QString &provider = QString());
protected:
PublicKey(const QString &type, const QString &provider);
private:
class Private;
Private *d;
};
class QCA_EXPORT PrivateKey : public PKey
{
public:
PrivateKey();
explicit PrivateKey(const QString &fileName, const SecureArray &passphrase = SecureArray());
PrivateKey(const PrivateKey &from);
~PrivateKey() override;
PrivateKey &operator=(const PrivateKey &from);
RSAPrivateKey toRSA() const;
DSAPrivateKey toDSA() const;
DHPrivateKey toDH() const;
bool canDecrypt() const;
bool canEncrypt() const;
bool canSign() const;
int maximumEncryptSize(EncryptionAlgorithm alg) const;
bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
SecureArray encrypt(const SecureArray &a, EncryptionAlgorithm alg);
void startSign(SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
void update(const MemoryRegion &a);
QByteArray signature();
QByteArray signMessage(const MemoryRegion &a, SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
SymmetricKey deriveKey(const PublicKey &theirs);
static QList<PBEAlgorithm> supportedPBEAlgorithms(const QString &provider = QString());
SecureArray toDER(const SecureArray &passphrase = SecureArray(), PBEAlgorithm pbe = PBEDefault) const;
QString toPEM(const SecureArray &passphrase = SecureArray(), PBEAlgorithm pbe = PBEDefault) const;
bool toPEMFile(const QString &fileName,
const SecureArray &passphrase = SecureArray(),
PBEAlgorithm pbe = PBEDefault) const;
static PrivateKey fromDER(const SecureArray &a,
const SecureArray &passphrase = SecureArray(),
ConvertResult *result = nullptr,
const QString &provider = QString());
static PrivateKey fromPEM(const QString &s,
const SecureArray &passphrase = SecureArray(),
ConvertResult *result = nullptr,
const QString &provider = QString());
static PrivateKey fromPEMFile(const QString &fileName,
const SecureArray &passphrase = SecureArray(),
ConvertResult *result = nullptr,
const QString &provider = QString());
protected:
PrivateKey(const QString &type, const QString &provider);
private:
class Private;
Private *d;
};
class QCA_EXPORT KeyGenerator : public QObject
{
Q_OBJECT
public:
KeyGenerator(QObject *parent = nullptr);
~KeyGenerator() override;
bool blockingEnabled() const;
void setBlockingEnabled(bool b);
bool isBusy() const;
PrivateKey createRSA(int bits, int exp = 65537, const QString &provider = QString());
PrivateKey createDSA(const DLGroup &domain, const QString &provider = QString());
PrivateKey createDH(const DLGroup &domain, const QString &provider = QString());
PrivateKey key() const;
DLGroup createDLGroup(QCA::DLGroupSet set, const QString &provider = QString());
DLGroup dlGroup() const;
Q_SIGNALS:
void finished();
private:
Q_DISABLE_COPY(KeyGenerator)
class Private;
friend class Private;
Private *d;
};
class QCA_EXPORT RSAPublicKey : public PublicKey
{
public:
RSAPublicKey();
RSAPublicKey(const BigInteger &n, const BigInteger &e, const QString &provider = QString());
RSAPublicKey(const RSAPrivateKey &k);
BigInteger n() const;
BigInteger e() const;
};
class QCA_EXPORT RSAPrivateKey : public PrivateKey
{
public:
RSAPrivateKey();
RSAPrivateKey(const BigInteger &n,
const BigInteger &e,
const BigInteger &p,
const BigInteger &q,
const BigInteger &d,
const QString &provider = QString());
BigInteger n() const;
BigInteger e() const;
BigInteger p() const;
BigInteger q() const;
BigInteger d() const;
};
class QCA_EXPORT DSAPublicKey : public PublicKey
{
public:
DSAPublicKey();
DSAPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider = QString());
DSAPublicKey(const DSAPrivateKey &k);
DLGroup domain() const;
BigInteger y() const;
};
class QCA_EXPORT DSAPrivateKey : public PrivateKey
{
public:
DSAPrivateKey();
DSAPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider = QString());
DLGroup domain() const;
BigInteger y() const;
BigInteger x() const;
};
class QCA_EXPORT DHPublicKey : public PublicKey
{
public:
DHPublicKey();
DHPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider = QString());
DHPublicKey(const DHPrivateKey &k);
DLGroup domain() const;
BigInteger y() const;
};
class QCA_EXPORT DHPrivateKey : public PrivateKey
{
public:
DHPrivateKey();
DHPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider = QString());
DLGroup domain() const;
BigInteger y() const;
BigInteger x() const;
};
}
#endif
QCA::Algorithm::provider
Provider * provider() const
The name of the provider.
QCA::Algorithm::Algorithm
Algorithm(const Algorithm &from)
Standard copy constructor.
QCA::BigInteger
Arbitrary precision integer.
Definition qca_tools.h:571
QCA::DHPrivateKey
Diffie-Hellman Private Key.
Definition qca_publickey.h:1526
QCA::DHPrivateKey::y
BigInteger y() const
The public random value associated with this key.
QCA::DHPrivateKey::DHPrivateKey
DHPrivateKey()
Create an empty Diffie-Hellman private key.
QCA::DHPrivateKey::domain
DLGroup domain() const
The discrete logarithm group that is being used.
QCA::DHPrivateKey::x
BigInteger x() const
The private random value associated with this key.
QCA::DHPrivateKey::DHPrivateKey
DHPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider=QString())
Create a Diffie-Hellman private key.
QCA::DHPublicKey
Diffie-Hellman Public Key.
Definition qca_publickey.h:1482
QCA::DHPublicKey::domain
DLGroup domain() const
The discrete logarithm group that is being used.
QCA::DHPublicKey::DHPublicKey
DHPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider=QString())
Create a Diffie-Hellman public key.
QCA::DHPublicKey::y
BigInteger y() const
The public random value associated with this key.
QCA::DHPublicKey::DHPublicKey
DHPublicKey(const DHPrivateKey &k)
Create a Diffie-Hellman public key from a specified private key.
QCA::DHPublicKey::DHPublicKey
DHPublicKey()
Create an empty Diffie-Hellman public key.
QCA::DLGroup
A discrete logarithm group.
Definition qca_publickey.h:172
QCA::DLGroup::DLGroup
DLGroup(const DLGroup &from)
Standard copy constructor.
QCA::DLGroup::p
BigInteger p() const
Provide the p component of the group.
QCA::DLGroup::operator=
DLGroup & operator=(const DLGroup &from)
Standard assignment operator.
QCA::DLGroup::supportedGroupSets
static QList< DLGroupSet > supportedGroupSets(const QString &provider=QString())
Provide a list of the supported group sets.
QCA::DLGroup::isNull
bool isNull() const
Test if the group is empty.
QCA::DLGroup::DLGroup
DLGroup(const BigInteger &p, const BigInteger &g)
Construct a discrete logarithm group from raw parameters.
QCA::DLGroup::DLGroup
DLGroup(const BigInteger &p, const BigInteger &q, const BigInteger &g)
Construct a discrete logarithm group from raw parameters.
QCA::DLGroup::g
BigInteger g() const
Provide the g component of the group.
QCA::DLGroup::q
BigInteger q() const
Provide the q component of the group.
QCA::DSAPrivateKey
Digital Signature Algorithm Private Key.
Definition qca_publickey.h:1439
QCA::DSAPrivateKey::domain
DLGroup domain() const
The discrete logarithm group that is being used.
QCA::DSAPrivateKey::y
BigInteger y() const
the public random value
QCA::DSAPrivateKey::DSAPrivateKey
DSAPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider=QString())
Create a DSA public key.
QCA::DSAPrivateKey::DSAPrivateKey
DSAPrivateKey()
Create an empty DSA private key.
QCA::DSAPrivateKey::x
BigInteger x() const
the private random value
QCA::DSAPublicKey
Digital Signature Algorithm Public Key.
Definition qca_publickey.h:1395
QCA::DSAPublicKey::DSAPublicKey
DSAPublicKey()
Create an empty DSA public key.
QCA::DSAPublicKey::DSAPublicKey
DSAPublicKey(const DSAPrivateKey &k)
Create a DSA public key from a specified private key.
QCA::DSAPublicKey::y
BigInteger y() const
The public random value associated with this key.
QCA::DSAPublicKey::domain
DLGroup domain() const
The discrete logarithm group that is being used.
QCA::DSAPublicKey::DSAPublicKey
DSAPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider=QString())
Create a DSA public key.
QCA::KeyGenerator
Class for generating asymmetric key pairs.
Definition qca_publickey.h:1138
QCA::KeyGenerator::createDH
PrivateKey createDH(const DLGroup &domain, const QString &provider=QString())
Generate a Diffie-Hellman key.
QCA::KeyGenerator::key
PrivateKey key() const
Return the last generated key.
QCA::KeyGenerator::dlGroup
DLGroup dlGroup() const
The current discrete logarithm group.
QCA::KeyGenerator::blockingEnabled
bool blockingEnabled() const
Test whether the key generator is set to operate in blocking mode, or not.
QCA::KeyGenerator::finished
void finished()
Emitted when the key generation is complete.
QCA::KeyGenerator::createDSA
PrivateKey createDSA(const DLGroup &domain, const QString &provider=QString())
Generate a DSA key.
QCA::KeyGenerator::createRSA
PrivateKey createRSA(int bits, int exp=65537, const QString &provider=QString())
Generate an RSA key of the specified length.
QCA::KeyGenerator::createDLGroup
DLGroup createDLGroup(QCA::DLGroupSet set, const QString &provider=QString())
Create a new discrete logarithm group.
QCA::KeyGenerator::isBusy
bool isBusy() const
Test if the key generator is currently busy, or not.
QCA::KeyGenerator::KeyGenerator
KeyGenerator(QObject *parent=nullptr)
Create a new key generator.
QCA::KeyGenerator::setBlockingEnabled
void setBlockingEnabled(bool b)
Set whether the key generator is in blocking mode, nor not.
QCA::MemoryRegion
Array of bytes that may be optionally secured.
Definition qca_tools.h:91
QCA::PKey::set
void set(const PKey &k)
Set the key.
QCA::PKey::operator==
bool operator==(const PKey &a) const
test if two keys are equal
QCA::PKey::PKey
PKey(const PKey &from)
Standard copy constructor.
QCA::PKey::bitSize
int bitSize() const
Report the number of bits in the key.
QCA::PKey::supportedIOTypes
static QList< Type > supportedIOTypes(const QString &provider=QString())
Test what types of keys are supported for IO operations.
QCA::PKey::type
Type type() const
Report the Type of key (eg RSA, DSA or Diffie Hellman).
QCA::PKey::toDSAPublicKey
DSAPublicKey toDSAPublicKey() const
Interpret this key as an DSAPublicKey.
QCA::PKey::toRSAPrivateKey
RSAPrivateKey toRSAPrivateKey() const
Interpret this key as an RSAPrivateKey.
QCA::PKey::isDSA
bool isDSA() const
Test if the key is a DSA key.
QCA::PKey::toDHPrivateKey
DHPrivateKey toDHPrivateKey() const
Interpret this key as a DHPrivateKey.
QCA::PKey::toDHPublicKey
DHPublicKey toDHPublicKey() const
Interpret this key as an DHPublicKey.
QCA::PKey::isPublic
bool isPublic() const
Test if the key is a public key.
QCA::PKey::isPrivate
bool isPrivate() const
Test if the key is a private key.
QCA::PKey::PKey
PKey()
Standard constructor.
QCA::PKey::toPrivateKey
PrivateKey toPrivateKey() const
Interpret this key as a PrivateKey.
QCA::PKey::isDH
bool isDH() const
Test if the key is a Diffie Hellman key.
QCA::PKey::toPublicKey
PublicKey toPublicKey() const
Interpret this key as a PublicKey.
QCA::PKey::supportedTypes
static QList< Type > supportedTypes(const QString &provider=QString())
Test what types of keys are supported.
QCA::PKey::operator!=
bool operator!=(const PKey &a) const
test if two keys are not equal
QCA::PKey::isNull
bool isNull() const
Test if the key is null (empty).
QCA::PKey::toRSAPublicKey
RSAPublicKey toRSAPublicKey() const
Interpret this key as an RSAPublicKey.
QCA::PKey::canKeyAgree
bool canKeyAgree() const
Test if the key can be used for key agreement.
QCA::PKey::operator=
PKey & operator=(const PKey &from)
Standard assignment operator.
QCA::PKey::PKey
PKey(const QString &type, const QString &provider)
Create a key of the specified type.
QCA::PKey::toDSAPrivateKey
DSAPrivateKey toDSAPrivateKey() const
Interpret this key as a DSAPrivateKey.
QCA::PKey::isRSA
bool isRSA() const
Test if the key is an RSA key.
QCA::PKey::Type
Type
Types of public key cryptography keys supported by QCA.
Definition qca_publickey.h:257
QCA::PKey::DH
@ DH
Diffie Hellman key.
Definition qca_publickey.h:260
QCA::PKey::RSA
@ RSA
RSA key.
Definition qca_publickey.h:258
QCA::PKey::DSA
@ DSA
DSA key.
Definition qca_publickey.h:259
QCA::PKey::canExport
bool canExport() const
Test if the key data can be exported.
QCA::PrivateKey
Generic private key.
Definition qca_publickey.h:833
QCA::PrivateKey::fromPEM
static PrivateKey fromPEM(const QString &s, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
Import the key from Privacy Enhanced Mail (PEM) format.
QCA::PrivateKey::PrivateKey
PrivateKey(const QString &fileName, const SecureArray &passphrase=SecureArray())
Import a private key from a PEM representation in a file.
QCA::PrivateKey::update
void update(const MemoryRegion &a)
Update the signature process.
QCA::PrivateKey::toPEMFile
bool toPEMFile(const QString &fileName, const SecureArray &passphrase=SecureArray(), PBEAlgorithm pbe=PBEDefault) const
Export the key in Privacy Enhanced Mail (PEM) format to a file.
QCA::PrivateKey::supportedPBEAlgorithms
static QList< PBEAlgorithm > supportedPBEAlgorithms(const QString &provider=QString())
List the supported Password Based Encryption Algorithms that can be used to protect the key.
QCA::PrivateKey::decrypt
bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg)
Decrypt the message.
QCA::PrivateKey::encrypt
SecureArray encrypt(const SecureArray &a, EncryptionAlgorithm alg)
Encrypt a message using a specified algorithm.
QCA::PrivateKey::signature
QByteArray signature()
The resulting signature.
QCA::PrivateKey::toRSA
RSAPrivateKey toRSA() const
Interpret / convert the key to an RSA key.
QCA::PrivateKey::operator=
PrivateKey & operator=(const PrivateKey &from)
Assignment operator.
QCA::PrivateKey::canDecrypt
bool canDecrypt() const
Test if this key can be used for decryption.
QCA::PrivateKey::toDSA
DSAPrivateKey toDSA() const
Interpret / convert the key to a DSA key.
QCA::PrivateKey::PrivateKey
PrivateKey(const PrivateKey &from)
Copy constructor.
QCA::PrivateKey::signMessage
QByteArray signMessage(const MemoryRegion &a, SignatureAlgorithm alg, SignatureFormat format=DefaultFormat)
One step signature process.
QCA::PrivateKey::PrivateKey
PrivateKey(const QString &type, const QString &provider)
Create a new private key.
QCA::PrivateKey::maximumEncryptSize
int maximumEncryptSize(EncryptionAlgorithm alg) const
The maximum message size that can be encrypted with a specified algorithm.
QCA::PrivateKey::fromPEMFile
static PrivateKey fromPEMFile(const QString &fileName, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
Import the key in Privacy Enhanced Mail (PEM) format from a file.
QCA::PrivateKey::toDER
SecureArray toDER(const SecureArray &passphrase=SecureArray(), PBEAlgorithm pbe=PBEDefault) const
Export the key in Distinguished Encoding Rules (DER) format.
QCA::PrivateKey::startSign
void startSign(SignatureAlgorithm alg, SignatureFormat format=DefaultFormat)
Initialise the message signature process.
QCA::PrivateKey::toDH
DHPrivateKey toDH() const
Interpret / convert the key to a Diffie-Hellman key.
QCA::PrivateKey::PrivateKey
PrivateKey()
Create an empty private key.
QCA::PrivateKey::canEncrypt
bool canEncrypt() const
Test if this key can be used for encryption.
QCA::PrivateKey::deriveKey
SymmetricKey deriveKey(const PublicKey &theirs)
Derive a shared secret key from a public key.
QCA::PrivateKey::fromDER
static PrivateKey fromDER(const SecureArray &a, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
Import the key from Distinguished Encoding Rules (DER) format.
QCA::PrivateKey::toPEM
QString toPEM(const SecureArray &passphrase=SecureArray(), PBEAlgorithm pbe=PBEDefault) const
Export the key in Privacy Enhanced Mail (PEM) format.
QCA::PrivateKey::canSign
bool canSign() const
Test if this key can be used for signing.
QCA::PublicKey
Generic public key.
Definition qca_publickey.h:529
QCA::PublicKey::PublicKey
PublicKey(const PublicKey &from)
Copy constructor.
QCA::PublicKey::update
void update(const MemoryRegion &a)
Update the signature verification process with more data.
QCA::PublicKey::toDSA
DSAPublicKey toDSA() const
Convenience method to convert this key to a DSAPublicKey.
QCA::PublicKey::toRSA
RSAPublicKey toRSA() const
Convenience method to convert this key to an RSAPublicKey.
QCA::PublicKey::verifyMessage
bool verifyMessage(const MemoryRegion &a, const QByteArray &sig, SignatureAlgorithm alg, SignatureFormat format=DefaultFormat)
Single step message verification.
QCA::PublicKey::PublicKey
PublicKey(const QString &type, const QString &provider)
Create a new key of a specified type.
QCA::PublicKey::toDER
QByteArray toDER() const
Export the key in Distinguished Encoding Rules (DER) format.
QCA::PublicKey::canEncrypt
bool canEncrypt() const
Test if this key can be used for encryption.
QCA::PublicKey::validSignature
bool validSignature(const QByteArray &sig)
Check the signature is valid for the message.
QCA::PublicKey::toDH
DHPublicKey toDH() const
Convenience method to convert this key to a DHPublicKey.
QCA::PublicKey::fromPEM
static PublicKey fromPEM(const QString &s, ConvertResult *result=nullptr, const QString &provider=QString())
Import a key in Privacy Enhanced Mail (PEM) format.
QCA::PublicKey::fromPEMFile
static PublicKey fromPEMFile(const QString &fileName, ConvertResult *result=nullptr, const QString &provider=QString())
Import a key in Privacy Enhanced Mail (PEM) format from a file.
QCA::PublicKey::decrypt
bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg)
Decrypt the message.
QCA::PublicKey::toPEMFile
bool toPEMFile(const QString &fileName) const
Export the key in Privacy Enhanced Mail (PEM) to a file.
QCA::PublicKey::startVerify
void startVerify(SignatureAlgorithm alg, SignatureFormat format=DefaultFormat)
Initialise the signature verification process.
QCA::PublicKey::fromDER
static PublicKey fromDER(const QByteArray &a, ConvertResult *result=nullptr, const QString &provider=QString())
Import a key in Distinguished Encoding Rules (DER) format.
QCA::PublicKey::PublicKey
PublicKey(const PrivateKey &k)
Create a public key based on a specified private key.
QCA::PublicKey::canVerify
bool canVerify() const
Test if the key can be used for verifying signatures.
QCA::PublicKey::maximumEncryptSize
int maximumEncryptSize(EncryptionAlgorithm alg) const
The maximum message size that can be encrypted with a specified algorithm.
QCA::PublicKey::operator=
PublicKey & operator=(const PublicKey &from)
Assignment operator.
QCA::PublicKey::PublicKey
PublicKey(const QString &fileName)
Import a public key from a PEM representation in a file.
QCA::PublicKey::canDecrypt
bool canDecrypt() const
Test if this key can be used for decryption.
QCA::PublicKey::PublicKey
PublicKey()
Create an empty (null) public key.
QCA::PublicKey::encrypt
SecureArray encrypt(const SecureArray &a, EncryptionAlgorithm alg)
Encrypt a message using a specified algorithm.
QCA::PublicKey::toPEM
QString toPEM() const
Export the key in Privacy Enhanced Mail (PEM) format.
QCA::RSAPrivateKey
RSA Private Key.
Definition qca_publickey.h:1327
QCA::RSAPrivateKey::RSAPrivateKey
RSAPrivateKey()
Generate an empty RSA private key.
QCA::RSAPrivateKey::q
BigInteger q() const
The second of the two random primes used to generate the private key.
QCA::RSAPrivateKey::d
BigInteger d() const
The inverse of the exponent, module (p-1)(q-1).
QCA::RSAPrivateKey::n
BigInteger n() const
The public key value.
QCA::RSAPrivateKey::e
BigInteger e() const
The public key exponent.
QCA::RSAPrivateKey::p
BigInteger p() const
One of the two random primes used to generate the private key.
QCA::RSAPrivateKey::RSAPrivateKey
RSAPrivateKey(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d, const QString &provider=QString())
Generate an RSA private key from specified parameters.
QCA::RSAPublicKey
RSA Public Key.
Definition qca_publickey.h:1276
QCA::RSAPublicKey::RSAPublicKey
RSAPublicKey()
Generate an empty RSA public key.
QCA::RSAPublicKey::RSAPublicKey
RSAPublicKey(const BigInteger &n, const BigInteger &e, const QString &provider=QString())
Generate an RSA public key from specified parameters.
QCA::RSAPublicKey::RSAPublicKey
RSAPublicKey(const RSAPrivateKey &k)
Extract the public key components from an RSA private key.
QCA::RSAPublicKey::n
BigInteger n() const
The public key value.
QCA::RSAPublicKey::e
BigInteger e() const
The public key exponent.
QCA::SecureArray
Secure array of bytes.
Definition qca_tools.h:317
QCA::SymmetricKey
Container for keys for symmetric encryption algorithms.
Definition qca_core.h:1264
QList
QObject
QCA
QCA - the Qt Cryptographic Architecture.
Definition qca_basic.h:41
QCA::DLGroupSet
DLGroupSet
Well known discrete logarithm group sets.
Definition qca_publickey.h:135
QCA::DSA_512
@ DSA_512
512 bit group, for compatibility with JCE
Definition qca_publickey.h:136
QCA::DSA_768
@ DSA_768
768 bit group, for compatibility with JCE
Definition qca_publickey.h:137
QCA::IETF_1536
@ IETF_1536
1536-bit MODP Group ("group 5") from RFC3526 Section 2.
Definition qca_publickey.h:141
QCA::IETF_3072
@ IETF_3072
3072-bit MODP Group ("group 15") from RFC3526 Section 4.
Definition qca_publickey.h:143
QCA::IETF_1024
@ IETF_1024
Group 2 from RFC 2412, Section E.2.
Definition qca_publickey.h:140
QCA::DSA_1024
@ DSA_1024
1024 bit group, for compatibility with JCE
Definition qca_publickey.h:138
QCA::IETF_8192
@ IETF_8192
8192-bit MODP Group ("group 18") from RFC3526 Section 7.
Definition qca_publickey.h:146
QCA::IETF_6144
@ IETF_6144
6144-bit MODP Group ("group 17") from RFC3526 Section 6.
Definition qca_publickey.h:145
QCA::IETF_768
@ IETF_768
Group 1 from RFC 2412, Section E.1.
Definition qca_publickey.h:139
QCA::IETF_4096
@ IETF_4096
4096-bit MODP Group ("group 16") from RFC3526 Section 5.
Definition qca_publickey.h:144
QCA::IETF_2048
@ IETF_2048
2048-bit MODP Group ("group 14") from RFC3526 Section 3.
Definition qca_publickey.h:142
QCA::EncryptionAlgorithm
EncryptionAlgorithm
Encryption algorithms.
Definition qca_publickey.h:55
QCA::EME_PKCS1v15
@ EME_PKCS1v15
Block type 2 (PKCS#1, Version 1.5).
Definition qca_publickey.h:56
QCA::EME_PKCS1v15_SSL
@ EME_PKCS1v15_SSL
PKCS#1, Version 1.5 with an SSL-specific modification.
Definition qca_publickey.h:58
QCA::EME_NO_PADDING
@ EME_NO_PADDING
Raw RSA encryption.
Definition qca_publickey.h:59
QCA::EME_PKCS1_OAEP
@ EME_PKCS1_OAEP
Optimal asymmetric encryption padding (PKCS#1, Version 2.0).
Definition qca_publickey.h:57
QCA::PBEAlgorithm
PBEAlgorithm
Password-based encryption.
Definition qca_publickey.h:103
QCA::PBES2_AES192_SHA1
@ PBES2_AES192_SHA1
PKCS#5 v2.0 AES-192/CBC,SHA1.
Definition qca_publickey.h:108
QCA::PBES2_DES_SHA1
@ PBES2_DES_SHA1
PKCS#5 v2.0 DES/CBC,SHA1.
Definition qca_publickey.h:105
QCA::PBEDefault
@ PBEDefault
Use modern default (same as PBES2_TripleDES_SHA1).
Definition qca_publickey.h:104
QCA::PBES2_TripleDES_SHA1
@ PBES2_TripleDES_SHA1
PKCS#5 v2.0 TripleDES/CBC,SHA1.
Definition qca_publickey.h:106
QCA::PBES2_AES128_SHA1
@ PBES2_AES128_SHA1
PKCS#5 v2.0 AES-128/CBC,SHA1.
Definition qca_publickey.h:107
QCA::PBES2_AES256_SHA1
@ PBES2_AES256_SHA1
PKCS#5 v2.0 AES-256/CBC,SHA1.
Definition qca_publickey.h:109
QCA::ConvertResult
ConvertResult
Return value from a format conversion.
Definition qca_publickey.h:119
QCA::ErrorFile
@ ErrorFile
Failure because of incorrect file.
Definition qca_publickey.h:123
QCA::ErrorPassphrase
@ ErrorPassphrase
Failure because of incorrect passphrase.
Definition qca_publickey.h:122
QCA::ConvertGood
@ ConvertGood
Conversion succeeded, results should be valid.
Definition qca_publickey.h:120
QCA::ErrorDecode
@ ErrorDecode
General failure in the decode stage.
Definition qca_publickey.h:121
QCA::emsa3Encode
QCA_EXPORT QByteArray emsa3Encode(const QString &hashName, const QByteArray &digest, int size=-1)
Encode a hash result in EMSA3 (PKCS#1) format.
QCA::SignatureAlgorithm
SignatureAlgorithm
Signature algorithm variants.
Definition qca_publickey.h:74
QCA::EMSA3_RIPEMD160
@ EMSA3_RIPEMD160
RIPEMD160, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:80
QCA::EMSA3_Raw
@ EMSA3_Raw
EMSA3 without computing a message digest or a DigestInfo encoding (identical to PKCS#11's CKM_RSA_PKC...
Definition qca_publickey.h:81
QCA::EMSA3_SHA1
@ EMSA3_SHA1
SHA1, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:77
QCA::EMSA1_SHA1
@ EMSA1_SHA1
SHA1, with EMSA1 (IEEE1363-2000) encoding (this is the usual DSA algorithm - FIPS186).
Definition qca_publickey.h:76
QCA::EMSA3_SHA512
@ EMSA3_SHA512
SHA512, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:86
QCA::EMSA3_SHA256
@ EMSA3_SHA256
SHA256, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:84
QCA::EMSA3_SHA224
@ EMSA3_SHA224
SHA224, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:83
QCA::EMSA3_SHA384
@ EMSA3_SHA384
SHA384, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:85
QCA::EMSA3_MD2
@ EMSA3_MD2
MD2, with EMSA3 (ie PKCS#1 Version 1.5) encoding.
Definition qca_publickey.h:79
QCA::EMSA3_MD5
@ EMSA3_MD5
MD5, with EMSA3 (ie PKCS#1 Version 1.5) encoding (this is the usual RSA algorithm).
Definition qca_publickey.h:78
QCA::SignatureUnknown
@ SignatureUnknown
Unknown signing algorithm.
Definition qca_publickey.h:75
QCA::SignatureFormat
SignatureFormat
Signature formats (DSA only).
Definition qca_publickey.h:93
QCA::DERSequence
@ DERSequence
Signature wrapped in DER formatting (OpenSSL/Java).
Definition qca_publickey.h:96
QCA::DefaultFormat
@ DefaultFormat
For DSA, this is the same as IEEE_1363.
Definition qca_publickey.h:94
QCA::IEEE_1363
@ IEEE_1363
40-byte format from IEEE 1363 (Botan/.NET)
Definition qca_publickey.h:95
qca_core.h
Header file for core QCA infrastructure.