Skip to content

Commit

Permalink
crypto: caam - incapsulate dropping leading zeros into function
Browse files Browse the repository at this point in the history
This function will be used into further patches.

Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Radu Alexe authored and Herbert Xu committed May 18, 2017
1 parent 7fcaf62 commit 7ca4a9a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/crypto/caam/caampkc.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ static void caam_rsa_free_key(struct caam_rsa_key *key)
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.
* The function skips buffer's leading zeros, copies the remained data
Expand All @@ -370,10 +378,7 @@ static inline u8 *caam_read_raw_data(const u8 *buf, size_t *nbytes)
{
u8 *val;

while (!*buf && *nbytes) {
buf++;
(*nbytes)--;
}
caam_rsa_drop_leading_zeros(&buf, nbytes);
if (!*nbytes)
return NULL;

Expand Down

0 comments on commit 7ca4a9a

Please sign in to comment.