defined why2_chat_rsa_pub_encrypt
pog
This commit is contained in:
parent
ee3f319dd7
commit
6487ea8b85
@ -168,4 +168,28 @@ char *why2_get_chat_modulus(void)
|
|||||||
char *why2_get_chat_d(void)
|
char *why2_get_chat_d(void)
|
||||||
{
|
{
|
||||||
return rsa_d;
|
return rsa_d;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *why2_chat_rsa_pub_encrypt(long to_encrypt)
|
||||||
|
{
|
||||||
|
//VARIABLES
|
||||||
|
char *output;
|
||||||
|
mpz_t m, c, n, e;
|
||||||
|
mpz_init(c);
|
||||||
|
|
||||||
|
//GET ALL STUFF
|
||||||
|
mpz_init_set_si(m, to_encrypt);
|
||||||
|
mpz_init_set_str(n, why2_get_chat_modulus(), WHY2_CHAT_KEY_BASE);
|
||||||
|
mpz_init_set_si(e, WHY2_CHAT_RSA_EXPONENT);
|
||||||
|
|
||||||
|
//ENCRYPT MESSAGE
|
||||||
|
mpz_powm(c, m, e, n);
|
||||||
|
|
||||||
|
output = why2_malloc(mpz_sizeinbase(c, WHY2_CHAT_KEY_BASE) + 2); //ALLOCATE OUTPUT
|
||||||
|
mpz_get_str(output, WHY2_CHAT_KEY_BASE, c); //GET OUTPUT
|
||||||
|
|
||||||
|
//DEALLOCATION
|
||||||
|
mpz_clears(m, c, n, e, NULL);
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user