我试图在内核空间(2.6.34)进行aes加密,下面是我的示例代码模块,获得了错误。我无法解决这个"crypto_alloc_base“问题。任何帮助都将不胜感激。
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/crypto.h>
int init_module(void)
{
struct crypto_cipher *tfm;
const u8 key[16]= "my key";
u8 in[20] ="I Love India";
u8 encrypted[200];
u8 decrypted[200];
printk(KERN_INFO ">>>>>>>>aesModule Insmoded>>>>>>>>\n");
printk(KERN_INFO ">>>>>>>>Plain:%s \n",in);
tfm = crypto_alloc_cipher("aes", 0, 16);
//if (!IS_ERR(tfm))
crypto_cipher_setkey(tfm, key, ALG_CCMP_KEY_LEN);
crypto_cipher_encrypt_one(tfm, encrypted, in);
printk(KERN_INFO ">>>>Encrypted :%s \n",encrypted);
crypto_cipher_decrypt_one(tfm, decrypted, encrypted);
printk(KERN_INFO ">>>>Decrypted :%s \n ",decrypted);
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO ">>>>>>>>aesModule Removed>>>>>>>>\n");
}
#insmod aesTest.ko
aesTest: Unknown symbol crypto_alloc_base
insmod: error inserting 'aesTest.ko': -1 Unknown symbol in module谢谢你,
巴伦·帕利查
发布于 2012-02-07 05:49:25
我通过将下面的代码添加到模块的末尾来解决这个问题。
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Barun code for aes encryption test");
MODULE_AUTHOR("Barun Parichha<barun.parichha@gmail.com>");
MODULE_ALIAS("test");造成此错误的原因:
http://docs.blackfin.uclinux.org/kernel/generated/kernel-hacking/ch09s02.html
用EXPORT_SYMBOL()导出的符号只能由具有MODULE_LICENSE()指定GPL兼容许可证的模块看到。
致以敬意,
巴伦·帕利查
https://stackoverflow.com/questions/9156076
复制相似问题