okta / okta-oidc-android

OIDC SDK for Android
https://github.com/okta/okta-oidc-android
Other
59 stars 45 forks source link

Decrypting token on some devices seems to be slow. #226

Closed PreetamPatil closed 3 years ago

PreetamPatil commented 3 years ago

Hello, I have noticed on Samsung devices (I am using Samsung galaxy s7), the process of decrypting the tokens is considerably slow compared to other devices. The decrypt function inside the BaseEncryptionManager class seems to be taking some time around ~2-3 seconds to decrypt the encrypted string/token. I have attached the video with debug points before the decryption process starts and after the decryption process ends to get an idea of the issue.

I am not sure if this is even an issue on the OKTA end, but if it is, is there any way to fix this?

Decrypting_recording.mov.zip

JayNewstrom commented 3 years ago

Runtime with a debugger attached is likely very different than without it. Have you seen this as a problem in practice when using this?

The vast majority of the code run is Android framework/native platform code that we don't control.

There are likely things we could do to make this faster, but we've not seen this to be a problem in practice. Often times the time the network connections take, far out weigh the things that happen local on the device.

PreetamPatil commented 3 years ago

Even without attaching the debugger, the process of retrieving the token is visibly slow on some devices. I did the comparison between Samsung galaxy s7 and Pixel 3. The process of retrieving the tokens seems to be fast on Pixel 3 compared to Samsung. Do you think this issue is device-related where it takes more time on some devices to decrypt than others?

JayNewstrom commented 3 years ago

It's very possible that different devices have different hardware causing cryptographic operations to take differing amounts of time, as well as different Android versions having different code, causing cryptographic operations to take differing amounts of time.

It's worth noting, that this is an interface that can be replaced by you as a developer integrating with the SDK. It might be worth adding a fake encryption manager that does no encryption to test your assumptions around crypto taking a long time.

JayNewstrom commented 3 years ago

@PreetamPatil Please reopen if you have any next steps or more information for us. Thanks!