I apologise if this is already common knowledge, but I just found out you can have multiple layers of LUKS encryption on a drive!

[Image description:
Screenshot of terminal output:


<span style="color:#323232;">~ ❯ lsblk
</span><span style="color:#323232;">NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
</span><span style="color:#323232;">sda              8:0    1  62.5M  0 disk  
</span><span style="color:#323232;">└─topLuks      254:2    0  60.5M  0 crypt 
</span><span style="color:#323232;">  └─bottomLuks 254:3    0  44.5M  0 crypt
</span>

/end image description]

I had no idea!

If anyone else is curious, it’s pretty much what you would expect:


<span style="color:#323232;">cryptsetup -y -v luksFormat /dev/sda
</span><span style="color:#323232;">cryptsetup open /dev/sda topLuks
</span><span style="color:#323232;">cryptsetup -y -v luksFormat /dev/mapper/topLuks
</span><span style="color:#323232;">cryptsetup open /dev/mapper/topLuks bottomLuks
</span><span style="color:#323232;">lsblk
</span>

Then you can make a filesystem and mount it:


<span style="color:#323232;">mkfs.ext4 /dev/mapper/bottomLuks
</span><span style="color:#323232;">mount /dev/mapper/bottomLuks ~/mnt/embeddedLuksTest
</span>

I’ve tested putting files on it and then unmounting & re-encrypting it, and the files are indeed still there upon decrypting and re-mounting.

Again, sorry if this is not news to anyone else, but I didn’t realise this was possible before, and thought it was very cool when I found it out. Sharing in case other people didn’t know and also find it cool :)

fruitycoder,

Might be a way to enforce multiple algorithms or enforce two factor unlocking (say TPM AND password).

EpicFailGuy,
@EpicFailGuy@lemmy.world avatar

You guys are going to blow your top when you hear about DFC (Distributed Fragment Cryptography)

fruitycoder,

Any good reading the subject?!

EpicFailGuy,
@EpicFailGuy@lemmy.world avatar

Googling it takes you to the one company website that has managed to get a service out (a keyless) they haveA really good docs public repository.

I work with these folks thru my job and it’s a pleasure to deal with them (even tho the product it’s a bit complex)

It does my great good to see a company actually being run by engineers

www.akeyless.io/blog/how-akeyless-dfc-works/

jjlinux,

Never apologize for enjoying the discovery of new things. That’s awesome, enjoy it.

fmstrat,

Where’s the ZFS love…

CarbonScored,
@CarbonScored@hexbear.net avatar

Is it possible to… boot into a LUKS in a LUKS?

7heo,
@7heo@lemmy.ml avatar

Have fun with the initramfs.

possiblylinux127,

I will thanks

bjoern_tantau,
@bjoern_tantau@swg-empire.de avatar

Great! Although I think that security actually goes down that way. Something something about statistics. A crypto expert could probably explain that properly and we could pretend to understand it.

TankieTanuki,
possiblylinux127,

Yo dog I heard you like cryptography

crispy_kilt,

top / bottom

( ͡° ͜ʖ ͡°)

Evil_Shrubbery,

This guy LUKS!!

Evilsandwichman, (edited )

I guess your…Luks not running out.

CaptKoala,

Take my angry upvote, you heathen.

Goun,

If you think about, it makes sense, but I didn’t know this! Really cool indeed - do you have any use case for that or you were just poking around?

communism,
@communism@lemmy.ml avatar

I have an SSD and an HDD—I was considering on my next distro hop to put the root partition on the SSD and home partition on the HDD, decrypt the SSD and top level of the HDD upon boot, then decrypt the bottom level of the HDD upon user login. I’m sure many will think that’s overkill or silly, but hey, if you have full disk encryption you’ll have to enter two passwords to get into your computer anyway, just means your personal files get protected with two passwords. I would agree it’s mostly gimmicky but I still want to try it out lol

Goun,

Amazing! How do you setup the decryption on login? systemd-home or something like that?

communism,
@communism@lemmy.ml avatar

pam_mount. Arch wiki also suggests pam-exec although their explanation uses systemd (I’m using runit).

