Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new BigInteger() very slow during generation of rsa key #7

Open
akyGit opened this issue Mar 21, 2017 · 4 comments
Open

new BigInteger() very slow during generation of rsa key #7

akyGit opened this issue Mar 21, 2017 · 4 comments

Comments

@akyGit
Copy link

akyGit commented Mar 21, 2017

I have a trouble with performance during generation of key 2048 bit.
This process can spend from 3 minutes to 14-15.
Therefore I would like to know, what exactly spend time.
It was BigInteger constructors in rsa generate method. (src/crypto/public_key/rsa.js)
call of new BigInteger() can spend from 2 to 5 minutes.

Smartphone:

  • Android 6.0.1;
  • ASUS Zenfone (ZD551KL);
  • processor Qualcomm MSM8939 Snapdragon 615 + Adreno 405;
  • RAM 3072MB.

Project dependencies:

  • "react": "15.4.2"
  • "react-native": "0.42.3"
  • "react-native-openpgp": "^1.0.3"

Code snippet:

      const optionsGenerateKey = {
        userIds: [{ name:'FirstName LastName', email:'[email protected]' }],
        numBits: 2048,
        passphrase: 'password',
      };

      console.warn('prepare random values...');
      await openpgp.prepareRandomValues();

      console.warn('keys generation...');
      const start = Date.now();
      const key = await this.generateKey(optionsGenerateKey);
      const end = Date.now();
      console.warn((end - start) / 1000);``` 
@akyGit
Copy link
Author

akyGit commented Apr 4, 2017

Who had such a problem?
Maybe I do something wrong?
Keys generation is very slow.
Grateful for help

@amitaymolko
Copy link

Having same issue, key generation takes too long.
2048 bit key takes 6s on ios simulator, and multiple minute on android device and sim
@akyGit did you somehow fix this?

@raza-basit
Copy link

@orhan
Copy link
Owner

orhan commented Aug 31, 2017

Hey everyone,

the assumption in the StackOverflow post is correct, keys generation is very low (especially for everything over 1024 bit keys), because it uses React-Native's JavascriptCore to generate the keys instead of delegating the task to native libraries.

I want to port all crypto stuff to use native libraries sometime in the future, but haven't found the time yet (and for the apps I've built with this, 1024 was totally ok).

In the meantime, PRs are very welcome and sorry for not responding guys! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants