diff options
author | tb <> | 2024-11-02 16:02:01 +0000 |
---|---|---|
committer | tb <> | 2024-11-02 16:02:01 +0000 |
commit | 2ae7baf0d867b1683666e0ed6a35058fd4937ea9 (patch) | |
tree | aed537c37d103549fdbea38dc269ec5bd146791d /src | |
parent | 1f030b484ee11824e7f0695edfa9eafd0efffcf0 (diff) | |
download | openbsd-2ae7baf0d867b1683666e0ed6a35058fd4937ea9.tar.gz openbsd-2ae7baf0d867b1683666e0ed6a35058fd4937ea9.tar.bz2 openbsd-2ae7baf0d867b1683666e0ed6a35058fd4937ea9.zip |
ec_convert: remove _OCT also from the macro names
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ec_convert.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/lib/libcrypto/ec/ec_convert.c b/src/lib/libcrypto/ec/ec_convert.c index f3eb6d5791..08cd922ec7 100644 --- a/src/lib/libcrypto/ec/ec_convert.c +++ b/src/lib/libcrypto/ec/ec_convert.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_convert.c,v 1.9 2024/11/01 05:20:58 tb Exp $ */ | 1 | /* $OpenBSD: ec_convert.c,v 1.10 2024/11/02 16:02:01 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -82,24 +82,24 @@ | |||
82 | * ignore it except at the API boundary. | 82 | * ignore it except at the API boundary. |
83 | */ | 83 | */ |
84 | 84 | ||
85 | #define EC_OCT_YBIT 0x01 | 85 | #define EC_YBIT 0x01 |
86 | 86 | ||
87 | #define EC_OCT_POINT_AT_INFINITY 0x00 | 87 | #define EC_POINT_AT_INFINITY 0x00 |
88 | #define EC_OCT_POINT_COMPRESSED 0x02 | 88 | #define EC_POINT_COMPRESSED 0x02 |
89 | #define EC_OCT_POINT_UNCOMPRESSED 0x04 | 89 | #define EC_POINT_UNCOMPRESSED 0x04 |
90 | #define EC_OCT_POINT_HYBRID 0x06 | 90 | #define EC_POINT_HYBRID 0x06 |
91 | #define EC_OCT_POINT_CONVERSION_MASK 0x06 | 91 | #define EC_POINT_CONVERSION_MASK 0x06 |
92 | 92 | ||
93 | static int | 93 | static int |
94 | ec_conversion_form_is_valid(uint8_t form) | 94 | ec_conversion_form_is_valid(uint8_t form) |
95 | { | 95 | { |
96 | return (form & EC_OCT_POINT_CONVERSION_MASK) == form; | 96 | return (form & EC_POINT_CONVERSION_MASK) == form; |
97 | } | 97 | } |
98 | 98 | ||
99 | static int | 99 | static int |
100 | ec_check_hybrid_ybit_is_consistent(uint8_t form, int ybit, const BIGNUM *y) | 100 | ec_check_hybrid_ybit_is_consistent(uint8_t form, int ybit, const BIGNUM *y) |
101 | { | 101 | { |
102 | if (form == EC_OCT_POINT_HYBRID && ybit != BN_is_odd(y)) { | 102 | if (form == EC_POINT_HYBRID && ybit != BN_is_odd(y)) { |
103 | ECerror(EC_R_INVALID_ENCODING); | 103 | ECerror(EC_R_INVALID_ENCODING); |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
@@ -111,14 +111,14 @@ ec_check_hybrid_ybit_is_consistent(uint8_t form, int ybit, const BIGNUM *y) | |||
111 | static int | 111 | static int |
112 | ec_nonzero_ybit_allowed(uint8_t form) | 112 | ec_nonzero_ybit_allowed(uint8_t form) |
113 | { | 113 | { |
114 | return form == EC_OCT_POINT_COMPRESSED || form == EC_OCT_POINT_HYBRID; | 114 | return form == EC_POINT_COMPRESSED || form == EC_POINT_HYBRID; |
115 | } | 115 | } |
116 | 116 | ||
117 | static int | 117 | static int |
118 | ec_add_leading_octet_cbb(CBB *cbb, uint8_t form, int ybit) | 118 | ec_add_leading_octet_cbb(CBB *cbb, uint8_t form, int ybit) |
119 | { | 119 | { |
120 | if (ec_nonzero_ybit_allowed(form) && ybit != 0) | 120 | if (ec_nonzero_ybit_allowed(form) && ybit != 0) |
121 | form |= EC_OCT_YBIT; | 121 | form |= EC_YBIT; |
122 | 122 | ||
123 | return CBB_add_u8(cbb, form); | 123 | return CBB_add_u8(cbb, form); |
124 | } | 124 | } |
@@ -133,8 +133,8 @@ ec_get_leading_octet_cbs(CBS *cbs, uint8_t *out_form, int *out_ybit) | |||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | *out_ybit = octet & EC_OCT_YBIT; | 136 | *out_ybit = octet & EC_YBIT; |
137 | *out_form = octet & ~EC_OCT_YBIT; | 137 | *out_form = octet & ~EC_YBIT; |
138 | 138 | ||
139 | if (!ec_conversion_form_is_valid(*out_form)) { | 139 | if (!ec_conversion_form_is_valid(*out_form)) { |
140 | ECerror(EC_R_INVALID_ENCODING); | 140 | ECerror(EC_R_INVALID_ENCODING); |
@@ -153,14 +153,14 @@ static int | |||
153 | ec_encoded_length(const EC_GROUP *group, uint8_t form, size_t *out_len) | 153 | ec_encoded_length(const EC_GROUP *group, uint8_t form, size_t *out_len) |
154 | { | 154 | { |
155 | switch (form) { | 155 | switch (form) { |
156 | case EC_OCT_POINT_AT_INFINITY: | 156 | case EC_POINT_AT_INFINITY: |
157 | *out_len = 1; | 157 | *out_len = 1; |
158 | return 1; | 158 | return 1; |
159 | case EC_OCT_POINT_COMPRESSED: | 159 | case EC_POINT_COMPRESSED: |
160 | *out_len = 1 + BN_num_bytes(&group->field); | 160 | *out_len = 1 + BN_num_bytes(&group->field); |
161 | return 1; | 161 | return 1; |
162 | case EC_OCT_POINT_UNCOMPRESSED: | 162 | case EC_POINT_UNCOMPRESSED: |
163 | case EC_OCT_POINT_HYBRID: | 163 | case EC_POINT_HYBRID: |
164 | *out_len = 1 + 2 * BN_num_bytes(&group->field); | 164 | *out_len = 1 + 2 * BN_num_bytes(&group->field); |
165 | return 1; | 165 | return 1; |
166 | default: | 166 | default: |
@@ -228,7 +228,7 @@ ec_point2oct(const EC_GROUP *group, const EC_POINT *point, uint8_t form, | |||
228 | size_t ret = 0; | 228 | size_t ret = 0; |
229 | 229 | ||
230 | if (EC_POINT_is_at_infinity(group, point)) | 230 | if (EC_POINT_is_at_infinity(group, point)) |
231 | form = EC_OCT_POINT_AT_INFINITY; | 231 | form = EC_POINT_AT_INFINITY; |
232 | 232 | ||
233 | if (!ec_encoded_length(group, form, &encoded_length)) { | 233 | if (!ec_encoded_length(group, form, &encoded_length)) { |
234 | ECerror(EC_R_INVALID_FORM); | 234 | ECerror(EC_R_INVALID_FORM); |
@@ -247,7 +247,7 @@ ec_point2oct(const EC_GROUP *group, const EC_POINT *point, uint8_t form, | |||
247 | if (!CBB_init_fixed(&cbb, buf, len)) | 247 | if (!CBB_init_fixed(&cbb, buf, len)) |
248 | goto err; | 248 | goto err; |
249 | 249 | ||
250 | if (form == EC_OCT_POINT_AT_INFINITY) { | 250 | if (form == EC_POINT_AT_INFINITY) { |
251 | if (!EC_POINT_is_at_infinity(group, point)) | 251 | if (!EC_POINT_is_at_infinity(group, point)) |
252 | goto err; | 252 | goto err; |
253 | if (!ec_add_leading_octet_cbb(&cbb, form, 0)) | 253 | if (!ec_add_leading_octet_cbb(&cbb, form, 0)) |
@@ -266,7 +266,7 @@ ec_point2oct(const EC_GROUP *group, const EC_POINT *point, uint8_t form, | |||
266 | if (!ec_add_leading_octet_cbb(&cbb, form, BN_is_odd(y))) | 266 | if (!ec_add_leading_octet_cbb(&cbb, form, BN_is_odd(y))) |
267 | goto err; | 267 | goto err; |
268 | 268 | ||
269 | if (form == EC_OCT_POINT_COMPRESSED) { | 269 | if (form == EC_POINT_COMPRESSED) { |
270 | if (!ec_add_field_element_cbb(&cbb, group, x)) | 270 | if (!ec_add_field_element_cbb(&cbb, group, x)) |
271 | goto err; | 271 | goto err; |
272 | } else { | 272 | } else { |
@@ -308,7 +308,7 @@ ec_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
308 | if (!ec_get_leading_octet_cbs(&cbs, &form, &ybit)) | 308 | if (!ec_get_leading_octet_cbs(&cbs, &form, &ybit)) |
309 | goto err; | 309 | goto err; |
310 | 310 | ||
311 | if (form == EC_OCT_POINT_AT_INFINITY) { | 311 | if (form == EC_POINT_AT_INFINITY) { |
312 | if (!EC_POINT_set_to_infinity(group, point)) | 312 | if (!EC_POINT_set_to_infinity(group, point)) |
313 | goto err; | 313 | goto err; |
314 | 314 | ||
@@ -320,7 +320,7 @@ ec_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
320 | if ((y = BN_CTX_get(ctx)) == NULL) | 320 | if ((y = BN_CTX_get(ctx)) == NULL) |
321 | goto err; | 321 | goto err; |
322 | 322 | ||
323 | if (form == EC_OCT_POINT_COMPRESSED) { | 323 | if (form == EC_POINT_COMPRESSED) { |
324 | if (!ec_get_field_element_cbs(&cbs, group, x)) | 324 | if (!ec_get_field_element_cbs(&cbs, group, x)) |
325 | goto err; | 325 | goto err; |
326 | if (!EC_POINT_set_compressed_coordinates(group, point, x, ybit, ctx)) | 326 | if (!EC_POINT_set_compressed_coordinates(group, point, x, ybit, ctx)) |
@@ -404,7 +404,7 @@ ec_point_from_octets(const EC_GROUP *group, const unsigned char *buf, size_t buf | |||
404 | goto err; | 404 | goto err; |
405 | 405 | ||
406 | if (out_form != NULL) | 406 | if (out_form != NULL) |
407 | *out_form = buf[0] & ~EC_OCT_YBIT; | 407 | *out_form = buf[0] & ~EC_YBIT; |
408 | 408 | ||
409 | *out_point = point; | 409 | *out_point = point; |
410 | point = NULL; | 410 | point = NULL; |
@@ -433,7 +433,7 @@ ec_normalize_form(const EC_GROUP *group, const EC_POINT *point, int form, | |||
433 | 433 | ||
434 | *out_form = form; | 434 | *out_form = form; |
435 | if (EC_POINT_is_at_infinity(group, point)) | 435 | if (EC_POINT_is_at_infinity(group, point)) |
436 | *out_form = EC_OCT_POINT_AT_INFINITY; | 436 | *out_form = EC_POINT_AT_INFINITY; |
437 | 437 | ||
438 | return 1; | 438 | return 1; |
439 | } | 439 | } |