add des ecb definition

This commit is contained in:
Gregory 2019-03-14 12:45:15 +02:00
parent 6a3af7423e
commit 13ade8cde6
5 changed files with 36 additions and 56 deletions

View file

@ -126,6 +126,7 @@ DES_SRC = ft_des_initial_permutation.c \
ft_des_process_block.c \
ft_des_generate_encryption_round_keys.c \
ft_des_generate_decryption_round_keys.c \
ft_des_ecb.c
SRC = main.c \
ft_ssl_usage.c

View file

@ -26,6 +26,17 @@
typedef unsigned char t_byte1;
typedef struct s_des_ctx
{
int input_fd;
int output_fd;
int decode;
int output_in_base64;
char *key;
char *init_vector;
char *pass;
} t_des_ctx;
void ft_des_initial_permutation
(
t_byte1 message[FT_DES_BIT_BLOCK_SIZE],
@ -176,4 +187,10 @@ void ft_des_process_block
t_byte1 ciphertext[FT_DES_BIT_BLOCK_SIZE]
);
void ft_des_ecb
(
int argc,
char **argv
);
#endif

View file

@ -13,71 +13,15 @@
#ifndef FT_SSL_H
# define FT_SSL_H
# include <stddef.h>
# define FT_SSL_ALGS_COUNT 3
# define FT_SSL_BUFFER_SIZE 1024
typedef struct s_ft_ssl t_ft_ssl;
typedef void (*t_process_stdin)(t_ft_ssl *ft_ssl);
typedef void (*t_process_string)(const char *string,
t_ft_ssl *ft_ssl);
typedef void (*t_process_file)(const char *filename,
t_ft_ssl *ft_ssl);
typedef void (*t_alg_function)(int argc, char **argv);
typedef struct s_flags
{
int quiet;
int reverse;
int print_stdin;
int something_printed;
} t_flags;
typedef struct s_alorithm
{
const char *name;
t_alg_function function;
} t_algorithm;
struct s_ft_ssl
{
t_flags flags;
t_process_stdin process_stdin;
t_process_file process_file;
t_process_string process_string;
};
void ft_ssl_usage(void);
void ft_ssl_init(int argc, char **argv);
void ft_ssl_md5_stdin(t_ft_ssl *ft_ssl);
void ft_ssl_md5_string(const char *strng,
t_ft_ssl *ft_ssl);
void ft_ssl_md5_file(const char *filename,
t_ft_ssl *ft_ssl);
void ft_ssl_md5_print(const char *target,
unsigned char *digest,
t_ft_ssl *ft_ssl);
void ft_ssl_sha256_stdin(t_ft_ssl *ft_ssl);
void ft_ssl_sha256_string(const char *strng,
t_ft_ssl *ft_ssl);
void ft_ssl_sha256_file(const char *filename,
t_ft_ssl *ft_ssl);
void ft_ssl_sha224_print(const char *target,
unsigned char *digest,
t_ft_ssl *ft_ssl);
void ft_ssl_sha224_stdin(t_ft_ssl *ft_ssl);
void ft_ssl_sha224_string(const char *strng,
t_ft_ssl *ft_ssl);
void ft_ssl_sha224_file(const char *filename,
t_ft_ssl *ft_ssl);
void ft_ssl_sha256_print(const char *target,
unsigned char *digest,
t_ft_ssl *ft_ssl);
#endif

13
src/des/ft_des_ecb.c Normal file
View file

@ -0,0 +1,13 @@
#include <stdlib.h>
#include "ft_des.h"
void ft_des_ecb
(
int argc,
char **argv
)
{
(void)argc;
(void)argv;
exit(0);
}

View file

@ -14,6 +14,7 @@
#include "ft_md5.h"
#include "ft_sha.h"
#include "ft_base64.h"
#include "ft_des.h"
#include "libft.h"
t_algorithm g_algorithms[] = {
@ -33,6 +34,10 @@ t_algorithm g_algorithms[] = {
"base64",
ft_base64,
},
{
"des-ecb",
ft_des_ecb,
},
{NULL, NULL}
};