Barun Parichha
Barun Parichha

Reputation: 166

AES Encryption Error: Unknown symbol crypto_alloc_base

I am trying to do aes encryption in kernel space (2.6.34), and below is my sample code module with the error obtained. I am unable to resolve this "crypto_alloc_base" issue. Any help will be appreciated.

#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

With Thanks,
Barun Parichha

Upvotes: 0

Views: 1708

Answers (1)

Barun Parichha
Barun Parichha

Reputation: 166

I resolved this issue by adding below code to the end of the module.

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Barun code for aes encryption test");
MODULE_AUTHOR("Barun Parichha<[email protected]>");
MODULE_ALIAS("test");

Reason for this error:
http://docs.blackfin.uclinux.org/kernel/generated/kernel-hacking/ch09s02.html
symbols exported with EXPORT_SYMBOL(), can only be seen by modules with a MODULE_LICENSE() that specifies a GPL compatible license.

Regards,
Barun Parichha

Upvotes: 1

Related Questions