Skip to content

Commit ee6375a

Browse files
davidbentorben-hansen
authored andcommitted
Run convert_comments.go on the recently-converted files
This CL is the result of the following commands: for d in asn1 x509 x509v3 pem; do go run util/convert_comments.go crypto/$d/*.h go run util/convert_comments.go crypto/$d/*.c done Change-Id: If78433f68cb2f913b0de06ded744a5a65540e1cf Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/53087 Reviewed-by: Bob Beck <[email protected]> Commit-Queue: Bob Beck <[email protected]> (cherry picked from commit 46350487c1983268ac77ca9d63c34dc60b721058)
1 parent b93f52e commit ee6375a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1802
-2290
lines changed

crypto/asn1/a_bitstr.c

+15-23
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,17 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
164164
goto err;
165165
}
166166

167-
/* Unused bits in a BIT STRING must be zero. */
167+
// Unused bits in a BIT STRING must be zero.
168168
uint8_t padding_mask = (1 << padding) - 1;
169169
if (padding != 0 && (len < 1 || (p[len - 1] & padding_mask) != 0)) {
170170
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_PADDING);
171171
goto err;
172172
}
173173

174-
/*
175-
* We do this to preserve the settings. If we modify the settings, via
176-
* the _set_bit function, we will recalculate on output
177-
*/
178-
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear */
179-
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); /* set */
174+
// We do this to preserve the settings. If we modify the settings, via
175+
// the _set_bit function, we will recalculate on output
176+
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); // clear
177+
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); // set
180178

181179
if (len > 0) {
182180
s = OPENSSL_memdup(p, len);
@@ -205,9 +203,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
205203
return (NULL);
206204
}
207205

208-
/*
209-
* These next 2 functions from Goetz Babin-Ebell <[email protected]>
210-
*/
206+
// These next 2 functions from Goetz Babin-Ebell <[email protected]>
211207
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) {
212208
int w, v, iv;
213209
unsigned char *c;
@@ -223,11 +219,11 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) {
223219
return 0;
224220
}
225221

226-
a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear, set on write */
222+
a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); // clear, set on write
227223

228224
if ((a->length < (w + 1)) || (a->data == NULL)) {
229225
if (!value) {
230-
return (1); /* Don't need to set */
226+
return (1); // Don't need to set
231227
}
232228
if (a->data == NULL) {
233229
c = (unsigned char *)OPENSSL_malloc(w + 1);
@@ -262,27 +258,23 @@ int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n) {
262258
return ((a->data[w] & v) != 0);
263259
}
264260

265-
/*
266-
* Checks if the given bit string contains only bits specified by
267-
* the flags vector. Returns 0 if there is at least one bit set in 'a'
268-
* which is not specified in 'flags', 1 otherwise.
269-
* 'len' is the length of 'flags'.
270-
*/
261+
// Checks if the given bit string contains only bits specified by
262+
// the flags vector. Returns 0 if there is at least one bit set in 'a'
263+
// which is not specified in 'flags', 1 otherwise.
264+
// 'len' is the length of 'flags'.
271265
int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags,
272266
int flags_len) {
273267
int i, ok;
274-
/* Check if there is one bit set at all. */
268+
// Check if there is one bit set at all.
275269
if (!a || !a->data) {
276270
return 1;
277271
}
278272

279-
/*
280-
* Check each byte of the internal representation of the bit string.
281-
*/
273+
// Check each byte of the internal representation of the bit string.
282274
ok = 1;
283275
for (i = 0; i < a->length && ok; ++i) {
284276
unsigned char mask = i < flags_len ? ~flags[i] : 0xff;
285-
/* We are done if there is an unneeded bit set. */
277+
// We are done if there is an unneeded bit set.
286278
ok = (a->data[i] & mask) == 0;
287279
}
288280
return ok;

crypto/asn1/a_bool.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ int i2d_ASN1_BOOLEAN(ASN1_BOOLEAN a, unsigned char **pp) {
8080
ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL);
8181
*p = a ? 0xff : 0x00;
8282

83-
/*
84-
* If a new buffer was allocated, just return it back.
85-
* If not, return the incremented buffer pointer.
86-
*/
83+
// If a new buffer was allocated, just return it back.
84+
// If not, return the incremented buffer pointer.
8785
*pp = allocated != NULL ? allocated : p + 1;
8886
return r;
8987
}

