Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-30-2010, 11:16 AM
|
#1
|
|
LQ Newbie
Registered: Aug 2005
Location: Switzerland
Distribution: Kubuntu, Arch Linux
Posts: 20
Rep:
|
Tricky Problem with corrupted LUKS-encrypted partition
Hello,
I have a really tricky and may be intresting problem with a encrypted disk partition (cryptsetup luks...) which was fine until it accidentally got re-formatted by an instance of Windows 7. Most of the data on that 1TB-disk will probably still exist, only the LUKS header at the very beginning of the partition is - of course - gone.
So when I try to open the container, it gives no verbose, just the return value 234.
I scanned the whole partition for other LUKS headers with hexedit, none there. But, luckyly I have another partition which is encrypted in the exact same way with the exact same passphrase (which I remember very well!), so I had an idea: I copied the LUKS header (592 bytes) from the other LUKS encrypted partition over to the damaged partition.
When I now issue
Code:
cryptsetup luksOpen /dev/sde1
the passphrase is asked, I enter it, which results in the error
Code:
No key available with this passphrase
Here is the command how I created the container:
Code:
cryptsetup -c aes-cbc-essiv:sha256 -y -s 256 luksFormat /dev/sde1
How do I get the existing passphrase accepted by LUKS?
What an I missing?
Any ideas, suggestions are greatly appreciated!
Thanks in advance,
IceDragon
|
|
|
|
07-01-2010, 04:21 AM
|
#2
|
|
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515
Rep:
|
Not at all knowledgeable on LUKS and encrypted filesystems, so I'm just checking the basics from the man pages/google here:
Can you perform any action (remove, addKey, dump header,...)?
Secondly, cryptsetup seems to be a convenient shorthand util for the underlying dm-crypt. Did you search in that direction?
|
|
|
|
07-01-2010, 04:31 AM
|
#3
|
|
Member
Registered: Jun 2010
Posts: 361
Rep:
|
I hope you didn't have any valuable data on that partition  You're most definitely out of luck.
First: The encryption master key is completely random and stored in encrypted form in the header. When you lose the header, this key is lost.
Second: The key to decrypt the master key is indeed derived from your passphrase, but using a random salt. So there is no way to get the same "master-key-decryption-key" from a different luks header with the same passphrase.
|
|
|
1 members found this post helpful.
|
07-02-2010, 11:54 AM
|
#4
|
|
LQ Newbie
Registered: Aug 2005
Location: Switzerland
Distribution: Kubuntu, Arch Linux
Posts: 20
Original Poster
Rep:
|
Quote:
Originally Posted by timmeke
Can you perform any action (remove, addKey, dump header,...)?
Secondly, cryptsetup seems to be a convenient shorthand util for the underlying dm-crypt. Did you search in that direction?
|
No, I am not able to do ANY operation besides
cryptsetup isLuks /dev/sde1
which returns true since I copied the header of an other LUKS partition
thanks anyway,
Ice
|
|
|
|
07-02-2010, 12:13 PM
|
#5
|
|
LQ Newbie
Registered: Aug 2005
Location: Switzerland
Distribution: Kubuntu, Arch Linux
Posts: 20
Original Poster
Rep:
|
Quote:
Originally Posted by zirias
First: The encryption master key is completely random and stored in encrypted form in the header. When you lose the header, this key is lost.
Second: The key to decrypt the master key is indeed derived from your passphrase, but using a random salt. So there is no way to get the same "master-key-decryption-key" from a different luks header with the same passphrase.
|
No, the data on this partition wasn't crucial, mostly temporary files, and working directories of various projects. No working hours are lost, I just have to re-render a lot of things, not really a big deal.
(I now like my habit of backing up crucial files, HOWTOs, any project data, and documentation very much!)
But you just confirmed what I suspected anyway and other sources already said - that any LUKS header differs greatly from another even if the cypher mode, hash function and password are identical.
I consider the data lost and will reformat the drive.
But one last question:
To prevent such a loss in the future, how much do I have to save? Is it enough to save the 592 bytes of the LUKS header (as this info specifies here http://de.wikipedia.org/wiki/Dm-crypt#On-Disk-Format (in german) )or do I need more?
Thanks in advance,
Ice
|
|
|
|
07-02-2010, 05:05 PM
|
#6
|
|
Member
Registered: Jun 2010
Posts: 361
Rep:
|
AFAIK, the header SHOULD be enough, i don't know of any "backup headers" in LUKS like e.g. in truecrypt (that would have come to your rescue right now)... but please, no warranty of any kind on that info
I have a quite similar problem right now with truecrypt (lost keyfile, so existing header is useless), but I happen to know the master encryption key, so I hope to recover by "hacking" truecrypt 
|
|
|
|
07-02-2010, 05:39 PM
|
#7
|
|
LQ Newbie
Registered: Aug 2005
Location: Switzerland
Distribution: Kubuntu, Arch Linux
Posts: 20
Original Poster
Rep:
|
Know what? I just test that and let's see whether these 592Bytes are enough.
Besides, good luck with your "hacking"...
Ice
|
|
|
|
07-03-2010, 04:16 AM
|
#8
|
|
LQ Newbie
Registered: Aug 2005
Location: Switzerland
Distribution: Kubuntu, Arch Linux
Posts: 20
Original Poster
Rep:
|
Ok, I just tested whether saving the first 592bytes will do...
quick answer: No, it won't.
I generated a LUKS partition, copied some files into it, unmounted and closed it, saved the header with dd, issued an mkntfs (without zeroing the device, to simulate what apparently happened). Then I restored the LUKS header and tried to open it - nope, did not work.
It seems that backing up the first 592bytes is not enough to restore even part of the data on a LUKS partition after it got corrupted.
Something is missing, but what?
Greetings, Ice
|
|
|
|
07-03-2010, 05:31 PM
|
#9
|
|
Member
Registered: Nov 2009
Posts: 63
Rep:
|
I'm not any kind of programmer/hacker though familiar with disk editors. I tried a couple of experiments with luks and Truecrypt using small partition/files (make it easier) on a clean disk.
With identical sized startings and adding known size files plus same/diff length/words password and comparing sectors I tried the sectors copy to no avail. So I believe that hack is safe and your data is gone.
|
|
|
|
07-03-2010, 06:43 PM
|
#10
|
|
LQ Newbie
Registered: Aug 2005
Location: Switzerland
Distribution: Kubuntu, Arch Linux
Posts: 20
Original Poster
Rep:
|
LUKS is open source and I am a programmer for 25 years now, so when I find some time, I'm gonna look into this beast to determine how it is backed up (if one does not want to back up the whole partition)
Lesson learned for now: If a disk with a linux partition on it is moved to a PC with Windows 7 installed, make sure that it's partition type flag is NOT accidentally 0x07 = "Windows NTFS" or something similar, because then Windows may attempt to "repair" the "damaged" partition.
Greetings, Ice
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:09 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|