Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypting a 4 digit password/pincode - easy to crack?

I am currently working on a service which requires users to pick a 4-digit password/pin, because it is a mobile service. I am encrypting those passwords with either 256 or 2048bit encryption and it will be hashed. The account is blocked after 4 wrong entries, and can only be entered by mobile phone. Would it be hard to crack those PINs? I am asking this because sensitive information is being stored. The database is connected to a web application, the application is loaded to the phone using twilio. The thing I am most scared for is that the database is being hacked via the web. What would be a good way to keep sensitive data secure?

like image 424
Jay Mcquire Avatar asked Dec 21 '22 12:12

Jay Mcquire


2 Answers

If someone gets hold of the database, you would be pretty much screwed:

If you just encrypt the 4-digit passwords, an attacker can just build a table of the 10000 possible encrypted strings and can trivially decrypt the PINs.

If you use salt strings (and encrypt not PIN, but PIN+salt and store crypted(PIN+salt) alongside with salt), people have to make a per-password effort, but there are still only 10000 possibilities for each password (which is not very much).

Which means, yes, by all means you should keep the database off the web. (If the web application is only ever accessed through twilio, you can reject connections from any other IP range).

like image 88
Yannick Versley Avatar answered Dec 24 '22 00:12

Yannick Versley


Since you're using twilio, just make sure that twilo only talks to your web service using a secure protocol and reject any requests that you aren't sure are coming from a trusted source (that is, twilo). No real need for a pin at all.

This is a huge webpage on how to setup ssl between your web server and twilo. It even has a php example. http://www.twilio.com/docs/security

like image 39
Dunes Avatar answered Dec 24 '22 00:12

Dunes