I would like to program an application to allow people to encrypt files without using a password or pass-phrase but an arbitrary long file.

I'm searching for a library that allows me to safely create a front-end.

Example: user 1 on PC1 encrypt the picture selfie.png (size 2 MB) using the key-file ketfile.foo (size 2 MB), then send this file to user2 on PC2 that use keyfile.foo to decrypt selfie.png. Of course I assume that the keyfile.foo was "securely" sent.

This idea come from the Vernam Cipher "Unbreakable" cipher.

  • $\begingroup$ You may simply read file content (as bytes-string or bits-string) and pass it to the encryptor as the key. $\endgroup$ – Reversal Apr 22 '16 at 10:43
  • $\begingroup$ Good Point, but I'm asking myself if this solution is the most efficient or is practicable because some tools desn't read the pass-phrase from the command-line via parameter (they ask in an interactive way) $\endgroup$ – metas Apr 22 '16 at 10:53

Note: I won't recommend a specific library for these, because this would be off-topic and the risk would be there that this gets outdated sooner than later (especially as soon as CAESAR finishes).

This is a very standard solution to the authentication problem although usually one does do both (e.g. passphrase and keyfile).

On the conceptual level any library exposing some sort of KBKDF or PBKDF and a decent encryption mechanism is sufficient.

What you do is simple and clear: You look at your chunk of data and extract derivation paramters from it (they are associated data), then you ask the user for the file name and completely parse it into your PBKDF / KBKDF of choice. From this you derive an encryption key and a nonce / IV and you're good to go to apply authenticated encryption on your data

You should use a password based key derivation function (PBKDF such as Argon2, scrypt or bcrypt) if you suspect the file to be low entropy (less than $2^{128}$ plausible possibilities) and use a key based key derivation function (KBKDF such as HKDF or KDF2) in all the other cases. For the actual encryption AES-EAX is your mode of choice for files that get larger than 60GB and AES-GCM for anything smaller.

  • $\begingroup$ I'm open for a better standard link for KDF2. $\endgroup$ – SEJPM Apr 22 '16 at 15:15

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