# Encrypt/Decrypt cloud passwords with master password

I know it's generally bad to store password in the clouds, and that I should be using salted-hashed password only.

I'm making an application that will authenticate a user (with salted-hash), and then needs to return the credential of all their ip-cameras from the cloud database. For obvious reasons the camera password should not be hashed, neither saved as plain text as they are right now during development.

Of course, I will use HTTPS. But I'm concerned about the server-side, in case its security will be compromised, and I don't want all the password in plain text, naturally.

As I'm not an expert in cryptography (and information security in general) I am having a bad time trying to solve this.

What is the best cryptographic algorithm for this case? I've searched for password-based-encryption and authenticated-encryption but I don't like to add extra keys and prefer to use the user master password, saved as salted-hash (ie. Secret Key Cryptography (SKC) with a single key to encode/decode).

Can I ask some directions here? I don't need anything super-strong, but maybe something not too easy to crack, and not too much difficult to implement as a newbie

PS: I need to encode with PHP, and decode with JavaScript (or even do everything with client-side JS). I hope the algorithms are used worldwide and I don't have to implement them myself :)

• I think the main question to clarify here is what sort of access to the plaintext is required by the server. I see three possibilities: the server needs full access to the plaintext, the server generates the plaintext but does not require access afterwards, the server doesn't require access to the plaintext it just provides storage for the encrypted credentials. – geoff_h Feb 12 '16 at 10:17
• For now there is no need for the server to access any plaintext or secret. The plaintext is generated client-side, and I can even encrypt/decrypt entirely on the client – Zorgatone Feb 12 '16 at 10:19
• As an aside: Keep in mind that it’s hard to implement Javascript crypto that isn’t vulnerable to side-channel attacks. (As you seem to be focussing on your server side, I thought it would be a good idea to remind you of the potential client-side issues in case you don’t already know.) – e-sushi Feb 12 '16 at 10:20
• I don't have that problem in a Cordova application – Zorgatone Feb 12 '16 at 10:21
• This could be more specific to IT security, not sure. You could use X=PBKDF(iterations, salt, password), H=KBKDF(X, 'password hash') and K=KBKDF(X, 'secret key') to derive both a hash and key server side. – Maarten Bodewes Feb 12 '16 at 13:06