25 lines
572 B
C
25 lines
572 B
C
#include <linux/if_alg.h>
|
|
#include <linux/rtnetlink.h>
|
|
#include <sys/socket.h>
|
|
|
|
int main() {
|
|
int fd;
|
|
struct sockaddr_alg addr = {
|
|
.salg_type = "aead",
|
|
.salg_name = "authenc(hmac(sha256),cbc(aes))",
|
|
};
|
|
|
|
struct {
|
|
struct rtattr attr;
|
|
__be32 enckeylen;
|
|
char keys[1];
|
|
} __attribute__((packed)) key = {
|
|
.attr.rta_len = sizeof(key),
|
|
.attr.rta_type = 1 /* CRYPTO_AUTHENC_KEYA_PARAM */,
|
|
};
|
|
|
|
fd = socket(AF_ALG, SOCK_SEQPACKET, 0);
|
|
bind(fd, (void *)&addr, sizeof(addr));
|
|
setsockopt(fd, SOL_ALG, ALG_SET_KEY, &key, sizeof(key));
|
|
}
|