[CRYPTO] padlock: Get rid of padlock-generic.c
Merge padlock-generic.c into padlock-aes.c and compile AES as a standalone module. We won't make a monolithic padlock.ko with all supported algorithms, instead we'll compile each driver into its own module. Signed-off-by: Michal Ludvig <michal@logix.cz> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
b14cdd6704
commit
1191f0a493
|
@ -1,24 +1,30 @@
|
||||||
menu "Hardware crypto devices"
|
menu "Hardware crypto devices"
|
||||||
|
|
||||||
config CRYPTO_DEV_PADLOCK
|
config CRYPTO_DEV_PADLOCK
|
||||||
tristate "Support for VIA PadLock ACE"
|
bool "Support for VIA PadLock ACE"
|
||||||
depends on X86_32
|
depends on X86_32
|
||||||
select CRYPTO_ALGAPI
|
select CRYPTO_ALGAPI
|
||||||
|
default y
|
||||||
help
|
help
|
||||||
Some VIA processors come with an integrated crypto engine
|
Some VIA processors come with an integrated crypto engine
|
||||||
(so called VIA PadLock ACE, Advanced Cryptography Engine)
|
(so called VIA PadLock ACE, Advanced Cryptography Engine)
|
||||||
that provides instructions for very fast {en,de}cryption
|
that provides instructions for very fast cryptographic
|
||||||
with some algorithms.
|
operations with supported algorithms.
|
||||||
|
|
||||||
The instructions are used only when the CPU supports them.
|
The instructions are used only when the CPU supports them.
|
||||||
Otherwise software encryption is used. If you are unsure,
|
Otherwise software encryption is used. If you are unsure,
|
||||||
say Y.
|
say Y.
|
||||||
|
|
||||||
config CRYPTO_DEV_PADLOCK_AES
|
config CRYPTO_DEV_PADLOCK_AES
|
||||||
bool "Support for AES in VIA PadLock"
|
tristate "PadLock driver for AES algorithm"
|
||||||
depends on CRYPTO_DEV_PADLOCK
|
depends on CRYPTO_DEV_PADLOCK
|
||||||
default y
|
default m
|
||||||
help
|
help
|
||||||
Use VIA PadLock for AES algorithm.
|
Use VIA PadLock for AES algorithm.
|
||||||
|
|
||||||
|
Available in VIA C3 and newer CPUs.
|
||||||
|
|
||||||
|
If unsure say M. The compiled module will be
|
||||||
|
called padlock-aes.ko
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -1,7 +1 @@
|
||||||
|
obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
|
||||||
obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o
|
|
||||||
|
|
||||||
padlock-objs-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
|
|
||||||
|
|
||||||
padlock-objs := padlock-generic.o $(padlock-objs-y)
|
|
||||||
|
|
||||||
|
|
|
@ -495,15 +495,41 @@ static struct crypto_alg aes_alg = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int __init padlock_init_aes(void)
|
static int __init padlock_init(void)
|
||||||
{
|
{
|
||||||
printk(KERN_NOTICE PFX "Using VIA PadLock ACE for AES algorithm.\n");
|
int ret;
|
||||||
|
|
||||||
|
if (!cpu_has_xcrypt) {
|
||||||
|
printk(KERN_ERR PFX "VIA PadLock not detected.\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cpu_has_xcrypt_enabled) {
|
||||||
|
printk(KERN_ERR PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
gen_tabs();
|
gen_tabs();
|
||||||
return crypto_register_alg(&aes_alg);
|
if ((ret = crypto_register_alg(&aes_alg))) {
|
||||||
|
printk(KERN_ERR PFX "VIA PadLock AES initialization failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
printk(KERN_NOTICE PFX "Using VIA PadLock ACE for AES algorithm.\n");
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __exit padlock_fini_aes(void)
|
static void __exit padlock_fini(void)
|
||||||
{
|
{
|
||||||
crypto_unregister_alg(&aes_alg);
|
crypto_unregister_alg(&aes_alg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module_init(padlock_init);
|
||||||
|
module_exit(padlock_fini);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("VIA PadLock AES algorithm support");
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_AUTHOR("Michal Ludvig");
|
||||||
|
|
||||||
|
MODULE_ALIAS("aes-padlock");
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Cryptographic API.
|
|
||||||
*
|
|
||||||
* Support for VIA PadLock hardware crypto engine.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004 Michal Ludvig <michal@logix.cz>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <linux/module.h>
|
|
||||||
#include <linux/init.h>
|
|
||||||
#include <linux/types.h>
|
|
||||||
#include <linux/errno.h>
|
|
||||||
#include <linux/crypto.h>
|
|
||||||
#include <asm/byteorder.h>
|
|
||||||
#include "padlock.h"
|
|
||||||
|
|
||||||
static int __init
|
|
||||||
padlock_init(void)
|
|
||||||
{
|
|
||||||
int ret = -ENOSYS;
|
|
||||||
|
|
||||||
if (!cpu_has_xcrypt) {
|
|
||||||
printk(KERN_ERR PFX "VIA PadLock not detected.\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cpu_has_xcrypt_enabled) {
|
|
||||||
printk(KERN_ERR PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES
|
|
||||||
if ((ret = padlock_init_aes())) {
|
|
||||||
printk(KERN_ERR PFX "VIA PadLock AES initialization failed.\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret == -ENOSYS)
|
|
||||||
printk(KERN_ERR PFX "Hmm, VIA PadLock was compiled without any algorithm.\n");
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __exit
|
|
||||||
padlock_fini(void)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES
|
|
||||||
padlock_fini_aes();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
module_init(padlock_init);
|
|
||||||
module_exit(padlock_fini);
|
|
||||||
|
|
||||||
MODULE_DESCRIPTION("VIA PadLock crypto engine support.");
|
|
||||||
MODULE_LICENSE("Dual BSD/GPL");
|
|
||||||
MODULE_AUTHOR("Michal Ludvig");
|
|
Loading…
Reference in New Issue