CPBEncryptSet Class Reference

class CPBEncryptSet : public CPBEncryptElement

Derived class to allow the efficient password based encryption and decryption of multiple elements.

This is useful if one wants random access to an encrypted source consisting of multiple independent elements, for example, a database or a store.

Since it is unreasonable to force the decryption of an entire set to allow access to just a tiny portion of it, and since it is too costly to derive separate keys for each element within the set, a single randomly generated master key is used. This master key is encrypted with the password provided by the user of the class. Known plaintext attacks against the ciphertext are prevented by using a randomly chosen Initialisation Vector (IV) for each element.

Contains the master encryption key.

See the Cryptography api-guide documentation for more information and sample code.

CPBEncryptElement
Since
v8.0

Inherits from

Public Member Functions
~CPBEncryptSet(void)
IMPORT_C voidChangePasswordL(const TPBPassword &)
IMPORT_C const TDesC8 &EncryptedMasterKey(void)
TInt MaxCiphertextLength(TInt)
TInt MaxPlaintextLength(TInt)
CPBDecryptor *NewDecryptL(void)
CPBDecryptor *NewDecryptLC(void)
CPBEncryptor *NewEncryptL(void)
CPBEncryptor *NewEncryptLC(void)
IMPORT_C CPBEncryptSet *NewL(const TPBPassword &)
IMPORT_C CPBEncryptSet *NewL(const TPBPassword &, TPBECipher)
IMPORT_C CPBEncryptSet *NewL(const TPBPassword &, const CPBEncryptParms &)
IMPORT_C CPBEncryptSet *NewL(const CPBEncryptionData &, const TDesC8 &, const TPBPassword &)
IMPORT_C CPBEncryptSet *NewLC(const TPBPassword &)
IMPORT_C CPBEncryptSet *NewLC(const TPBPassword &, TPBECipher)
IMPORT_C CPBEncryptSet *NewLC(const TPBPassword &, const CPBEncryptParms &)
IMPORT_C CPBEncryptSet *NewLC(const CPBEncryptionData &, const TDesC8 &, const TPBPassword &)
Protected Member Functions
CPBEncryptSet(void)
voidConstructL(const TDesC8 &)
voidConstructL(const TDesC8 &, TPBECipher)
voidConstructL(const TDesC8 &, const CPBEncryptParms &)
voidConstructL(const CPBEncryptionData &, const TDesC8 &, const TPBPassword &)
voidConstructMasterKeyL(void)
voidDecryptMasterKeyL(TDes8 &)
voidEncryptMasterKeyL(const TDesC8 &)
Private Member Functions
CPBEncryptSet(const CPBEncryptSet &)
CPBEncryptSet &operator=(const CPBEncryptSet &)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
CPBEncryptElement::AuthenticateL(const TPBPassword &)
CPBEncryptElement::CPBEncryptElement(void)
CPBEncryptElement::ConstructL(const CPBEncryptionData &,const TPBPassword &)
CPBEncryptElement::EncryptionData(void)const
CPBEncryptElement::MakeEncryptKeyL(TUint,const TDesC8 &)
CPBEncryptElement::NewL(const CPBEncryptionData &,const TPBPassword &)
CPBEncryptElement::NewLC(const CPBEncryptionData &,const TPBPassword &)
CPBEncryptElement::~CPBEncryptElement(void)
Protected Attributes
HBufC8 *iEncryptedMasterKey
Inherited Attributes
CPBEncryptElement::iData
CPBEncryptElement::iEncryptKey

Constructor & Destructor Documentation

CPBEncryptSet(void)

CPBEncryptSet(void)[protected]

Parameters

void

CPBEncryptSet(const CPBEncryptSet &)

CPBEncryptSet(const CPBEncryptSet &)[private]

Parameters

const CPBEncryptSet &

~CPBEncryptSet(void)

~CPBEncryptSet(void)[virtual]

Destructor

Parameters

void

Member Functions Documentation

ChangePasswordL(const TPBPassword &)

