|
@@ -151,6 +151,7 @@ int drbg_instantiate ( struct drbg_state *state, const void *personal,
|
151
|
151
|
* in-situ.)
|
152
|
152
|
*/
|
153
|
153
|
state->reseed_required = 0;
|
|
154
|
+ state->valid = 1;
|
154
|
155
|
|
155
|
156
|
/* 12. Return SUCCESS and state_handle. */
|
156
|
157
|
return 0;
|
|
@@ -187,9 +188,13 @@ int drbg_reseed ( struct drbg_state *state, const void *additional,
|
187
|
188
|
* If state_handle indicates an invalid or empty internal
|
188
|
189
|
* state, return an ERROR_FLAG.
|
189
|
190
|
*
|
190
|
|
- * (Nothing to do since the memory holding the internal state
|
191
|
|
- * was passed in by the caller.)
|
|
191
|
+ * (Almost nothing to do since the memory holding the internal
|
|
192
|
+ * state was passed in by the caller.)
|
192
|
193
|
*/
|
|
194
|
+ if ( ! state->valid ) {
|
|
195
|
+ DBGC ( state, "DRBG %p not valid\n", state );
|
|
196
|
+ return -EINVAL;
|
|
197
|
+ }
|
193
|
198
|
|
194
|
199
|
/* 2. If prediction_resistance_request is set, and
|
195
|
200
|
* prediction_resistance_flag is not set, then return an
|
|
@@ -273,9 +278,13 @@ int drbg_generate ( struct drbg_state *state, const void *additional,
|
273
|
278
|
* for the instantiation. If state_handle indicates an
|
274
|
279
|
* invalid or empty internal state, then return an ERROR_FLAG.
|
275
|
280
|
*
|
276
|
|
- * (Nothing to do since the memory holding the internal state
|
277
|
|
- * was passed in by the caller.)
|
|
281
|
+ * (Almost nothing to do since the memory holding the internal
|
|
282
|
+ * state was passed in by the caller.)
|
278
|
283
|
*/
|
|
284
|
+ if ( ! state->valid ) {
|
|
285
|
+ DBGC ( state, "DRBG %p not valid\n", state );
|
|
286
|
+ return -EINVAL;
|
|
287
|
+ }
|
279
|
288
|
|
280
|
289
|
/* 2. If requested_number_of_bits >
|
281
|
290
|
* max_number_of_bits_per_request, then return an
|