crypto/weakcryptospi/source/bigint/bigint.cpp
branchRCL_3
changeset 43 9b5a3a9fddf8
parent 17 cd501b96611d
child 72 de46a57f75fb
equal deleted inserted replaced
34:721a5e5fe251 43:9b5a3a9fddf8
   803 	const TUint bytes = BitsToBytes(aBits);
   803 	const TUint bytes = BitsToBytes(aBits);
   804 	const TUint words = BitsToWords(aBits);
   804 	const TUint words = BitsToWords(aBits);
   805 	CleanGrowL(words);
   805 	CleanGrowL(words);
   806 	TPtr8 buf((TUint8*)(Ptr()), bytes, WordsToBytes(Size()));
   806 	TPtr8 buf((TUint8*)(Ptr()), bytes, WordsToBytes(Size()));
   807 	TUint bitpos = aBits % BYTE_BITS;
   807 	TUint bitpos = aBits % BYTE_BITS;
   808 	GenerateRandomBytesL(buf);
   808 	TRAPD(err, GenerateRandomBytesL(buf));
       
   809 	if((err != KErrNone) && (err != KErrNotSecure))
       
   810 	    User::Leave(err);
   809 	//mask with 0 all bits above the num requested in the most significant byte
   811 	//mask with 0 all bits above the num requested in the most significant byte
   810 	if(bitpos)
   812 	if(bitpos)
   811 		{
   813 		{
   812 		buf[bytes-1] = TUint8( buf[bytes-1] & ((1L << bitpos) - 1) );
   814 		buf[bytes-1] = TUint8( buf[bytes-1] & ((1L << bitpos) - 1) );
   813 		}
   815 		}