Goun,

Fancy! TIL about pam_mount. Thanks, comrade!

possiblylinux127,

Wouldn’t it be easier to just use a longer password and or a longer hash

communism,
@communism@lemmy.ml avatar

Yes, it would. But it’s less fun lol

hperrin,

It would be good if you wanted to have a system that two people need to be present to unlock. Like those nuke launch locks that need two keys.

Jawa,

You can also just split the password for a single LUKS into two parts and give one each to the two people :D

hperrin,

Yeah, you’re right. That’s better.

flashgnash,

But then you know both parts of the password and so must be killed to keep the machine secure

Jawa,

Ideally you would never have to because you just have the two people come up with their part of the password and then initialise the LUKS partition together. Sorta like a key ceremony

possiblylinux127,

I don’t think that’s how its done. I see where your going with this.

communism,
@communism@lemmy.ml avatar

Tbf this would enforce the order in which the two people decrypt it, which may not be good if you expect these two people to “arrive” asyncrhonously and you don’t want them to have to wait for the other before entering their password/key. But maybe that’s too specific of a use case.

TimeSquirrel,
TimeSquirrel avatar

You're a programmer, aren't you? Always thinking about those race conditions and edge cases.

Sabata11792,
Sabata11792 avatar

Didn't account for the 2 sticky notes cleverly hidden under they keyboard.

communism,
@communism@lemmy.ml avatar

Definitely not professionally lol. I think I’d only want a programming job if I could somehow develop FOSS for a living, which is hard to get a full-time job in. And only to a limited extent as a hobby, though I do enjoy programming and am trying to teach myself more whenever I have the time :)

Opisek,

What about this: Top layer encrypted by Alice Middle layer encrypted by Bob Bottom layer encrypted by Alice

If Alice arrives first, she decrypts the top layer and has to wait for Bob to arrive. She cannot go because she has to decrypt the last layer. If Bob arrives first, he has to wait for Alice to arrive. He cannot go because he hasn’t decrypted anything yet.

Not really a solution but kind of helps.

communism,
@communism@lemmy.ml avatar

That would just mean they both have to wait for each other rather than one having to wait for the other but not vice versa. Worse if you want to reduce the total amount of waiting, I guess better if you want there to be equality in having to wait for the other person lol

Opisek, (edited )

Oh yeah, seems I hyper focused on your usage of “arrive”. I personally saw it as a problem if one person unlocked the first layer and just left leaving only one layer for days.

LostXOR,

Now recursively create more layers until you have barely any free space left on the disk, then do some performance benchmarks. ;)

Max_P,
@Max_P@lemmy.max-p.me avatar

Yeah, LUKS and most block level overlays just don’t care. That’s what good abstraction layers do for you!

You can LUKS on a disk image mounted over SSHFS that itself resides on a Ceph cluster and mounted over iSCSI for all it cares. Is it a block device? Yes? Good to go.

You can even LUKS a floppy if you want. Or a CD.

Bitrot,
@Bitrot@lemmy.sdf.org avatar

I remember years ago investigating alternatives to VMware vSAN and doing hyperconverged storage clusters in Red Hat with glusterFS in top of a couple of other layers. Feels rickety as heck putting it all together but it works well. Hard sell for “normal” people who expect to hit a Next button and get some pretty graphical chart though.

hperrin,

You wouldn’t LUKS a floppy?

MigratingtoLemmy,

I absolutely will, if I can find one

tgxn,
@tgxn@lemmy.tgxn.net avatar

And a suitable reader that my computer knows how to talk to.

MigratingtoLemmy,

Connections to the reader need to be encrypted or I don’t want it

Qkall,
@Qkall@lemmy.ml avatar

we really ain’t making any jokes on the name of the drives? okay…

communism,
@communism@lemmy.ml avatar

Yes, perhaps I should have named them outerLuks and innerLuks… oh well lol

unexposedhazard,

Well considdering it was posted by a user with the username “communism” i will assume bottomLuks

delirious_owl,
@delirious_owl@discuss.online avatar

Communism doesn’t have hierarchy tho

Overshoot2648,

