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

crypto: stm32 - remove unnecessary 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 stm32 driver no longer use it. This driver didn't actually
rely on it; it only writes to the result buffer in stm32_hash_finish(),
simply using memcpy(). And stm32_hash_setkey() does not assume any
alignment for the key buffer.

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
54eea8e2 8c87553e

-20
-20
drivers/crypto/stm32/stm32-hash.c
··· 1283 1283 CRYPTO_ALG_KERN_DRIVER_ONLY, 1284 1284 .cra_blocksize = MD5_HMAC_BLOCK_SIZE, 1285 1285 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1286 - .cra_alignmask = 3, 1287 1286 .cra_init = stm32_hash_cra_init, 1288 1287 .cra_exit = stm32_hash_cra_exit, 1289 1288 .cra_module = THIS_MODULE, ··· 1312 1313 CRYPTO_ALG_KERN_DRIVER_ONLY, 1313 1314 .cra_blocksize = MD5_HMAC_BLOCK_SIZE, 1314 1315 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1315 - .cra_alignmask = 3, 1316 1316 .cra_init = stm32_hash_cra_hmac_init, 1317 1317 .cra_exit = stm32_hash_cra_exit, 1318 1318 .cra_module = THIS_MODULE, ··· 1343 1345 CRYPTO_ALG_KERN_DRIVER_ONLY, 1344 1346 .cra_blocksize = SHA1_BLOCK_SIZE, 1345 1347 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1346 - .cra_alignmask = 3, 1347 1348 .cra_init = stm32_hash_cra_init, 1348 1349 .cra_exit = stm32_hash_cra_exit, 1349 1350 .cra_module = THIS_MODULE, ··· 1372 1375 CRYPTO_ALG_KERN_DRIVER_ONLY, 1373 1376 .cra_blocksize = SHA1_BLOCK_SIZE, 1374 1377 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1375 - .cra_alignmask = 3, 1376 1378 .cra_init = stm32_hash_cra_hmac_init, 1377 1379 .cra_exit = stm32_hash_cra_exit, 1378 1380 .cra_module = THIS_MODULE, ··· 1403 1407 CRYPTO_ALG_KERN_DRIVER_ONLY, 1404 1408 .cra_blocksize = SHA224_BLOCK_SIZE, 1405 1409 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1406 - .cra_alignmask = 3, 1407 1410 .cra_init = stm32_hash_cra_init, 1408 1411 .cra_exit = stm32_hash_cra_exit, 1409 1412 .cra_module = THIS_MODULE, ··· 1432 1437 CRYPTO_ALG_KERN_DRIVER_ONLY, 1433 1438 .cra_blocksize = SHA224_BLOCK_SIZE, 1434 1439 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1435 - .cra_alignmask = 3, 1436 1440 .cra_init = stm32_hash_cra_hmac_init, 1437 1441 .cra_exit = stm32_hash_cra_exit, 1438 1442 .cra_module = THIS_MODULE, ··· 1463 1469 CRYPTO_ALG_KERN_DRIVER_ONLY, 1464 1470 .cra_blocksize = SHA256_BLOCK_SIZE, 1465 1471 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1466 - .cra_alignmask = 3, 1467 1472 .cra_init = stm32_hash_cra_init, 1468 1473 .cra_exit = stm32_hash_cra_exit, 1469 1474 .cra_module = THIS_MODULE, ··· 1492 1499 CRYPTO_ALG_KERN_DRIVER_ONLY, 1493 1500 .cra_blocksize = SHA256_BLOCK_SIZE, 1494 1501 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1495 - .cra_alignmask = 3, 1496 1502 .cra_init = stm32_hash_cra_hmac_init, 1497 1503 .cra_exit = stm32_hash_cra_exit, 1498 1504 .cra_module = THIS_MODULE, ··· 1523 1531 CRYPTO_ALG_KERN_DRIVER_ONLY, 1524 1532 .cra_blocksize = SHA384_BLOCK_SIZE, 1525 1533 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1526 - .cra_alignmask = 3, 1527 1534 .cra_init = stm32_hash_cra_init, 1528 1535 .cra_exit = stm32_hash_cra_exit, 1529 1536 .cra_module = THIS_MODULE, ··· 1552 1561 CRYPTO_ALG_KERN_DRIVER_ONLY, 1553 1562 .cra_blocksize = SHA384_BLOCK_SIZE, 1554 1563 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1555 - .cra_alignmask = 3, 1556 1564 .cra_init = stm32_hash_cra_hmac_init, 1557 1565 .cra_exit = stm32_hash_cra_exit, 1558 1566 .cra_module = THIS_MODULE, ··· 1580 1590 CRYPTO_ALG_KERN_DRIVER_ONLY, 1581 1591 .cra_blocksize = SHA512_BLOCK_SIZE, 1582 1592 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1583 - .cra_alignmask = 3, 1584 1593 .cra_init = stm32_hash_cra_init, 1585 1594 .cra_exit = stm32_hash_cra_exit, 1586 1595 .cra_module = THIS_MODULE, ··· 1609 1620 CRYPTO_ALG_KERN_DRIVER_ONLY, 1610 1621 .cra_blocksize = SHA512_BLOCK_SIZE, 1611 1622 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1612 - .cra_alignmask = 3, 1613 1623 .cra_init = stm32_hash_cra_hmac_init, 1614 1624 .cra_exit = stm32_hash_cra_exit, 1615 1625 .cra_module = THIS_MODULE, ··· 1640 1652 CRYPTO_ALG_KERN_DRIVER_ONLY, 1641 1653 .cra_blocksize = SHA3_224_BLOCK_SIZE, 1642 1654 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1643 - .cra_alignmask = 3, 1644 1655 .cra_init = stm32_hash_cra_sha3_init, 1645 1656 .cra_exit = stm32_hash_cra_exit, 1646 1657 .cra_module = THIS_MODULE, ··· 1669 1682 CRYPTO_ALG_KERN_DRIVER_ONLY, 1670 1683 .cra_blocksize = SHA3_224_BLOCK_SIZE, 1671 1684 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1672 - .cra_alignmask = 3, 1673 1685 .cra_init = stm32_hash_cra_sha3_hmac_init, 1674 1686 .cra_exit = stm32_hash_cra_exit, 1675 1687 .cra_module = THIS_MODULE, ··· 1697 1711 CRYPTO_ALG_KERN_DRIVER_ONLY, 1698 1712 .cra_blocksize = SHA3_256_BLOCK_SIZE, 1699 1713 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1700 - .cra_alignmask = 3, 1701 1714 .cra_init = stm32_hash_cra_sha3_init, 1702 1715 .cra_exit = stm32_hash_cra_exit, 1703 1716 .cra_module = THIS_MODULE, ··· 1726 1741 CRYPTO_ALG_KERN_DRIVER_ONLY, 1727 1742 .cra_blocksize = SHA3_256_BLOCK_SIZE, 1728 1743 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1729 - .cra_alignmask = 3, 1730 1744 .cra_init = stm32_hash_cra_sha3_hmac_init, 1731 1745 .cra_exit = stm32_hash_cra_exit, 1732 1746 .cra_module = THIS_MODULE, ··· 1754 1770 CRYPTO_ALG_KERN_DRIVER_ONLY, 1755 1771 .cra_blocksize = SHA3_384_BLOCK_SIZE, 1756 1772 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1757 - .cra_alignmask = 3, 1758 1773 .cra_init = stm32_hash_cra_sha3_init, 1759 1774 .cra_exit = stm32_hash_cra_exit, 1760 1775 .cra_module = THIS_MODULE, ··· 1783 1800 CRYPTO_ALG_KERN_DRIVER_ONLY, 1784 1801 .cra_blocksize = SHA3_384_BLOCK_SIZE, 1785 1802 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1786 - .cra_alignmask = 3, 1787 1803 .cra_init = stm32_hash_cra_sha3_hmac_init, 1788 1804 .cra_exit = stm32_hash_cra_exit, 1789 1805 .cra_module = THIS_MODULE, ··· 1811 1829 CRYPTO_ALG_KERN_DRIVER_ONLY, 1812 1830 .cra_blocksize = SHA3_512_BLOCK_SIZE, 1813 1831 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1814 - .cra_alignmask = 3, 1815 1832 .cra_init = stm32_hash_cra_sha3_init, 1816 1833 .cra_exit = stm32_hash_cra_exit, 1817 1834 .cra_module = THIS_MODULE, ··· 1840 1859 CRYPTO_ALG_KERN_DRIVER_ONLY, 1841 1860 .cra_blocksize = SHA3_512_BLOCK_SIZE, 1842 1861 .cra_ctxsize = sizeof(struct stm32_hash_ctx), 1843 - .cra_alignmask = 3, 1844 1862 .cra_init = stm32_hash_cra_sha3_hmac_init, 1845 1863 .cra_exit = stm32_hash_cra_exit, 1846 1864 .cra_module = THIS_MODULE,