browserify / diffie-hellman

pure js diffie-hellman
MIT License
94 stars 26 forks source link

Method checkPrime() is too slow #16

Closed zhulduz closed 8 years ago

zhulduz commented 8 years ago

Hi.

I use ssh2 library https://github.com/mscdex/ssh2 in a browser. I have faced up with next problem.

Method checkPrime() at this code

defineError(this, checkPrime(this.__prime, generator));

works very very slowly, so I can't connect to my server. I try to connect by key with a passphrase, 'ctr' ciphers is used. As I discovered method Red.prototype.pow make such delays.

Thanks a lot.

calvinmetcalf commented 8 years ago

so diffie-hellman arithmetic is pretty slow in general, so if you are able to use elliptical curve diffie hellman to authenticate then that is probably preferable for you.

checkPrime is simply the very first bit of big number math being done, if it can't get through that it probably won't get there the latter stuff.

zhulduz commented 8 years ago

Can you please get additional information about this method? As I understood, this method checks is number prime or not?

Commented code is always usefull)

calvinmetcalf commented 8 years ago

In previous versions of node it would throw an error if you used an unsafe prime but in more recent versions it just sets a property so we could switch that to a lazily calculated getter so we only do the work if we need to.

On Mon, Oct 26, 2015, 2:14 AM zhulduz notifications@github.com wrote:

I can't understand a meaning of this method. If I set another value (8, 4, 2, "any_string") instead of calling checkPrime(this.__prime, generator)), the connection to the server is work correctly.

Can you please get additional information about this method?

When code is commented, it is also useful.

— Reply to this email directly or view it on GitHub https://github.com/crypto-browserify/diffie-hellman/issues/16#issuecomment-151037148 .

zhulduz commented 8 years ago

Thanks a lot)