sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006-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 |
* Random generator interface
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@publishedPartner
|
sl@0
|
23 |
@released
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __CRYPTOAPI_RANDOMPLUGIN_H__
|
sl@0
|
27 |
#define __CRYPTOAPI_RANDOMPLUGIN_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <cryptospi/cryptoplugin.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
namespace CryptoSpi
|
sl@0
|
32 |
{
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
A pseudo-random number generator (PRNG).
|
sl@0
|
35 |
Generates random numbers derived from entropy obtained from another
|
sl@0
|
36 |
source, usually a hardware random number generator or if unavailable,
|
sl@0
|
37 |
from a combination variety of unpredictable system variables, added
|
sl@0
|
38 |
to an entropy pool which is used for seeding. This might include
|
sl@0
|
39 |
keypresses generated by a user, hardware interrupts, etc.
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
class MRandom : public MPlugin
|
sl@0
|
42 |
{
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
/**
|
sl@0
|
45 |
* Implementations of this method should fill the passed
|
sl@0
|
46 |
* buffer with the generated pseudo-random data up to the
|
sl@0
|
47 |
* current length, discarding any current contents. The
|
sl@0
|
48 |
* implementations should leave with KErrNotSecure when
|
sl@0
|
49 |
* the generated random data is not secure enough.
|
sl@0
|
50 |
*
|
sl@0
|
51 |
* @param aDest The buffer to fill with random data
|
sl@0
|
52 |
* @leave KErrNotSecure Random data generated is not
|
sl@0
|
53 |
* secure enough for crytographic operations
|
sl@0
|
54 |
* otherwise, leaves with any other system wide error code.
|
sl@0
|
55 |
*
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
virtual void GenerateRandomBytesL(TDes8& aDest) = 0;
|
sl@0
|
58 |
};
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
class MAsyncRandom : public MPlugin
|
sl@0
|
62 |
{
|
sl@0
|
63 |
public:
|
sl@0
|
64 |
/**
|
sl@0
|
65 |
* Implementations of this method should fill the passed
|
sl@0
|
66 |
* buffer with the generated pseudo-random data up to the
|
sl@0
|
67 |
* current length, discarding any current contents. The
|
sl@0
|
68 |
* implementations should leave with KErrNotSecure when
|
sl@0
|
69 |
* the generated random data is not secure enough.
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* @param aDest The buffer to fill with random data
|
sl@0
|
72 |
* @param aStatus The argument to carry the asynchonous request completion
|
sl@0
|
73 |
* status to notify the client when buffer is filled with random data.
|
sl@0
|
74 |
* @leave KErrNotSecure Random data generated is not
|
sl@0
|
75 |
* secure enough for crytographic operations
|
sl@0
|
76 |
* otherwise, leaves with any other system wide error code.
|
sl@0
|
77 |
*
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
virtual void GenerateRandomBytesL(TDes8& aDest, TRequestStatus& aStatus) = 0;
|
sl@0
|
80 |
|
sl@0
|
81 |
/**
|
sl@0
|
82 |
Cancel an outstanding request
|
sl@0
|
83 |
*/
|
sl@0
|
84 |
virtual void Cancel() = 0;
|
sl@0
|
85 |
};
|
sl@0
|
86 |
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
#endif // __CRYPTOAPI_RANDOMPLUGIN_H__
|