raddirad
raddirad

Reputation: 331

Use Kernel functions in userspace

I am currently trying to use the functions of

/usr/src/linux/crypto/aes_generic.c 

in a userspace program I want to encode allocated memory and use the ecnrypt function of the above file.

how can i use these kernel functions in a userspace program?

I tried to include the needed kernel headers in my userspace program with

-I /usr/src/linux/include/

but i dindt get far as I get the error that asm/irqflags.h, file or directory not found.

here's the include

#include <asm-generic/irqflags.h> 

I do not have an asm directory and other two headers with the above stated error got included fine with asm-generic as directory

Thanks in advance

Upvotes: 1

Views: 750

Answers (2)

onemouth
onemouth

Reputation: 2277

There is User-space interface for Crypto API. So you can use AF_ALG interface to access kernel crypto API (after version 2.6.38 of the Linux kernel).

Here are some working examples in cryptsetup source code.

Upvotes: 1

falkb
falkb

Reputation: 1349

The Cryptodev-linux module allows you to access the Linux kernel cryptographic drivers from userspace via /dev/crypto. Examples can be found e.g. here. The advantage is you can benefit from its possibly used hardware acceleration.

Otherwise you need to use one of many derivatives of the AES library to be linked against your user application. See here for a list.

Upvotes: 0

Related Questions