2024-02-14 16:14:03 +00:00
|
|
|
#ifndef _RSA_H
|
|
|
|
#define _RSA_H 1
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
// TODO remove bytes bits helper
|
|
|
|
#define RSA_SIZE 1024
|
|
|
|
#define RSA_SIZE_BYTES 1024 / 8
|
|
|
|
|
|
|
|
#define ERROR 0
|
|
|
|
#define WARNING 1
|
|
|
|
#define INFO 2
|
|
|
|
|
2024-02-15 20:25:35 +00:00
|
|
|
typedef struct s_rsa {
|
|
|
|
t_bigint p;
|
|
|
|
t_bigint q;
|
|
|
|
t_bigint n;
|
|
|
|
t_bigint e;
|
|
|
|
} t_rsa;
|
|
|
|
|
|
|
|
typedef struct s_bigint {
|
|
|
|
int *data;
|
|
|
|
int size;
|
|
|
|
} t_bigint;
|
|
|
|
|
2024-02-14 16:14:03 +00:00
|
|
|
void ft_log(int level, char *s);
|
|
|
|
|
|
|
|
char *ft_itoa(int n);
|
2024-02-15 20:25:35 +00:00
|
|
|
size_t ft_strlen(const char *s);
|
|
|
|
char *ft_strjoin(char const *s1, char const *s2);
|
|
|
|
|
2024-02-14 16:14:03 +00:00
|
|
|
|
|
|
|
void generate_keys(int *p, int *q, int *e);
|
|
|
|
int *random_bits(int n);
|
|
|
|
void generate_prime(int *p);
|
|
|
|
int *phi(int *p, int *q);
|
|
|
|
|
2024-02-15 20:25:35 +00:00
|
|
|
t_rsa rsa_new(int block_size);
|
|
|
|
|
2024-02-14 16:14:03 +00:00
|
|
|
#endif
|