Toychain!
A toy blockchain in C
|
a collection of RSA related functions More...
#include "lib/rsa.h"
#include "lib/error.h"
#include "lib/overflow.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
Functions | |
void | init_key (Key *key, int64 val, int64 n) |
initializes a key struct More... | |
Key * | copy_key (const Key *o) |
copies key More... | |
void | init_pair_keys (Key *pKey, Key *sKey, int low_size, int up_size) |
initializes a key struct 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... | |
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... | |
a collection of RSA related functions
decrypt a message using modular exponentiation and a RSA key (u,n).
crypted | message to be decrypted |
size | |
u | |
n |
encrypt a message using modular exponentiation and a public RSA key (s,n).
chaine | message to be crypted |
s | |
n |
generates public and private RSA keys public = (s, n) ; private = (u, n)
p | prime |
q | prime |
n | return value |
s | return value |
u | return value |
initializes a key struct
p | prime |
q | prime |
initializes a key struct
p | prime |
q | prime |
char * key_to_str | ( | const Key * | key | ) |
converts a Key to string of the form " (v, n) "
Key | key to convert |
Key * str_to_key | ( | const char * | str | ) |
parses a string of the form " (v, n) " into a Key struct
char | string to convert |