Return-Path: Received: from mx3.freesources.org (mx3.freesources.org [195.34.172.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Tue, 28 Jan 2020 16:05:27 +0100 (CET) Received: from anon-39-119.vpn.ipredator.se ([46.246.39.119]) by mx3.freesources.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1iwSDH-0004yt-Kp for dm-crypt@saout.de; Tue, 28 Jan 2020 14:51:35 +0000 From: Jonas Meurer Message-ID: <9c428b57-b3e7-38e1-d963-4596e46f69ea@freesources.org> Date: Tue, 28 Jan 2020 15:51:25 +0100 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cwJkjKytL50PzQeVTeIiFIb0GoIoY0Shu" Subject: [dm-crypt] how to get keyslog PBKDF settings via libcryptsetup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dm-crypt This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cwJkjKytL50PzQeVTeIiFIb0GoIoY0Shu Content-Type: multipart/mixed; boundary="N01s0JzxzuFXImAd8G2c9GWP4g895xvIL"; protected-headers="v1" From: Jonas Meurer To: dm-crypt Message-ID: <9c428b57-b3e7-38e1-d963-4596e46f69ea@freesources.org> Subject: how to get keyslog PBKDF settings via libcryptsetup --N01s0JzxzuFXImAd8G2c9GWP4g895xvIL Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable Hello dm-crypt folks, I want to retrieve pbkdf params for active keyslots of LUKS devices. First I looked into `crypt_keyslot_get_pbkdf()`, but contrary to what the code suggests[1], it doesn't return values for LUKS1 devices. Also, looking at the actual return valudes, it seems to return the calculated values for a new keyslot, not the ones for the active keyslot, right? Is there another way to retrieve the values that `cryptsetup luksDump` shows? I'm particularely interested in the `iterations` values for LUKS1 and `memory` values for LUKS2 devices. Here's my (non-working code): struct crypt_device *cd =3D NULL; if (crypt_init_by_name(&cd, devices[i])) { errx(EXIT_FAILURE, "couldn't init LUKS device %s", devices[i]); } else { int ks_max =3D crypt_keyslot_max(crypt_get_type(cd)); for (int j =3D 0; j < ks_max; j++) { crypt_keyslot_info ki =3D crypt_keyslot_status(cd, j); if (ki =3D=3D CRYPT_SLOT_ACTIVE || ki =3D=3D CRYPT_SLOT_ACTIVE_LA= ST) { // Keyslot is active struct crypt_pbkdf_type pbkdf_ki; if (crypt_keyslot_get_pbkdf(cd, ki, &pbkdf_ki)) { printf(" max_memory_kb: %d\n", pbkdf_ki.max_memory_kb); } else { warn("No PBKDF for ks %d (device %s)", j, devices[i]); } } } } crypt_free(cd); When giving a LUKS2 device, I get (somewhat strange) results: max_memory_kb: 1824273616 When giving a LUKS1 device, crypt_keyslot_get_pbkdf isn't successful: cryptsetup-suspend: No PBKDF for ks 0 (device cont3_crypt): Success Cheers jonas [1] https://gitlab.com/cryptsetup/cryptsetup/blob/4448ddc/lib/setup.c#L5175-5= 178 --N01s0JzxzuFXImAd8G2c9GWP4g895xvIL-- --cwJkjKytL50PzQeVTeIiFIb0GoIoY0Shu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEELIzSg9Pv30M4kOeDUmLn/0kQSf4FAl4wSm4ACgkQUmLn/0kQ Sf40rw/9Ge2b77X7GpcL5OcMVNWy9qDU1cbkbCgQZFIdIVLJk5YsXGrMC8Vr2SVP BRU+8YAgTk1rI1gCmFCR25VoyZrnwwwfoXEXqFrD4zfvXFNvpkOdwt+QC9QtCLbg lezWDAXY+7mvPhvkHI/ahaBufhU5saP1lwx0CzWNMZkrxAPMK8GK8yAV2G+1dK3f VQcnHVL7+vk8tKd/d22BjK9UpDIkPgCVhKeRk4H79lYl5KxnrIkEVjp24KmzkPA2 lpIJe98q/VJ5Lk0Gh4NceggFkjsSKTU8/vHD7xvXywWc4RpvZEXffL1l5OFuokWi MyXilGjLPhYSH1LdXTU4xVyMmiNivn8/zAgf+pGD4IJoVmr/SOIbIPB/fhFydBE+ SkG29xBM9qy7C44YE2iezMe6DcunAIk6E8NAGUP46jxC9ofRohRqs2GLW9LFRYqv H4i6VWl8gnr9TXymwSbigZoO9n4KgVCHY75GbDdpAYuKRVkq95g+/asVa2Bcu3uy Fes+iedeB4lhyoC6TyTPIw/upXoBMlm47p6Vhx38fQOohM3llixFEdwZc5pnB3yn /9oijEufEpgmwNRTfCHjjJ/KrWTMFnwf8ZHwSZ4Bq2PXTRLiIkMKPlJbAybTU/35 HD5j8M2c0Dv93Z9UGmwY3aUOiMMUKiIlxnvT4qMgY+1yFuVKYcI= =ljvj -----END PGP SIGNATURE----- --cwJkjKytL50PzQeVTeIiFIb0GoIoY0Shu--