Created
November 13, 2020 01:06
-
-
Save syed-ahmed/2581e3ecb486fe3540a76211569f5fd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/socket.h> | |
#include <linux/if_alg.h> | |
#include <linux/socket.h> | |
#define SHA384_DIGEST_SZ 48 | |
int main(void) { | |
sockaddr_alg | |
sa | |
{ | |
AF_ALG, "hash", 0, 0, "xilinx-keccak-384" | |
}; | |
unsigned char digest[SHA384_DIGEST_SZ]; | |
char *input = "Hellhash"; /* Input Data should be multiple of 4-bytes */ | |
int i, sockfd, fd; | |
sockfd = socket(AF_ALG, SOCK_SEQPACKET, 0); | |
bind(sockfd, (sockaddr *) &sa, sizeof(sa)); | |
fd = accept(sockfd, NULL, 0); | |
write(fd, input, strlen(input)); | |
read(fd, digest, SHA384_DIGEST_SZ); | |
close(fd); | |
close(sockfd); | |
for (i = 0; i < SHA384_DIGEST_SZ; i++) | |
printf("%02x", digest[i]); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment