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!]
Public Member Functions | |
---|---|
~CSymmetricCipher () | |
void | Finish ( TDes8 &) |
void | Init (const TDesC8 &, TAction ) |
TInt | Setkey (const TDesC8 &) |
void | Update ( TDes8 &, const TDesC8 &) |
Public Member Enumerations | |
---|---|
enum | TAction { EEncrypt , EDecrypt } |
void | Finish | ( | 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.
TDes8 & aIV | the place to return the final IV. |
void | Init | ( | const TDesC8 & | aIV, |
TAction | aMode | |||
) | [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.
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.
const TDesC8 & aKey | the cipher key. The length of the key is defined by the length of this descriptor, and is always multiple of 8 bits. |
void | Update | ( | 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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.