QCA::Cipher Class Reference

General class for cipher (encryption / decryption) algorithms. More...

#include <QtCrypto>

Inheritance diagram for QCA::Cipher:

QCA::Algorithm QCA::Filter Collaboration diagram for QCA::Cipher:

Collaboration graph
[legend]
List of all members.

Public Types

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

Public Member Functions

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

Static Public Member Functions

static QString withAlgorithms (const QString &cipherType, Mode modeType, Padding paddingType)

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:

Examples:

aes-cmac.cpp, and ciphertest.cpp.


Member Enumeration Documentation

enum QCA::Cipher::Mode
 

Mode settings for cipher algorithms.

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

enum QCA::Cipher::Padding
 

Padding variations for cipher algorithms.

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


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.

QCA::Cipher::Cipher const Cipher from  ) 
 

Standard copy constructor.


Member Function Documentation

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

Assignment operator.

Parameters:
from the Cipher to copy state from

QString QCA::Cipher::type  )  const
 

Return the cipher type.

Reimplemented from QCA::Algorithm.

Mode QCA::Cipher::mode  )  const
 

Return the cipher mode.

Padding QCA::Cipher::padding  )  const
 

Return the cipher padding type.

Direction QCA::Cipher::direction  )  const
 

Return the cipher direction.

KeyLength QCA::Cipher::keyLength  )  const
 

Return acceptable key lengths.

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

int QCA::Cipher::blockSize  )  const
 

return the block size for the cipher object

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

reset the cipher object, to allow re-use

Implements QCA::Filter.

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

Examples:
ciphertest.cpp.

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

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

Implements QCA::Filter.

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

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

Returns:
true if the previous call succeeded

Implements QCA::Filter.

Examples:
ciphertest.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

static 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)


The documentation for this class was generated from the following file:
Generated on Fri Jul 6 12:14:40 2007 for Qt Cryptographic Architecture by  doxygen 1.4.6