Reputation: 23489
I know linux kernel has "aes" module internally , so perhaps someone could provide me an example for it , as i'm making a kernel module which utiliser this function.
Many thanks.
Upvotes: 4
Views: 3822
Reputation: 6543
You could look at net/mac80211/aes_ccm.c
for example. The basic sequence is
crypto_alloc_cipher("aes", ...)
crypto_cipher_setkey(...)
crypto_cipher_encrypt_one(...)
as much as you needcrypto_free_cipher(...)
Or net/ceph/crypto.c
gives an example of using AES in CBC mode.
In any case be very careful of how you generate keys and the chaining mode, or else you are likely to make a mistake and do something insecure.
Upvotes: 5