QCA::SecureLayer Class Referenceabstract
QCA user API

`#include <QtCrypto>`

Collaboration diagram for QCA::SecureLayer:
[legend]

## 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=nullptr)=0
virtual QByteArray | readUnprocessed ()
| SecureLayer (QObject *parent=nullptr)
virtual void | write (const QByteArray &a)=0
virtual void | writeIncoming (const QByteArray &a)=0

## Detailed Description

Abstract interface to a security layer.

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 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.

## Constructor & Destructor Documentation

## SecureLayer()

QCA::SecureLayer::SecureLayer | ( | QObject * | parent = nullptr | ) |

Constructor for an abstract secure communications layer.

Parameters

  parent | the parent object for this object

Referenced by error().

## Member Function Documentation

## isClosable()

virtual bool QCA::SecureLayer::isClosable | ( |  | ) | const

virtual

Returns true if the layer has a meaningful "close".

Reimplemented in QCA::TLS.

## bytesAvailable()

virtual int QCA::SecureLayer::bytesAvailable | ( |  | ) | const

pure virtual

Returns the number of bytes available to be read() on the application side.

Implemented in QCA::SASL, and QCA::TLS.

## bytesOutgoingAvailable()

virtual int QCA::SecureLayer::bytesOutgoingAvailable | ( |  | ) | const

pure virtual

Returns the number of bytes available to be readOutgoing() on the network side.

Implemented in QCA::SASL, and QCA::TLS.

## close()

virtual void QCA::SecureLayer::close | ( |  | ) |

virtual

Close the link.

Note that this may not be meaningful / possible for all implementations.

See also
  isClosable() for a test that verifies if the link can be closed.

Reimplemented in QCA::TLS.

## write()

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.

Parameters

  a | the source of the application-side data

Implemented in QCA::SASL, and QCA::TLS.

## read()

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.

Implemented in QCA::SASL, and QCA::TLS.

## writeIncoming()

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.

Parameters

  a | the ByteArray to take network-side data from

Implemented in QCA::SASL, and QCA::TLS.

## readOutgoing()

virtual QByteArray QCA::SecureLayer::readOutgoing | ( | int * | plainBytes = nullptr | ) |

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.

Parameters

  plainBytes | the number of bytes that were read.

Implemented in QCA::SASL, and QCA::TLS.

## readUnprocessed()

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.

## convertBytesWritten()

virtual int QCA::SecureLayer::convertBytesWritten | ( | qint64 | encryptedBytes | ) |

pure virtual

Convert encrypted bytes written to plain text bytes written.

Parameters

  encryptedBytes | the number of bytes to convert

Implemented in QCA::SASL, and QCA::TLS.

## readyRead

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()).

Examples
  saslclient.cpp, saslserver.cpp, sslservtest.cpp, ssltest.cpp, and tlssocket.cpp.

## readyReadOutgoing

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.

Examples
  saslclient.cpp, saslserver.cpp, sslservtest.cpp, ssltest.cpp, and tlssocket.cpp.

## closed

void QCA::SecureLayer::closed | ( |  | ) |

signal

This signal is emitted when the SecureLayer connection is closed.

Examples
  sslservtest.cpp, ssltest.cpp, and tlssocket.cpp.

## error

void QCA::SecureLayer::error | ( |  | ) |

signal

This signal is emitted when an error is detected.

You can determine the error type using errorCode().

Examples
  saslclient.cpp, saslserver.cpp, sslservtest.cpp, ssltest.cpp, and tlssocket.cpp.

References SecureLayer().

The documentation for this class was generated from the following file:

- qca_securelayer.h