#include <QtCrypto>
Signals | |
void | closed () |
void | error () |
void | readyRead () |
void | readyReadOutgoing () |
Public Member Functions | |
virtual int | bytesAvailable () const =0 |
virtual int | bytesOutgoingAvailable () const =0 |
virtual void | close () |
virtual int | convertBytesWritten (qint64 encryptedBytes)=0 |
virtual bool | isClosable () const |
virtual QByteArray | read ()=0 |
virtual QByteArray | readOutgoing (int *plainBytes=0)=0 |
virtual QByteArray | readUnprocessed () |
SecureLayer (QObject *parent=0) | |
virtual void | write (const QByteArray &a)=0 |
virtual void | writeIncoming (const QByteArray &a)=0 |
SecureLayer is normally used between an application and a potentially insecure network. It provides secure communications over that network.
The concept is that (after some initial setup), the application can write() some data to the SecureLayer implementation, and that data is encrypted (or otherwise protected, depending on the setup). The SecureLayer implementation then emits the readyReadOutgoing() signal, and the application uses readOutgoing() to retrieve the the encrypted data from the SecureLayer implementation. The encrypted data is then sent out on the network.
When some encrypted data comes back from the network, the application does a writeIncoming() to the SecureLayer implementation. Some time later, the SecureLayer implementation may emit readyRead() to the application, which then read()s the decrypted data from the SecureLayer implementation.
Note that sometimes data is sent or received between the SecureLayer implementation and the network without any data being sent between the application and the SecureLayer implementation. This is a result of the initial negotiation activities (which require network traffic to agree a configuration to use) and other overheads associated with the secure link.
QCA::SecureLayer::SecureLayer | ( | QObject * | parent = 0 |
) |
Constructor for an abstract secure communications layer.
parent | the parent object for this object |
virtual int QCA::SecureLayer::bytesAvailable | ( | ) | const [pure virtual] |
virtual int QCA::SecureLayer::bytesOutgoingAvailable | ( | ) | const [pure virtual] |
Returns the number of bytes available to be readOutgoing() on the network side.
virtual void QCA::SecureLayer::close | ( | ) | [virtual] |
Close the link.
Note that this may not be meaningful / possible for all implementations.
Reimplemented in QCA::TLS.
void QCA::SecureLayer::closed | ( | ) | [signal] |
This signal is emitted when the SecureLayer connection is closed.
virtual int QCA::SecureLayer::convertBytesWritten | ( | qint64 | encryptedBytes | ) | [pure virtual] |
void QCA::SecureLayer::error | ( | ) | [signal] |
This signal is emitted when an error is detected.
You can determine the error type using errorCode().
virtual bool QCA::SecureLayer::isClosable | ( | ) | const [virtual] |
virtual QByteArray QCA::SecureLayer::read | ( | ) | [pure virtual] |
This method reads decrypted (plain) data from the SecureLayer implementation.
You normally call this function on the application side after receiving the readyRead() signal.
virtual QByteArray QCA::SecureLayer::readOutgoing | ( | int * | plainBytes = 0 |
) | [pure virtual] |
This method provides encoded (typically encrypted) data.
You normally call this function to get data to write out to the network socket (e.g. using QTcpSocket::write()) after receiving the readyReadOutgoing() signal.
plainBytes | the number of bytes that were read. |
virtual QByteArray QCA::SecureLayer::readUnprocessed | ( | ) | [virtual] |
This allows you to read data without having it decrypted first.
This is intended to be used for protocols that close off the connection and return to plain text transfer. You do not normally need to use this function.
Reimplemented in QCA::TLS.
void QCA::SecureLayer::readyRead | ( | ) | [signal] |
This signal is emitted when SecureLayer has decrypted (application side) data ready to be read.
Typically you will connect this signal to a slot that reads the data (using read()).
void QCA::SecureLayer::readyReadOutgoing | ( | ) | [signal] |
This signal is emitted when SecureLayer has encrypted (network side) data ready to be read.
Typically you will connect this signal to a slot that reads the data (using readOutgoing()) and writes it to a network socket.
virtual void QCA::SecureLayer::write | ( | const QByteArray & | a | ) | [pure virtual] |
This method writes unencrypted (plain) data to the SecureLayer implementation.
You normally call this function on the application side.
a | the source of the application-side data |
virtual void QCA::SecureLayer::writeIncoming | ( | const QByteArray & | a | ) | [pure virtual] |
This method accepts encoded (typically encrypted) data for processing.
You normally call this function using data read from the network socket (e.g. using QTcpSocket::readAll()) after receiving a signal that indicates that the socket has data to read.
a | the ByteArray to take network-side data from |