I'm writing a project to securely store and share passwords between users, I've been doing tons of research into encryption algorithms, CSPRNGs, hashing algorithms, key stretching etc...

I just want to layout my thinking as to how to use all of these, to create the secure application - and hopefully someone(s) can point our flaws or direct me if I'm seeing things wrong:


So, first of all, I need to store hashes of account passwords (these are the account that log into the application to view the shared passwords).

After reading around, my understanding is that to make a hash "more secure", you need to use scrypt or bcrypt or pbkdv2. I've found an implementation of these in "CryptSharp" (hopefully this is a secure implementation) - also after further research (http://www.tarsnap.com/scrypt/scrypt.pdf) it looks like scrypt is a more secure way of creating a hash.


As the data will be shared between users, I shall need to make sure that the system uses a master encryption key for the entire project, and that this is stored securely.

My thinking here is generate an encryption key and initialization vector (3 of them - I'll explain why) - these will be generated with RNGCryptoServiceProvider, and all 3 will be concatenated into Key1|IV1|Key2|IV2|Key3|IV3 so that they can be split and used with the encryption algorithms.

I need some way of storing this concatenated string of IVs and Keys so after some research I came across Microsoft's Data Protection API (ProtectedMemory.Protect( secret, MemoryProtectionScope.SameLogon )) - my understanding with this, is that the App Pool will need to run under a user account, and "load profile" set to true. The resulting encrypted string will then be stored in an XML setting file.

With regards to encrypting the passwords to be shared, I read about cascading encryption (used in TrueCrypt). The encryption algorithms TrueCrypt uses are AES, TwoFish, and Serpent. I've found an implementation of these (http://www.bouncycastle.org/csharp/ - which again, I hope is a secure implementation). This is where the 3 IVs and Keys will be used; so effectively the data will be encrypted like so: Serpent(TwoFish(AES(data,key1),key2),key3).


So, these are my ideas to create a secure data storage system; am I over looking something? have I misunderstood something? should I be doing something more?

I appreciate any advice on this.

closed as unclear what you're asking by CaffeineAddiction, Serge Ballesta, ThoriumBR, Purefan, John Deters Feb 20 '17 at 16:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. 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.

  • 1
    The operative motto is: "Don't roll yer own". – Deer Hunter Jul 4 '14 at 9:59
  • What you're asking is not clear. What is the high-level design of the application? As what point are passwords encrypted-decrypted and shown to the user? You seem to focus on what technologies you will use for encryption, but are not describing the main architecture on how you will store your data and how it will be accessed. – BgrWorker Feb 20 '17 at 14:25

Don't invent your own cryptographic protocols. It's easy to come up with all kinds of ideas and combine all kinds of techniques, but doing this properly is exceptionally hard and requires a lot of experience and extensive peer reviews. This isn't something you can do on your own in a few minutes, especially if you don't happen to be a cryptographer.

What confirms this impression is that you jump straight to random implementation details before you've even analyzed the problem and specified the goal. How is the nested encryption feature relevant at this early stage? This all sounds rather chaotic and vague.

I strongly recommend that you first get clear about the bigger picture and then choose an established solution for this specific scenario.


"securely store and share passwords between users"

This just requires a strong hashing algorithm and some sort of encryption. The encryption to make it unreadable and hashing for integrity checks (plus helps storage, searching as well as reduces overhead while sharing over the network). Besides, sharing the hashes of your passwords over an insecure channel is frowned upon, given that the most popular hashing algo MD5 has been shown to have collisions.

I found the question a little vague, but here's a shot that might help. You'll need to plan what your storage system looks like. The separate components, and modularize it in such a way that each layer has it's own security that is independent from each others.

Meanwhile @Deer Hunter is right. Don't reinvent the wheel, there are robust encryption algos out there that you can use, and have been exhaustively tested.

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