diff options
Diffstat (limited to 'include/crypto/drbg.h')
-rw-r--r-- | include/crypto/drbg.h | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h index a43a7ed4d9fc..480d7a0f4dac 100644 --- a/include/crypto/drbg.h +++ b/include/crypto/drbg.h | |||
@@ -121,7 +121,7 @@ struct drbg_state { | |||
121 | #endif | 121 | #endif |
122 | const struct drbg_state_ops *d_ops; | 122 | const struct drbg_state_ops *d_ops; |
123 | const struct drbg_core *core; | 123 | const struct drbg_core *core; |
124 | struct drbg_test_data *test_data; | 124 | struct drbg_string test_data; |
125 | }; | 125 | }; |
126 | 126 | ||
127 | static inline __u8 drbg_statelen(struct drbg_state *drbg) | 127 | static inline __u8 drbg_statelen(struct drbg_state *drbg) |
@@ -177,19 +177,8 @@ static inline size_t drbg_max_requests(struct drbg_state *drbg) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | /* | 179 | /* |
180 | * kernel crypto API input data structure for DRBG generate in case dlen | ||
181 | * is set to 0 | ||
182 | */ | ||
183 | struct drbg_gen { | ||
184 | unsigned char *outbuf; /* output buffer for random numbers */ | ||
185 | unsigned int outlen; /* size of output buffer */ | ||
186 | struct drbg_string *addtl; /* additional information string */ | ||
187 | struct drbg_test_data *test_data; /* test data */ | ||
188 | }; | ||
189 | |||
190 | /* | ||
191 | * This is a wrapper to the kernel crypto API function of | 180 | * This is a wrapper to the kernel crypto API function of |
192 | * crypto_rng_get_bytes() to allow the caller to provide additional data. | 181 | * crypto_rng_generate() to allow the caller to provide additional data. |
193 | * | 182 | * |
194 | * @drng DRBG handle -- see crypto_rng_get_bytes | 183 | * @drng DRBG handle -- see crypto_rng_get_bytes |
195 | * @outbuf output buffer -- see crypto_rng_get_bytes | 184 | * @outbuf output buffer -- see crypto_rng_get_bytes |
@@ -204,21 +193,15 @@ static inline int crypto_drbg_get_bytes_addtl(struct crypto_rng *drng, | |||
204 | unsigned char *outbuf, unsigned int outlen, | 193 | unsigned char *outbuf, unsigned int outlen, |
205 | struct drbg_string *addtl) | 194 | struct drbg_string *addtl) |
206 | { | 195 | { |
207 | int ret; | 196 | return crypto_rng_generate(drng, addtl->buf, addtl->len, |
208 | struct drbg_gen genbuf; | 197 | outbuf, outlen); |
209 | genbuf.outbuf = outbuf; | ||
210 | genbuf.outlen = outlen; | ||
211 | genbuf.addtl = addtl; | ||
212 | genbuf.test_data = NULL; | ||
213 | ret = crypto_rng_get_bytes(drng, (u8 *)&genbuf, 0); | ||
214 | return ret; | ||
215 | } | 198 | } |
216 | 199 | ||
217 | /* | 200 | /* |
218 | * TEST code | 201 | * TEST code |
219 | * | 202 | * |
220 | * This is a wrapper to the kernel crypto API function of | 203 | * This is a wrapper to the kernel crypto API function of |
221 | * crypto_rng_get_bytes() to allow the caller to provide additional data and | 204 | * crypto_rng_generate() to allow the caller to provide additional data and |
222 | * allow furnishing of test_data | 205 | * allow furnishing of test_data |
223 | * | 206 | * |
224 | * @drng DRBG handle -- see crypto_rng_get_bytes | 207 | * @drng DRBG handle -- see crypto_rng_get_bytes |
@@ -236,14 +219,10 @@ static inline int crypto_drbg_get_bytes_addtl_test(struct crypto_rng *drng, | |||
236 | struct drbg_string *addtl, | 219 | struct drbg_string *addtl, |
237 | struct drbg_test_data *test_data) | 220 | struct drbg_test_data *test_data) |
238 | { | 221 | { |
239 | int ret; | 222 | crypto_rng_set_entropy(drng, test_data->testentropy->buf, |
240 | struct drbg_gen genbuf; | 223 | test_data->testentropy->len); |
241 | genbuf.outbuf = outbuf; | 224 | return crypto_rng_generate(drng, addtl->buf, addtl->len, |
242 | genbuf.outlen = outlen; | 225 | outbuf, outlen); |
243 | genbuf.addtl = addtl; | ||
244 | genbuf.test_data = test_data; | ||
245 | ret = crypto_rng_get_bytes(drng, (u8 *)&genbuf, 0); | ||
246 | return ret; | ||
247 | } | 226 | } |
248 | 227 | ||
249 | /* | 228 | /* |
@@ -264,14 +243,9 @@ static inline int crypto_drbg_reset_test(struct crypto_rng *drng, | |||
264 | struct drbg_string *pers, | 243 | struct drbg_string *pers, |
265 | struct drbg_test_data *test_data) | 244 | struct drbg_test_data *test_data) |
266 | { | 245 | { |
267 | int ret; | 246 | crypto_rng_set_entropy(drng, test_data->testentropy->buf, |
268 | struct drbg_gen genbuf; | 247 | test_data->testentropy->len); |
269 | genbuf.outbuf = NULL; | 248 | return crypto_rng_reset(drng, pers->buf, pers->len); |
270 | genbuf.outlen = 0; | ||
271 | genbuf.addtl = pers; | ||
272 | genbuf.test_data = test_data; | ||
273 | ret = crypto_rng_reset(drng, (u8 *)&genbuf, 0); | ||
274 | return ret; | ||
275 | } | 249 | } |
276 | 250 | ||
277 | /* DRBG type flags */ | 251 | /* DRBG type flags */ |