-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsa.h
36 lines (29 loc) · 964 Bytes
/
rsa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef RSA_H
#define RSA_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libgen.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <gmp.h>
#include <time.h>
/* Header file for RSA functions */
/* Miller-Rabin functions */
int witness(mpz_t a, mpz_t n);
int miller_rabin(mpz_t n, int s);
/* Prime-Generator functions */
int generate_prime(mpz_t candidate, int bt_len, int s);
/* Key-Generator functions */
int generate_keys(mpz_t e, mpz_t d, mpz_t n, int bt_len, int s);
int save_keys(mpz_t e, mpz_t d, mpz_t n);
char *create_filename(char *timestr, char *filetype);
int create_new_keypair(int bt_len, int s);
/* RSA functions */
int encrypt(char *keyfile, char *filein, char *fileout);
int decrypt(char *keyfile, char *filein, char *fileout);
int open_key_file(mpz_t exponent, mpz_t n, char *filename);
int read_text_file(char *filename, mpz_t message);
int write_text_file(char *filename, mpz_t message);
#endif