forked from google/boringssl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
84 changed files
with
1,798 additions
and
2,287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,19 +164,17 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, | |
goto err; | ||
} | ||
|
||
/* Unused bits in a BIT STRING must be zero. */ | ||
// Unused bits in a BIT STRING must be zero. | ||
uint8_t padding_mask = (1 << padding) - 1; | ||
if (padding != 0 && (len < 1 || (p[len - 1] & padding_mask) != 0)) { | ||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BIT_STRING_PADDING); | ||
goto err; | ||
} | ||
|
||
/* | ||
* We do this to preserve the settings. If we modify the settings, via | ||
* the _set_bit function, we will recalculate on output | ||
*/ | ||
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear */ | ||
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); /* set */ | ||
// We do this to preserve the settings. If we modify the settings, via | ||
// the _set_bit function, we will recalculate on output | ||
ret->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); // clear | ||
ret->flags |= (ASN1_STRING_FLAG_BITS_LEFT | padding); // set | ||
|
||
if (len > 0) { | ||
s = OPENSSL_memdup(p, len); | ||
|
@@ -205,9 +203,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, | |
return (NULL); | ||
} | ||
|
||
/* | ||
* These next 2 functions from Goetz Babin-Ebell <[email protected]> | ||
*/ | ||
// These next 2 functions from Goetz Babin-Ebell <[email protected]> | ||
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) { | ||
int w, v, iv; | ||
unsigned char *c; | ||
|
@@ -223,11 +219,11 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) { | |
return 0; | ||
} | ||
|
||
a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); /* clear, set on write */ | ||
a->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); // clear, set on write | ||
|
||
if ((a->length < (w + 1)) || (a->data == NULL)) { | ||
if (!value) { | ||
return (1); /* Don't need to set */ | ||
return (1); // Don't need to set | ||
} | ||
if (a->data == NULL) { | ||
c = (unsigned char *)OPENSSL_malloc(w + 1); | ||
|
@@ -262,27 +258,23 @@ int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n) { | |
return ((a->data[w] & v) != 0); | ||
} | ||
|
||
/* | ||
* Checks if the given bit string contains only bits specified by | ||
* the flags vector. Returns 0 if there is at least one bit set in 'a' | ||
* which is not specified in 'flags', 1 otherwise. | ||
* 'len' is the length of 'flags'. | ||
*/ | ||
// Checks if the given bit string contains only bits specified by | ||
// the flags vector. Returns 0 if there is at least one bit set in 'a' | ||
// which is not specified in 'flags', 1 otherwise. | ||
// 'len' is the length of 'flags'. | ||
int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, const unsigned char *flags, | ||
int flags_len) { | ||
int i, ok; | ||
/* Check if there is one bit set at all. */ | ||
// Check if there is one bit set at all. | ||
if (!a || !a->data) { | ||
return 1; | ||
} | ||
|
||
/* | ||
* Check each byte of the internal representation of the bit string. | ||
*/ | ||
// Check each byte of the internal representation of the bit string. | ||
ok = 1; | ||
for (i = 0; i < a->length && ok; ++i) { | ||
unsigned char mask = i < flags_len ? ~flags[i] : 0xff; | ||
/* We are done if there is an unneeded bit set. */ | ||
// We are done if there is an unneeded bit set. | ||
ok = (a->data[i] & mask) == 0; | ||
} | ||
return ok; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.