I am looking for a way to call Linux kernel crypto API from user space for RSA encryption/decryption. RSA function are implemented in linux kernel.
Currently, I found 2 way to call crypto API from user space:
- AF_ALG socket, using [libkapi] (http://www.chronox.de/libkcapi.html). It seems to be the offical solution (https://www.kernel.org/doc/html/v4.19/crypto/userspace-if.html).
- [cryptodev] (http://cryptodev-linux.org/) which uses ioctl.
Unfortunaly, cryptodev doesn't support asymmetric algorithms like RSA.
And I am not sur if AF_ALG supports akcipher like RSA. The result of cat /proc/crypto is:
...
name : rsa
driver : rsa-generic
module : kernel
priority : 100
refcnt : 1
selftest : passed
internal : no
type : akcipher
But, I tried to bind an AF_ALG socket with :
int sockfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
struct sockaddr_alg sa = {
.salg_family = AF_ALG,
.salg_type = "akcipher",
.salg_name = "rsa"
};
The bind failed with ***ERROR : bind socket failed (2) : No such file or directory.
Did I miss something ? Is there an other way to call crypto API from user space ?
user-interface? - Scott Hunter