1/* Loading arbitrary modules using crypto api since v2.6.38
2 *
3 * - minipli
4 */
5#include <linux/if_alg.h>
6#include <sys/socket.h>
7#include <unistd.h>
8#include <stdlib.h>
9#include <string.h>
10#include <stdio.h>
11#ifndef AF_ALG
12#define AF_ALG 38
13#endif
14
15
16int main(int argc, char **argv) {
17	struct sockaddr_alg sa_alg = {
18		.salg_family = AF_ALG,
19		.salg_type = "hash",
20	};
21	int sock;
22	if (argc != 2) {
23		printf("usage: %s MODULE_NAME\n", argv[0]);
24		exit(1);
25	}
26	sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
27	if (sock < 0) {
28		perror("socket(AF_ALG)");
29		exit(1);
30	}
31	strncpy((char *) sa_alg.salg_name, argv[1], sizeof(sa_alg.salg_name));
32	bind(sock, (struct sockaddr *) &sa_alg, sizeof(sa_alg));
33	close(sock);
34
35	return 0;
36}
37