IMPORT_C voidChangePasswordL(const TPBPassword &aNewPassword)

Re-encrypts the master key with the specified new password.

Parameters

const TPBPassword & aNewPasswordThe new password

ConstructL(const TDesC8 &)

voidConstructL(const TDesC8 &aPassword)[protected]

Parameters

const TDesC8 & aPassword

ConstructL(const TDesC8 &, TPBECipher)

voidConstructL(const TDesC8 &aPassword,
TPBECipheraCipher
)[protected]

Parameters

const TDesC8 & aPassword
TPBECipher aCipher

ConstructL(const TDesC8 &, const CPBEncryptParms &)

voidConstructL(const TDesC8 &aPassword,
const CPBEncryptParms &aParms
)[protected]

Parameters

const TDesC8 & aPassword
const CPBEncryptParms & aParms

ConstructL(const CPBEncryptionData &, const TDesC8 &, const TPBPassword &)

voidConstructL(const CPBEncryptionData &aData,
const TDesC8 &aEncryptedMasterKey,
const TPBPassword &aPassword
)[protected]

Parameters

const CPBEncryptionData & aData
const TDesC8 & aEncryptedMasterKey
const TPBPassword & aPassword

ConstructMasterKeyL(void)

voidConstructMasterKeyL(void)[protected]

Parameters

void

DecryptMasterKeyL(TDes8 &)

voidDecryptMasterKeyL(TDes8 &aMasterKey)const [protected]

Parameters

TDes8 & aMasterKey

EncryptMasterKeyL(const TDesC8 &)

voidEncryptMasterKeyL(const TDesC8 &aMasterKey)[protected]

Parameters

const TDesC8 & aMasterKey

EncryptedMasterKey(void)

IMPORT_C const TDesC8 &EncryptedMasterKey(void)const

Gets the encrypted form of the master key.

This must be stored along with the object returned by CPBEncryptElement::EncryptionData() in order for the object to be reconstructed with the same state at some time in the future. Failure to do so will result in the permanent loss of any information encrypted with this object.

Parameters

void

MaxCiphertextLength(TInt)

TInt MaxCiphertextLength(TIntaPlaintextLength)const [virtual]

Gets the maximum output ciphertext length given a specified input plaintext length.

Parameters

TInt aPlaintextLengthThe plaintext length

MaxPlaintextLength(TInt)

TInt MaxPlaintextLength(TIntaCiphertextLength)const [virtual]

Gets the maximum output plaintext length given a specified input ciphertext length.

Parameters

TInt aCiphertextLengthThe ciphertext length

NewDecryptL(void)

CPBDecryptor *NewDecryptL(void)const [virtual]

Constructs a CPBDecryptor object based on the state of this object (i.e., the cipher and master key) allowing the decryption of data.

Parameters

void

NewDecryptLC(void)

CPBDecryptor *NewDecryptLC(void)const [virtual]

Constructs a CPBDecryptor object based on the state of this object (i.e., the cipher and master key) allowing the decryption of data.

Parameters

void

NewEncryptL(void)

CPBEncryptor *NewEncryptL(void)const [virtual]

Constructs a CPBEncryptor object based on the state of this object (i.e., the cipher and master key) allowing the encryption of data.

Parameters

void

NewEncryptLC(void)

CPBEncryptor *NewEncryptLC(void)const [virtual]

Constructs a CPBEncryptor object based on the state of this object (i.e., the cipher and master key) allowing the encryption of data.

Parameters

void

NewL(const TPBPassword &)

IMPORT_C CPBEncryptSet *NewL(const TPBPassword &aPassword)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

If strong cryptography is present, a 128 bit AES cipher is used; otherwise, for weak cryptography, a 56 bit DES cipher is used.

The symmetric key is derived from the password and a random salt using TPKCS5KDF::DeriveKeyL().

Parameters

const TPBPassword & aPasswordThe users password.

NewL(const TPBPassword &, TPBECipher)

