Skip to content

Commit f35a4e2

Browse files
ebiggersherbertx
authored andcommitted
crypto: omap-sham - stop setting alignmask for ahashes
The crypto API's support for alignmasks for ahash algorithms is nearly useless, as its only effect is to cause the API to align the key and result buffers. The drivers that happen to be specifying an alignmask for ahash rarely actually need it. When they do, it's easily fixable, especially considering that these buffers cannot be used for DMA. In preparation for removing alignmask support from ahash, this patch makes the omap-sham driver no longer use it. This driver did actually rely on it, but only for storing to the result buffer using __u32 stores in omap_sham_copy_ready_hash(). This patch makes omap_sham_copy_ready_hash() use put_unaligned() instead. (It really should use a specific endianness, but that's an existing bug.) Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 492444c commit f35a4e2

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

drivers/crypto/omap-sham.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ static void omap_sham_copy_ready_hash(struct ahash_request *req)
356356

357357
if (big_endian)
358358
for (i = 0; i < d; i++)
359-
hash[i] = be32_to_cpup((__be32 *)in + i);
359+
put_unaligned(be32_to_cpup((__be32 *)in + i), &hash[i]);
360360
else
361361
for (i = 0; i < d; i++)
362-
hash[i] = le32_to_cpup((__le32 *)in + i);
362+
put_unaligned(le32_to_cpup((__le32 *)in + i), &hash[i]);
363363
}
364364

