Return-Path: Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Wed, 19 Feb 2020 20:30:53 +0100 (CET) Received: by mail-wm1-x344.google.com with SMTP id p17so1955275wma.1 for ; Wed, 19 Feb 2020 11:30:53 -0800 (PST) References: From: Milan Broz Message-ID: <7fc85398-a14e-bba1-c996-5d398fef8e7d@gmail.com> Date: Wed, 19 Feb 2020 20:30:51 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dm-crypt] Bug in cryptsetup 2.3.0 (BitLocker key-file support) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Quentin Lefebvre , dm-crypt@saout.de Hi, On 19/02/2020 17:05, Quentin Lefebvre wrote: > Dear cryptsetup maintainer, > > I discovered a functional bug in the recently added BitLocker support > (thanks by the way!) > Not sure whether it is the place to report it... The best is to report issue here https://gitlab.com/cryptsetup/cryptsetup/issues but this list works as well. > > Summary: > cryptsetup 2.3.0 cannot open a bitlk device when I provide a file > containing its password (fails with error -2). > > Command failing: > > cryptsetup open --type bitlk --key-file > /dev/ bitlocker_mapping > > It is very easy to reproduce, so I don't copy paste the --debug output. The debug output provides information of all subsystem versions, this could be important. This is why I require it on all reports. > > I digged in the source code and found the problem in > src/cryptsetup.c:543-545, where opt_keyfile_size is used when calling > tools_get_key(). And default is 0, so the full keyfile is read (limited by maximal keyfile size). So it should work... > The workaround is actually to provide the exact password size on the > command line, e.g.: > > cryptsetup open --type bitlk --keyfile-size 55 --key-file > /dev/ bitlocker_mapping Hm, so what is the on-disk keyfile size here? In cryptsetup, the whole keyfile is read, unless you limit it (as in your workaround). So what is the exact content of your keyfile? Is there additional EOL, or it had some more characters there? Milan