diff --git a/include/chat/crypto.h b/include/chat/crypto.h index 0fefa7b..9249e8a 100644 --- a/include/chat/crypto.h +++ b/include/chat/crypto.h @@ -41,8 +41,8 @@ void why2_chat_deallocate_keys(void); //DEALLOCATE :) (NO SLUR HERE) char *why2_get_chat_modulus(void); //GET THE RSA MODULUS char *why2_get_chat_d(void); //GET THE RSA d -char *why2_chat_rsa_pub_encrypt(long to_encrypt); //RSA ENCRYPT USING PUBLIC KEY -char *why2_chat_rsa_pri_decrypt(long to_decrypt); //RSA DECRYPT USING PRIVATE KEY +char *why2_chat_rsa_pub_encrypt(char *to_encrypt); //RSA ENCRYPT USING PUBLIC KEY +char *why2_chat_rsa_pri_decrypt(char *to_decrypt); //RSA DECRYPT USING PRIVATE KEY #ifdef __cplusplus } diff --git a/src/chat/crypto.c b/src/chat/crypto.c index 947a4e3..3426570 100644 --- a/src/chat/crypto.c +++ b/src/chat/crypto.c @@ -76,7 +76,7 @@ void read_file(FILE *file, char **output) *output = buffer; } -char *exp_mod(long to_encrypt, char *exponent) +char *exp_mod(char *to_exp, char *exponent) { //VARIABLES char *output; @@ -84,15 +84,15 @@ char *exp_mod(long to_encrypt, char *exponent) mpz_init(c); //GET ALL STUFF - mpz_init_set_si(m, to_encrypt); + mpz_init_set_str(m, to_exp, 10); mpz_init_set_str(n, why2_get_chat_modulus(), WHY2_CHAT_KEY_BASE); mpz_init_set_str(e, exponent, 10); //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 + output = why2_malloc(mpz_sizeinbase(c, 10) + 2); //ALLOCATE OUTPUT + mpz_get_str(output, 10, c); //GET OUTPUT //DEALLOCATION mpz_clears(m, c, n, e, NULL); @@ -194,12 +194,12 @@ char *why2_get_chat_d(void) return rsa_d; } -char *why2_chat_rsa_pub_encrypt(long to_encrypt) +char *why2_chat_rsa_pub_encrypt(char *to_encrypt) { return exp_mod(to_encrypt, WHY2_CHAT_RSA_EXPONENT); } -char *why2_chat_rsa_pri_decrypt(long to_decrypt) +char *why2_chat_rsa_pri_decrypt(char *to_decrypt) { return exp_mod(to_decrypt, why2_get_chat_d()); } \ No newline at end of file