102 // Create default PBE paramenters |
103 // Create default PBE paramenters |
103 CSystemRandom* rand = CSystemRandom::NewLC(); |
104 CSystemRandom* rand = CSystemRandom::NewLC(); |
104 HBufC8* saltc = HBufC8::NewMaxLC(KDefaultSaltSize); |
105 HBufC8* saltc = HBufC8::NewMaxLC(KDefaultSaltSize); |
105 TPtr8 salt(saltc->Des()); |
106 TPtr8 salt(saltc->Des()); |
106 salt.FillZ(); |
107 salt.FillZ(); |
107 rand->GenerateBytesL(salt); |
108 TRAPD(err, rand->GenerateBytesL(salt)); |
|
109 if((err != KErrNone) && (err != KErrNotSecure)) |
|
110 User::Leave(err); |
108 |
111 |
109 HBufC8* ivc = HBufC8::NewMaxLC(KDESBlockBytes); |
112 HBufC8* ivc = HBufC8::NewMaxLC(KDESBlockBytes); |
110 |
113 |
111 TPtr8 iv(ivc->Des()); |
114 TPtr8 iv(ivc->Des()); |
112 iv.FillZ(); |
115 iv.FillZ(); |
113 rand->GenerateBytesL(iv); |
116 TRAP(err, rand->GenerateBytesL(iv)); |
|
117 if((err != KErrNone) && (err != KErrNotSecure)) |
|
118 User::Leave(err); |
114 |
119 |
115 ASSERT(!iPbeParams); |
120 ASSERT(!iPbeParams); |
116 iPbeParams = CPBEncryptParms::NewL(ECipherDES_CBC, salt, iv, 2048); |
121 iPbeParams = CPBEncryptParms::NewL(ECipherDES_CBC, salt, iv, 2048); |
117 |
122 |
118 CleanupStack::PopAndDestroy(3, rand); // rand, saltc, ivc |
123 CleanupStack::PopAndDestroy(3, rand); // rand, saltc, ivc |