LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-05-2024, 03:03 PM   #1
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Rep: Reputation: Disabled
Accessing an old file encrypted with the serpent cipher


Many years ago I created an encrypted file to store some very personal stuff I didn't want to be accessible to anyone: at that time I was running slackware-1x on a 32 bit laptop with no disk encryption. A few years later, with slackware-14.x I moved to x86_64 and I started encrypting my whole disk, so I opened that old file and transferred its content (all of it?) to my file system.

Today I was cleaning up my home directory and, finding that old file still sitting there, I thought to open it to check if everything was actually saved. To open it I used to use these commands:

Code:
losetup -e serpent /dev/loop0 crypto.serpent
mount -t ext2 /dev/loop0 /mnt/tmp/
(crypto.serpent is the file... I named it so to remember the cipher)

Now, losetup -e has gone but, if I'm reading the documentation correctly, cryptsetup should be backward compatible, and so something like this should do the job:

Code:
cryptsetup plainOpen crypto.serpent mysecrets -c serpent
mount -t ext2 /dev/mapper/mysecrets /mnt/tmp/
The problem is that I'm now getting:

Code:
mount: /mnt/tmp: wrong fs type, bad option, bad superblock on /dev/mapper/mysecrets, missing codepage or helper program, or other error
Now, serpent support, in slackware, should be built into the kernel so I do not know what I'm missing.

As I said, I do not think I'm facing a data loss problem, but I'm puzzled because when I created that file I thought I would not have problems accessing it in the (also far) future. Am I doing something wrong?

Best,
andrea

ps: obviously I remember the passphrase, and I know because I already opened it a few years after creating it.
 
Old 04-05-2024, 06:38 PM   #2
tjallen
Member
 
Registered: Jan 2014
Location: Central New York
Distribution: Slackware
Posts: 77

Rep: Reputation: 26
Are you sure that the filesystem is ext2? If so, is ext2 compiled into the kernel or loaded as a module?
 
Old 04-05-2024, 08:44 PM   #3
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,523

Rep: Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489Reputation: 8489
Quote:
Originally Posted by tjallen View Post
Are you sure that the filesystem is ext2? If so, is ext2 compiled into the kernel or loaded as a module?
Indeed. I'd leave out the -t and let it figure it out. Also, I'd probably add -o ro for safety of the filesystem, at first.
 
Old 04-05-2024, 09:03 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
You can run "file -sL /dev/mapper/mysecrets" to see if that file decrypted into something recognizable.
 
Old 04-06-2024, 04:04 AM   #5
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tjallen View Post
Are you sure that the filesystem is ext2? If so, is ext2 compiled into the kernel or loaded as a module?
yes I'm sure, also because when I created the file I also created a short shell script to open it, in case I was going to forget how to do it...;-)

and yes, the ext2 module is indeed loaded.


Quote:
Originally Posted by rknichols View Post
You can run "file -sL /dev/mapper/mysecrets" to see if that file decrypted into something recognizable.
thanks for the hint, which gives me some more info to work with. what I get is:

Code:
file -sL /dev/mapper/mysecrets
/dev/mapper/mysecrets: OpenPGP Secret Key
I'll do some more research...

thanks for your kind attention and help!
 
Old 04-06-2024, 08:59 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,781

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by gattocarlo View Post
thanks for the hint, which gives me some more info to work with. what I get is:

Code:
file -sL /dev/mapper/mysecrets
/dev/mapper/mysecrets: OpenPGP Secret Key
How big is that crypto.serpent file? It appears that you have merely decrypted a secret key file, not the file that holds your actual filesystem.
 
Old 04-06-2024, 02:42 PM   #7
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
How big is that crypto.serpent file? It appears that you have merely decrypted a secret key file, not the file that holds your actual filesystem.
probably I did something wrong when getting the result I posted in my previous message... the file is 300M and I tried everything I could imagine and so I probably posted something which was the result of some wrong command I issued.

anyway, just to double check, I downloaded slackware-12 (32bit) and slackware64-14, installed them on a virtual machine with qemu and successfully decrypted my file on both of them (the file was created in 2005 and decrypted the last time in 2017). Everything was indeed saved on my file system... but, on the other side, I can confirm that, unless I'm missing something, cryptsetup is NOT backward compatible. which means that long term encryption in linux had not been not reliable -- which makes me think it won't be in the future. which is annoying because out there there are people relying on encryption to protect their freedoms and, sometimes, their lives: this should be something to be taken seriously.

