Skip to content

Commit 985b609

Browse files
montjoiegregkh
authored andcommitted
crypto: sun4i-ss - handle BigEndian for cipher
commit 5ab6177 upstream. Ciphers produce invalid results on BE. Key and IV need to be written in LE. Fixes: 6298e94 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator") Cc: <stable@vger.kernel.org> Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 19be286 commit 985b609

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
5454

5555
spin_lock_irqsave(&ss->slock, flags);
5656

57-
for (i = 0; i < op->keylen; i += 4)
58-
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
57+
for (i = 0; i < op->keylen / 4; i++)
58+
writesl(ss->base + SS_KEY0 + i * 4, &op->key[i], 1);
5959

6060
if (areq->iv) {
6161
for (i = 0; i < 4 && i < ivsize / 4; i++) {
6262
v = *(u32 *)(areq->iv + i * 4);
63-
writel(v, ss->base + SS_IV0 + i * 4);
63+
writesl(ss->base + SS_IV0 + i * 4, &v, 1);
6464
}
6565
}
6666
writel(mode, ss->base + SS_CTL);
@@ -238,13 +238,13 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
238238

239239
spin_lock_irqsave(&ss->slock, flags);
240240

241-
for (i = 0; i < op->keylen; i += 4)
242-
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
241+
for (i = 0; i < op->keylen / 4; i++)
242+
writesl(ss->base + SS_KEY0 + i * 4, &op->key[i], 1);
243243

244244
if (areq->iv) {
245245
for (i = 0; i < 4 && i < ivsize / 4; i++) {
246246
v = *(u32 *)(areq->iv + i * 4);
247-
writel(v, ss->base + SS_IV0 + i * 4);
247+
writesl(ss->base + SS_IV0 + i * 4, &v, 1);
248248
}
249249
}
250250
writel(mode, ss->base + SS_CTL);

0 commit comments

Comments
 (0)