155 |
155 |
156 CSystemRandom* rand = CSystemRandom::NewLC(); |
156 CSystemRandom* rand = CSystemRandom::NewLC(); |
157 HBufC8* saltc = HBufC8::NewMaxLC(16); |
157 HBufC8* saltc = HBufC8::NewMaxLC(16); |
158 TPtr8 salt(saltc->Des()); |
158 TPtr8 salt(saltc->Des()); |
159 salt.FillZ(); |
159 salt.FillZ(); |
160 rand->GenerateBytesL(salt); |
160 TRAPD(err, rand->GenerateBytesL(salt)); |
|
161 if((err != KErrNone) && (err != KErrNotSecure)) |
|
162 User::Leave(err); |
161 |
163 |
162 HBufC8* ivc = HBufC8::NewMaxLC(8); |
164 HBufC8* ivc = HBufC8::NewMaxLC(8); |
163 |
165 |
164 TPtr8 iv(ivc->Des()); |
166 TPtr8 iv(ivc->Des()); |
165 iv.FillZ(); |
167 iv.FillZ(); |
227 |
229 |
228 CSystemRandom* rand = CSystemRandom::NewLC(); |
230 CSystemRandom* rand = CSystemRandom::NewLC(); |
229 HBufC8* saltc = HBufC8::NewMaxLC(16); |
231 HBufC8* saltc = HBufC8::NewMaxLC(16); |
230 TPtr8 salt(saltc->Des()); |
232 TPtr8 salt(saltc->Des()); |
231 salt.FillZ(); |
233 salt.FillZ(); |
232 rand->GenerateBytesL(salt); |
234 TRAPD(err, rand->GenerateBytesL(salt)); |
|
235 if((err != KErrNone) && (err != KErrNotSecure)) |
|
236 User::Leave(err); |
233 |
237 |
234 HBufC8* ivc = HBufC8::NewMaxLC(8); |
238 HBufC8* ivc = HBufC8::NewMaxLC(8); |
235 |
239 |
236 TPtr8 iv(ivc->Des()); |
240 TPtr8 iv(ivc->Des()); |
237 iv.FillZ(); |
241 iv.FillZ(); |
238 rand->GenerateBytesL(iv); |
242 TRAP(err, rand->GenerateBytesL(iv)); |
|
243 if((err != KErrNone) && (err != KErrNotSecure)) |
|
244 User::Leave(err); |
239 |
245 |
240 CPBEncryptParms* params = CPBEncryptParms::NewLC(ECipher3DES_CBC, salt, iv, 2048); |
246 CPBEncryptParms* params = CPBEncryptParms::NewLC(ECipher3DES_CBC, salt, iv, 2048); |
241 CPBEncryptElement* encryptElement = CPBEncryptElement::NewLC(pass, *params); |
247 CPBEncryptElement* encryptElement = CPBEncryptElement::NewLC(pass, *params); |
242 CPBEncryptor* encryptor = encryptElement->NewEncryptLC(); |
248 CPBEncryptor* encryptor = encryptElement->NewEncryptLC(); |
243 |
249 |