Wouldn’t that be Anarchism/ Libertarian Socialism? Communism requires a state which is an implicit hierarchy.

delirious_owl,
@delirious_owl@discuss.online avatar

No, anarcho-communists build their own systems of governments that are ruled from the bottom, without a hierarchy.

You dont need a hierarchy to have a State that works for the people

JustEnoughDucks,
@JustEnoughDucks@feddit.nl avatar

That’s very true.

But Marxist-Leninism (Lemmy.ml), the attempt to make communism practical and achievable and bumbling into fascism, does have a hierarchy.

maniacal_gaff,

Actually the bottomLuks generates most of the power.

SatyrSack,

Speed has everything to do with it.

radiofreeval,
@radiofreeval@hexbear.net avatar

That’s cool and I hope I never see that in the wild

communism,
@communism@lemmy.ml avatar

Why not?

LostXOR,

Seems like it would be fairly inefficient having to encrypt and decrypt data twice.

ryannathans,

Not only twice but two streams sequentially on the same hardware

theit8514,

You can, sure, but you probably shouldn’t. Encrypting and decrypting consume additional cpu time, and you won’t gain much in terms of security.

authed,

not really if you have a hardware chip that does the encrypt/decrypting

theit8514,

Does cryptsetup/luks do that? I thought that was only software encryption.

authed,

it depends if your hardware supports the algos that cryptsetup/luks use I guess…

crispy_kilt,

It does if the CPU supports it. Otherwise i/o would be stupidly slow, AES is expensive

cbarrick, (edited )

AES has been accelerated on all Intel CPUs since Broadwell, was common as far back as Sandy Bridge, and has been available since Westmere.

AMD has had AES acceleration since Bulldozer.

But the commenter is right that adding a second layer of encryption is useless in everything except very specific circumstances.

authed,

agreed that it is useless for most cases but I could see it being useful if you need multiple people to agree on decrypting a file.

Killing_Spark,

That’s pretty nitty although you can always just partition a long key and distribute the partitions to the different people

authed,

there’s always more than one way to skin a rat

cbarrick,

multiple people to agree on decrypting a file

For that, you would use Shamir’s Secret Sharing algorithm rather than multiple encryption.

en.wikipedia.org/wiki/Shamir's_secret_sharing

authed, (edited )

that’s another way, I guess… if you want to split the file, that is

cbarrick,

No, you don’t split the file. You split the master decryption key.

Each user just needs to remember their own password, and SSS can reconstruct the master key when enough users enter their passwords.

taaz,

I’ve also found about this recently when moving my root from drive to drive which was after I upgraded to 13th gen intel (from various older i5s) and the best cipher changed (cryptsetup benchmark).

krash,

What circumstances would that be? I can’t see the use case doe this, but I’m open to see how and when that would be needed.

cbarrick,

There’s a Wikipedia article on multiple encryption that talks about this, but the arguments are not that compelling to me.

The main thing is mostly about protecting your data from flawed implementations. Like, AES has not been broken theoretically, but a particular implementation may be broken. By stacking implementations from multiple vendors, you reduce the chance of being exposed by a vulnerability in one of them.

That’s way overkill for most businesses. That’s like nation state level paranoia.

theit8514,

Yes, but as I’ve found recently AES-NI is only as good as your software support for it. Had a team using an ancient version of winscp and they kept complaining about download speeds on our 10Gb circuit. Couldn’t replicate it on any other machine with the newest version of winscp so I installed their exact version. AES-NI support wasn’t added until like 2020 and it gave them 5x better download speed after upgrading.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • DreamBathrooms
  • mdbf
  • thenastyranch
  • magazineikmin
  • khanakhh
  • rosin
  • Durango
  • ethstaker
  • Youngstown
  • slotface
  • osvaldo12
  • kavyap
  • cisconetworking
  • ngwrru68w68
  • JUstTest
  • GTA5RPClips
  • InstantRegret
  • tacticalgear
  • modclub
  • everett
  • anitta
  • Leos
  • cubers
  • tester
  • normalnudes
  • megavids
  • provamag3
  • lostlight
  • All magazines