Skip to content

Instantly share code, notes, and snippets.

@syed-ahmed
Created November 13, 2020 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syed-ahmed/2581e3ecb486fe3540a76211569f5fd5 to your computer and use it in GitHub Desktop.
Save syed-ahmed/2581e3ecb486fe3540a76211569f5fd5 to your computer and use it in GitHub Desktop.
#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