IMPORT_C CPBEncryptSet *NewL(const TPBPassword &aPassword,
TPBECipheraCipher
)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

The symmetric key is derived from the password and a random salt using TPKCS5KDF::DeriveKeyL().

Parameters

const TPBPassword & aPasswordThe user supplied password
TPBECipher aCipherThe cipher to use

NewL(const TPBPassword &, const CPBEncryptParms &)

IMPORT_C CPBEncryptSet *NewL(const TPBPassword &aPassword,
const CPBEncryptParms &aParms
)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

The symmetric key is derived from the password using TPKCS5KDF::DeriveKeyL().

Parameters

const TPBPassword & aPasswordThe user supplied password
const CPBEncryptParms & aParmsAn encryption parameter object comprising the cipher, salt, IV, and iteration count value.

NewL(const CPBEncryptionData &, const TDesC8 &, const TPBPassword &)

IMPORT_C CPBEncryptSet *NewL(const CPBEncryptionData &aData,
const TDesC8 &aEncryptedMasterKey,
const TPBPassword &aPassword
)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

If the specified password is valid, the function regenerates the encryption key; otherwise, it leaves with KErrBadPassphrase.

leave
KErrBadPassphrase If the specified password is incorrect

Parameters

const CPBEncryptionData & aDataThe encryption data object to copy
const TDesC8 & aEncryptedMasterKeyOn return, the encrypted master key
const TPBPassword & aPasswordThe user supplied password

NewLC(const TPBPassword &)

IMPORT_C CPBEncryptSet *NewLC(const TPBPassword &aPassword)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

The returned pointer is put onto the cleanup stack.

If strong cryptography is present, a 128 bit AES cipher is used; otherwise, for weak cryptography, a 56 bit DES cipher is used.

The symmetric key is derived from the password and a random salt using TPKCS5KDF::DeriveKeyL().

Parameters

const TPBPassword & aPasswordThe user supplied password

NewLC(const TPBPassword &, TPBECipher)

IMPORT_C CPBEncryptSet *NewLC(const TPBPassword &aPassword,
TPBECipheraCipher
)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

The returned pointer is put onto the cleanup stack.

The symmetric key is derived from the password and a random salt using TPKCS5KDF::DeriveKeyL().

Parameters

const TPBPassword & aPasswordThe user supplied password
TPBECipher aCipherThe cipher to use

NewLC(const TPBPassword &, const CPBEncryptParms &)

IMPORT_C CPBEncryptSet *NewLC(const TPBPassword &aPassword,
const CPBEncryptParms &aParms
)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

The returned pointer is put onto the cleanup stack.

The symmetric key is derived from the password using TPKCS5KDF::DeriveKeyL().

Parameters

const TPBPassword & aPasswordThe user supplied password
const CPBEncryptParms & aParmsAn encryption parameter object comprising the cipher, salt, IV, and iteration count value.

NewLC(const CPBEncryptionData &, const TDesC8 &, const TPBPassword &)

IMPORT_C CPBEncryptSet *NewLC(const CPBEncryptionData &aData,
const TDesC8 &aEncryptedMasterKey,
const TPBPassword &aPassword
)[static]

Creates a new CPBEncryptSet object for encryption of new data (and generates an encrypted master key).

The returned pointer is put onto the cleanup stack.

If the specified password is valid, the function regenerates the encryption key; otherwise, it leaves with KErrBadPassphrase.

leave
KErrBadPassphrase If the specified password is incorrect

Parameters

const CPBEncryptionData & aDataThe encryption data object to copy
const TDesC8 & aEncryptedMasterKeyOn return, the encrypted master key
const TPBPassword & aPasswordThe user supplied password

operator=(const CPBEncryptSet &)

CPBEncryptSet &operator=(const CPBEncryptSet &)[private]

Parameters

const CPBEncryptSet &

Member Data Documentation

HBufC8 * iEncryptedMasterKey

HBufC8 *iEncryptedMasterKey[protected]

The derived encrypted master key