|
1 /* |
|
2 * Copyright (c) 2006-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 * Random generator interface |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @publishedPartner |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __CRYPTOAPI_RANDOMPLUGIN_H__ |
|
27 #define __CRYPTOAPI_RANDOMPLUGIN_H__ |
|
28 |
|
29 #include <cryptospi/cryptoplugin.h> |
|
30 |
|
31 namespace CryptoSpi |
|
32 { |
|
33 /** |
|
34 A cryptographically secure pseudo-random number generator (CSPRNG) |
|
35 Generates random numbers derived from entropy obtained from another |
|
36 source, usually a hardware random number generator or if unavailable, |
|
37 from a combination variety of unpredictable system variables, added |
|
38 to an entropy pool which is used for seeding. This might include |
|
39 keypresses generated by a user, hardware interrupts, etc. |
|
40 */ |
|
41 class MRandom : public MPlugin |
|
42 { |
|
43 public: |
|
44 /** |
|
45 Generate enough random bytes to fill the supplied descriptor |
|
46 If there is not enough entropy available, or another error |
|
47 occurs (e.g. out of memory) then this method may leave. |
|
48 @param aDest The returned generated random bytes |
|
49 */ |
|
50 virtual void GenerateRandomBytesL(TDes8& aDest) = 0; |
|
51 }; |
|
52 |
|
53 |
|
54 class MAsyncRandom : public MPlugin |
|
55 { |
|
56 public: |
|
57 /** |
|
58 Generate enough random bytes to fill the supplied descriptor |
|
59 If there is not enough entropy available, or another error |
|
60 occurs (e.g. out of memory) then this method may leave. |
|
61 @param aDest The returned generated random bytes |
|
62 */ |
|
63 virtual void GenerateRandomBytesL(TDes8& aDest, TRequestStatus& aStatus) = 0; |
|
64 |
|
65 /** |
|
66 Cancel an outstanding request |
|
67 */ |
|
68 virtual void Cancel() = 0; |
|
69 }; |
|
70 |
|
71 } |
|
72 |
|
73 #endif // __CRYPTOAPI_RANDOMPLUGIN_H__ |