Skip to content
New issue

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

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

Already on GitHub? # to your account

check why the key generation is slow on some devices #511

Closed
r10s opened this issue Aug 31, 2018 · 4 comments
Closed

check why the key generation is slow on some devices #511

r10s opened this issue Aug 31, 2018 · 4 comments
Labels

Comments

@r10s
Copy link
Member

r10s commented Aug 31, 2018

currently, the key generation is done during dc_configure() after the connection could be established.

in the code, this is here https://github.com/deltachat/deltachat-core/blob/master/src/dc_configure.c#L697 (the progress is at 92% during key generation)

  • on desktop, this is always fast, a second, not more.
  • in the old delta-telegram-app, this was often fast, but i have some devices (eg. motog4play) where it takes 2 minutes or so. on my nexus4 was fast (have to check this again)
  • in the new delta-signal-app, however, this is also slow on my nexus4 (~2 minutes)

i have suspected some issues with the openssl random number generation, and played around a bit when i noticed that RAND_seed() and RAND_status() needs to be seeded for every thread explicitly - without success. however, it was just "playing around", this needs more research to exclude this.

i also notices, RSA_generate_key_ex() provides a callback that may give more hints. maybe also openssl needs to be updated.

on telegram-delta i profiled the generation in july using times(): motog4play (openssl=1.0.1t, _SC_CLK_TCK=100) returned utime=2500 stime=400, cutime=0, cstime=0 while i7pc (openssl=1.0.2g, _SC_CLK_TCK=100) returned utime=16, stime=0, cutime=0, cstime=0 - so the issue seems not to be blocking or so.

interesting: $ openssl speed rsa returns thousands of keypairs per second - we would need only one ...

related: deltachat/deltachat-core#224, https://gitlab.com/sequoia-pgp/sequoia/issues/19

@Boehrsi @angelo-fuchs how long does configure() take on your devices?

@Boehrsi
Copy link
Contributor

Boehrsi commented Aug 31, 2018

Checked it on a Samsung Galaxy S7 and it took 1-2 minutes. Pretty strange.

08-31 10:58:43.474 4930-4949/chat.delta.androidii I/DeltaChat: Generating keypair ...
08-31 10:58:43.475 4930-4930/chat.delta.androidii I/DeltaChat: configure-progress=920

@Boehrsi Boehrsi closed this as completed Aug 31, 2018
@Boehrsi Boehrsi reopened this Aug 31, 2018
@r10s
Copy link
Member Author

r10s commented Sep 26, 2018

the reason for this seems to be the bundled openssl() version; when using this version on desktop, there is the same issue

@r10s
Copy link
Member Author

r10s commented Oct 9, 2018

closing this here in favour to deltachat/deltachat-core#376 which already dived deeper into the OpenSSL code.

@r10s r10s closed this as completed Oct 9, 2018
@r10s r10s transferred this issue from another repository Jan 21, 2019
@r10s r10s added the bug label Jan 21, 2019
@r10s
Copy link
Member Author

r10s commented Mar 17, 2019

the keysize seems to have a rather large impact: 3072bit key generation took about 60 seconds, 2048bit only about 10 on a "slow" nexus 4

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

No branches or pull requests

2 participants