header of rsa.c
More...
#include "lib/mmath.h"
#include "lib/types.h"
#include <stdbool.h>
Go to the source code of this file.
|
void | init_key (Key *key, int64 val, int64 n) |
| initializes a key struct More...
|
|
Key * | copy_key (const Key *o) |
| copies key More...
|
|
char * | key_to_str (const Key *key) |
| converts a Key to string of the form " (v, n) " More...
|
|
Key * | str_to_key (const char *str) |
| parses a string of the form " (v, n) " into a Key struct More...
|
|
void | init_pair_keys (Key *pKey, Key *sKey, int low_size, int up_size) |
| initializes a key struct More...
|
|
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) More...
|
|
int64 * | encrypt (const char *chaine, int64 s, int64 n) |
| encrypt a message using modular exponentiation and a public RSA key (s,n). More...
|
|
char * | decrypt (const int64 *crypted, int size, int64 u, int64 n) |
| decrypt a message using modular exponentiation and a RSA key (u,n). More...
|
|
◆ Key
A struct for storing a key
◆ copy_key()
Key * copy_key |
( |
const Key * |
o | ) |
|
copies key
- Parameters
-
- Returns
- Key*
◆ decrypt()
decrypt a message using modular exponentiation and a RSA key (u,n).
- Parameters
-
crypted | message to be decrypted |
size | |
u | |
n | |
- Returns
- char* : original message
◆ encrypt()
encrypt a message using modular exponentiation and a public RSA key (s,n).
- Parameters
-
chaine | message to be crypted |
s | |
n | |
- Returns
- int64* : encrypted message
◆ generate_key_values()
generates public and private RSA keys public = (s, n) ; private = (u, n)
- Parameters
-
p | prime |
q | prime |
n | return value |
s | return value |
u | return value |
- Returns
- true : the generation was successfull!
-
false : is most probably impossible to generate a valid key pair!
◆ init_key()
initializes a key struct
- Parameters
-
- Returns
- void
◆ init_pair_keys()
void init_pair_keys |
( |
Key * |
pKey, |
|
|
Key * |
sKey, |
|
|
int |
low_size, |
|
|
int |
up_size |
|
) |
| |
initializes a key struct
- Parameters
-
- Returns
- void
◆ key_to_str()
char * key_to_str |
( |
const Key * |
key | ) |
|
converts a Key to string of the form " (v, n) "
- Parameters
-
- Returns
- char* : allocated on the heap
◆ str_to_key()
Key * str_to_key |
( |
const char * |
str | ) |
|
parses a string of the form " (v, n) " into a Key struct
- Parameters
-
- Returns
- Key* : allocated on the heap