#include <QtCrypto>
Inheritance diagram for QCA::PublicKey:
Public Member Functions | |
PublicKey () | |
PublicKey (const PrivateKey &k) | |
PublicKey (const QString &fileName) | |
PublicKey (const PublicKey &from) | |
PublicKey & | operator= (const PublicKey &from) |
RSAPublicKey | toRSA () const |
DSAPublicKey | toDSA () const |
DHPublicKey | toDH () const |
bool | canEncrypt () const |
bool | canVerify () const |
int | maximumEncryptSize (EncryptionAlgorithm alg) const |
SecureArray | encrypt (const SecureArray &a, 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 Public Member Functions | |
static PublicKey | fromDER (const QByteArray &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()) |
Protected Member Functions | |
PublicKey (const QString &type, const QString &provider) |
|
Create an empty (null) public key.
|
|
Create a public key based on a specified private key.
|
|
Import a public key from a PEM representation in a file.
|
|
Copy constructor.
|
|
Create a new key of a specified type.
|
|
Assignment operator.
|
|
Convenience method to convert this key to an RSAPublicKey. Note that if the key is not an RSA key (eg it is DSA or DH), then this will produce a null key. |
|
Convenience method to convert this key to a DSAPublicKey. Note that if the key is not an DSA key (eg it is RSA or DH), then this will produce a null key. |
|
Convenience method to convert this key to a DHPublicKey. Note that if the key is not an DH key (eg it is DSA or RSA), then this will produce a null key. |
|
Test if this key can be used for encryption.
|
|
Test if the key can be used for verifying signatures.
|
|
The maximum message size that can be encrypted with a specified algorithm.
|
|
Encrypt a message using a specified algorithm.
|
|
Initialise the signature verification process.
|
|
Update the signature verification process with more data.
|
|
Check the signature is valid for the message. The process to check that a signature is correct is shown below: // note that pubkey is a PublicKey if( pubkey.canVerify() ) { pubkey.startVerify( QCA::EMSA3_MD5 ); pubkey.update( theMessage ); // might be called multiple times if ( pubkey.validSignature( theSignature ) ) { // then signature is valid } else { // then signature is invalid } }
|
|
Single step message verification. If you have the whole message to be verified, then this offers a more convenient approach to verification.
|
|
Export the key in Distinguished Encoding Rules (DER) format.
|
|
Export the key in Privacy Enhanced Mail (PEM) format.
|
|
Export the key in Privacy Enhanced Mail (PEM) to a file.
|
|
Import a key in Distinguished Encoding Rules (DER) format. This function takes a binary array, which is assumed to contain a public key in DER encoding, and returns the key. Unless you don't care whether the import succeeded, you should test the result, as shown below.
QCA::ConvertResult conversionResult; QCA::PublicKey publicKey = QCA::PublicKey::fromDER(keyArray, &conversionResult); if (! QCA::ConvertGood == conversionResult) { std::cout << "Public key read failed" << std::endl; }
|
|
Import a key in Privacy Enhanced Mail (PEM) format. This function takes a string, which is assumed to contain a public key in PEM encoding, and returns that key. Unless you don't care whether the import succeeded, you should test the result, as shown below.
QCA::ConvertResult conversionResult; QCA::PublicKey publicKey = QCA::PublicKey::fromPEM(keyAsString, &conversionResult); if (! QCA::ConvertGood == conversionResult) { std::cout << "Public key read failed" << std::endl; }
|
|
Import a key in Privacy Enhanced Mail (PEM) format from a file. This function takes the name of a file, which is assumed to contain a public key in PEM encoding, and returns that key. Unless you don't care whether the import succeeded, you should test the result, as shown below.
QCA::ConvertResult conversionResult; QCA::PublicKey publicKey = QCA::PublicKey::fromPEMFile(fileName, &conversionResult); if (! QCA::ConvertGood == conversionResult) { std::cout << "Public key read failed" << std::endl; }
|