0
$\begingroup$

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?

$\endgroup$
5
  • 4
    $\begingroup$ This has been answered a few times before: encrypt a data key with two different public keys. $\endgroup$
    – Maarten Bodewes
    Jul 31, 2022 at 20:19
  • $\begingroup$ @MaartenBodewes yup, but is there a way to do so without using asymmetric algorithms ? $\endgroup$ Jul 31, 2022 at 21:00
  • 1
    $\begingroup$ Sure, there are secret sharing schemes $\endgroup$
    – Maarten Bodewes
    Jul 31, 2022 at 21:49
  • $\begingroup$ @MaartenBodewes But secret sharing does not allow that one party can decrypt without the other. $\endgroup$
    – not2savvy
    Aug 1, 2022 at 8:06
  • $\begingroup$ 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. $\endgroup$
    – Maarten Bodewes
    Aug 1, 2022 at 8:35

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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