Deltachat-android: check why the key generation is slow on some devices

Created on 31 Aug 2018  路  4Comments  路  Source: deltachat/deltachat-android

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: https://github.com/deltachat/deltachat-core/issues/224, https://gitlab.com/sequoia-pgp/sequoia/issues/19

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

bug

All 4 comments

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

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

closing this here in favour to https://github.com/deltachat/deltachat-core/issues/376 which already dived deeper into the OpenSSL code.

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

Was this page helpful?
0 / 5 - 0 ratings