daisy
daisy

Reputation: 23489

Want an example for using aes encryption method in kernel version above or equal 2.6.38

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

Answers (1)

Roland
Roland

Reputation: 6543

You could look at net/mac80211/aes_ccm.c for example. The basic sequence is

  • crypto_alloc_cipher("aes", ...)
  • crypto_cipher_setkey(...)
  • Do crypto_cipher_encrypt_one(...) as much as you need
  • crypto_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

Related Questions