Codebase list openssl / 1b25dc0
Use order not degree to calculate a buffer size in ecdsatest Otherwise this can result in an incorrect calculation of the maximum encoded integer length, meaning an insufficient buffer size is allocated. Thanks to Billy Brumley for helping to track this down. Fixes #8209 Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8237) (cherry picked from commit 9fc8f18f59f4a4c853466dca64a23b8af681bf1c) Matt Caswell 5 years ago
1 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
222222 const BIGNUM *sig_r, *sig_s;
223223 BIGNUM *modified_r = NULL, *modified_s = NULL;
224224 BIGNUM *unmodified_r = NULL, *unmodified_s = NULL;
225 unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len;
225 unsigned int sig_len, order, r_len, s_len, bn_len, buf_len;
226226 int nid, ret = 0;
227227
228228 /* fill digest values with some random data */
250250 || !TEST_true(EC_KEY_set_group(eckey, group)))
251251 goto builtin_err;
252252 EC_GROUP_free(group);
253 degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey));
253 order = EC_GROUP_order_bits(EC_KEY_get0_group(eckey));
254254
255255 TEST_info("testing %s", OBJ_nid2sn(nid));
256256
315315 /* Store the two BIGNUMs in raw_buf. */
316316 r_len = BN_num_bytes(sig_r);
317317 s_len = BN_num_bytes(sig_s);
318 bn_len = (degree + 7) / 8;
318 bn_len = (order + 7) / 8;
319319 if (!TEST_false(r_len > bn_len)
320320 || !TEST_false(s_len > bn_len))
321321 goto builtin_err;