crypto/asn1/a_dup.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@
5959
#include <openssl/err.h>
6060
#include <openssl/mem.h>
6161

62-
/*
63-
* ASN1_ITEM version of dup: this follows the model above except we don't
64-
* need to allocate the buffer. At some point this could be rewritten to
65-
* directly dup the underlying structure instead of doing and encode and
66-
* decode.
67-
*/
62+
// ASN1_ITEM version of dup: this follows the model above except we don't
63+
// need to allocate the buffer. At some point this could be rewritten to
64+
// directly dup the underlying structure instead of doing and encode and
65+
// decode.
6866
void *ASN1_item_dup(const ASN1_ITEM *it, void *x) {
6967
unsigned char *b = NULL;
7068
const unsigned char *p;

crypto/asn1/a_int.c

+29-31
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x) {
7272
}
7373

7474
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) {
75-
/* Compare signs. */
75+
// Compare signs.
7676
int neg = x->type & V_ASN1_NEG;
7777
if (neg != (y->type & V_ASN1_NEG)) {
7878
return neg ? -1 : 1;
7979
}
8080

8181
int ret = ASN1_STRING_cmp(x, y);
8282
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|.
8585
if (ret < 0) {
8686
return 1;
8787
} else if (ret > 0) {
@@ -94,8 +94,8 @@ int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) {
9494
return ret;
9595
}
9696

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.
9999
static void negate_twos_complement(uint8_t *buf, size_t len) {
100100
uint8_t borrow = 0;
101101
for (size_t i = len - 1; i < len; i--) {
@@ -119,9 +119,9 @@ int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, unsigned char **outp) {
119119
return 0;
120120
}
121121

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.
125125
int start = 0;
126126
while (start < in->length && in->data[start] == 0) {
127127
start++;
@@ -130,20 +130,20 @@ int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, unsigned char **outp) {
130130
int is_negative = (in->type & V_ASN1_NEG) != 0;
131131
int pad;
132132
if (start >= in->length) {
133-
/* Zero is represented as a single byte. */
133+
// Zero is represented as a single byte.
134134
is_negative = 0;
135135
pad = 1;
136136
} 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.
141141
pad = in->data[start] > 0x80 ||
142142
(in->data[start] == 0x80 &&
143143
!is_all_zeros(in->data + start + 1, in->length - start - 1));
144144
} 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.
147147
pad = (in->data[start] & 0x80) != 0;
148148
}
149149

@@ -173,11 +173,9 @@ int i2c_ASN1_INTEGER(const ASN1_INTEGER *in, unsigned char **outp) {
173173

174174
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **out, const unsigned char **inp,
175175
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.
181179
if (len < 0 || len > INT_MAX / 2) {
182180
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
183181
return NULL;
@@ -201,19 +199,19 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **out, const unsigned char **inp,
201199
ret = *out;
202200
}
203201

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.
206204
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.
211209
if (CBS_len(&cbs) > 0 && CBS_data(&cbs)[0] == 0xff &&
212210
!is_all_zeros(CBS_data(&cbs) + 1, CBS_len(&cbs) - 1)) {
213211
CBS_skip(&cbs, 1);
214212
}
215213
} else {
216-
/* Remove the leading zero byte, if any. */
214+
// Remove the leading zero byte, if any.
217215
if (CBS_len(&cbs) > 0 && CBS_data(&cbs)[0] == 0x00) {
218216
CBS_skip(&cbs, 1);
219217
}
@@ -230,9 +228,9 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **out, const unsigned char **inp,
230228
ret->type = V_ASN1_INTEGER;
231229
}
232230

233-
/* The value should be minimally-encoded. */
231+
// The value should be minimally-encoded.
234232
assert(ret->length == 0 || ret->data[0] != 0);
235-
/* Zero is not negative. */
233+
// Zero is not negative.
236234
assert(!is_negative || ret->length > 0);
237235

238236
*inp += len;
@@ -347,7 +345,7 @@ static long asn1_string_get_long(const ASN1_STRING *a, int type) {
347345

348346
int64_t i64;
349347
int fits_in_i64;
350-
/* Check |v != 0| to handle manually-constructed negative zeros. */
348+
// Check |v != 0| to handle manually-constructed negative zeros.
351349
if ((a->type & V_ASN1_NEG) && v != 0) {
352350
i64 = (int64_t)(0u - v);
353351
fits_in_i64 = i64 < 0;
@@ -362,7 +360,7 @@ static long asn1_string_get_long(const ASN1_STRING *a, int type) {
362360
}
363361

364362
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.
366364
ERR_clear_error();
367365
return -1;
368366
}

crypto/asn1/a_mbstr.c

+19-21
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@
6666
#include "../bytestring/internal.h"
6767
#include "internal.h"
6868

69-
/*
70-
* These functions take a string in UTF8, ASCII or multibyte form and a mask
71-
* of permissible ASN1 string types. It then works out the minimal type
72-
* (using the order Printable < IA5 < T61 < BMP < Universal < UTF8) and
73-
* creates a string of the correct type with the supplied data. Yes this is
74-
* horrible: it has to be :-( The 'ncopy' form checks minimum and maximum
75-
* size limits too.
76-
*/
69+
// These functions take a string in UTF8, ASCII or multibyte form and a mask
70+
// of permissible ASN1 string types. It then works out the minimal type
71+
// (using the order Printable < IA5 < T61 < BMP < Universal < UTF8) and
72+
// creates a string of the correct type with the supplied data. Yes this is
73+
// horrible: it has to be :-( The 'ncopy' form checks minimum and maximum
74+
// size limits too.
7775

7876
int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
7977
int inform, unsigned long mask) {
@@ -127,7 +125,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
127125
return -1;
128126
}
129127

130-
/* Check |minsize| and |maxsize| and work out the minimal type, if any. */
128+
// Check |minsize| and |maxsize| and work out the minimal type, if any.
131129
CBS cbs;
132130
CBS_init(&cbs, in, len);
133131
size_t utf8_len = 0;
@@ -139,17 +137,17 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
139137
}
140138
if (nchar == 0 && (inform == MBSTRING_BMP || inform == MBSTRING_UNIV) &&
141139
c == 0xfeff) {
142-
/* Reject byte-order mark. We could drop it but that would mean
143-
* adding ambiguity around whether a BOM was included or not when
144-
* matching strings.
145-
*
146-
* For a little-endian UCS-2 string, the BOM will appear as 0xfffe
147-
* and will be rejected as noncharacter, below. */
140+
// Reject byte-order mark. We could drop it but that would mean
141+
// adding ambiguity around whether a BOM was included or not when
142+
// matching strings.
143+
//
144+
// For a little-endian UCS-2 string, the BOM will appear as 0xfffe
145+
// and will be rejected as noncharacter, below.
148146
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
149147
return -1;
150148
}
151149

