CPadding Class Reference

#include <padding.h>

class CPadding : public CBase

Inherits from

  • CPadding

    Detailed Description

    Abstract base class defining the interface to padding schemes.

    It is designed to be used by both symmetric and asymmetric ciphers.

    Constructor & Destructor Documentation

    CPadding ( TInt )

    IMPORT_CCPadding(TIntaBlockBytes)[protected]

    Constructor

    ParameterDescription
    aBlockBytesThe block size in bytes.

    Member Function Documentation

    BlockSize ( void )

    IMPORT_C TIntBlockSize(void)const

    Retrieves the block size for this padding system.

    Returns: The block size in bytes.

    GetExtension ( TUint, TAny *&, TAny * )

    TInt GetExtension(TUintaExtensionId,
    TAny *&a0,
    TAny *a1
    )

    Used to retrieve the extended interfaces by id. For Crypto SPI internal use only.

    MaxPaddedLength ( TInt )

    IMPORT_C TIntMaxPaddedLength(TIntaInputBytes)const [virtual]

    Gets the size of the aOutput buffer, in a call to PadL(), must be in order to accommodate a block size of BlockSize() and an input size of aInputBytes.

    Note:

    By default, this function returns the output of BlockSize(). If a derived padding system outputs more than a single block of padding, one must override this function and return the appropriate value.

    ParameterDescription
    aInputBytesThe amount of data to be padded out in bytes.

    Returns: A TInt representing the maximum amount of padded output data (in bytes) for a given block and input size.

    MaxUnPaddedLength ( TInt )

    IMPORT_C TIntMaxUnPaddedLength(TIntaInputBytes)const [virtual]

    Gets the size of the aOutput buffer, in a call to UnPadL(), must be in order to accommodate an input size of aInputBytes.

    Note:

    By default, this function returns the value of aInputBytes minus MinPaddingBytes(). Most padding systems cannot determine anything about the unpadded length without looking at the data. If your padding system allows you to give a better bound, then you should reimplement this function.

    ParameterDescription
    aInputBytesThe amount of data to be unpadded in bytes.

    Returns: A TInt containing the maximum amount of unpadded output data (in bytes) for a given padded input.

    MinPaddingLength ( void )

    TInt MinPaddingLength(void)const [pure virtual]

    Gets the smallest number of bytes that PadL() will ever add to aInput in order to get a valid block aligned aOutput.

    For example, in SSLv3 padding, if the block size is 8 and aInput is 7 bytes, it will append 1 byte of padding. For SSLv3 padding, this is the smallest amount possible as an 8 byte input will add another block size (8 more bytes) of padded data.

    Returns: A TInt containing the smallest number of padding bytes possible.

    PadL ( const TDesC8 &, TDes8 & )

    IMPORT_C voidPadL(const TDesC8 &aInput,
    TDes8 &aOutput
    )

    Pads aInput to be BlockSize() bytes long and places the result in aOutput.

    ParameterDescription
    aInputData to be padded. The size must be less than or equal to BlockSize() minus MinPaddingLength().
    aOutputOn return, the resulting padded, block size aligned data appended to aOutput.

    SetBlockSize ( TInt )

    IMPORT_C voidSetBlockSize(TIntaBlockBytes)

    Sets the block size for this padding system.

    ParameterDescription
    aBlockBytesThe block size in bytes.

    UnPadL ( const TDesC8 &, TDes8 & )

    voidUnPadL(const TDesC8 &aInput,
    TDes8 &aOutput
    )[pure virtual]

    Removes padding from aInput and appends unpadded result to aOutput.

    ParameterDescription
    aInputData to be unpadded.
    aOutputOn return, the unpadded data.