X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Frsa.c;h=4b7db8ff3c0df3c4c741861a82e0f10ed59ca165;hb=8fbe7f30cd16654e55a5a77c2d187c0e0ae64c1d;hp=368fc75dcfd8e886a04b454ad5925591ba3b2b5c;hpb=34b8fd123cb92dd2f1d7be8a4187a3fd85e2a3b6;p=silc.git diff --git a/lib/silccrypt/rsa.c b/lib/silccrypt/rsa.c index 368fc75d..4b7db8ff 100644 --- a/lib/silccrypt/rsa.c +++ b/lib/silccrypt/rsa.c @@ -66,6 +66,11 @@ Use the SilcRng sent as argument to SILC_PKCS_API_INIT in prime generation. + o Sat Sep 26 19:59:48 EEST 2002 Pekka + + Fixed double free in public key setting. Use a bit larger e as + starting point in key generation. + */ #include "silcincludes.h" @@ -516,7 +521,7 @@ void rsa_generate_keys(RsaKey *key, SilcUInt32 bits, /* Set e, the public exponent. We try to use same public exponent for all keys. Also, to make encryption faster we use small number. */ - silc_mp_set_ui(&key->e, 127); + silc_mp_set_ui(&key->e, 65533); retry_e: /* See if e is relatively prime to phi. gcd == greates common divisor, if gcd equals 1 they are relatively prime. */ @@ -526,7 +531,7 @@ void rsa_generate_keys(RsaKey *key, SilcUInt32 bits, goto retry_e; } - /* Find d, the private exponent. */ + /* Find d, the private exponent, e ^ -1 mod lcm(phi). */ silc_mp_gcd(&div, &pm1, &qm1); silc_mp_div(&lcm, &phi, &div); silc_mp_modinv(&key->d, &key->e, &lcm);