|
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 |
|
28 #include "randsvr.h" |
|
29 #include "randcliserv.h" |
|
30 #include "randomshim.h" |
|
31 |
|
32 extern "C" { |
|
33 EXPORT_C void RAND_bytes(unsigned char* buf,int bytes) |
|
34 { |
|
35 TPtr8 ptr(buf,bytes,bytes); |
|
36 buf[0]++; |
|
37 TRandom::Random(ptr); |
|
38 } |
|
39 } |
|
40 |
|
41 EXPORT_C CRandom::CRandom(void) |
|
42 { |
|
43 } |
|
44 |
|
45 EXPORT_C CSystemRandom* CSystemRandom::NewL(void) |
|
46 { |
|
47 CSystemRandom* self = NewLC(); |
|
48 CleanupStack::Pop(self); |
|
49 return self; |
|
50 } |
|
51 |
|
52 EXPORT_C CSystemRandom* CSystemRandom::NewLC(void) |
|
53 { |
|
54 CSystemRandom* self = new(ELeave)CSystemRandom(); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 void CSystemRandom::GenerateBytesL(TDes8& aDest) |
|
61 { |
|
62 iShim->GenerateBytesL(aDest); |
|
63 } |
|
64 |
|
65 CSystemRandom::CSystemRandom(void) |
|
66 { |
|
67 } |
|
68 |
|
69 CSystemRandom::~CSystemRandom() |
|
70 { |
|
71 delete iShim; |
|
72 } |
|
73 |
|
74 void CSystemRandom::ConstructL() |
|
75 { |
|
76 iShim = CRandomShim::NewL(); |
|
77 } |
|
78 |
|
79 // Methods replace by shim are excluded from coverage. |
|
80 #ifdef _BullseyeCoverage |
|
81 #pragma suppress_warnings on |
|
82 #pragma BullseyeCoverage off |
|
83 #pragma suppress_warnings off |
|
84 #endif |
|
85 EXPORT_C void TRandom::Random(TDes8& aDestination) |
|
86 { |
|
87 // Method replaced by shim |
|
88 TRandomShim::Random(aDestination); |
|
89 } |
|
90 |
|
91 EXPORT_C void TRandom::RandomL(TDes8& aDestination) |
|
92 { |
|
93 // Method replaced by shim |
|
94 TRandomShim::RandomL(aDestination); |
|
95 } |
|
96 |
|
97 EXPORT_C RRandomSession::RRandomSession(void) |
|
98 { |
|
99 } |
|
100 |
|
101 EXPORT_C void RRandomSession::ConnectL(void) |
|
102 { |
|
103 // All of the ConnectL() code has moved to randomimpl.cpp |
|
104 // in the new CryptoSPI pluggable framework. This is just |
|
105 // a stub now that is retained for binary compatibility. |
|
106 |
|
107 // Method replaced by shim |
|
108 ASSERT(EFalse); |
|
109 } |
|
110 |
|
111 EXPORT_C TInt RRandomSession::GetRandom(TDes8& aDestination) |
|
112 { |
|
113 // Method replaced by shim |
|
114 TRandomShim::Random(aDestination); |
|
115 return KErrNone; |
|
116 } |
|
117 |