Commit 7ca4a9a1 authored by Radu Alexe's avatar Radu Alexe Committed by Herbert Xu

crypto: caam - incapsulate dropping leading zeros into function

This function will be used into further patches.
Signed-off-by: default avatarRadu Alexe <radu.alexe@nxp.com>
Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 7fcaf62a
...@@ -357,6 +357,14 @@ static void caam_rsa_free_key(struct caam_rsa_key *key) ...@@ -357,6 +357,14 @@ static void caam_rsa_free_key(struct caam_rsa_key *key)
key->n_sz = 0; key->n_sz = 0;
} }
static void caam_rsa_drop_leading_zeros(const u8 **ptr, size_t *nbytes)
{
while (!**ptr && *nbytes) {
(*ptr)++;
(*nbytes)--;
}
}
/** /**
* caam_read_raw_data - Read a raw byte stream as a positive integer. * caam_read_raw_data - Read a raw byte stream as a positive integer.
* The function skips buffer's leading zeros, copies the remained data * The function skips buffer's leading zeros, copies the remained data
...@@ -370,10 +378,7 @@ static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes) ...@@ -370,10 +378,7 @@ static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes)
{ {
u8 *val; u8 *val;
while (!*buf && *nbytes) { caam_rsa_drop_leading_zeros(&buf, nbytes);
buf++;
(*nbytes)--;
}
if (!*nbytes) if (!*nbytes)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment