# Encrypting a document with 2 different keys

Is there a way to encrypt a file with 2 (or more) keys and then access it with only 1?

Scenario:

• Bob and Alice have a tight memory and can only remember ONE key.
• Bob and Alice encrypt a file with their keys.
• Bob goes in coma and Alice wants to access the file, but has only one key.

Is there an algorithm that solves this?

• This has been answered a few times before: encrypt a data key with two different public keys. Jul 31, 2022 at 20:19
• @MaartenBodewes yup, but is there a way to do so without using asymmetric algorithms ? Jul 31, 2022 at 21:00
• Sure, there are secret sharing schemes Jul 31, 2022 at 21:49
• @MaartenBodewes But secret sharing does not allow that one party can decrypt without the other. Aug 1, 2022 at 8:06
• Well, you can always wrap a data key with multiple secret keys I suppose. Of course, you have the problem of distributing those secret keys, but hey: you cannot have public key-like distribution without public key cryptography. That's why I didn't mention it before. Aug 1, 2022 at 8:35

Pretty much all encryption using public cryptography support this. When you are encrypting a file F with the Public keys of Bob and Alice, the encrypted file actually contains:

• Encryption of random key K with public key of Alice
• Encryption of random key K with public key of Bob
• Symmetric encryption of the file with key K

Thus, both Alice and Bob can, with their own private key, find out K and decrypt the file.

You mention int the comments another requisite of not using an asymmetric algorithm. You can do exactly the same using only symmetric algorithms:

• Symmetric encryption of random key K with password of Alice
• Symmetric encryption of random key K with password of Bob
• Symmetric encryption of the file with key K

But this has a number of drawbacks since whoever encrypts the document will need the symmetric key / passwords of both Alice and Bob, and would be able to decrypt anything encrypted to any of them. It's an inferior solution. I recommend not to go this route unless you are working on a severely constrained system (IoT?), and even in that case ECC would likely be affordable, allowing you to use public key cryptography.