mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-22 00:40:41 +00:00
Tidy up mbedtls_asn1_write_len
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
cf5f746a8c
commit
33287ae134
@ -37,9 +37,8 @@ int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start, size_t
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int required = 1;
|
int required = 1;
|
||||||
if (len < 0x80) {
|
|
||||||
required = 1;
|
if (len >= 0x80) {
|
||||||
} else {
|
|
||||||
for (size_t l = len; l != 0; l >>= 8) {
|
for (size_t l = len; l != 0; l >>= 8) {
|
||||||
required++;
|
required++;
|
||||||
}
|
}
|
||||||
@ -55,7 +54,7 @@ int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start, size_t
|
|||||||
} while (len);
|
} while (len);
|
||||||
|
|
||||||
if (required > 1) {
|
if (required > 1) {
|
||||||
*--(*p) = (unsigned char) (required + 0x7f);
|
*--(*p) = (unsigned char) (0x80 + required - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return required;
|
return required;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user