• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

qca

QCA::Cipher

QCA::Cipher Class Reference
[QCA user API]

#include <QtCrypto>

Inheritance diagram for QCA::Cipher:

Inheritance graph
[legend]

List of all members.


Detailed Description

General class for cipher (encryption / decryption) algorithms.

Cipher is the class for the various algorithms that perform low level encryption and decryption within QCA.

AES128, AES192 and AES256 are recommended for new applications.

Standard names for ciphers are:

  • Blowfish - "blowfish"
  • TripleDES - "tripledes"
  • DES - "des"
  • AES128 - "aes128"
  • AES192 - "aes192"
  • AES256 - "aes256"
  • CAST5 (CAST-128) - "cast5"

When checking for the availability of a particular kind of cipher operation (e.g. AES128 in CBC mode with PKCS7 padding), you append the mode and padding type (in that example "aes128-cbc-pkcs7"). CFB and OFB modes don't use padding, so they are always just the cipher name followed by the mode (e.g. "blowfish-cfb" or "aes192-ofb"). If you are not using padding with CBC mode (i.e. you are ensuring block size operations yourself), just use the cipher name followed by "-cbc" (e.g. "blowfish-cbc" or "aes256-cbc").

Definition at line 575 of file qca_basic.h.


Public Types

enum  Mode { CBC, CFB, ECB, OFB }
enum  Padding { DefaultPadding, NoPadding, PKCS7 }

Public Member Functions

int blockSize () const
 Cipher (const Cipher &from)
 Cipher (const QString &type, Mode mode, Padding pad=DefaultPadding, Direction dir=Encode, const SymmetricKey &key=SymmetricKey(), const InitializationVector &iv=InitializationVector(), const QString &provider=QString())
virtual void clear ()
Direction direction () const
virtual MemoryRegion final ()
KeyLength keyLength () const
Mode mode () const
virtual bool ok () const
Cipher & operator= (const Cipher &from)
Padding padding () const
void setup (Direction dir, const SymmetricKey &key, const InitializationVector &iv=InitializationVector())
QString type () const
virtual MemoryRegion update (const MemoryRegion &a)
bool validKeyLength (int n) const
 ~Cipher ()

Static Public Member Functions

static QStringList supportedTypes (const QString &provider=QString())
static QString withAlgorithms (const QString &cipherType, Mode modeType, Padding paddingType)

Member Enumeration Documentation

enum QCA::Cipher::Mode

Mode settings for cipher algorithms.

Note:
ECB is almost never what you want, unless you are trying to implement a Cipher variation that is not supported by QCA.
Enumerator:
CBC  operate in Cipher Block Chaining mode
CFB  operate in Cipher FeedBack mode
ECB  operate in Electronic Code Book mode
OFB  operate in Output FeedBack Mode

Definition at line 585 of file qca_basic.h.

enum QCA::Cipher::Padding

Padding variations for cipher algorithms.

See the Padding description for more details on padding schemes.

Enumerator:
DefaultPadding  Default for cipher-mode.
NoPadding  Do not use padding.
PKCS7  Pad using the scheme in PKCS#7.

Definition at line 599 of file qca_basic.h.


Constructor & Destructor Documentation

QCA::Cipher::Cipher ( const QString &  type,
Mode  mode,
Padding  pad = DefaultPadding,
Direction  dir = Encode,
const SymmetricKey &  key = SymmetricKey(),
const InitializationVector &  iv = InitializationVector(),
const QString &  provider = QString() 
)

Standard constructor.

Parameters:
type the name of the cipher specialisation to use (e.g. "aes128")
mode the operating Mode to use (e.g. QCA::Cipher::CBC)
pad the type of Padding to use
dir the Direction that this Cipher should use (Encode for encryption, Decode for decryption)
key the SymmetricKey array that is the key
iv the InitializationVector to use (not used for ECB mode)
provider the name of the Provider to use
Note:
Padding only applies to CBC and ECB modes. CFB and OFB ciphertext is always the length of the plaintext.

Definition at line 269 of file qca_basic.cpp.

QCA::Cipher::Cipher ( const Cipher &  from  ) 

