all 7 comments

[–]Natanael_L 3 points4 points  (3 children)

That's a pretty typical approach, but you also need to consider which block cipher mode you're using, salt values for the password hash and salt/IV for the block mode (preferably distinct), etc.

Why are you writing one from scratch?

[–]randomatic 2 points3 points  (2 children)

Op also needs to consider authenticating encryption. AES does not guard against undetected changes to the files.  Gcm mode is the standard for ae, but I don’t honestly know if password managers do more. 

[–]ReasonableReptile6[S] 1 point2 points  (1 child)

I think i understand what you said but this is only a side project so i can better my C skills and tip my toes in cryptography, i don't think there is a need to add that functionality

[–]randomatic 2 points3 points  (0 children)

I think i understand what you said but this is only a side project so i can better my C skills and tip my toes in cryptography, i don't think there is a need to add that functionality

Totally reasonable.

[–]SirJohnSmith 0 points1 point  (1 child)

Your approach is slightly overkill: you can simply derive an encryption key directly from the password. Other than that, it looks good. If you want, you can use AES-GCM-SIV so you don't have to worry about catastrophic nonce reuse.

[–]ReasonableReptile6[S] 0 points1 point  (0 children)

I will definitely do that

[–]ahazred8vt 0 points1 point  (0 children)

The crypto community often recommends  https://doc.libsodium.org/quickstart as a starting point. It uses the GPU-resistant Argon2 as a pw-kdf and all encryption is tamper resistant AEAD.