From d3cfece2527042b6fbbb09c33d8936f54c9938b7 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 23 Jan 2017 11:31:24 -0500 Subject: [PATCH] Added sha512 encoding --- crypto/Makefile | 2 +- crypto/sha512.c | 13 +++++++++++++ include/libp2p/crypto/sha512.h | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 crypto/sha512.c create mode 100644 include/libp2p/crypto/sha512.h diff --git a/crypto/Makefile b/crypto/Makefile index adf6fa4..4fa2c34 100644 --- a/crypto/Makefile +++ b/crypto/Makefile @@ -2,7 +2,7 @@ CC = gcc CFLAGS = -O0 -I../include -g3 LFLAGS = DEPS = -OBJS = rsa.o sha256.o +OBJS = rsa.o sha256.o sha512.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/crypto/sha512.c b/crypto/sha512.c new file mode 100644 index 0000000..21ffc32 --- /dev/null +++ b/crypto/sha512.c @@ -0,0 +1,13 @@ +#include "mbedtls/sha512.h" + +/*** + * hash a string using SHA512 + * @param input the input string + * @param input_length the length of the input string + * @param output where to place the results + * @returns 1 + */ +int libp2p_crypto_hashing_sha512(const unsigned char* input, size_t input_length, unsigned char output[128]) { + mbedtls_sha512(input, input_length, output, 0); + return 1; +} diff --git a/include/libp2p/crypto/sha512.h b/include/libp2p/crypto/sha512.h new file mode 100644 index 0000000..c8d4699 --- /dev/null +++ b/include/libp2p/crypto/sha512.h @@ -0,0 +1,11 @@ +#pragma once + +/*** + * hash a string using SHA512 + * @param input the input string + * @param input_length the length of the input string + * @param output where to place the results + * @returns 1 + */ +int libp2p_crypto_hashing_sha512(const unsigned char* input, size_t input_length, unsigned char output[128]); +