Standard copy constructor.

Parameters:
from the Cipher to copy state from

Definition at line 283 of file qca_basic.cpp.

QCA::Cipher::~Cipher (  ) 

Definition at line 289 of file qca_basic.cpp.


Member Function Documentation

int QCA::Cipher::blockSize (  )  const

return the block size for the cipher object

Definition at line 337 of file qca_basic.cpp.

void QCA::Cipher::clear (  )  [virtual]

reset the cipher object, to allow re-use

Implements QCA::Filter.

Definition at line 342 of file qca_basic.cpp.

Direction QCA::Cipher::direction (  )  const

Return the cipher direction.

Definition at line 321 of file qca_basic.cpp.

MemoryRegion QCA::Cipher::final (  )  [virtual]

complete the block of data, padding as required, and returning the completed block

Implements QCA::Filter.

Definition at line 357 of file qca_basic.cpp.

KeyLength QCA::Cipher::keyLength (  )  const

Return acceptable key lengths.

Definition at line 326 of file qca_basic.cpp.

Cipher::Mode QCA::Cipher::mode (  )  const

Return the cipher mode.

Definition at line 311 of file qca_basic.cpp.

bool QCA::Cipher::ok (  )  const [virtual]

Test if an update() or final() call succeeded.

Returns:
true if the previous call succeeded

Implements QCA::Filter.

Definition at line 367 of file qca_basic.cpp.

Cipher & QCA::Cipher::operator= ( const Cipher &  from  ) 

Assignment operator.

Parameters:
from the Cipher to copy state from

Definition at line 294 of file qca_basic.cpp.

Cipher::Padding QCA::Cipher::padding (  )  const

Return the cipher padding type.

Definition at line 316 of file qca_basic.cpp.

void QCA::Cipher::setup ( Direction  dir,
const SymmetricKey &  key,
const InitializationVector &  iv = InitializationVector() 
)

Reset / reconfigure the Cipher.

You can use this to re-use an existing Cipher, rather than creating a new object with a slightly different configuration.

Parameters:
dir the Direction that this Cipher should use (Encode for encryption, Decode for decryption)
key the SymmetricKey array that is the key
iv the InitializationVector to use (not used for ECB Mode)
Note:
You should not leave iv empty for any Mode except ECB.

Definition at line 372 of file qca_basic.cpp.

QStringList QCA::Cipher::supportedTypes ( const QString &  provider = QString()  )  [static]

Returns a list of all of the cipher types available.

Parameters:
provider the name of the provider to get a list from, if one provider is required. If not specified, available cipher types from all providers will be returned.

Definition at line 301 of file qca_basic.cpp.

QString QCA::Cipher::type (  )  const

Return the cipher type.

Reimplemented from QCA::Algorithm.

Definition at line 306 of file qca_basic.cpp.

MemoryRegion QCA::Cipher::update ( const MemoryRegion &  a  )  [virtual]

pass in a byte array of data, which will be encrypted or decrypted (according to the Direction that was set in the constructor or in setup() ) and returned.

Parameters:
a the array of data to encrypt / decrypt

Implements QCA::Filter.

Definition at line 348 of file qca_basic.cpp.

bool QCA::Cipher::validKeyLength ( int  n  )  const

Test if a key length is valid for the cipher algorithm.

Parameters:
n the key length in bytes
Returns:
true if the key would be valid for the current algorithm

Definition at line 331 of file qca_basic.cpp.

QString QCA::Cipher::withAlgorithms ( const QString &  cipherType,
Mode  modeType,
Padding  paddingType 
) [static]

Construct a Cipher type string.

Parameters:
cipherType the name of the algorithm (eg AES128, DES)
modeType the mode to operate the cipher in (eg QCA::CBC, QCA::CFB)
paddingType the padding required (eg QCA::NoPadding, QCA::PCKS7)

Definition at line 380 of file qca_basic.cpp.


The documentation for this class was generated from the following files:
  • qca_basic.h
  • qca_basic.cpp

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • akonadi
  • Decibel
  • eigen
  • Eigen2
  • kdewin32
  • Phonon
  •     Backend
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal