@@ -72,16 +72,16 @@ ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x) {
72
72
}
73
73
74
74
int ASN1_INTEGER_cmp (const ASN1_INTEGER * x , const ASN1_INTEGER * y ) {
75
- /* Compare signs. */
75
+ // Compare signs.
76
76
int neg = x -> type & V_ASN1_NEG ;
77
77
if (neg != (y -> type & V_ASN1_NEG )) {
78
78
return neg ? -1 : 1 ;
79
79
}
80
80
81
81
int ret = ASN1_STRING_cmp (x , y );
82
82
if (neg ) {
83
- /* This could be |-ret|, but |ASN1_STRING_cmp| is not forbidden from
84
- * returning |INT_MIN|. */
83
+ // This could be |-ret|, but |ASN1_STRING_cmp| is not forbidden from
84
+ // returning |INT_MIN|.
85
85
if (ret < 0 ) {
86
86
return 1 ;
87
87
} else if (ret > 0 ) {
@@ -94,8 +94,8 @@ int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) {
94
94
return ret ;
95
95
}
96
96
97
- /* negate_twos_complement negates |len| bytes from |buf| in-place, interpreted
98
- * as a signed, big-endian two's complement value. */
97
+ // negate_twos_complement negates |len| bytes from |buf| in-place, interpreted
98
+ // as a signed, big-endian two's complement value.
99
99
static void negate_twos_complement (uint8_t * buf , size_t len ) {
100
100
uint8_t borrow = 0 ;
101
101
for (size_t i = len - 1 ; i < len ; i -- ) {
@@ -119,9 +119,9 @@ int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, unsigned char **outp) {
119
119
return 0 ;
120
120
}
121
121
122
- /* |ASN1_INTEGER|s should be represented minimally, but it is possible to
123
- * construct invalid ones. Skip leading zeros so this does not produce an
124
- * invalid encoding or break invariants. */
122
+ // |ASN1_INTEGER|s should be represented minimally, but it is possible to
123
+ // construct invalid ones. Skip leading zeros so this does not produce an
124
+ // invalid encoding or break invariants.
125
125
int start = 0 ;
126
126
while (start < in -> length && in -> data [start ] == 0 ) {
127
127
start ++ ;
@@ -130,20 +130,20 @@ int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, unsigned char **outp) {
130
130
int is_negative = (in -> type & V_ASN1_NEG ) != 0 ;
131
131
int pad ;
132
132
if (start >= in -> length ) {
133
- /* Zero is represented as a single byte. */
133
+ // Zero is represented as a single byte.
134
134
is_negative = 0 ;
135
135
pad = 1 ;
136
136
} else if (is_negative ) {
137
- /* 0x80...01 through 0xff...ff have a two's complement of 0x7f...ff
138
- * through 0x00...01 and need an extra byte to be negative.
139
- * 0x01...00 through 0x80...00 have a two's complement of 0xfe...ff
140
- * through 0x80...00 and can be negated as-is. */
137
+ // 0x80...01 through 0xff...ff have a two's complement of 0x7f...ff
138
+ // through 0x00...01 and need an extra byte to be negative.
139
+ // 0x01...00 through 0x80...00 have a two's complement of 0xfe...ff
140
+ // through 0x80...00 and can be negated as-is.
141
141
pad = in -> data [start ] > 0x80 ||
142
142
(in -> data [start ] == 0x80 &&
143
143
!is_all_zeros (in -> data + start + 1 , in -> length - start - 1 ));
144
144
} else {
145
- /* If the high bit is set, the signed representation needs an extra
146
- * byte to be positive. */
145
+ // If the high bit is set, the signed representation needs an extra
146
+ // byte to be positive.
147
147
pad = (in -> data [start ] & 0x80 ) != 0 ;
148
148
}
149
149
@@ -173,11 +173,9 @@ int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, unsigned char **outp) {
173
173
174
174
ASN1_INTEGER * c2i_ASN1_INTEGER (ASN1_INTEGER * * out , const unsigned char * * inp ,
175
175
long len ) {
176
- /*
177
- * This function can handle lengths up to INT_MAX - 1, but the rest of the
178
- * legacy ASN.1 code mixes integer types, so avoid exposing it to
179
- * ASN1_INTEGERS with larger lengths.
180
- */
176
+ // This function can handle lengths up to INT_MAX - 1, but the rest of the
177
+ // legacy ASN.1 code mixes integer types, so avoid exposing it to
178
+ // ASN1_INTEGERS with larger lengths.
181
179
if (len < 0 || len > INT_MAX / 2 ) {
182
180
OPENSSL_PUT_ERROR (ASN1 , ASN1_R_TOO_LONG );
183
181
return NULL ;
@@ -201,19 +199,19 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **out, const unsigned char **inp,
201
199
ret = * out ;
202
200
}
203
201
204
- /* Convert to |ASN1_INTEGER|'s sign-and-magnitude representation. First,
205
- * determine the size needed for a minimal result. */
202
+ // Convert to |ASN1_INTEGER|'s sign-and-magnitude representation. First,
203
+ // determine the size needed for a minimal result.
206
204
if (is_negative ) {
207
- /* 0xff00...01 through 0xff7f..ff have a two's complement of 0x00ff...ff
208
- * through 0x000100...001 and need one leading zero removed. 0x8000...00
209
- * through 0xff00...00 have a two's complement of 0x8000...00 through
210
- * 0x0100...00 and will be minimally-encoded as-is. */
205
+ // 0xff00...01 through 0xff7f..ff have a two's complement of 0x00ff...ff
206
+ // through 0x000100...001 and need one leading zero removed. 0x8000...00
207
+ // through 0xff00...00 have a two's complement of 0x8000...00 through
208
+ // 0x0100...00 and will be minimally-encoded as-is.
211
209
if (CBS_len (& cbs ) > 0 && CBS_data (& cbs )[0 ] == 0xff &&
212
210
!is_all_zeros (CBS_data (& cbs ) + 1 , CBS_len (& cbs ) - 1 )) {
213
211
CBS_skip (& cbs , 1 );
214
212
}
215
213
} else {
216
- /* Remove the leading zero byte, if any. */
214
+ // Remove the leading zero byte, if any.
217
215
if (CBS_len (& cbs ) > 0 && CBS_data (& cbs )[0 ] == 0x00 ) {
218
216
CBS_skip (& cbs , 1 );
219
217
}
@@ -230,9 +228,9 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **out, const unsigned char **inp,
230
228
ret -> type = V_ASN1_INTEGER ;
231
229
}
232
230
233
- /* The value should be minimally-encoded. */
231
+ // The value should be minimally-encoded.
234
232
assert (ret -> length == 0 || ret -> data [0 ] != 0 );
235
- /* Zero is not negative. */
233
+ // Zero is not negative.
236
234
assert (!is_negative || ret -> length > 0 );
237
235
238
236
* inp += len ;
@@ -347,7 +345,7 @@ static long asn1_string_get_long(const ASN1_STRING *a, int type) {
347
345
348
346
int64_t i64 ;
349
347
int fits_in_i64 ;
350
- /* Check |v != 0| to handle manually-constructed negative zeros. */
348
+ // Check |v != 0| to handle manually-constructed negative zeros.
351
349
if ((a -> type & V_ASN1_NEG ) && v != 0 ) {
352
350
i64 = (int64_t )(0u - v );
353
351
fits_in_i64 = i64 < 0 ;
@@ -362,7 +360,7 @@ static long asn1_string_get_long(const ASN1_STRING *a, int type) {
362
360
}
363
361
364
362
err :
365
- /* This function's return value does not distinguish overflow from -1. */
363
+ // This function's return value does not distinguish overflow from -1.
366
364
ERR_clear_error ();
367
365
return -1 ;
368
366
}
0 commit comments