Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
f35a4e23 492444c3

+2 -14
+2 -14
drivers/crypto/omap-sham.c
··· 356 356 357 357 if (big_endian) 358 358 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]); 360 360 else 361 361 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]); 363 363 } 364 364 365 365 static void omap_sham_write_ctrl_omap2(struct omap_sham_dev *dd, size_t length, ··· 1435 1435 CRYPTO_ALG_NEED_FALLBACK, 1436 1436 .cra_blocksize = SHA1_BLOCK_SIZE, 1437 1437 .cra_ctxsize = sizeof(struct omap_sham_ctx), 1438 - .cra_alignmask = OMAP_ALIGN_MASK, 1439 1438 .cra_module = THIS_MODULE, 1440 1439 .cra_init = omap_sham_cra_init, 1441 1440 .cra_exit = omap_sham_cra_exit, ··· 1457 1458 CRYPTO_ALG_NEED_FALLBACK, 1458 1459 .cra_blocksize = SHA1_BLOCK_SIZE, 1459 1460 .cra_ctxsize = sizeof(struct omap_sham_ctx), 1460 - .cra_alignmask = OMAP_ALIGN_MASK, 1461 1461 .cra_module = THIS_MODULE, 1462 1462 .cra_init = omap_sham_cra_init, 1463 1463 .cra_exit = omap_sham_cra_exit, ··· 1481 1483 .cra_blocksize = SHA1_BLOCK_SIZE, 1482 1484 .cra_ctxsize = sizeof(struct omap_sham_ctx) + 1483 1485 sizeof(struct omap_sham_hmac_ctx), 1484 - .cra_alignmask = OMAP_ALIGN_MASK, 1485 1486 .cra_module = THIS_MODULE, 1486 1487 .cra_init = omap_sham_cra_sha1_init, 1487 1488 .cra_exit = omap_sham_cra_exit, ··· 1505 1508 .cra_blocksize = SHA1_BLOCK_SIZE, 1506 1509 .cra_ctxsize = sizeof(struct omap_sham_ctx) + 1507 1510 sizeof(struct omap_sham_hmac_ctx), 1508 - .cra_alignmask = OMAP_ALIGN_MASK, 1509 1511 .cra_module = THIS_MODULE, 1510 1512 .cra_init = omap_sham_cra_md5_init, 1511 1513 .cra_exit = omap_sham_cra_exit, ··· 1531 1535 CRYPTO_ALG_NEED_FALLBACK, 1532 1536 .cra_blocksize = SHA224_BLOCK_SIZE, 1533 1537 .cra_ctxsize = sizeof(struct omap_sham_ctx), 1534 - .cra_alignmask = OMAP_ALIGN_MASK, 1535 1538 .cra_module = THIS_MODULE, 1536 1539 .cra_init = omap_sham_cra_init, 1537 1540 .cra_exit = omap_sham_cra_exit, ··· 1553 1558 CRYPTO_ALG_NEED_FALLBACK, 1554 1559 .cra_blocksize = SHA256_BLOCK_SIZE, 1555 1560 .cra_ctxsize = sizeof(struct omap_sham_ctx), 1556 - .cra_alignmask = OMAP_ALIGN_MASK, 1557 1561 .cra_module = THIS_MODULE, 1558 1562 .cra_init = omap_sham_cra_init, 1559 1563 .cra_exit = omap_sham_cra_exit, ··· 1577 1583 .cra_blocksize = SHA224_BLOCK_SIZE, 1578 1584 .cra_ctxsize = sizeof(struct omap_sham_ctx) + 1579 1585 sizeof(struct omap_sham_hmac_ctx), 1580 - .cra_alignmask = OMAP_ALIGN_MASK, 1581 1586 .cra_module = THIS_MODULE, 1582 1587 .cra_init = omap_sham_cra_sha224_init, 1583 1588 .cra_exit = omap_sham_cra_exit, ··· 1601 1608 .cra_blocksize = SHA256_BLOCK_SIZE, 1602 1609 .cra_ctxsize = sizeof(struct omap_sham_ctx) + 1603 1610 sizeof(struct omap_sham_hmac_ctx), 1604 - .cra_alignmask = OMAP_ALIGN_MASK, 1605 1611 .cra_module = THIS_MODULE, 1606 1612 .cra_init = omap_sham_cra_sha256_init, 1607 1613 .cra_exit = omap_sham_cra_exit, ··· 1626 1634 CRYPTO_ALG_NEED_FALLBACK, 1627 1635 .cra_blocksize = SHA384_BLOCK_SIZE, 1628 1636 .cra_ctxsize = sizeof(struct omap_sham_ctx), 1629 - .cra_alignmask = OMAP_ALIGN_MASK, 1630 1637 .cra_module = THIS_MODULE, 1631 1638 .cra_init = omap_sham_cra_init, 1632 1639 .cra_exit = omap_sham_cra_exit, ··· 1648 1657 CRYPTO_ALG_NEED_FALLBACK, 1649 1658 .cra_blocksize = SHA512_BLOCK_SIZE, 1650 1659 .cra_ctxsize = sizeof(struct omap_sham_ctx), 1651 - .cra_alignmask = OMAP_ALIGN_MASK, 1652 1660 .cra_module = THIS_MODULE, 1653 1661 .cra_init = omap_sham_cra_init, 1654 1662 .cra_exit = omap_sham_cra_exit, ··· 1672 1682 .cra_blocksize = SHA384_BLOCK_SIZE, 1673 1683 .cra_ctxsize = sizeof(struct omap_sham_ctx) + 1674 1684 sizeof(struct omap_sham_hmac_ctx), 1675 - .cra_alignmask = OMAP_ALIGN_MASK, 1676 1685 .cra_module = THIS_MODULE, 1677 1686 .cra_init = omap_sham_cra_sha384_init, 1678 1687 .cra_exit = omap_sham_cra_exit, ··· 1696 1707 .cra_blocksize = SHA512_BLOCK_SIZE, 1697 1708 .cra_ctxsize = sizeof(struct omap_sham_ctx) + 1698 1709 sizeof(struct omap_sham_hmac_ctx), 1699 - .cra_alignmask = OMAP_ALIGN_MASK, 1700 1710 .cra_module = THIS_MODULE, 1701 1711 .cra_init = omap_sham_cra_sha512_init, 1702 1712 .cra_exit = omap_sham_cra_exit,