365365
static void omap_sham_write_ctrl_omap2(struct omap_sham_dev *dd, size_t length,
@@ -1435,7 +1435,6 @@ static struct ahash_engine_alg algs_sha1_md5[] = {
14351435
CRYPTO_ALG_NEED_FALLBACK,
14361436
.cra_blocksize = SHA1_BLOCK_SIZE,
14371437
.cra_ctxsize = sizeof(struct omap_sham_ctx),
1438-
.cra_alignmask = OMAP_ALIGN_MASK,
14391438
.cra_module = THIS_MODULE,
14401439
.cra_init = omap_sham_cra_init,
14411440
.cra_exit = omap_sham_cra_exit,
@@ -1458,7 +1457,6 @@ static struct ahash_engine_alg algs_sha1_md5[] = {
14581457
CRYPTO_ALG_NEED_FALLBACK,
14591458
.cra_blocksize = SHA1_BLOCK_SIZE,
14601459
.cra_ctxsize = sizeof(struct omap_sham_ctx),
1461-
.cra_alignmask = OMAP_ALIGN_MASK,
14621460
.cra_module = THIS_MODULE,
14631461
.cra_init = omap_sham_cra_init,
14641462
.cra_exit = omap_sham_cra_exit,
@@ -1483,7 +1481,6 @@ static struct ahash_engine_alg algs_sha1_md5[] = {
14831481
.cra_blocksize = SHA1_BLOCK_SIZE,
14841482
.cra_ctxsize = sizeof(struct omap_sham_ctx) +
14851483
sizeof(struct omap_sham_hmac_ctx),
1486-
.cra_alignmask = OMAP_ALIGN_MASK,
14871484
.cra_module = THIS_MODULE,
14881485
.cra_init = omap_sham_cra_sha1_init,
14891486
.cra_exit = omap_sham_cra_exit,
@@ -1508,7 +1505,6 @@ static struct ahash_engine_alg algs_sha1_md5[] = {
15081505
.cra_blocksize = SHA1_BLOCK_SIZE,
15091506
.cra_ctxsize = sizeof(struct omap_sham_ctx) +
15101507
sizeof(struct omap_sham_hmac_ctx),
1511-
.cra_alignmask = OMAP_ALIGN_MASK,
15121508
.cra_module = THIS_MODULE,
15131509
.cra_init = omap_sham_cra_md5_init,
15141510
.cra_exit = omap_sham_cra_exit,
@@ -1535,7 +1531,6 @@ static struct ahash_engine_alg algs_sha224_sha256[] = {
15351531
CRYPTO_ALG_NEED_FALLBACK,
15361532
.cra_blocksize = SHA224_BLOCK_SIZE,
15371533
.cra_ctxsize = sizeof(struct omap_sham_ctx),
1538-
.cra_alignmask = OMAP_ALIGN_MASK,
15391534
.cra_module = THIS_MODULE,
15401535
.cra_init = omap_sham_cra_init,
15411536
.cra_exit = omap_sham_cra_exit,
@@ -1558,7 +1553,6 @@ static struct ahash_engine_alg algs_sha224_sha256[] = {
15581553
CRYPTO_ALG_NEED_FALLBACK,
15591554
.cra_blocksize = SHA256_BLOCK_SIZE,
15601555
.cra_ctxsize = sizeof(struct omap_sham_ctx),
1561-
.cra_alignmask = OMAP_ALIGN_MASK,
15621556
.cra_module = THIS_MODULE,
15631557
.cra_init = omap_sham_cra_init,
15641558
.cra_exit = omap_sham_cra_exit,
@@ -1583,7 +1577,6 @@ static struct ahash_engine_alg algs_sha224_sha256[] = {
15831577
.cra_blocksize = SHA224_BLOCK_SIZE,
15841578
.cra_ctxsize = sizeof(struct omap_sham_ctx) +
15851579
sizeof(struct omap_sham_hmac_ctx),
1586-
.cra_alignmask = OMAP_ALIGN_MASK,
15871580
.cra_module = THIS_MODULE,
15881581
.cra_init = omap_sham_cra_sha224_init,
15891582
.cra_exit = omap_sham_cra_exit,
@@ -1608,7 +1601,6 @@ static struct ahash_engine_alg algs_sha224_sha256[] = {
16081601
.cra_blocksize = SHA256_BLOCK_SIZE,
16091602
.cra_ctxsize = sizeof(struct omap_sham_ctx) +
16101603
sizeof(struct omap_sham_hmac_ctx),
1611-
.cra_alignmask = OMAP_ALIGN_MASK,
16121604
.cra_module = THIS_MODULE,
16131605
.cra_init = omap_sham_cra_sha256_init,
16141606
.cra_exit = omap_sham_cra_exit,
@@ -1634,7 +1626,6 @@ static struct ahash_engine_alg algs_sha384_sha512[] = {
16341626
CRYPTO_ALG_NEED_FALLBACK,
16351627
.cra_blocksize = SHA384_BLOCK_SIZE,
16361628
.cra_ctxsize = sizeof(struct omap_sham_ctx),
1637-
.cra_alignmask = OMAP_ALIGN_MASK,
16381629
.cra_module = THIS_MODULE,
16391630
.cra_init = omap_sham_cra_init,
16401631
.cra_exit = omap_sham_cra_exit,
@@ -1657,7 +1648,6 @@ static struct ahash_engine_alg algs_sha384_sha512[] = {
16571648
CRYPTO_ALG_NEED_FALLBACK,
16581649
.cra_blocksize = SHA512_BLOCK_SIZE,
16591650
.cra_ctxsize = sizeof(struct omap_sham_ctx),
1660-
.cra_alignmask = OMAP_ALIGN_MASK,
16611651
.cra_module = THIS_MODULE,
16621652
.cra_init = omap_sham_cra_init,
16631653
.cra_exit = omap_sham_cra_exit,
@@ -1682,7 +1672,6 @@ static struct ahash_engine_alg algs_sha384_sha512[] = {
16821672
.cra_blocksize = SHA384_BLOCK_SIZE,
16831673
.cra_ctxsize = sizeof(struct omap_sham_ctx) +
16841674
sizeof(struct omap_sham_hmac_ctx),
1685-
.cra_alignmask = OMAP_ALIGN_MASK,
16861675
.cra_module = THIS_MODULE,
16871676
.cra_init = omap_sham_cra_sha384_init,
16881677
.cra_exit = omap_sham_cra_exit,
@@ -1707,7 +1696,6 @@ static struct ahash_engine_alg algs_sha384_sha512[] = {
17071696
.cra_blocksize = SHA512_BLOCK_SIZE,
17081697
.cra_ctxsize = sizeof(struct omap_sham_ctx) +
17091698
sizeof(struct omap_sham_hmac_ctx),
1710-
.cra_alignmask = OMAP_ALIGN_MASK,
17111699
.cra_module = THIS_MODULE,
17121700
.cra_init = omap_sham_cra_sha512_init,
17131701
.cra_exit = omap_sham_cra_exit,

0 commit comments

Comments
 (0)