#include <QSSLDevice.h>
This is a generic container of an asymmetric encryption key used with FX::QSSLDevice and FX::FXSSLKey which can be dumped to and from storage. Its internal state resides within the FX::Secure namespace and thus is automatically zeroed on deletion.
Currently the only supported key format is RSA. The somewhat tricky implementation details are abstracted away from you so even if new formats were to be added in the future, there would be almost no code changes.
Support for public/private key interoperability with PGP, SSH or Apache is provided by readFromPEM() and writeToPEM() which use the standard PEM format without encryption. You should even be able to give these routines X509 certificates without a problem.
Saving and loading saves the full key (both private and public parts). This is because a key takes up so little space you might as well save regenerating the public part of a key. Obviously, the storage of private keys should be secure. If you want to save just the public or private part alone, hatch it off using publicKey() and privateKey() and save just that part.
If you are dealing with a party who you cannot trust (ie; non- local software), run verify() on any FXSSLPKey's you receive from a third party before use.
+0: Key size in bits
+4: Key type (the enum)
+6: "PUB1" or "PRV1" denoting public or private key respectively
+10: length of key in bytes
+14: Key data in big-endian format
+n: next tag, or "ENDK" for no more
Definition at line 82 of file QSSLDevice.h.
Public Types | |
NoEncryption | |
RSA | |
DH | |
enum | KeyType { NoEncryption, RSA, DH } |
Public Member Functions | |
FXSSLPKey (FXuint bitsize=0, KeyType type=NoEncryption) | |
~FXSSLPKey () | |
FXSSLPKey (const FXSSLPKey &other) | |
FXSSLPKey & | operator= (const FXSSLPKey &other) |
bool | operator== (const FXSSLPKey &other) const |
bool | operator!= (const FXSSLPKey &other) const |
bool | operator< (const FXSSLPKey &other) const |
bool | operator> (const FXSSLPKey &other) const |
KeyType | type () const throw () |
void | setType (KeyType type) |
FXString | typeAsString () const |
FXuint | bytesLen () const throw () |
FXuint | bitsLen () const throw () |
void | setBitsLen (FXuint newsize) |
bool | hasPublicKey () const throw () |
FXSSLPKey | publicKey () const |
FXString | publicKeyAsString () const |
Secure::TigerHashValue | publicKeyAsHash () const |
bool | hasPrivateKey () const throw () |
FXSSLPKey | privateKey () const |
void | generate () |
bool | verify () const |
void | readFromPEM (QIODevice *dev) |
void | writeAsPEM (QIODevice *dev) const |
Static Public Member Functions | |
static FXSSLPKey | publicKeyFromString (const FXString &s, KeyType type) |
Friends | |
class | QSSLDevice |
FXAPI FXStream & | operator<< (FXStream &s, const FXSSLPKey &i) |
FXAPI FXStream & | operator>> (FXStream &s, FXSSLPKey &i) |