author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Sat, 20 Feb 2010 00:36:18 +0200 | |
branch | RCL_3 |
changeset 41 | 9b5a3a9fddf8 |
parent 19 | cd501b96611d |
child 44 | d07aa956024a |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
/** |
|
20 |
@file |
|
21 |
*/ |
|
22 |
||
23 |
#include <e32std.h> |
|
24 |
#include <e32math.h> |
|
25 |
#include <random.h> |
|
26 |
#include <hash.h> |
|
27 |
#include "randomshim.h" |
|
28 |
||
29 |
extern "C" { |
|
30 |
EXPORT_C void RAND_bytes(unsigned char* buf,int bytes) |
|
31 |
{ |
|
32 |
TPtr8 ptr(buf,bytes,bytes); |
|
33 |
buf[0]++; |
|
34 |
TRandom::Random(ptr); |
|
35 |
} |
|
36 |
} |
|
37 |
||
38 |
EXPORT_C CRandom::CRandom(void) |
|
39 |
{ |
|
40 |
} |
|
41 |
||
42 |
EXPORT_C CSystemRandom* CSystemRandom::NewL(void) |
|
43 |
{ |
|
44 |
CSystemRandom* self = NewLC(); |
|
45 |
CleanupStack::Pop(self); |
|
46 |
return self; |
|
47 |
} |
|
48 |
||
49 |
EXPORT_C CSystemRandom* CSystemRandom::NewLC(void) |
|
50 |
{ |
|
51 |
CSystemRandom* self = new(ELeave)CSystemRandom(); |
|
52 |
CleanupStack::PushL(self); |
|
53 |
self->ConstructL(); |
|
54 |
return self; |
|
55 |
} |
|
56 |
||
57 |
void CSystemRandom::GenerateBytesL(TDes8& aDest) |
|
58 |
{ |
|
59 |
iShim->GenerateBytesL(aDest); |
|
60 |
} |
|
61 |
||
62 |
CSystemRandom::CSystemRandom(void) |
|
63 |
{ |
|
64 |
} |
|
65 |
||
66 |
CSystemRandom::~CSystemRandom() |
|
67 |
{ |
|
68 |
delete iShim; |
|
69 |
} |
|
70 |
||
71 |
void CSystemRandom::ConstructL() |
|
72 |
{ |
|
73 |
iShim = CRandomShim::NewL(); |
|
74 |
} |
|
75 |
||
76 |
// Methods replace by shim are excluded from coverage. |
|
77 |
#ifdef _BullseyeCoverage |
|
78 |
#pragma suppress_warnings on |
|
79 |
#pragma BullseyeCoverage off |
|
80 |
#pragma suppress_warnings off |
|
81 |
#endif |
|
82 |
EXPORT_C void TRandom::Random(TDes8& aDestination) |
|
83 |
{ |
|
84 |
// Method replaced by shim |
|
85 |
TRandomShim::Random(aDestination); |
|
86 |
} |
|
87 |
||
88 |
EXPORT_C void TRandom::RandomL(TDes8& aDestination) |
|
89 |
{ |
|
90 |
// Method replaced by shim |
|
91 |
TRandomShim::RandomL(aDestination); |
|
92 |
} |
|
41
9b5a3a9fddf8
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
93 |
|
9b5a3a9fddf8
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
94 |
EXPORT_C void TRandom::SecureRandomL(TDes8& aDestination) |
9b5a3a9fddf8
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
95 |
{ |
9b5a3a9fddf8
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
96 |
// Method replaced by shim |
9b5a3a9fddf8
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
97 |
TRandomShim::SecureRandomL(aDestination); |
9b5a3a9fddf8
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
98 |
} |
19 | 99 |
|
100 |
EXPORT_C RRandomSession::RRandomSession(void) |
|
101 |
{ |
|
102 |
} |
|
103 |
||
104 |
EXPORT_C void RRandomSession::ConnectL(void) |
|
105 |
{ |
|
106 |
// All of the ConnectL() code has moved to randomimpl.cpp |
|
107 |
// in the new CryptoSPI pluggable framework. This is just |
|
108 |
// a stub now that is retained for binary compatibility. |
|
109 |
||
110 |
// Method replaced by shim |
|
111 |
ASSERT(EFalse); |
|
112 |
} |
|
113 |
||
114 |
EXPORT_C TInt RRandomSession::GetRandom(TDes8& aDestination) |
|
115 |
{ |
|
116 |
// Method replaced by shim |
|
117 |
TRandomShim::Random(aDestination); |
|
118 |
return KErrNone; |
|
119 |
} |