I would like to encrypt some data and create 5 keys. These keys are stored in different places. If I want to decrypt the data I just need 3 of these 5 keys.
Is there a way to do this?
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.Sign up to join this community
Yes, there is. And it generalizes easily to requiring any $k$ out of $n$ keys, not just 3 out of 5:
Generate a random key for some symmetric encryption scheme (say, AES-SIV).
Encrypt your data with that random key.
Use a threshold secret sharing scheme such as Shamir's secret sharing to split the random key into $n$ shares, such that any $k$ of them are needed to reconstruct the key.
You can use those $n$ shares directly as the $n$ "keys" to be stored in different places. However, if you'd instead prefer to use $n$ pre-existing keys, you'll need one more step:
To decrypt the data, do the same in reverse: first decrypt at least $k$ of the shares (if needed), then reconstruct the random key from those shares, and finally decrypt the data using the random key.
Shamir's secret sharing is unconditionally secure, so the whole scheme is as secure as the encryption schemes you use in steps 2 and (optionally) 4.