152-
/* Update which output formats are still possible. */
150+
// Update which output formats are still possible.
153151
if ((mask & B_ASN1_PRINTABLESTRING) && !asn1_is_printable(c)) {
154152
mask &= ~B_ASN1_PRINTABLESTRING;
155153
}
@@ -185,7 +183,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
185183
return -1;
186184
}
187185

188-
/* Now work out output format and string type */
186+
// Now work out output format and string type
189187
int (*encode_func)(CBB *, uint32_t) = cbb_add_latin1;
190188
size_t size_estimate = nchar;
191189
int outform = MBSTRING_ASC;
@@ -237,7 +235,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
237235
*out = dest;
238236
}
239237

240-
/* If both the same type just copy across */
238+
// If both the same type just copy across
241239
if (inform == outform) {
242240
if (!ASN1_STRING_set(dest, in, len)) {
243241
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
@@ -261,8 +259,8 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
261259
}
262260
uint8_t *data = NULL;
263261
size_t data_len;
264-
if (/* OpenSSL historically NUL-terminated this value with a single byte,
265-
* even for |MBSTRING_BMP| and |MBSTRING_UNIV|. */
262+
if (// OpenSSL historically NUL-terminated this value with a single byte,
263+
// even for |MBSTRING_BMP| and |MBSTRING_UNIV|.
266264
!CBB_add_u8(&cbb, 0) || !CBB_finish(&cbb, &data, &data_len) ||
267265
data_len < 1 || data_len > INT_MAX) {
268266
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
@@ -285,7 +283,7 @@ int asn1_is_printable(uint32_t value) {
285283
if (value > 0x7f) {
286284
return 0;
287285
}
288-
/* Note we cannot use |isalnum| because it is locale-dependent. */
286+
// Note we cannot use |isalnum| because it is locale-dependent.
289287
return ('a' <= value && value <= 'z') || //
290288
('A' <= value && value <= 'Z') || //
291289
('0' <= value && value <= '9') || //

0 commit comments

Comments
 (0)