crypto: Alchemy AES engine driver
Subsystems (2)
RFC PATCH 1/1 crypto: Alchemy AES engine driver
Driver for the AES engine in ECB and CBC modes found on some Alchemy Au1200/Au1300 SoCs.
---
lightly "tested" with the tcrypt module on Au1200; I have no idea whether it really works correctly:
# modprobe alchemy-aes alg: skcipher: setkey failed on test 2 for ecb-aes-alchemy: flags=200000 # modprobe tcrypt mode=10 alg: skcipher: setkey failed on test 3 for cbc-aes-alchemy: flags=0 alg: skcipher: Failed to load transform for cbc(aes): -2 alg: skcipher: Failed to load transform for cbc(aes): -2 tcrypt: one or more tests failed! FATAL: Error inserting tcrypt (/lib/modules/2.6.34-rc6-db1200-00214-g9f84af9/kernel/crypto/tcrypt.ko): Unknown symbol in module, or unknown parameter (see dmesg)
The error in "test 3 for cbc-aes-alchemy" probably comes from the inability to process keys larger than 128 bits.
Please have a look.
Thanks!
drivers/crypto/Kconfig | 8 + drivers/crypto/Makefile | 1 + drivers/crypto/alchemy-aes.c | 579 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 588 insertions(+), 0 deletions(-) create mode 100644 drivers/crypto/alchemy-aes.c
drivers/crypto/Kconfig +8 -0
@@ -222,4 +222,12 @@ config CRYPTO_DEV_PPC4XX help This option allows you to have support for AMCC crypto acceleration. +config CRYPTO_DEV_ALCHEMY_AES + tristate "Au1200/Au1300 AES engine" + depends on MACH_ALCHEMY + select CRYPTO_ALGAPI + select CRYPTO_BLKCIPHER + help + Driver for the AES engine in Alchemy Au1200/Au1300 series SoCs. + endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/ +obj-$(CONFIG_CRYPTO_DEV_ALCHEMY_AES) += alchemy-aes.o
drivers/crypto/alchemy-aes.c new file +579 -0
579 lines not on this page · raw message
Signature · 1 line
1.7.0.4
* Manuel Lauss | 2010-05-06 17:50:45 [+0200]:
A brief look.
Quoted 12 lines
lightly "tested" with the tcrypt module on Au1200; I have no idea whether it really works correctly:
# modprobe alchemy-aes alg: skcipher: setkey failed on test 2 for ecb-aes-alchemy: flags=200000 # modprobe tcrypt mode=10 alg: skcipher: setkey failed on test 3 for cbc-aes-alchemy: flags=0 alg: skcipher: Failed to load transform for cbc(aes): -2 alg: skcipher: Failed to load transform for cbc(aes): -2 tcrypt: one or more tests failed! FATAL: Error inserting tcrypt (/lib/modules/2.6.34-rc6-db1200-00214-g9f84af9/kernel/crypto/tcrypt.ko): Unknown symbol in module, or unknown parameter (see dmesg)
Quoted 2 lines
The error in "test 3 for cbc-aes-alchemy" probably comes from the inability to process keys larger than 128 bits.
You have to fix this, you have to be able to handle other keys as well. In case your hardware does not support it, you have to handle this in software. Look at the geode driver, via or s390. All of them have fallbacks for. If you fail the self test, you driver will no be used afaik.
Quoted 8 lines
Please have a look.
Thanks!drivers/crypto/alchemy-aes.c new file +0
-0
drivers/crypto/alchemy-aes.c line 557
Quoted 6 lines
drivers/crypto/alchemy-aes.c new file +6
-0+static int __init alchemy_aes_load (void ) +{ +/* FIXME: hier sollte auch noch der PRId des prozessors getestet +* werden; Au1210 (0x0503xxxx) und einige Au1300 haben lt. Daten- +* blatt keine AES engine. +*/
You German right? You should handle this in SoC code. So if you figure out, that you have an engine here you add the device. If you don't have it you don't do it and the probe call won't be called. Also the module won't be loaded by udev.
drivers/crypto/alchemy-aes.c line 562
Quoted 4 lines
drivers/crypto/alchemy-aes.c new file +4
-0+/* need to do 8bit accesses to memory to get correct data */ + __alchemy_aes_memid =au1xxx_ddma_add_device (&alchemy_aes_mem_dbdev); +if (!__alchemy_aes_memid) +return -ENODEV ;
What does it do? You don't want to add devices here. If you need something additional do it in SoC code and pass it via platform_data.
drivers/crypto/alchemy-aes.c line 566
Quoted 4 lines
drivers/crypto/alchemy-aes.c new file +4
-0+ +return platform_driver_register (&alchemy_aes_driver); +} +
Sebastian
Hi Sebastian,
Quoted 9 lines
Quoted 8 lines
# modprobe alchemy-aes alg: skcipher: setkey failed on test 2 for ecb-aes-alchemy: flags=200000 # modprobe tcrypt mode=10 alg: skcipher: setkey failed on test 3 for cbc-aes-alchemy: flags=0 alg: skcipher: Failed to load transform for cbc(aes): -2 alg: skcipher: Failed to load transform for cbc(aes): -2 tcrypt: one or more tests failed! FATAL: Error inserting tcrypt (/lib/modules/2.6.34-rc6-db1200-00214-g9f84af9/kernel/crypto/tcrypt.ko): Unknown symbol in module, or unknown parameter (see dmesg)
Quoted 7 lines
Quoted 2 lines
The error in "test 3 for cbc-aes-alchemy" probably comes from the inability to process keys larger than 128 bits.
You have to fix this, you have to be able to handle other keys as well. In case your hardware does not support it, you have to handle this in software. Look at the geode driver, via or s390. All of them have fallbacks for. If you fail the self test, you driver will no be used afaik.
Ah, I wondered what those were used for. I'll fix the driver to use them
as well. Interestingly the algos provided are marked as tested in/proc/crypto though. I assumed the cryptoapi knows that the hw algo can't handle these keylengths (it didn't even call the setkeys callback before throwing the error) and fall back on software aes instead.
Quoted 7 lines
Quoted 7 lines
drivers/crypto/alchemy-aes.c new file +2
-0+static int __init alchemy_aes_load (void ) +{
Quoted 8 lines
Quoted 4 lines
+ /* FIXME: hier sollte auch noch der PRId des prozessors getestet
+ * werden; Au1210 (0x0503xxxx) und einige Au1300 haben lt. Daten-
+ * blatt keine AES engine.
+ */You German right? You should handle this in SoC code. So if you figure out, that you have an engine here you add the device. If you don't have it you don't do it and the probe call won't be called. Also the module won't be loaded by udev.
Hm, I'll think about it.
Quoted 6 lines
Quoted 4 lines
+ /* need to do 8bit accesses to memory to get correct data */
+ __alchemy_aes_memid =au1xxx_ddma_add_device(&alchemy_aes_mem_dbdev);
+ if (!__alchemy_aes_memid)
+ return-ENODEV;What does it do? You don't want to add devices here. If you need something additional do it in SoC code and pass it via
platform_data.
The dbdma code needs templates to get the memory access width right, this adds a template for use with the AES engine. Every instance could use the same template that's why it's registered in the module_init callback. (see drivers/mmc/au1xmmc.c for instance; yes this is a workaround for a shortcoming of the alchemy dbdma framework).
Thanks!
Manuel Lauss
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html