Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
p6random.h
Go to the documentation of this file.
1 
10 #ifndef P6RANDOM_H__
11 #define P6RANDOM_H__ 1
12 
13 #include "p6entropy.h"
14 
15 namespace P6R {
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
31 const P6RANDFLAGS P6RAND_NOFLAGS = 0x00000000;
32 const P6RANDFLAGS P6RAND_TRACEON = 0x00000001;
33 
34 
35 interface p6IRandomInit : public p6ICom
36 {
56  P6COMMETHOD initialize( P6RANDFLAGS flags, p6IEntropySource* pSource ) = 0;
57 
58 };
59 
60 /*{DCDA7529-475E-ED58-D81E-B9AE78496939}*/
61 #define IF_p6IRandomInit {0xDCDA7529,0x475E,0xED58,{0xD8,0x1E,0xB9,0xAE,0x78,0x49,0x69,0x39}};
62 
63 
70 interface p6IRandom : public p6ICom
71 {
86  P6COMMETHOD genRandomBytes( P6UCHAR* pBuffer, P6UINT32 cBuffer ) = 0;
87 
98  P6COMMETHOD reSeed() = 0;
99 
116  P6COMMETHOD getQuality(P6ENTROPYFLAGS *pQuality) = 0;
117 
118 };
119 
120 // {5A77D043-2FB1-4834-AE30-3F2B5678607A}
121 #define IF_p6IRandom {0x5A77D043,0x2FB1,0x4834,{0xAE,0x30,0x3F,0x2B,0x56,0x78,0x60,0x7A}}
122 
123 // {AD16A285-9FF3-4CFF-A190-E3E06B9D0B4C}
124 #define COMP_p6Random {0xAD16A285,0x9FF3,0x4CFF,{0xA1,0x90,0xE3,0xE0,0x6B,0x9D,0x0B,0x4C}}
125 
126 #define P6_ENTROPY_SERVICE_INTERFACE "p6r.com.entropy.service"
127 
157 //interface p6IEntropyService : p6ICom
158 //{
159 // /**
160 // * Retrieves the specified number of random bytes. If there is not sufficient entropy in the pool, this method
161 // * will block until enough entropy has been gather to fulfill the request.
162 // *
163 // * @param pBuffer [ out ] A pointer to a buffer in which the generated number sequence will be written.
164 // * @param cBuffer [ in ] The size (in bytes) of the buffer pointed to by pBuffer.
165 // *
166 // * @return <table class="p6err">
167 // * <tr class='P6ERR'><td>Success</td><td>P6R::eOk</td><td>&nbsp;</td></tr>
168 // * <tr class='P6ERR'><td rowspan='3' valign="top">Failure</td><td>P6R::eNotInitialized</td><td>A successful call to initialize() must be made before this function can be called.</td></tr>
169 // * <tr class='P6ERR'> <td>P6R::eInvalidArg</td><td></td>pBuffer is NULL or cBuffer is zero.</tr>
170 // * <tr class='P6ERR'> <td>P6R::eFailAndException</td><td>Random number generation failed. Exception record provides detailed error info.</td></tr>
171 // * </table>
172 // */
173 // P6COMMETHOD genRandomBytes( P6UCHAR* pBuffer, P6UINT32 cBuffer ) = 0;
174 //
175 // /**
176 // * Get the entropy quality that the PRNG's entropy
177 // * source was created with. Some platforms provide
178 // * entropy sources of different quality. This is
179 // * useful if you do not want to use a PRNG seeded
180 // * using a low quality entropy source. You are able
181 // * to deletect that using this method and create
182 // * your own p6IRandom with an entropy source of your
183 // * choosing.
184 // *
185 // * @param pQuality [ out ] The address of a P6ENTROPYFLAGS which on
186 // * return wil contain the entropy quality used to seed
187 // * the services PRNG.
188 // *
189 // * @return
190 // */
191 // P6COMMETHOD getQuality(P6ENTROPYFLAGS *pQuality) = 0;
192 //};
193 //
195 //#define IF_p6IEntropyService {0x89A540C4,0x7794,0x4DE3,{0x8B,0x5A,0x2F,0xAA,0x54,0xE1,0x7D,0xDF}}
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 } // namespace
202 
203 #endif
204 
unsigned char P6UCHAR
Definition: p6types.h:74
unsigned int P6UINT32
Definition: p6types.h:40
virtual P6R::P6ERR getQuality(P6ENTROPYFLAGS *pQuality)=0
Get the entropy quality that the PRNG&#39;s entropy source was created with.
P6UINT32 P6ENTROPYFLAGS
P6ENTROPYFLAGS.
Definition: p6entropy.h:41
const P6RANDFLAGS P6RAND_NOFLAGS
Definition: p6random.h:31
virtual P6R::P6ERR genRandomBytes(P6UCHAR *pBuffer, P6UINT32 cBuffer)=0
Retrieves the specified number of random bytes.
virtual P6R::P6ERR reSeed()=0
This method is used to re-seed the RNG.
The base interface all [p6]COM components must derive from and implement.
Definition: p6comdef.h:96
virtual P6R::P6ERR initialize(P6RANDFLAGS flags, p6IEntropySource *pSource)=0
Initialize and seed the random number generator (RNG).
Provides a cryptographically strong random number generator.
Definition: p6random.h:70
P6UINT32 P6RANDFLAGS
P6RANDFLAGS.
Definition: p6random.h:30
This is a plugin interface for the customer of the ICrypto interface to enhance the built in entropy ...
Definition: p6entropy.h:58
#define P6COMMETHOD
Definition: p6types.h:872
const P6RANDFLAGS P6RAND_TRACEON
Definition: p6random.h:32
Interface definition for 3rd parties to provide separate entropy implementations. ...