#include <QtCrypto>
General superclass for public (PublicKey) and private (PrivateKey) keys used with asymmetric encryption techniques.
◆ Type
Types of public key cryptography keys supported by QCA.
Enumerator |
---|
RSA | RSA key.
|
DSA | DSA key.
|
DH | Diffie Hellman key.
|
◆ PKey() [1/3]
◆ PKey() [2/3]
QCA::PKey::PKey |
( |
const PKey & |
from | ) |
|
Standard copy constructor.
- Parameters
-
◆ PKey() [3/3]
QCA::PKey::PKey |
( |
const QString & |
type, |
|
|
const QString & |
provider |
|
) |
| |
|
protected |
Create a key of the specified type.
- Parameters
-
type | the name of the type of key to create |
provider | the name of the provider to create the key in |
◆ operator=()
PKey & QCA::PKey::operator= |
( |
const PKey & |
from | ) |
|
Standard assignment operator.
- Parameters
-
from | the PKey to copy from |
◆ supportedTypes()
static QList< Type > QCA::PKey::supportedTypes |
( |
const QString & |
provider = QString() | ) |
|
|
static |
Test what types of keys are supported.
Normally you would just test if the capability is present, however
for PKey, you also need to test which types of keys are available.
So if you want to figure out if RSA keys are supported, you need to
do something like:
\code
if(!QCAisSupported("pkey") || !QCAPKey::supportedTypes().contains(QCA::PKey::RSA)) { // then there is no RSA key support } else { // there is RSA key support }
To make things a bit more complex, supportedTypes() only checks for basic functionality. If you want to check that you can do operations with PEM or DER (eg toPEM(), fromPEM(), and the equivalent DER and PEMfile operations, plus anything else that uses them, including the constructor form that takes a fileName), then you need to check for supportedIOTypes() instead.
- Parameters
-
provider | the name of the provider to use, if a particular provider is required. |
- See also
- supportedIOTypes()
◆ supportedIOTypes()
static QList< Type > QCA::PKey::supportedIOTypes |
( |
const QString & |
provider = QString() | ) |
|
|
static |
Test what types of keys are supported for IO operations
If you are using PKey DER or PEM operations, then you need
to check for appropriate support using this method. For example,
if you want to check if you can export or import an RSA key, then
you need to do something like:
\code
if(!QCAisSupported("pkey") || !QCAPKey::supportedIOTypes().contains(QCA::PKey::RSA)) { // then there is no RSA key IO support } else { // there is RSA key IO support }
Note that if you only want to check for basic functionality (ie not PEM or DER import/export), then you can use supportedTypes(). There is no need to use both - if the key type is supported for IO, then is also supported for basic operations.
- Parameters
-
provider | the name of the provider to use, if a particular provider is required. |
- See also
- supportedTypes()
- Examples
- rsatest.cpp.
◆ isNull()
bool QCA::PKey::isNull |
( |
| ) |
const |
Test if the key is null (empty)
- Returns
- true if the key is null
- Examples
- rsatest.cpp.
◆ type()
Type QCA::PKey::type |
( |
| ) |
const |
Report the Type of key (eg RSA, DSA or Diffie Hellman)
- See also
- isRSA, isDSA and isDH for boolean tests.
◆ bitSize()
int QCA::PKey::bitSize |
( |
| ) |
const |
◆ isRSA()
bool QCA::PKey::isRSA |
( |
| ) |
const |
Test if the key is an RSA key.
◆ isDSA()
bool QCA::PKey::isDSA |
( |
| ) |
const |
Test if the key is a DSA key.
◆ isDH()
bool QCA::PKey::isDH |
( |
| ) |
const |
Test if the key is a Diffie Hellman key.
◆ isPublic()
bool QCA::PKey::isPublic |
( |
| ) |
const |
Test if the key is a public key.
◆ isPrivate()
bool QCA::PKey::isPrivate |
( |
| ) |
const |
Test if the key is a private key.
◆ canExport()
bool QCA::PKey::canExport |
( |
| ) |
const |
Test if the key data can be exported.
If the key resides on a smart card or other such device, this will likely return false.
◆ canKeyAgree()
bool QCA::PKey::canKeyAgree |
( |
| ) |
const |
Test if the key can be used for key agreement.
◆ toPublicKey()
◆ toPrivateKey()
◆ operator==()
bool QCA::PKey::operator== |
( |
const PKey & |
a | ) |
const |
test if two keys are equal
- Parameters
-
a | the key to compare with this key |
◆ operator!=()
bool QCA::PKey::operator!= |
( |
const PKey & |
a | ) |
const |
test if two keys are not equal
- Parameters
-
a | the key to compare with this key |
◆ set()
void QCA::PKey::set |
( |
const PKey & |
k | ) |
|
|
protected |
◆ toRSAPublicKey()
Interpret this key as an RSAPublicKey.
- Note
- This function is essentially a convenience cast - if the key was created as a DSA key, this function cannot turn it into an RSA key.
- See also
- toPublicKey() for the public version of this method
◆ toRSAPrivateKey()
Interpret this key as an RSAPrivateKey.
- Note
- This function is essentially a convenience cast - if the key was created as a DSA key, this function cannot turn it into a RSA key.
- See also
- toPrivateKey() for the public version of this method
◆ toDSAPublicKey()
Interpret this key as an DSAPublicKey.
- Note
- This function is essentially a convenience cast - if the key was created as an RSA key, this function cannot turn it into a DSA key.
- See also
- toPublicKey() for the public version of this method
◆ toDSAPrivateKey()
Interpret this key as a DSAPrivateKey.
- Note
- This function is essentially a convenience cast - if the key was created as an RSA key, this function cannot turn it into a DSA key.
- See also
- toPrivateKey() for the public version of this method
◆ toDHPublicKey()
Interpret this key as an DHPublicKey.
- Note
- This function is essentially a convenience cast - if the key was created as a DSA key, this function cannot turn it into a DH key.
- See also
- toPublicKey() for the public version of this method
◆ toDHPrivateKey()
Interpret this key as a DHPrivateKey.
- Note
- This function is essentially a convenience cast - if the key was created as a DSA key, this function cannot turn it into a DH key.
- See also
- toPrivateKey() for the public version of this method
The documentation for this class was generated from the following file: