How to encrypt a pendrive in C?

3

First of all, I have a security idea, and to put this idea into practice I would need to learn how to encrypt a USB stick.

The idea is that the pendrive works as a 'key', and at the same time this pendrive can not be easily accessed (hence the encryption).

I could simply use BitLocker, or several other programs for encryption. But my intention is that the pendrive can not be accessed by any 'common' operating system. I want the pendrive to be accessed, solely and exclusively by my hardware (an Arduino for example (which I will also need to learn, but one thing at a time kk)).

I know little about cryptography, but if anyone knows, if it has already happened in a similar situation and can help me, give me a direction, where to start etc.

Thank you !!

    
asked by anonymous 18.08.2016 / 15:36

1 answer

4

Here are some tips and hints:

1) It's not just because information can not be read orthodox (through common operating systems) that it is secure. This is called falsa sensação de segurança . The best way to protect your data is through encryption (and all the power of the mathematics behind it) once encrypted, no matter what medium or medium on which that data will be trafficked, stored and / or copied, which it is important that to be decrypted would require a tremendous computational effort, a lot of time and / or a lot of money;

2) Basically, there are 2 distinct types of cryptographic algorithms using keys: Simétrico and Assimétrico . To simplify, I suggest using a symmetric key cryptography algorithm. Currently, there are several such as: AES , Twofish , Serpent , Blowfish , CAST5 , RC4 , 3DES and / or IDEA , and it will not be difficult to find libraries in C capable of implementing them;

3) Your hardware can work quietly using a standard file system, such as NTFS , and simply read and write files and uncomplicated using arduino hardware;

4)

If the intent is to store the cryptographic key in the pen-drive , I suggest that it be protected by a% this could also be done through symmetric key cryptography, with a key that is easy to remember. I suggest using a compression library (such as zlib ) that is able to compress and protect data with a password, such as on chip credit cards;

5) On * nix systems, the pen-drive device is represented by a special file within the PIN directory. For example: /dev , /dev/sdb , etc. Such a file can be opened by means of the /dev/sdc function while reading and writing the data can be done using the open() and read() functions respectively. Another alternative would be to use the write() function for direct manipulation of the USB device.

References:

PIN: link

Symmetric Encryption: link

Asymmetric Cryptography: link

Function: ioctl() : link

Function: ioctl() : link

I hope I have helped!

    
18.08.2016 / 16:22