sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "tutils.h"
|
sl@0
|
20 |
#include <bigint.h>
|
sl@0
|
21 |
#include "t_output.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
void Utils::DumpInteger(Output& aOut, const TDesC& aDesc,
|
sl@0
|
24 |
const RInteger& aThat)
|
sl@0
|
25 |
{
|
sl@0
|
26 |
aOut.writeString(aDesc);
|
sl@0
|
27 |
HBufC8* buf = aThat.BufferLC();
|
sl@0
|
28 |
aOut.writeOctetString(*buf);
|
sl@0
|
29 |
aOut.writeNewLine();
|
sl@0
|
30 |
CleanupStack::PopAndDestroy(buf);
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
|
sl@0
|
34 |
/* CRandomSetSource */
|
sl@0
|
35 |
CRandomSetSource::CRandomSetSource(const TDesC8& aSource)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
SetSource(aSource);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
void CRandomSetSource::GenerateBytesL(TDes8& aDest)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
TInt i=0;
|
sl@0
|
43 |
//Reverse the string by bytes up to the point of the end of the given string
|
sl@0
|
44 |
//of "random" bytes.
|
sl@0
|
45 |
for (i=0; iCounter >= 0 && i< aDest.Length(); ++i,--iCounter)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
aDest[i] = iValue[iCounter];
|
sl@0
|
48 |
}
|
sl@0
|
49 |
//Then fill the remaining (if any) bytes in aDest with 0's. This is all to
|
sl@0
|
50 |
//allow the stuff to work with bigint style integers; we're writing straight
|
sl@0
|
51 |
//into a RInteger.Ptr() here
|
sl@0
|
52 |
for(;i<aDest.Length(); ++i)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
aDest[i] = 0x00;
|
sl@0
|
55 |
}
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
void CRandomSetSource::SetSource(const TDesC8& aSource)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
iValue.Set(aSource);
|
sl@0
|
61 |
Reset();
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
void CRandomSetSource::Reset(void)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
iCounter = iValue.Length() - 1;
|
sl@0
|
67 |
}
|