Toychain!
A toy blockchain in C
rsa.h
Go to the documentation of this file.
1#ifndef __RSA_H
2#define __RSA_H
3
4#include "lib/mmath.h"
5#include "lib/types.h"
6#include <stdbool.h>
7
16typedef struct _Key{
17 int64 v, n;
19
20void init_key(Key* key, int64 val, int64 n);
21Key* copy_key(const Key* o);
22char* key_to_str(const Key* key);
23Key* str_to_key(const char* str);
24void init_pair_keys(Key* pKey, Key* sKey, int low_size, int up_size);
25
26bool generate_key_values(int64 p, int64 q, int64* n, int64* s, int64* u);
27int64* encrypt(const char* chaine, int64 s, int64 n);
28char* decrypt(const int64* crypted, int size, int64 u, int64 n);
29
30#endif
Header for mmath.c.
struct _Key Key
int64 * encrypt(const char *chaine, int64 s, int64 n)
encrypt a message using modular exponentiation and a public RSA key (s,n).
Definition: rsa.c:162
Key * str_to_key(const char *str)
parses a string of the form " (v, n) " into a Key struct
Definition: rsa.c:94
Key * copy_key(const Key *o)
copies key
Definition: rsa.c:37
void init_key(Key *key, int64 val, int64 n)
initializes a key struct
Definition: rsa.c:22
char * decrypt(const int64 *crypted, int size, int64 u, int64 n)
decrypt a message using modular exponentiation and a RSA key (u,n).
Definition: rsa.c:188
char * key_to_str(const Key *key)
converts a Key to string of the form " (v, n) "
Definition: rsa.c:81
bool generate_key_values(int64 p, int64 q, int64 *n, int64 *s, int64 *u)
generates public and private RSA keys public = (s, n) ; private = (u, n)
Definition: rsa.c:123
void init_pair_keys(Key *pKey, Key *sKey, int low_size, int up_size)
initializes a key struct
Definition: rsa.c:55
Definition: rsa.h:16
int64 n
Definition: rsa.h:17
a file with comfy aliases for long type signatures
#define int64
alias for long long int
Definition: types.h:17