Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261906AbVBDOJG (ORCPT ); Fri, 4 Feb 2005 09:09:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S266409AbVBDOI7 (ORCPT ); Fri, 4 Feb 2005 09:08:59 -0500 Received: from websrv2.werbeagentur-aufwind.de ([213.239.197.240]:59554 "EHLO websrv2.werbeagentur-aufwind.de") by vger.kernel.org with ESMTP id S266334AbVBDODm (ORCPT ); Fri, 4 Feb 2005 09:03:42 -0500 Subject: Re: [dm-crypt] Re: dm-crypt crypt_status reports key? From: Christophe Saout To: dm-crypt@saout.de Cc: linux-kernel , Clemens Fruhwirth , Alasdair G Kergon In-Reply-To: <20050203040542.GQ2493@waste.org> References: <20050202211916.GJ2493@waste.org> <1107394381.10497.16.camel@server.cs.pocnet.net> <20050203015236.GO2493@waste.org> <1107398069.11826.16.camel@server.cs.pocnet.net> <20050203040542.GQ2493@waste.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-AlzowkfodPzYa4vo1yUX" Date: Fri, 04 Feb 2005 15:03:17 +0100 Message-Id: <1107525797.12265.66.camel@leto.cs.pocnet.net> Mime-Version: 1.0 X-Mailer: Evolution 2.0.3 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 30814 Lines: 440 --=-AlzowkfodPzYa4vo1yUX Content-Type: multipart/mixed; boundary="=-4UgPdHF7cmHnpgI/ICyR" --=-4UgPdHF7cmHnpgI/ICyR Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Am Mittwoch, den 02.02.2005, 20:05 -0800 schrieb Matt Mackall: > Dunno here, seems that having one tool that gave the kernel a key named > "foo" and then telling dm-crypt to use key "foo" is probably not a bad > way to go. Then we don't have stuff like "echo | dmsetup create" > and the like and the key-handling smarts can all be put in one > separate place. >=20 > Getting from here to there might be interesting though. Perhaps we can > teach dm-crypt to understand keys of the form "keyname:"? in > addition to raw keys to keep compatibility. Might even be possible to > push this down into crypt_decode_key() (or a smarter variant of same). I've hacked together a working implementation. It's just a prototype though. The patch requires that the key retention service is activated unconditionally. It would probably be better to introduce #ifdefs and the possibility turn of the cleartext key way in the kernel configuration. I've separated out the crypto configuration from the device-mapper configuration. Several device mappings can now share/reference the same key. This might be useful if you want to span your mapping over several devices (without stacking device mappings on top of each other). So basically the crypto and the device-mapper part of the configuration are in its own "classes" now. It makes even more sense now to rename IV operations to crypto/key operations (which only work on the new structure) like it's done in the LRW patch. This crypto configuration that I separated out can be referenced by the device-mapper target directly (old way) or indirectly by the new key retention service. It holds the cipher, chaining mode and IV mechanisms as well as the key itself. A dm table configuration line then looks like "0 1000000 crypt key my_key_name 0 /dev/bla 0". And dm-crypt.c is slowly getting large. Thirty functions already. Hmm. --=-4UgPdHF7cmHnpgI/ICyR Content-Description: Content-Disposition: inline; filename=dm-crypt-key-retention-v1.diff Content-Type: text/x-patch; charset=UTF-8 Content-Transfer-Encoding: base64 LS0tIGxpbnV4LTIuNi4xMS1yYzMub3JpZy9kcml2ZXJzL21kL2RtLWNyeXB0LmMJMjAwNS0wMi0w NCAwMTowMDo1MS45ODM5MTA3NTIgKzAxMDANCisrKyBsaW51eC0yLjYuMTEtcmMzL2RyaXZlcnMv bWQvZG0tY3J5cHQuYwkyMDA1LTAyLTA0IDE0OjMwOjQ3LjYyOTExNzg1NiArMDEwMA0KQEAgLTEz LDYgKzEzLDcgQEANCiAjaW5jbHVkZSA8bGludXgvbWVtcG9vbC5oPg0KICNpbmNsdWRlIDxsaW51 eC9zbGFiLmg+DQogI2luY2x1ZGUgPGxpbnV4L2NyeXB0by5oPg0KKyNpbmNsdWRlIDxsaW51eC9r ZXkuaD4NCiAjaW5jbHVkZSA8bGludXgvd29ya3F1ZXVlLmg+DQogI2luY2x1ZGUgPGFzbS9hdG9t aWMuaD4NCiAjaW5jbHVkZSA8YXNtL3NjYXR0ZXJsaXN0Lmg+DQpAQCAtNDgsMTQgKzQ5LDI1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kdHIoY2MtPmNyeXB0byk7DQorDQogCWRtX3B1dF9kZXZpY2UodGksIGNjLT5kZXYp Ow0KIAlrZnJlZShjYyk7DQogfQ0KQEAgLTg2NSwxMyArOTQ1LDUxIEBADQogCXJldHVybiAtRU5P TUVNOw0KIH0NCiANCitzdGF0aWMgdW5zaWduZWQgaW50IGNyeXB0X2tleV9zdGF0dXMoc3RydWN0 IGNyeXB0X2tleSAqY2ssIGNoYXIgKnJlc3VsdCwNCisgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgdW5zaWduZWQgaW50IG1heGxlbikNCit7DQorCWNvbnN0IGNoYXIgKmNpcGhl cjsNCisJY29uc3QgY2hhciAqY2hhaW5tb2RlID0gTlVMTDsNCisJdW5zaWduZWQgaW50IHN6ID0g MDsNCisNCisJY2lwaGVyID0gY3J5cHRvX3RmbV9hbGdfbmFtZShjay0+dGZtKTsNCisNCisJc3dp dGNoKGNrLT50Zm0tPmNydF9jaXBoZXIuY2l0X21vZGUpIHsNCisJY2FzZSBDUllQVE9fVEZNX01P REVfQ0JDOg0KKwkJY2hhaW5tb2RlID0gImNiYyI7DQorCQlicmVhazsNCisJY2FzZSBDUllQVE9f VEZNX01PREVfRUNCOg0KKwkJY2hhaW5tb2RlID0gImVjYiI7DQorCQlicmVhazsNCisJZGVmYXVs dDoNCisJCUJVRygpOw0KKwl9DQorDQorCWlmIChjay0+aXZfbW9kZSkNCisJCURNRU1JVCgiJXMt JXMtJXMgIiwgY2lwaGVyLCBjaGFpbm1vZGUsIGNrLT5pdl9tb2RlKTsNCisJZWxzZQ0KKwkJRE1F TUlUKCIlcy0lcyAiLCBjaXBoZXIsIGNoYWlubW9kZSk7DQorDQorCWlmIChjay0+a2V5X3NpemUg PiAwKSB7DQorCQlpZiAoKG1heGxlbiAtIHN6KSA8ICgoY2stPmtleV9zaXplIDw8IDEpICsgMSkp DQorCQkJcmV0dXJuIC1FTk9NRU07DQorDQorCQljcnlwdF9lbmNvZGVfa2V5KHJ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mY3J5cHRfdGFyZ2V0KTsNCiAJaWYgKHIgPCAwKQ0KIAkJRE1FUlIoUEZYICJ1bnJlZ2lzdGVy IGZhaWxlZCAlZCIsIHIpOw0KIA0K --=-4UgPdHF7cmHnpgI/ICyR-- --=-AlzowkfodPzYa4vo1yUX Content-Type: application/pgp-signature; name=signature.asc Content-Description: Dies ist ein digital signierter Nachrichtenteil -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQBCA4ClZCYBcts5dM0RAnzbAKCrP6ttLsWCfSOy2scdabU7e6RJiQCePgpJ tGRYkbFjQHvV5PEq7DSAouQ= =3UdW -----END PGP SIGNATURE----- --=-AlzowkfodPzYa4vo1yUX-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/