aboutsummaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-01 19:32:51 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-01 19:32:51 +0200
commitcbd3905f01dcc1e884d778be9437012b93fe317a (patch)
treec681a209fcce9d895cb646c7248d9feeb7d00274 /inc
parentc86a27cca36c4bcc5439f17c673d2029ef5038c5 (diff)
downloadft_ssl-cbd3905f01dcc1e884d778be9437012b93fe317a.tar.gz
ft_ssl-cbd3905f01dcc1e884d778be9437012b93fe317a.tar.bz2
ft_ssl-cbd3905f01dcc1e884d778be9437012b93fe317a.zip
Refactoring md5 to generalize message digest
Diffstat (limited to 'inc')
-rw-r--r--inc/ft_ssl.h39
-rw-r--r--inc/ft_ssl_md5.h25
2 files changed, 37 insertions, 27 deletions
diff --git a/inc/ft_ssl.h b/inc/ft_ssl.h
index f3e3595..c88e7c3 100644
--- a/inc/ft_ssl.h
+++ b/inc/ft_ssl.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/03 20:27:19 by cacharle #+# #+# */
-/* Updated: 2020/07/27 21:38:12 by charles ### ########.fr */
+/* Updated: 2020/08/01 19:24:12 by charles ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
@@ -14,9 +14,29 @@
#ifndef FT_SSL_H
# define FT_SSL_H
+# include <stdint.h>
+
# include "libft.h"
-# include "ft_ssl_md5.h"
+typedef void *(*t_compression_func)(void *state, uint8_t *chunk);
+
+typedef struct
+{
+ t_compression_func compression_func;
+ void *compression_state;
+ size_t compression_state_size;
+ size_t chunk_size;
+ uint8_t *message;
+ uint64_t size;
+} t_message_digest_param;
+
+void *md5_compression_func(void *v_state, uint8_t *chunk);
+char *message_digest(t_message_digest_param *param);
+
+#define MD5_A_INIT 0x67452301
+#define MD5_B_INIT 0xefcdab89
+#define MD5_C_INIT 0x98badcfe
+#define MD5_D_INIT 0x10325476
// # include "ft_ssl_md5.h"
// # include "ft_ssl_sha256.h"
@@ -50,4 +70,19 @@ typedef char *(*t_func_hash)(char *message);
// int parse_args(char *name, int argc, char **argv, t_func_hash func_hash);
+
+/*
+** utils.c
+*/
+
+uint32_t rotate_left(uint32_t x, int s);
+uint32_t rotate_right(uint32_t x, int s);
+char *bytes_to_str(uint8_t *bytes, size_t size);
+
+/*
+** md5
+*/
+
+char *message_digest_md5(uint8_t *msg, size_t size);
+
#endif
diff --git a/inc/ft_ssl_md5.h b/inc/ft_ssl_md5.h
deleted file mode 100644
index 22d0845..0000000
--- a/inc/ft_ssl_md5.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_ssl_md5.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/02/22 07:14:45 by cacharle #+# #+# */
-/* Updated: 2020/07/27 16:36:41 by charles ### ########.fr */
-/* */
-/* ************************************************************************** */
-#include <stdio.h>
-
-#ifndef FT_SSL_MD5_H
-# define FT_SSL_MD5_H
-
-# include <stdlib.h>
-# include <stdint.h>
-# include <stddef.h>
-
-# include "libft.h"
-
-char *message_digest_md5(uint8_t *msg, size_t size);
-
-#endif