CSymmetricCipher Class Reference

class CSymmetricCipher : public CBase

Base Symmetric Cipher (abstract) class.

All cipher algorithms must be derived from this base class, which defines the IPSEC required API for cipher algorithms (used by ESP implementation).

Because IPSEC needs to run cipher for each packet independently, it is important that the implementation can reset the computation by InitL() without needing to do any additional allocations [which means that it being a leaving function is a bad sign!]

Inherits from

Constructor & Destructor Documentation

~CSymmetricCipher()

~CSymmetricCipher()[inline, virtual]

Member Functions Documentation

Finish(TDes8 &)

voidFinish(TDes8 &aIV)[pure virtual]

Finish encryption or decryption.

Calling Finish is optional, it is needed if the total bytes is not multiple of the blocksize, or if one wants to get the final IV.

IPSEC does use the final IV.

Parameters

TDes8 & aIVthe place to return the final IV.

Init(const TDesC8 &, TAction)

voidInit(const TDesC8 &aIV,
TActionaMode
)[pure virtual]

Reset the cipher engine to initial state.

As this method is called for each packet, it should not do any memory allocation or heavy computations.

Parameters

const TDesC8 & aIVinitial vector.
TAction aModetells whether initialize is for decrypt or encrypt.

Setkey(const TDesC8 &)

TInt Setkey(const TDesC8 &aKey)[pure virtual]

Define the cipher key.

Because setting the key can be time consuming, this is only called once after instantiation of the class. Then, each packet is started with a call to InitL.

Parameters

const TDesC8 & aKeythe cipher key. The length of the key is defined by the length of this descriptor, and is always multiple of 8 bits.

Update(TDes8 &, const TDesC8 &)

voidUpdate(TDes8 &aOutbuf,
const TDesC8 &aInbuf
)[pure virtual]

Perform encryption or decryption.

Because algorithms are expected to work blocks, the caller will guarantee that ALL Outbuf's given to Update will exist up to Finish call (or at least as long as at least blocksize octets have been given to Update after it). The implementation of the algorithm can store pointer(s) to aOutbuf described memory area, and return data to such memory area on some later Update or Finish call.

The lengths of buffers are always equal, e.g. aInbuf.Length() octets will always fit into aOutbuf. This length can be anything from zero upwards. The cipher must work even if octets were fed to it one by one.

Parameters

TDes8 & aOutbufresult of the decrypt/encrypt
const TDesC8 & aInbufinput to decrypt/encrypt

Member Enumerations Documentation

Enum TAction

Enumerators

EEncrypt
EDecrypt