]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
crypto: caam - incapsulate dropping leading zeros into function
authorRadu Alexe <radu.alexe@nxp.com>
Tue, 25 Apr 2017 13:26:37 +0000 (16:26 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 May 2017 05:19:50 +0000 (13:19 +0800)
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>
drivers/crypto/caam/caampkc.c

index 999ba18495b0f6bef835109edc4a12c43bd9e7bb..d2c6977ba82e100545fc9f82f5b0f0a2850664bc 100644 (file)
@@ -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;