#include #include #include #include #include #include int main(void) { int opfd; int tfmfd; struct sockaddr_alg sa = { .salg_family = AF_ALG, .salg_type = "hash", .salg_name = "sha1" }; char buf2[10000000]; char buf[20]; int i; struct stat st; tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0); bind(tfmfd, (struct sockaddr *)&sa, sizeof(sa)); opfd = accept(tfmfd, NULL, 0); int true = open("/bin/true", O_RDONLY); fstat(true, &st); sendfile(opfd, true, NULL, st.st_size); read(opfd, &buf, 20); for (i = 0; i < 20; i++) { printf("%02x", (unsigned char)buf[i]); } printf("\n"); lseek(true, 0, SEEK_SET); read(true, &buf2, st.st_size); write(opfd, &buf2, st.st_size); read(opfd, &buf, 20); for (i = 0; i < 20; i++) { printf("%02x", (unsigned char)buf[i]); } printf("\n"); close(opfd); close(tfmfd); return 0; }