I am about to go paperless, and I want to protect the documents that I scan. The use case is that I'll be scanning paper documents, encrypting each file, and storing them locally and on various backup destinations. I've been researching various ideas for how to protect those documents, but I need more guidance. Here are the details of the system I'm trying to implement:

  • Protection is at file level. If someone gets their hands on a file, I want them to be unable to use it.
  • Transmission safety is out-of-scope, and assumed to be handled by whatever system is transporting the file.
  • The files will be encrypted on a Mac.
  • Decryption should be as widely-available as possible. For example, if I want to view a file on my iPhone, I should be able to use an existing library to write an app to do so.

I've looked at using security and encryption libraries in OS X to make a lightweight tool for this. I'm a software engineer, so I'm perfectly comfortable with writing my own application, but I am new to security. I am not comfortable making the security decisions without consulting people who know more than I do.

  • I've considered AES, but then I read about padding and encryption modes, and I got lost in the details of which to choose.
  • I've considered GnuPG, but I don't like the idea of having to download a separate tool. Yes, it's open source, but if I can use functionality built into the OS, that would be preferred.

Is there a recommended approach for this?

  • "Decryption should be as widely available as possible" seems to conflict with an OS level tool. Maybe that's not an issue if you're exclusively in the OSX/iOS world, but even then you may have differences in version and inclusion, and if not now then next release cycle. tgdaily.com/software-features/…
    – Dave
    Feb 10 '16 at 0:04

You can use openssl like this:

openssl enc -e -aes-256-cbc -salt -a -in /file/to/encrypt -out /file/encrypted

Replace -e with -d to decrypt. It should work both on OS X and Linux, don't know on other systems however. man openssl to list the options and the available cipher.

Edit: looks like openssl applies few rounds of MD5 (not the best hashing algorithm) to the key derivation. This makes brute force attacks easier.

A better solution could be GnuPG (i know you asked for a preinstalled tool by the way):

To encrypt:

gpg -c -a --cipher-algo AES256 /file/to/encrypt

To decrypt:

gpg /file/to/decrypt
  • 1
    This may not be a great solution. security.stackexchange.com/questions/31492/…
    – Halen
    Jan 10 '16 at 16:28
  • Matteo, I think if you add a few comments about the limitations of this solution, it will be a good answer. Jan 10 '16 at 19:31
  • @NeilSmithline I think you are referring to Halen's comment, he posted the security implications.
    – Matteo
    Jan 10 '16 at 20:53
  • I am, but you can incorporate the info into your answer. What you wrote isn't really wrong, it just has limitations. Jan 10 '16 at 21:21
  • @NeilSmithline Updated the answer
    – Matteo
    Jan 10 '16 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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