29 #include <cryptospi/cryptoplugin.h> |
29 #include <cryptospi/cryptoplugin.h> |
30 |
30 |
31 namespace CryptoSpi |
31 namespace CryptoSpi |
32 { |
32 { |
33 /** |
33 /** |
34 A cryptographically secure pseudo-random number generator (CSPRNG) |
34 A pseudo-random number generator (PRNG). |
35 Generates random numbers derived from entropy obtained from another |
35 Generates random numbers derived from entropy obtained from another |
36 source, usually a hardware random number generator or if unavailable, |
36 source, usually a hardware random number generator or if unavailable, |
37 from a combination variety of unpredictable system variables, added |
37 from a combination variety of unpredictable system variables, added |
38 to an entropy pool which is used for seeding. This might include |
38 to an entropy pool which is used for seeding. This might include |
39 keypresses generated by a user, hardware interrupts, etc. |
39 keypresses generated by a user, hardware interrupts, etc. |
40 */ |
40 */ |
41 class MRandom : public MPlugin |
41 class MRandom : public MPlugin |
42 { |
42 { |
43 public: |
43 public: |
44 /** |
44 /** |
45 Generate enough random bytes to fill the supplied descriptor |
45 * Implementations of this method should fill the passed |
46 If there is not enough entropy available, or another error |
46 * buffer with the generated pseudo-random data up to the |
47 occurs (e.g. out of memory) then this method may leave. |
47 * current length, discarding any current contents. The |
48 @param aDest The returned generated random bytes |
48 * implementations should leave with KErrNotSecure when |
49 */ |
49 * the generated random data is not secure enough. |
|
50 * |
|
51 * @param aDest The buffer to fill with random data |
|
52 * @leave KErrNotSecure Random data generated is not |
|
53 * secure enough for crytographic operations |
|
54 * otherwise, leaves with any other system wide error code. |
|
55 * |
|
56 */ |
50 virtual void GenerateRandomBytesL(TDes8& aDest) = 0; |
57 virtual void GenerateRandomBytesL(TDes8& aDest) = 0; |
51 }; |
58 }; |
52 |
59 |
53 |
60 |
54 class MAsyncRandom : public MPlugin |
61 class MAsyncRandom : public MPlugin |
55 { |
62 { |
56 public: |
63 public: |
57 /** |
64 /** |
58 Generate enough random bytes to fill the supplied descriptor |
65 * Implementations of this method should fill the passed |
59 If there is not enough entropy available, or another error |
66 * buffer with the generated pseudo-random data up to the |
60 occurs (e.g. out of memory) then this method may leave. |
67 * current length, discarding any current contents. The |
61 @param aDest The returned generated random bytes |
68 * implementations should leave with KErrNotSecure when |
62 */ |
69 * the generated random data is not secure enough. |
|
70 * |
|
71 * @param aDest The buffer to fill with random data |
|
72 * @param aStatus The argument to carry the asynchonous request completion |
|
73 * status to notify the client when buffer is filled with random data. |
|
74 * @leave KErrNotSecure Random data generated is not |
|
75 * secure enough for crytographic operations |
|
76 * otherwise, leaves with any other system wide error code. |
|
77 * |
|
78 */ |
63 virtual void GenerateRandomBytesL(TDes8& aDest, TRequestStatus& aStatus) = 0; |
79 virtual void GenerateRandomBytesL(TDes8& aDest, TRequestStatus& aStatus) = 0; |
64 |
80 |
65 /** |
81 /** |
66 Cancel an outstanding request |
82 Cancel an outstanding request |
67 */ |
83 */ |