0

I thought I would learn a little bit of cryptography programming by making myself a simple password manager program that I can potentially even use to keep track of my passwords. The idea is that my program would keep a list of passwords in encrypted form and names of the services the passwords are used for. Then I could give as an input the name of the service I would like to access and a master password and the program would give me the password for that service.

What encryption method should I use? What other security issues I should think about? Is it a viable goal (with no experience) to make myself a password manager that is safe enough for me to actually use it?

closed as too broad by Adi, TildalWave, Xander, NULLZ, Ayrx Nov 29 '13 at 0:07

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Regarding your last sentence: probably no. Even if all your questions are answered here, it's trivial to get cryptography wrong during implementation with the smallest mistakes. If you have no experience at all, you'll likely make these mistakes and create a product which is not secure. It's certainly worth the experience though I'd think. – deceze Nov 28 '13 at 15:14
  • Everything should be learnt by having a go, but don't make the mistake of turning a weekend messing around project into a usable program without properly developing it first. – Owen Nov 29 '13 at 10:39
2

Good on you for trying to learn this. Keep in mind that whatever you produce shouldn't be put into an actual production environment even on the personal level. Consider this as a learning opportunity and not a recipe to cook your own password manager. Usually, you'd do something along these lines:

  • Generate a random 256-bit key. This is your master encryption key.

  • Take the master password and run it through PBKDF2 along with a 64-bit salt and get a 128-bit key. This is your secondary encryption key.

  • Use the secondary encryption key to encrypt the master encryption key using AES in the EAX mode and store it somewhere.

  • For the database, use any format you want. As I'm not sure which one to choose, I'll say XML. Encrypt the database using the master encryption key.

  • When the user wants to access database you load the encrypted file in the memory, take the master password and run it through PBKDF2 with salt and get the secondary key, use the secondary key to decrypt the master key, and finally use the master key to decrypt the database.

  • After the user finishes accessing; adding; modifying; or deleting entries from the database, you simply encrypt it again and discard everything from the memory.

  • When the user wants to change the password, you decrypt derive the secondary key from the old password, decrypt the master key, derive a new secondary key from the new password, use that key to encrypt the master key. By doing this, you don't have to decrypt and re-encrypt the database when the password is changed as the master key is kept the same.

Finally, I recommend that you take a look at KeePassX's source code. A lot of information can be harvested from there.

I'll say this again, do not use the actual application you produce. You might (and very likely will) do something wrong at some point. Heck, my instructions themselves could be (and probably are) wrong.

Happy learning!

  • Thanks a lot! Even though my original idea was to actually use my application, it might be better, as you said, not to. – Echows Nov 29 '13 at 9:07
0

If you want to learn how to make a good password manager, I would start by looking to open-source password managers. Review how they work (database implementation + encryption methods) and try to create something yourself.

For the used encryption I would use AES256 CBC. AES is well documented.

Do not use your own implementation!

  • Can you recommend me any open source password managers (that work on linux) that are well-enough established and reviewed to be secure to use? – Echows Nov 29 '13 at 9:07
  • @Echows On Linux, I use KeePassX. – Adi Nov 29 '13 at 11:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.