Codebase list openssl / 39df515
Remove superfluous NULL checks. Add Andy's BN_FLG comment. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6009) Billy Brumley authored 6 years ago Matt Caswell committed 6 years ago
2 changed file(s) with 20 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
742742 a->neg ^= t;
743743 b->neg ^= t;
744744
745 /*
746 * cannot just arbitrarily swap flags.
747 * The way a->d is allocated etc.
748 * BN_FLG_MALLOCED, BN_FLG_STATIC_DATA, ...
745 /*-
746 * Idea behind BN_FLG_STATIC_DATA is actually to
747 * indicate that data may not be written to.
748 * Intention is actually to treat it as it's
749 * read-only data, and some (if not most) of it does
750 * reside in read-only segment. In other words
751 * observation of BN_FLG_STATIC_DATA in
752 * BN_consttime_swap should be treated as fatal
753 * condition. It would either cause SEGV or
754 * effectively cause data corruption.
755 * BN_FLG_MALLOCED refers to BN structure itself,
756 * and hence must be preserved. Remaining flags are
757 * BN_FLG_CONSTIME and BN_FLG_SECURE. Latter must be
758 * preserved, because it determines how x->d was
759 * allocated and hence how to free it. This leaves
760 * BN_FLG_CONSTTIME that one can do something about.
761 * To summarize it's sufficient to mask and swap
762 * BN_FLG_CONSTTIME alone. BN_FLG_STATIC_DATA should
763 * be treated as fatal.
749764 */
750 t = (a->flags ^ b->flags) & condition & BN_FLG_CONSTTIME;
765 t = ((a->flags ^ b->flags) & BN_FLG_CONSTTIME) & condition;
751766 a->flags ^= t;
752767 b->flags ^= t;
753768
141141 if (ctx == NULL && (ctx = new_ctx = BN_CTX_secure_new()) == NULL)
142142 goto err;
143143
144 if ((group->order == NULL) || (group->field == NULL))
145 goto err;
146
147144 order_bits = BN_num_bits(group->order);
148145
149146 s = EC_POINT_new(group);
151148 goto err;
152149
153150 if (point == NULL) {
154 if (group->generator == NULL)
155 goto err;
156151 if (!EC_POINT_copy(s, group->generator))
157152 goto err;
158153 } else {