Skip to content

[Project]: ft_ssl_des {WIP} #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 73 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
20fc466
Working in progress: base64.
Apr 11, 2019
1222434
Working in progress: base64
Apr 12, 2019
8127d7b
Base64 parsing ok norme euh no
Apr 12, 2019
0f0297e
Base64 parsing ok
Apr 12, 2019
80720a1
Norme <3
Apr 12, 2019
d2b1878
norrme 2
Apr 12, 2019
306efc5
Base64 algo in progress
Apr 12, 2019
73d264f
Base64 algo in progress
Apr 12, 2019
b70a07f
Base64 in progress:
Apr 15, 2019
42dfbb7
Base64 in progress;
Apr 15, 2019
7b4174a
Base64 in progress:
Apr 22, 2019
48b27a3
base64 in progress
Apr 26, 2019
4e2c6bd
base64 printing okay
Apr 29, 2019
002dd7a
printing okay but base64 decode don't working
Apr 29, 2019
dc6f5be
debug b64 decode
Apr 29, 2019
2b94189
Base64 debug
Apr 30, 2019
7b57e95
Base64 end
Apr 30, 2019
f18bbee
push
Apr 30, 2019
1b16579
rm segf
Apr 30, 2019
14f2f40
Fix bug of parsing b64
May 3, 2019
3371927
b64
May 3, 2019
531317e
b64 refactor parsing
May 3, 2019
4b0d1f1
Refactor: tools in dir
May 6, 2019
ac756cd
Refactor: add deps in makefile
May 6, 2019
4e50b0d
Starting des
May 6, 2019
7b01f77
ok
May 6, 2019
c8d3ed5
check flags
May 6, 2019
2be1a9a
[Feature]: App Enc Sym
May 7, 2019
2657f1f
rm logs test
May 7, 2019
4696ba1
move test in test
May 7, 2019
5a1aaeb
[Feature]: Symmetric Parsing
May 8, 2019
1fdfcf5
[Feature]: Symmetric Parsing
May 8, 2019
97bf4d9
[Feature]: Symmetric Parsing
May 8, 2019
fdb853a
[Refactor]: Clean Headers
May 8, 2019
43f79d4
[Refactor]: Cleaning Headers
May 8, 2019
8650b34
[Refactor]: Norminette ok
May 8, 2019
2257789
[Debug]: Solve segv in parsing des
May 14, 2019
3aacccd
[Feature]: Create PBKDF2
May 20, 2019
74fa6f4
[Feature]: PBKDF2 in progress
May 20, 2019
59e0920
[Debug]: hex2char* swap ifinite :(
May 21, 2019
c7e93f1
[Feature]: PBKDF2
May 21, 2019
83fa65c
[Refactor]: Change md5 and sha256
May 22, 2019
9d7eca1
[Debug + Test]: Check hash
May 22, 2019
5420e90
[Feature]: PBKDF2
May 22, 2019
58593af
[Refactor]: Re-order function for parsing des
Dec 9, 2019
ae3cb5e
[Debug]: Add function check_pbkdf2
Dec 9, 2019
cfdd6be
wip
Dec 11, 2019
e18ccb2
pbkdf2 wip
Dec 13, 2019
b64cb7e
hmac_sha256
Dec 17, 2019
8128a39
hmac_256 wip
Dec 17, 2019
6eaa9c3
refactor pbkdf2 and wip hmac_sha256
Dec 23, 2019
4cf165b
[Function]: Create the function SHA1
Dec 30, 2019
8190b9e
[Norme]: Sha1
Dec 31, 2019
783ba76
[Fonctions]: Create HMAC Functions (sha1, md5, sha256)
Dec 31, 2019
df9190e
[Function]: Create the function PBKDF2
Dec 31, 2019
59c9e60
[Refactor]: Remove files sym_key, move functions pbkdf2 in dir pbkdf2…
Jan 9, 2020
504e3a7
start evp functions
Jan 9, 2020
64a18eb
evp_bytes2key
Feb 3, 2020
2fc2720
merge conflit
lpieri Feb 3, 2020
09ca5c1
evp_bytes2key
lpieri Feb 3, 2020
cbb2765
[Function]: EVP_BytesToKey {wip}
lpieri Feb 4, 2020
59a367b
[Functions]: EVP_BytesToKey {wip}
lpieri Feb 4, 2020
4b4f06c
{wip}
lpieri Feb 4, 2020
7b82829
[Option]: Create option -pbkdf2
lpieri Feb 5, 2020
de75178
[Update]: Change the parsing of evp_function
Apr 17, 2020
b6c4e86
[Libft]: Update ft_ishexa.c
Apr 17, 2020
05cf89c
[Debug]: Function "get_sym_opt_s"
Apr 17, 2020
8b51201
[Update]: Generate IV
Apr 17, 2020
0cbf4d0
[Norm]: Norm of 42 ok
Apr 20, 2020
f4e3317
[Refactor]: Remove leaks & stdio.h
Apr 20, 2020
4c65e3d
Cleaning of the branch before the merge
Apr 20, 2020
4a10f85
Merge branch 'des' into dev/functions/evp_functions
Apr 20, 2020
5695d5b
Remove while(1)
Apr 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

ft_ssl
.vscode
82 changes: 56 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
# By: cpieri <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/03/15 11:20:25 by cpieri #+# #+# #
# Updated: 2019/04/11 16:35:38 by cpieri ### ########.fr #
# Updated: 2020/02/04 10:12:31 by cpieri ### ########.fr #
# #
# **************************************************************************** #


NAME = ft_ssl

CC = gcc
Expand All @@ -27,31 +26,62 @@ SRC_PATH= srcs

OBJ_PATH= obj

DEPS = Makefile \
includes/ft_ssl.h \
includes/define.h \
includes/constant.h \
includes/enum.h \
includes/functions.h \
includes/structure.h \
includes/hash/sha256.h \
includes/hash/hash.h \
includes/hash/md5.h \
DEPS = Makefile \
includes/ft_ssl.h \
includes/define.h \
includes/enum.h \
includes/functions.h \
includes/structure.h \
includes/hash/sha256.h \
includes/hash/hash.h \
includes/hash/md5.h \
includes/hash/sha1.h \
includes/hash/hmac.h \
includes/base64/base64.h \
includes/evp/pbkdf.h \
includes/symmetric/symmetric.h \
includes/symmetric/des/des.h \
libft/libft.a

SRC_NAME= main.c \
clean.c \
usage.c \
parsing.c \
get_data.c \
lst_opt.c \
hash/hash.c \
hash/hash_parsing.c \
hash/display_hash.c \
hash/sha256/sha256.c \
hash/sha256/sha256_utils.c \
hash/md5/md5_utils.c \
hash/md5/md5.c \
SRC_NAME= main.c \
parsing.c \
dispatch.c \
tools/clean.c \
tools/usage.c \
tools/error.c \
tools/get_data.c \
tools/get_data_1.c \
tools/open_fd.c \
tools/lst_opt.c \
hash/hash_parsing.c \
hash/display_hash.c \
hash/hash_tools.c \
hash/sha256/sha256.c \
hash/sha256/sha256_utils.c \
hash/md5/md5_utils.c \
hash/md5/md5.c \
hash/sha1/sha1.c \
hash/sha1/sha1_utils.c \
hash/hmac/hmac_utils.c \
hash/hmac/hmac_md5.c \
hash/hmac/hmac_sha1.c \
hash/hmac/hmac_sha256.c \
base64/base64.c \
base64/base64_encode.c \
base64/base64_decode.c \
base64/base64_parsing.c \
base64/base64_help_parsing.c \
base64/base64_display.c \
evp/pbkdf2.c \
evp/pbkdf2_utils.c \
evp/evp_struct.c \
evp/evp_bytes2key.c \
evp/evp_b2k_utils.c \
symmetric/symmetric_usage.c \
symmetric/symmetric_parsing.c \
symmetric/symmetric_parsing_pt_f.c \
symmetric/symmetric_parsing_pt_f_2.c \
symmetric/des/des.c \

OBJ_NAME= $(SRC_NAME:.c=.o)

Expand All @@ -67,7 +97,7 @@ BLUE = \033[34m
MAGENTA = \033[35m
CYAN = \033[36m

.PHONY: all clean fclean re echo norm
.PHONY: all clean fclean re echo

all: LFT $(NAME)

Expand Down
55 changes: 55 additions & 0 deletions includes/base64/base64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* base64.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/12 11:59:40 by cpieri #+# #+# */
/* Updated: 2019/05/08 13:03:15 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef BASE64_H
# define BASE64_H

# include "../libft/include/libft.h"
# include "../structure.h"

enum e_base64_flags
{
e_base64_encode = 0x00000001,
e_base64_decode = 0x00000010,
e_base64_inputf = 0x00000100,
e_base64_outputf = 0x00001000,
};

typedef struct s_base64_encode
{
uint8_t n0;
uint8_t n1;
uint8_t n2;
uint8_t n3;
} t_base64_encode;

/*
** Encode/Decode Base64
*/
void *base64(void *opts, size_t len_opts);
uint8_t *base64_encode(uint8_t *msg, size_t len);
uint8_t *base64_decode(uint8_t *msg, size_t len);

/*
** Functions for Print Base64
*/
void printing_base64(t_data *data, const char *hash_type,
t_flags flags);

/*
** Funtions for Parse opts Base64
*/
t_opt *base64_opts(const int ac, char **av, t_opt *opts, int now);
void get_b64_ed(t_data **data, t_flags *flags, char *fd, char c);
void get_b64_i(t_data **data, t_flags *flags, char *fd, int *now);

#endif
15 changes: 12 additions & 3 deletions includes/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/11 12:43:16 by cpieri #+# #+# */
/* Updated: 2019/04/11 12:43:43 by cpieri ### ########.fr */
/* Updated: 2019/12/17 09:31:11 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef DEFINE_H
#ifndef DEFINE_H
# define DEFINE_H

# define FAILURE -1
Expand All @@ -19,4 +19,13 @@
# define NO_CMD 1
# define INVALID_CMD 2

#endif
# define NONE "\033[0m"
# define RED "\033[31m"
# define GREEN "\033[32m"
# define YELLOW "\033[33m"
# define BLUE "\033[34m"
# define MAGENTA "\033[35m"
# define CYAN "\033[36m"
# define PINK "\033[38;5;206m"

#endif
14 changes: 3 additions & 11 deletions includes/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/11 14:34:08 by cpieri #+# #+# */
/* Updated: 2019/04/11 16:11:35 by cpieri ### ########.fr */
/* Updated: 2019/05/08 12:45:48 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef ENUM_H
#ifndef ENUM_H
# define ENUM_H

enum e_algo
Expand All @@ -19,12 +19,4 @@ enum e_algo
e_cipher,
};

enum e_cipher_flags
{
e_base64_encode = 1,
e_base64_decode,
e_base64_inputf,
e_base64_outputf,
};

#endif
#endif
46 changes: 46 additions & 0 deletions includes/evp/evp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* evp.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/03 09:13:54 by cpieri #+# #+# */
/* Updated: 2020/04/20 10:42:41 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef EVP_H
# define EVP_H

# include "../../libft/include/libft.h"
# include "../structure.h"
# include "../functions.h"
# include "../hash/hash.h"
# include <math.h>

typedef struct s_evp
{
void *pass;
void *salt;
void *key;
void *vect;
size_t pass_len;
size_t salt_len;
size_t dk_len;
size_t iv_len;
} t_evp;

typedef struct s_evp_size
{
size_t key_len;
size_t iv_len;
size_t dk_len;
} t_evp_size;

t_evp *new_t_evp(uint8_t *pass, void *salt, void *key, void *vect);
void print_evp(t_evp *to_print);
void free_evp(t_evp **to_free);
void free_vevp(void **to_free);

#endif
39 changes: 39 additions & 0 deletions includes/evp/evp_bytes2key.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* evp_bytes2key.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/04 10:03:30 by cpieri #+# #+# */
/* Updated: 2020/04/20 10:26:35 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef EVP_BYTES2KEY_H
# define EVP_BYTES2KEY_H

# include "./evp.h"
# include "../hash/md5.h"
# include "../hash/sha1.h"
# include "../hash/sha256.h"

enum e_hash_f
{
EVP_MD5 = 0x000000001,
EVP_SHA1 = 0x000000010,
EVP_SHA256 = 0x000000100
};

typedef struct s_evp_hash
{
enum e_hash_f hash_f;
void *(*f)(void *, size_t);
size_t nb_word;
} t_evp_hash;

t_evp_hash evp_get_hashf(enum e_hash_f name);
void *evp_bytes2key(t_evp *k, uint32_t c,
t_evp_size full_size, int func);

#endif
37 changes: 37 additions & 0 deletions includes/evp/pbkdf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pbkdf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/20 10:11:40 by cpieri #+# #+# */
/* Updated: 2020/04/20 10:26:56 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef PBKDF_H
# define PBKDF_H

# include "./evp.h"
# include "../hash/hmac.h"

enum e_prf
{
HMAC_MD5 = 0x000000001,
HMAC_SHA1 = 0x000000010,
HMAC_SHA256 = 0x000000100
};

typedef struct s_prf
{
enum e_prf prf;
void *(*f)(void *, size_t, void *, size_t);
size_t nb_word;
} t_prf;

t_prf pbkdf2_get_prf(enum e_prf name);
void pbkdf2_xor_dgst(void const *dgst1, void const *dgst2, size_t n);
void *pbkdf2(t_evp *k, uint32_t c, t_evp_size full_size, int func);

#endif
6 changes: 4 additions & 2 deletions includes/ft_ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: cpieri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/06 12:40:02 by cpieri #+# #+# */
/* Updated: 2019/04/11 16:36:18 by cpieri ### ########.fr */
/* Updated: 2019/12/30 09:01:15 by cpieri ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -15,11 +15,13 @@

# include "../libft/include/libft.h"
# include "./hash/md5.h"
# include "./hash/sha1.h"
# include "./hash/sha256.h"
# include "./base64/base64.h"
# include "./symmetric/symmetric.h"
# include "define.h"
# include "enum.h"
# include "structure.h"
# include "functions.h"
# include "constant.h"

#endif
Loading