I'd like to mark this thread as unsolvable, but I do not know how to do it and I still have a residual doubt that I may be missing something.
 
Old 04-06-2024, 03:03 PM   #8
tjallen
Member
 
Registered: Jan 2014
Location: Central New York
Distribution: Slackware
Posts: 77

Rep: Reputation: 26
The only change I know of that might affect cryptsetup is one that bit me. I used the whirlpool hashing function with the serpent cipher on my encrypted backup hard drive with one of the 13.x versions (IIRC) of Slackware, but there was a flaw found in the implementation of the whirlpool hashing function and the fix in cryptsetup made the the new version of cryptsetup incompatible. I'm not sure if your encrypted image uses hashing or not, or whether you're using the whirlpool hash function, but if you are, that could be the incompatibility.

I had to use the old version of cryptsetup to replace the hashing function in the header with a more common one (I think I used SHA512) that the new version could work with and then use the new version to replace the more common one with the fixed whirlpool hash. I remember feeling a little panicky at the time.
 
2 members found this post helpful.
Old 04-06-2024, 03:48 PM   #9
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Original Poster
Rep: Reputation: Disabled
I'm pretty sure I did not use the whirlpool hash function but went with the plain default (probably, at the time, it was SHA-1)...
 
Old 04-06-2024, 04:06 PM   #10
tjallen
Member
 
Registered: Jan 2014
Location: Central New York
Distribution: Slackware
Posts: 77

Rep: Reputation: 26
If you weren't using whirlpool, I'm out of ideas.

When you opened the encrypted file on the older versions of Slackware, did you use cryptsetup, or losetup? If cryptsetup, perhaps it is possible to figure out what changed in the intervening versions.
 
Old 04-06-2024, 04:24 PM   #11
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Original Poster
Rep: Reputation: Disabled
I used losetup with the cryptoloop kernel module... cryptoloop is still available in linux-5.15.x and, on slackware-15, installing util-linux-2.19 (the one I tried) it is still possible to use losetup to decrypt my file...

edit: even losetup from util-linux-2.21.2 (slackware-14.1) works.... the last one.

Last edited by gattocarlo; 04-06-2024 at 04:31 PM.
 
Old 04-06-2024, 04:38 PM   #12
tjallen
Member
 
Registered: Jan 2014
Location: Central New York
Distribution: Slackware
Posts: 77

Rep: Reputation: 26
I wonder if VeraCrypt will open your file and mount it for you.
 
Old 04-06-2024, 06:32 PM   #13
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tjallen View Post
I wonder if VeraCrypt will open your file and mount it for you.
no it does not, and now I know why... sorry, my fault... apparently losetup, when creating an encrypted loop device with cryptoloop DID NOT use any hash function for the passphrase. dm-crypt and veracrypt require a hash function instead.

cryptsetup comes with the option to set the hash, but it also accepts "plain" for... no hash. and so:

Code:
cryptsetup plainOpen -c serpent  -h plain crypto.serpent mysecrets
does the job!

I apologize: dm-crypt is indeed backward compatible with cryptoloop.

I'm deeply sorry for the noise. (as an excuse I could say that "-h plain" is not documented in the man page and I think it is fair to say, as an option, it is counterintuitive).
 
2 members found this post helpful.
Old 04-06-2024, 06:43 PM   #14
tjallen
Member
 
Registered: Jan 2014
Location: Central New York
Distribution: Slackware
Posts: 77

Rep: Reputation: 26
Good work! It's great to know that cryptsetup does work after all.
 
Old 04-06-2024, 06:55 PM   #15
gattocarlo
Member
 
Registered: Jan 2020
Posts: 63

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tjallen View Post
Good work! It's great to know that cryptsetup does work after all.
thank you for your precious hints that led me to the solution!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] dm-crypt "Cannot use serpent-xts-plain64 cipher for keyslot encryption." After migration to LUKS2 serafean Linux - Software 1 02-14-2021 02:20 PM
LXer: Serpent Is an Open-Source Game Framework Focused on 2D Games LXer Syndicated Linux News 0 02-04-2020 05:00 PM
[SOLVED] NCrypt - unable to use Serpent (?) paziulek Linux - Security 6 07-08-2014 10:19 AM
How do you change cipher list order with openssl cipher command? markseger Linux - Security 1 03-20-2013 04:45 AM
F11 installer: affecting the cipher used for encrypted partitions (e. g. blowfish) furryspider Fedora - Installation 1 08-16-2009 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration