2005-01-01 02:44:28 +00:00
|
|
|
/*
|
|
|
|
* qca_publickey.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_PUBLICKEY_H
|
|
|
|
#define QCA_PUBLICKEY_H
|
|
|
|
|
2005-02-27 01:12:26 +00:00
|
|
|
#include <QObject>
|
2005-01-01 02:44:28 +00:00
|
|
|
#include "qca_core.h"
|
|
|
|
|
|
|
|
namespace QCA
|
|
|
|
{
|
|
|
|
class PublicKey;
|
|
|
|
class PrivateKey;
|
|
|
|
class KeyGenerator;
|
|
|
|
class RSAPublicKey;
|
|
|
|
class RSAPrivateKey;
|
|
|
|
class DSAPublicKey;
|
|
|
|
class DSAPrivateKey;
|
|
|
|
class DHPublicKey;
|
|
|
|
class DHPrivateKey;
|
|
|
|
|
2005-01-25 13:01:45 +00:00
|
|
|
/**
|
|
|
|
Encryption algorithms
|
|
|
|
*/
|
2005-02-24 21:14:03 +00:00
|
|
|
enum EncryptionAlgorithm
|
2005-01-25 13:01:45 +00:00
|
|
|
{
|
2005-04-10 03:06:51 +00:00
|
|
|
EME_PKCS1v15, ///< Block type 2 (PKCS1, Version 1.5)
|
2005-01-25 13:01:45 +00:00
|
|
|
EME_PKCS1_OAEP ///< Optimal asymmetric encryption padding (PKCS1, Version 2.0)
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Signature algorithm variants
|
|
|
|
*/
|
2005-02-24 21:14:03 +00:00
|
|
|
enum SignatureAlgorithm
|
2005-01-25 13:01:45 +00:00
|
|
|
{
|
2005-02-24 21:14:03 +00:00
|
|
|
SignatureUnknown, ///< Unknown signing algorithm
|
2005-01-25 13:01:45 +00:00
|
|
|
EMSA1_SHA1, ///< SHA1, with EMSA1 (IEEE1363-2000) encoding (this is the usual DSA algorithm - FIPS186)
|
|
|
|
EMSA3_SHA1, ///< SHA1, with EMSA3 (ie PKCS1 Version 1.5) encoding
|
|
|
|
EMSA3_MD5, ///< MD5, with EMSA3 (ie PKCS1 Version 1.5) encoding (this is the usual RSA algorithm)
|
|
|
|
EMSA3_MD2, ///< MD2, with EMSA3 (ie PKCS1 Version 1.5) encoding
|
|
|
|
EMSA3_RIPEMD160 ///< RIPEMD160, with EMSA3 (ie PKCS1 Version 1.5) encoding
|
|
|
|
};
|
|
|
|
|
2005-03-05 20:50:49 +00:00
|
|
|
/**
|
|
|
|
Signature formats (DSA only)
|
|
|
|
*/
|
|
|
|
enum SignatureFormat
|
|
|
|
{
|
|
|
|
DefaultFormat, ///< For DSA, this is the same as IEEE_1363
|
|
|
|
IEEE_1363, ///< 40-byte format from IEEE 1363 (Botan/.NET)
|
|
|
|
DERSequence ///< Signature wrapped in DER formatting (OpenSSL/Java)
|
|
|
|
};
|
|
|
|
|
2005-01-25 13:01:45 +00:00
|
|
|
/**
|
|
|
|
Password-based encryption
|
|
|
|
*/
|
2005-02-24 21:14:03 +00:00
|
|
|
enum PBEAlgorithm
|
2005-01-25 13:01:45 +00:00
|
|
|
{
|
2005-01-27 16:42:44 +00:00
|
|
|
PBEDefault, ///< Use modern default (same as PBES2_TripleDES_SHA1)
|
|
|
|
PBES2_DES_SHA1, ///< PKCS#5 v2.0 DES/CBC,SHA1
|
|
|
|
PBES2_TripleDES_SHA1, ///< PKCS#5 v2.0 TripleDES/CBC,SHA1
|
|
|
|
PBES2_AES128_SHA1, ///< PKCS#5 v2.0 AES-128/CBC,SHA1
|
|
|
|
PBES2_AES192_SHA1, ///< PKCS#5 v2.0 AES-192/CBC,SHA1
|
|
|
|
PBES2_AES256_SHA1 ///< PKCS#5 v2.0 AES-256/CBC,SHA1
|
2005-01-25 13:01:45 +00:00
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Return value from a format conversion
|
|
|
|
|
|
|
|
Note that if you are checking for any result other than ConvertGood,
|
|
|
|
then you may be introducing a provider specific dependency.
|
|
|
|
*/
|
2005-02-25 04:23:12 +00:00
|
|
|
enum ConvertResult
|
|
|
|
{
|
2005-04-10 03:06:51 +00:00
|
|
|
ConvertGood, ///< Conversion succeeded, results should be valid
|
|
|
|
ErrorDecode, ///< General failure in the decode stage
|
|
|
|
ErrorPassphrase, ///< Failure because of incorrect pass phrase
|
|
|
|
ErrorFile ///< Failure because of incorrect file
|
2005-02-25 04:23:12 +00:00
|
|
|
};
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Well known discrete logarithm group sets
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
enum DLGroupSet
|
|
|
|
{
|
|
|
|
DSA_512,
|
|
|
|
DSA_768,
|
|
|
|
DSA_1024,
|
|
|
|
IETF_768,
|
|
|
|
IETF_1024,
|
|
|
|
IETF_1536,
|
|
|
|
IETF_2048,
|
|
|
|
IETF_3072,
|
|
|
|
IETF_4096
|
|
|
|
};
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
A discrete logarithm group
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
class DLGroup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DLGroup();
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Construct a discrete logarithm group from raw parameters
|
|
|
|
|
|
|
|
\param p
|
|
|
|
\param q
|
|
|
|
\param g
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup(const QBigInteger &p, const QBigInteger &q, const QBigInteger &g);
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Construct a discrete logarithm group from raw parameters
|
|
|
|
|
|
|
|
\param p
|
|
|
|
\param g
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup(const QBigInteger &p, const QBigInteger &g);
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Standard copy constructor
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup(const DLGroup &from);
|
|
|
|
~DLGroup();
|
|
|
|
DLGroup & operator=(const DLGroup &from);
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Provide a list of the supported group sets
|
|
|
|
|
|
|
|
\param provider the provider to report which group sets are available. If not
|
|
|
|
specified, all providers will be checked
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
static QList<DLGroupSet> supportedGroupSets(const QString &provider = QString());
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Test if the group is empty
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
bool isNull() const;
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Provide the p component of the group
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
QBigInteger p() const;
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Provide the q component of the group
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
QBigInteger q() const;
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Provide the g component of the group
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
QBigInteger g() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private *d;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
General superclass for public (PublicKey) and private (PrivateKey) keys
|
|
|
|
used with asymmetric encryption techniques.
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT PKey : public Algorithm
|
|
|
|
{
|
|
|
|
public:
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Types of public key cryptography keys supported by QCA
|
|
|
|
*/
|
|
|
|
enum Type {
|
|
|
|
RSA, ///< RSA key
|
|
|
|
DSA, ///< DSA key
|
|
|
|
DH ///< Diffie Hellman key
|
|
|
|
};
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
PKey();
|
|
|
|
PKey(const PKey &from);
|
|
|
|
~PKey();
|
|
|
|
|
|
|
|
PKey & operator=(const PKey &from);
|
|
|
|
|
2005-02-27 01:12:26 +00:00
|
|
|
static QList<Type> supportedTypes(const QString &provider = QString());
|
2005-03-08 03:17:37 +00:00
|
|
|
static QList<Type> supportedIOTypes(const QString &provider = QString());
|
2005-02-24 21:14:03 +00:00
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Test if the key is null (empty)
|
|
|
|
|
|
|
|
\return true if the key is null
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isNull() const;
|
2005-04-10 03:06:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Report the Type of key (eg RSA, DSA or Diffie Hellman)
|
|
|
|
|
|
|
|
\sa isRSA, isDSA and isDH for boolean tests.
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
Type type() const;
|
2005-04-10 03:06:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Report the number of bits in the key
|
|
|
|
*/
|
2005-04-04 00:34:13 +00:00
|
|
|
int bitSize() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Test if the key is an RSA key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isRSA() const;
|
2005-04-10 03:06:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test if the key is a DSA key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isDSA() const;
|
2005-04-10 03:06:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test if the key is a Diffie Hellman key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isDH() const;
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Test if the key is a public key
|
|
|
|
*/
|
|
|
|
bool isPublic() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Test if the key is a private key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool isPrivate() const;
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Test if the key can be used for key agreement
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool canKeyAgree() const;
|
|
|
|
|
|
|
|
PublicKey toPublicKey() const;
|
|
|
|
PrivateKey toPrivateKey() const;
|
|
|
|
|
2005-03-05 04:04:38 +00:00
|
|
|
bool operator==(const PKey &a) const;
|
|
|
|
bool operator!=(const PKey &a) const;
|
|
|
|
|
2005-01-01 02:44:28 +00:00
|
|
|
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:
|
2005-03-03 21:56:23 +00:00
|
|
|
void assignToPublic(PKey *dest) const;
|
|
|
|
void assignToPrivate(PKey *dest) const;
|
|
|
|
|
2005-01-01 02:44:28 +00:00
|
|
|
class Private;
|
|
|
|
Private *d;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Generic public key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT PublicKey : public PKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PublicKey();
|
|
|
|
PublicKey(const PrivateKey &k);
|
2005-02-25 04:23:12 +00:00
|
|
|
PublicKey(const QString &fileName);
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
RSAPublicKey toRSA() const;
|
|
|
|
DSAPublicKey toDSA() const;
|
|
|
|
DHPublicKey toDH() const;
|
|
|
|
|
|
|
|
bool canEncrypt() const;
|
|
|
|
bool canVerify() const;
|
|
|
|
|
|
|
|
// encrypt / verify
|
2005-02-24 21:14:03 +00:00
|
|
|
int maximumEncryptSize(EncryptionAlgorithm alg) const;
|
2005-03-05 20:50:49 +00:00
|
|
|
QSecureArray encrypt(const QSecureArray &a, EncryptionAlgorithm alg) const;
|
|
|
|
void startVerify(SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
2005-01-01 02:44:28 +00:00
|
|
|
void update(const QSecureArray &a);
|
|
|
|
bool validSignature(const QSecureArray &sig);
|
2005-03-05 20:50:49 +00:00
|
|
|
bool verifyMessage(const QSecureArray &a, const QSecureArray &sig, SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
// import / export
|
|
|
|
QSecureArray toDER() const;
|
|
|
|
QString toPEM() const;
|
2005-02-25 04:23:12 +00:00
|
|
|
bool toPEMFile(const QString &fileName) const;
|
|
|
|
static PublicKey fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static PublicKey fromPEM(const QString &s, ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static PublicKey fromPEMFile(const QString &fileName, ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
PublicKey(const QString &type, const QString &provider);
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Generic private key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT PrivateKey : public PKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PrivateKey();
|
2005-02-25 04:23:12 +00:00
|
|
|
PrivateKey(const QString &fileName, const QSecureArray &passphrase = QSecureArray());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Interpret / convert the key to an RSA key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
RSAPrivateKey toRSA() const;
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Interpret / convert the key to a DSA key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
DSAPrivateKey toDSA() const;
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Interpret / convert the key to a Diffie-Hellman key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
DHPrivateKey toDH() const;
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Test if this key can be used for decryption
|
|
|
|
|
|
|
|
\return true if the key can be used for decryption
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool canDecrypt() const;
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Test if this key can be used for signing
|
|
|
|
|
|
|
|
\return true if the key can be used to make a signature
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
bool canSign() const;
|
|
|
|
|
|
|
|
// decrypt / sign / key agreement
|
2005-03-05 20:50:49 +00:00
|
|
|
bool decrypt(const QSecureArray &in, QSecureArray *out, EncryptionAlgorithm alg) const;
|
|
|
|
void startSign(SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
|
|
|
void update(const QSecureArray &a);
|
2005-01-01 02:44:28 +00:00
|
|
|
QSecureArray signature();
|
2005-03-05 20:50:49 +00:00
|
|
|
QSecureArray signMessage(const QSecureArray &a, SignatureAlgorithm alg, SignatureFormat = DefaultFormat);
|
2005-03-04 07:56:05 +00:00
|
|
|
SymmetricKey deriveKey(const PublicKey &theirs) const;
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
// import / export
|
2005-03-03 21:56:23 +00:00
|
|
|
static QList<PBEAlgorithm> supportedPBEAlgorithms(const QString &provider = QString());
|
2005-02-24 21:14:03 +00:00
|
|
|
QSecureArray toDER(const QSecureArray &passphrase = QSecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
|
|
|
QString toPEM(const QSecureArray &passphrase = QSecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
2005-02-25 04:23:12 +00:00
|
|
|
bool toPEMFile(const QString &fileName, const QSecureArray &passphrase = QSecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
|
|
|
static PrivateKey fromDER(const QSecureArray &a, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static PrivateKey fromPEM(const QString &s, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
|
|
|
static PrivateKey fromPEMFile(const QString &fileName, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
PrivateKey(const QString &type, const QString &provider);
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Class for generating asymmetric key pairs
|
|
|
|
|
|
|
|
This class is used for generating asymmetric keys (public/private key pairs)
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT KeyGenerator : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2005-02-27 01:12:26 +00:00
|
|
|
KeyGenerator(QObject *parent = 0);
|
2005-01-01 02:44:28 +00:00
|
|
|
~KeyGenerator();
|
|
|
|
|
|
|
|
bool blocking() const;
|
|
|
|
void setBlocking(bool b);
|
|
|
|
bool isBusy() const;
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
Generate an RSA key of the specified length
|
|
|
|
|
|
|
|
This method creates both the public key and corresponding private key. You
|
|
|
|
almost certainly want to extract the public key part out - see PKey::toPublicKey
|
|
|
|
for an easy way.
|
|
|
|
|
|
|
|
Key length is a tricky judgement - using less than 2048 is probably being
|
|
|
|
too liberal for long term use. Don't use less than 1024 without serious
|
|
|
|
analysis.
|
|
|
|
|
|
|
|
\param bits the length of key that is required
|
|
|
|
\param exp the exponent - typicall 3, 17 or 65537
|
|
|
|
\param provider the name of the provider to use
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
PrivateKey createRSA(int bits, int exp = 65537, const QString &provider = QString());
|
2005-04-10 08:17:03 +00:00
|
|
|
|
2005-03-07 10:23:45 +00:00
|
|
|
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;
|
2005-01-01 02:44:28 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
|
2005-03-03 21:56:23 +00:00
|
|
|
public:
|
2005-01-01 02:44:28 +00:00
|
|
|
class Private;
|
2005-03-03 21:56:23 +00:00
|
|
|
private:
|
|
|
|
friend class Private;
|
2005-01-01 02:44:28 +00:00
|
|
|
Private *d;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
RSA Public Key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT RSAPublicKey : public PublicKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RSAPublicKey();
|
2005-01-21 10:20:41 +00:00
|
|
|
RSAPublicKey(const QBigInteger &n, const QBigInteger &e, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
RSAPublicKey(const RSAPrivateKey &k);
|
|
|
|
|
2005-04-10 08:17:03 +00:00
|
|
|
/**
|
|
|
|
The public key value
|
|
|
|
|
|
|
|
This value is the actual public key value (the product of p and q, the random prime numbers
|
|
|
|
used to generate the RSA key), also known as the public modulus.
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger n() const;
|
2005-04-10 08:17:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The public key exponent
|
|
|
|
|
|
|
|
This value is the exponent chosen in the original key generator step
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger e() const;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
RSA Private Key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT RSAPrivateKey : public PrivateKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RSAPrivateKey();
|
2005-03-07 10:23:45 +00:00
|
|
|
RSAPrivateKey(const QBigInteger &n, const QBigInteger &e, const QBigInteger &p, const QBigInteger &q, const QBigInteger &d, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-03-07 10:23:45 +00:00
|
|
|
QBigInteger n() const;
|
|
|
|
QBigInteger e() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger p() const;
|
|
|
|
QBigInteger q() const;
|
|
|
|
QBigInteger d() const;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Digital Signature Algorithm Public Key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT DSAPublicKey : public PublicKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DSAPublicKey();
|
2005-03-07 10:23:45 +00:00
|
|
|
DSAPublicKey(const DLGroup &domain, const QBigInteger &y, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
DSAPublicKey(const DSAPrivateKey &k);
|
|
|
|
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup domain() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger y() const;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Digital Signature Algorithm Private Key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT DSAPrivateKey : public PrivateKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DSAPrivateKey();
|
2005-03-07 10:23:45 +00:00
|
|
|
DSAPrivateKey(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup domain() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger y() const;
|
2005-03-07 10:23:45 +00:00
|
|
|
QBigInteger x() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Diffie-Hellman Public Key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT DHPublicKey : public PublicKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DHPublicKey();
|
2005-03-07 10:23:45 +00:00
|
|
|
DHPublicKey(const DLGroup &domain, const QBigInteger &y, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
DHPublicKey(const DHPrivateKey &k);
|
|
|
|
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup domain() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger y() const;
|
|
|
|
};
|
|
|
|
|
2005-04-10 03:06:51 +00:00
|
|
|
/**
|
|
|
|
Diffie-Hellman Private Key
|
|
|
|
*/
|
2005-01-01 02:44:28 +00:00
|
|
|
class QCA_EXPORT DHPrivateKey : public PrivateKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DHPrivateKey();
|
2005-03-07 10:23:45 +00:00
|
|
|
DHPrivateKey(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x, const QString &provider = QString());
|
2005-01-01 02:44:28 +00:00
|
|
|
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroup domain() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
QBigInteger y() const;
|
2005-03-07 10:23:45 +00:00
|
|
|
QBigInteger x() const;
|
2005-01-01 02:44:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|