inner workings of block mode encryption
Hi,
I'm interessted in the inner workings of encrypting block devices like the encrypted volumes created with the cryptsetup tool.
Let's say a file of size 200K is stored on an encrypted ext2 filesystem. How is the enrcyption key applied to it?
I guess the password is used only for accessing/mounting the volume, and the key is only a starting value (ie. a "seed") for the underlying cipher.
Since in these cases usually a blockwise operating cipher is used, that means that the file will be encrypted of course blockwise, for example in blocks of 32 bytes.
Now the question: are the blocks of that file all encrypted using the same one key? Or does a kind of "streaming" or HMAC get used for the subsequent blocks of the file?
Signature · 2 lines
TIA Uenal
Hi,
maybe you should start here:
https://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestions
Quoted 6 lines · U.Mutlu
Hi,
I'm interessted in the inner workings of encrypting block devices like the encrypted volumes created with the cryptsetup tool.Let's say a file of size 200K is stored on an encrypted ext2 filesystem. How is the enrcyption key applied to it?
To sum it up:
cryptsetup is independent of the overlying filesystem and does not care about it.
It just acts as a "mapper" and creates a new block device which represents plain text data.
You can use this device for any purpose of your choice: create a filesystem on it, use it as a LVM Volume, ....
Quoted 4 lines
I guess the password is used only for accessing/mounting the volume, and the key is only a starting value (ie. a "seed") for the underlying cipher.
You can use a passphrase or a keyfile with cryptsetup LUKS. This key is applied to a key derivation function which derives an intermediate key which is used for decrypting a key slot which contains the actual master-key for decrypting your volume.
This key slot or "lock box" concept opens the possibility that several key files or passphrases may unlock the volume.
The material which is needed for decrypting the device is located in the LUKS header. See FAQ.
Quoted 4 lines
Since in these cases usually a blockwise operating cipher is used, that means that the file will be encrypted of course blockwise, for example in blocks of 32 bytes.
Yes, almost.
dm-crypt uses a sector size of (correct me if i'm wrong) 512 Byte which means that every sector of 512 Byte gets en/decrypted independently. The encryption of each sector is parameterized by an initialization vector which may be influenced by the logical number of the sector.
Quoted 4 lines
Now the question: are the blocks of that file all encrypted using the same one key? Or does a kind of "streaming" or HMAC get used for the subsequent blocks of the file?
Well yes and no.
Yes, the same key is used for all sectors of the volume and no, dm-crypt does not use HMAC to generate key streams.
Just imagine: if you'd like to access the last sector of your volume you'd have to generate the whole key stream which would probably take a long time.
cheers
Ralf
Ralf Ramsauer wrote, On 02/08/2015 03:22 PM:
Quoted 41 lines
Hi,
maybe you should start here:
https://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestionsQuoted 6 lines · U.Mutlu
Hi,
I'm interessted in the inner workings of encrypting block devices like the encrypted volumes created with the cryptsetup tool.Let's say a file of size 200K is stored on an encrypted ext2 filesystem. How is the enrcyption key applied to it?
To sum it up:
cryptsetup is independent of the overlying filesystem and does not care about it.
It just acts as a "mapper" and creates a new block device which represents plain text data.
You can use this device for any purpose of your choice: create a filesystem on it, use it as a LVM Volume, ....Quoted 4 lines
I guess the password is used only for accessing/mounting the volume, and the key is only a starting value (ie. a "seed") for the underlying cipher.
You can use a passphrase or a keyfile with cryptsetup LUKS. This key is applied to a key derivation function which derives an intermediate key which is used for decrypting a key slot which contains the actual master-key for decrypting your volume.
This key slot or "lock box" concept opens the possibility that several key files or passphrases may unlock the volume.
The material which is needed for decrypting the device is located in the LUKS header. See FAQ.Quoted 4 lines
Since in these cases usually a blockwise operating cipher is used, that means that the file will be encrypted of course blockwise, for example in blocks of 32 bytes.
Yes, almost.
dm-crypt uses a sector size of (correct me if i'm wrong) 512 Byte which means that every sector of 512 Byte gets en/decrypted independently. The encryption of each sector is parameterized by an initialization vector which may be influenced by the logical number of the sector.Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Now the question: are the blocks of that file all encrypted using the same one key? Or does a kind of "streaming" or HMAC get used for the subsequent blocks of the file?
Well yes and no.
Yes, the same key is used for all sectors of the volume and no, dm-crypt does not use HMAC to generate key streams.
Hmm. IMO this is the major weak point of such static/symmetric crypto solutions. Knowing just one cleartext file, for example a well known static system file from the /etc directory, and its encrpted data, could easily lead to the master key (assuming the encrypted volume contains such system files).
OTOH, a streaming crypto solution (I think also called 'asymmetric'), ie. where each block gets encrypted with a new key derived from
the previous/initial key together with xoring with varying parts
of the user data in the block, would IMO make up a much more secure crypto solution.
Quoted 3 lines
Just imagine: if you'd like to access the last sector of your volume you'd have to generate the whole key stream which would probably take a long time.
Yes, true, but I think this problem could be somehow solved.
Quoted 3 lines
cheers
Ralf
Signature · 2 lines
cu Uenal
Quoted 4 lines · U.Mutlu
Knowing just one cleartext file, for example a well known static system file from the /etc directory, and its encrpted data, could easily lead to the master key (assuming the encrypted volume contains such system files).
Neither AES, serpent nor twofish are prone to known-plaintext attacks. Breaking some rounds is not the same as breaking the cipher.
Quoted 5 lines
OTOH, a streaming crypto solution (I think also called 'asymmetric'), ie. where each block gets encrypted with a new key derived from the previous/initial key together with xoring with varying parts of the user data in the block, would IMO make up a much more secure crypto solution.
You're mixing symmetric/asymmetric crypto and block cipher modes. A stream cipher is a symmetric key cipher. The random keystream is used to encrypt the plaintext, using its seed as the "key". (Btw: dm-crypt works symmetrically, too). An example for asymmetric encryption would be GPG, which uses a public/private keypair.
What you describe reminds me on the (ages old - around 1980?) CBC mode, where the IV is derived from the previous encrypted block. The first plaintext block is xor'ed to an IV with the same size as the plaintext block itself. CBC is therefore prone to choosen plaintext attacks. The last "C" in the name says it.
All of this is by no means specific for LUKS/dmcrypt. And there are surely a lot of others with deeper knowledge who can explain this better to you..
Hi
Quoted 7 lines · Heinz Diehl
Quoted 4 lines
Knowing just one cleartext file, for example a well known static
Quoted 3 lines
system file from the /etc directory, and its encrpted data, could easily lead to the master key (assuming the encrypted volume contains such system files).
Neither AES, serpent nor twofish are prone to known-plaintext attacks. Breaking some rounds is not the same as breaking the cipher.
I absolutely agree, Heinz.
Only the knowledge of a plain text block an the corresponding cipher text block is NOT sufficient to "guess" or derive the key. This is one of the major design criteria of symmetric block ciphers.
When I did my first steps in cryptography I also naively thought that knowing a cipher text and a corresponsing plain text automatically offers the possibility to derive the key but this is absolutely not the truth.
And the use of the same key throughout your volume is NOT a vulnerability.
If you're of another opinion please show me references.
I recommend you to read the following links:
http://git.dyne.org/tomb/plain/doc/New_methods_in_HD_encryption.pdf
http://en.wikipedia.org/wiki/Watermarking_attack
http://en.wikipedia.org/wiki/Disk_encryption_theory
http://cacr.uwaterloo.ca/hac/ <- great book, online available for free
cheers
Ralf
Quoted 12 lines · Ralf Ramsauer
Hi
Quoted 7 lines · Heinz Diehl
Quoted 4 lines
Knowing just one cleartext file, for example a well known static
Quoted 3 lines
system file from the /etc directory, and its encrpted data, could easily lead to the master key (assuming the encrypted volume contains such system files).
Neither AES, serpent nor twofish are prone to known-plaintext attacks. Breaking some rounds is not the same as breaking the cipher.
I absolutely agree, Heinz.
Quoted 8 lines
Only the knowledge of a plain text block an the corresponding cipher text block is NOT sufficient to "guess" or derive the key. This is one of the major design criteria of symmetric block ciphers.
When I did my first steps in cryptography I also naively thought that knowing a cipher text and a corresponsing plain text automatically offers the possibility to derive the key but this is absolutely not the truth.
And information-theoretically it does. It is just computational effort that stands in between and computationel effort is tricky, but also very real in this universe.
Quoted 1 line
And the use of the same key throughout your volume is NOT a vulnerability.
It is not. What is a vulnerablility is that the same key is used for multiple writes to the same sector. It does not allow decryption, but it does allow seeing whether a sector has changed if the attacker can access the volume several times.
This is also unavoidable when block sizes are mapped 1:1, metadata is of fixed size, and performance needs to be not too badly impacted. Hence it is accepted as a known limitation.
Crypto is not perfect. Most crypto has known limitations and vulnerabilities. The trick is to use the right method in the right situation so that an attacker does not gain anything substantial. Hence crypto security is always with respect to an attacker model (or equivalently, a set of attacker capabilities).
In addition, an attacker that can access a computer 2 or more times with the user unlocking the encrypted storage in between is generally assumed to have won in disk encryption, as this attacker can compromise the boot proccess.
Quoted 7 lines
If you're of another opinion please show me references.
I recommend you to read the following links:
http://git.dyne.org/tomb/plain/doc/New_methods_in_HD_encryption.pdf
http://en.wikipedia.org/wiki/Watermarking_attack
http://en.wikipedia.org/wiki/Disk_encryption_theory
http://cacr.uwaterloo.ca/hac/ <- great book, online available for free
I second that. In particular the thesis by Clemens is excellent.
It is not that we think you have no clue and should go away, it is that it is very hard talking to you when we have to clear up beginners mistakes all the time. Crypto is hard and complicated, some knowledge is required to even ask questions well.
Gr"usse,
Arno
Signature · 7 lines
Arno Wagner, Dr. sc. techn., Dipl. Inform., Email: [email protected] GnuPG: ID: CB5D9718 FP: 12D6 C03B 1B30 33BB 13CF B774 E35C 5FA1 CB5D 9718 ---- A good decision is based on knowledge and not on numbers. -- Plato If it's in the news, don't worry about it. The very definition of "news" is "something that hardly ever happens." -- Bruce Schneier
Quoted 1 line · U.Mutlu
Ralf Ramsauer wrote, On 02/08/2015 03:22 PM:
[...]
Quoted 5 lines
Hmm. IMO this is the major weak point of such static/symmetric crypto solutions. Knowing just one cleartext file, for example a well known static system file from the /etc directory, and its encrpted data, could easily lead to the master key (assuming the encrypted volume contains such system files).
With modern block-ciphers there is no "easily" here. In fact there is "infeasible" here as you basically always can get some ciphertext/ plaintext pairs also in communication encryption and it does not even need to be a "chosen plaintext" attack. Ciphers vulnerable to that are worthless.
Really, you need to read up on what modern ciphers do. You also need to read up on the terminology. Getting the meaning of "symmetric" and "asymmetric" wrong is a pretty bad mistake. Not that I accuse you of anything, it is just that communication gets hard if one side does not understand the basics.
Quoted 5 lines
OTOH, a streaming crypto solution (I think also called 'asymmetric'), ie. where each block gets encrypted with a new key derived from the previous/initial key together with xoring with varying parts of the user data in the block, would IMO make up a much more secure crypto solution.
That is infeasible for block-layer encryption and very expensive for file-level encryption. Hence nobody does it on system layer. You may be thinkling of things like CBC-mode communication encryption. Block- device storage is not a communication device, it works differently. For character-device storage where you do never seek you could do this, but you donot get a file-system on these, just a raw bit-stream.
Quoted 5 lines
Quoted 3 lines
Just imagine: if you'd like to access the last sector of your volume you'd have to generate the whole key stream which would probably take a long time.
Yes, true, but I think this problem could be somehow solved.
You think wrong. This problem has been studied for at least two decades and nobody found a solution for it. In fact, it can very likely be formally proven that this problem cannot be solved and keep the security guarantees intact.
Gr"usse,
Arno
Signature · 7 lines
Arno Wagner, Dr. sc. techn., Dipl. Inform., Email: [email protected] GnuPG: ID: CB5D9718 FP: 12D6 C03B 1B30 33BB 13CF B774 E35C 5FA1 CB5D 9718 ---- A good decision is based on knowledge and not on numbers. -- Plato If it's in the news, don't worry about it. The very definition of "news" is "something that hardly ever happens." -- Bruce Schneier