How to generate secret with sufficient iterations on device with little CPU power

Viewed 73

Our application runs on a Raspberry Pi and is installed on many places on customer sites. The Pi is cheap and good enough for our purposes. However, we have a problenm that for storing the user's login password on disk generating a secret with something like 50.000 iterations to be reasonably safe takes way too much time on the slow Pi. When the user logs in the password has to be decrypted and those 50.000 iterations have to be executed again which takes minutes on the Pi. The web frontend gets a timeout and the user won't wait for minutes to log in anyway.

My question is whether anyone has an idea how to encrypt and decrypt passwords in a safe way on disk given a CPU with little processing power.

2 Answers

However, we have a problem that for storing the user's login password on disk generating a secret

I hope you mean hashing (non-reversible mangle) the password

with something like 50.000 iterations to be reasonably safe
50.000 iterations have to be executed again which takes minutes on the Pi

I'm not sure where/how did you get to the 50k number, but in this case it's important to understand the context/reason. The iterations are intended, if the database is leaked, as a way to slow down options for dictionary or brute-force attacks to find passwords, which tends to be weak (short, simple, reused, known).

Effectively you don't need any iteration if you could ensure the user passwords are secure (long, random) enough.

Indeed on the IoT devices this iteration is tricky, as you cannot compete with hashing farms and tolerable delay (100-300ms) on default servers comes to prohibiting times on low-end devices.

My question is whether anyone has an idea how ... given a CPU with little processing power.

I see two options

  • Make the number of iteration reasonable. Yes, it lowers the security margin for brute/dictionary attacks, but you can make up to the level using the strong user passwords
  • If the password is intended for authentication to a web application, you could delegate the authentication to a 3rd party service (Azure AD, AWS Cognito, IBM AppId, OAuth0, Okta, ... ), there are plenty of free or not-so-free services.

Haveged will do the job in this case. Just let it run for a while and it will generate enough entropy.

Related