qca
QCA::PKey Class Reference
[QCA user API]
General superclass for public (PublicKey) and private (PrivateKey) keys used with asymmetric encryption techniques. More...
#include <QtCrypto>

Public Types | |
| enum | Type { RSA, DSA, DH } |
Public Member Functions | |
| PKey (const PKey &from) | |
| PKey () | |
| ~PKey () | |
| int | bitSize () const |
| bool | canExport () const |
| bool | canKeyAgree () const |
| bool | isDH () const |
| bool | isDSA () const |
| bool | isNull () const |
| bool | isPrivate () const |
| bool | isPublic () const |
| bool | isRSA () const |
| bool | operator!= (const PKey &a) const |
| PKey & | operator= (const PKey &from) |
| bool | operator== (const PKey &a) const |
| PrivateKey | toPrivateKey () const |
| PublicKey | toPublicKey () const |
| Type | type () const |
Static Public Member Functions | |
| static QList< Type > | supportedIOTypes (const QString &provider=QString()) |
| static QList< Type > | supportedTypes (const QString &provider=QString()) |
Protected Member Functions | |
| PKey (const QString &type, const QString &provider) | |
| void | set (const PKey &k) |
| DHPrivateKey | toDHPrivateKey () const |
| DHPublicKey | toDHPublicKey () const |
| DSAPrivateKey | toDSAPrivateKey () const |
| DSAPublicKey | toDSAPublicKey () const |
| RSAPrivateKey | toRSAPrivateKey () const |
| RSAPublicKey | toRSAPublicKey () const |
Detailed Description
General superclass for public (PublicKey) and private (PrivateKey) keys used with asymmetric encryption techniques.
Definition at line 239 of file qca_publickey.h.
Member Enumeration Documentation
| enum QCA::PKey::Type |
Types of public key cryptography keys supported by QCA.
Definition at line 245 of file qca_publickey.h.
Constructor & Destructor Documentation
| QCA::PKey::PKey | ( | ) |
Standard constructor.
Definition at line 555 of file qca_publickey.cpp.
| QCA::PKey::PKey | ( | const PKey & | from | ) |
Standard copy constructor.
- Parameters:
-
from the key to copy from
Definition at line 566 of file qca_publickey.cpp.
| QCA::PKey::~PKey | ( | ) |
Definition at line 573 of file qca_publickey.cpp.
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
Definition at line 560 of file qca_publickey.cpp.
Member Function Documentation
| int QCA::PKey::bitSize | ( | ) | const |
Report the number of bits in the key.
Definition at line 626 of file qca_publickey.cpp.
| 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.
Definition at line 660 of file qca_publickey.cpp.
| bool QCA::PKey::canKeyAgree | ( | ) | const |
Test if the key can be used for key agreement.
Definition at line 665 of file qca_publickey.cpp.
| bool QCA::PKey::isDH | ( | ) | const |
Test if the key is a Diffie Hellman key.
Definition at line 641 of file qca_publickey.cpp.
| bool QCA::PKey::isDSA | ( | ) | const |
Test if the key is a DSA key.
Definition at line 636 of file qca_publickey.cpp.
| bool QCA::PKey::isNull | ( | ) | const |
Test if the key is null (empty).
- Returns:
- true if the key is null
Definition at line 614 of file qca_publickey.cpp.
| bool QCA::PKey::isPrivate | ( | ) | const |
Test if the key is a private key.
Definition at line 653 of file qca_publickey.cpp.
| bool QCA::PKey::isPublic | ( | ) | const |
Test if the key is a public key.
Definition at line 646 of file qca_publickey.cpp.
| bool QCA::PKey::isRSA | ( | ) | const |
Test if the key is an RSA key.
Definition at line 631 of file qca_publickey.cpp.
| bool QCA::PKey::operator!= | ( | const PKey & | a | ) | const |
test if two keys are not equal
- Parameters:
-
a the key to compare with this key
Definition at line 745 of file qca_publickey.cpp.
Standard assignment operator.
- Parameters:
-
from the PKey to copy from
Reimplemented from QCA::Algorithm.
Reimplemented in QCA::PublicKey, and QCA::PrivateKey.
Definition at line 578 of file qca_publickey.cpp.
| bool QCA::PKey::operator== | ( | const PKey & | a | ) | const |
test if two keys are equal
- Parameters:
-
a the key to compare with this key
Definition at line 734 of file qca_publickey.cpp.
| void QCA::PKey::set | ( | const PKey & | k | ) | [protected] |
| QList< PKey::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:
if(!QCA::isSupported("pkey") || !QCA::PKey::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()
Definition at line 609 of file qca_publickey.cpp.
| QList< PKey::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:
if(!QCA::isSupported("pkey") || !QCA::PKey::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()
Definition at line 604 of file qca_publickey.cpp.
| DHPrivateKey QCA::PKey::toDHPrivateKey | ( | ) | const [protected] |
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
Definition at line 726 of file qca_publickey.cpp.
| DHPublicKey QCA::PKey::toDHPublicKey | ( | ) | const [protected] |
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
Definition at line 718 of file qca_publickey.cpp.
| DSAPrivateKey QCA::PKey::toDSAPrivateKey | ( | ) | const [protected] |
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
Definition at line 710 of file qca_publickey.cpp.
| DSAPublicKey QCA::PKey::toDSAPublicKey | ( | ) | const [protected] |
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
Definition at line 702 of file qca_publickey.cpp.
| PrivateKey QCA::PKey::toPrivateKey | ( | ) | const |
Interpret this key as a PrivateKey.
Definition at line 678 of file qca_publickey.cpp.
| PublicKey QCA::PKey::toPublicKey | ( | ) | const |
Interpret this key as a PublicKey.
- See also:
- toRSAPublicKey(), toDSAPublicKey() and toDHPublicKey() for protected forms of this call.
Definition at line 670 of file qca_publickey.cpp.
| RSAPrivateKey QCA::PKey::toRSAPrivateKey | ( | ) | const [protected] |
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
Definition at line 694 of file qca_publickey.cpp.
| RSAPublicKey QCA::PKey::toRSAPublicKey | ( | ) | const [protected] |
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
Definition at line 686 of file qca_publickey.cpp.
| PKey::Type QCA::PKey::type | ( | ) | const |
Report the Type of key (eg RSA, DSA or Diffie Hellman).
Reimplemented from QCA::Algorithm.
Definition at line 619 of file qca_publickey.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference