mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
CR50: move utility method reverse() to common/util.c
reverse() swaps the endian-ness of a buffer of specified length. This change moves the implementation to a common location. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=compilation succeeds Change-Id: If8c97f53cc199d63c1caebbd999e1c099814387e Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/331333 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
6e0309ffa9
commit
88e0161583
@@ -297,19 +297,6 @@ static int check_pkcs1_type1_pad(const uint8_t *msg, uint32_t msg_len,
|
||||
return memcmp(msg, &padded[i], hash_size) == 0;
|
||||
}
|
||||
|
||||
static void reverse(uint8_t *start, size_t len)
|
||||
{
|
||||
int i;
|
||||
uint8_t *end = start + len;
|
||||
|
||||
for (i = 0; i < len / 2; ++i) {
|
||||
uint8_t tmp = *start;
|
||||
|
||||
*start++ = *--end;
|
||||
*end = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static int check_modulus_params(const struct BIGNUM *N, uint32_t *out_len)
|
||||
{
|
||||
if (bn_size(N) > RSA_MAX_BYTES)
|
||||
|
||||
@@ -305,6 +305,21 @@ void *memmove(void *dest, const void *src, size_t len)
|
||||
}
|
||||
|
||||
|
||||
void reverse(void *dest, size_t len)
|
||||
{
|
||||
int i;
|
||||
uint8_t *start = dest;
|
||||
uint8_t *end = start + len;
|
||||
|
||||
for (i = 0; i < len / 2; ++i) {
|
||||
uint8_t tmp = *start;
|
||||
|
||||
*start++ = *--end;
|
||||
*end = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *strzcpy(char *dest, const char *src, int len)
|
||||
{
|
||||
char *d = dest;
|
||||
|
||||
@@ -146,6 +146,11 @@ int uint64divmod(uint64_t *v, int by);
|
||||
*/
|
||||
int get_next_bit(uint32_t *mask);
|
||||
|
||||
/**
|
||||
* Reverse's the byte-order of the provided buffer.
|
||||
*/
|
||||
void reverse(void *dest, size_t len);
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Conditional stuff.
|
||||
|
||||
Reference in New Issue
Block a user