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