summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRadu Alexe <radu.alexe@nxp.com>2017-04-25 16:26:37 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2017-05-18 13:19:50 +0800
commit7ca4a9a10fe82ee50ce0da02c72791ecf7c83869 (patch)
tree39c9de62193874efed106c6e51c8f2e5be67f7b6 /drivers
parent7fcaf62a9f6348bcdc8d2816f93f64cf7f3f87fc (diff)
crypto: caam - incapsulate dropping leading zeros into function
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/crypto/caam/caampkc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
index 999ba18495b0..d2c6977ba82e 100644
--- a/drivers/crypto/caam/caampkc.c
+++ b/drivers/crypto/caam/caampkc.c
@@ -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
@@ -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;