From: Milan Broz <mbroz@redhat.com>
To: Vinodh Sundararajan <vsundara@sta.samsung.com>
Cc: dm-crypt@saout.de
Subject: Re: [dm-crypt] Question on cryptsetup options
Date: Tue, 16 Nov 2010 12:12:26 +0100 [thread overview]
Message-ID: <4CE2671A.5050407@redhat.com> (raw)
In-Reply-To: <4A2DFEA767C0CB4396FF2CE75559A48805A4BD2B@mx2.telecom.sna.samsung.com>
On 11/16/2010 10:09 AM, Vinodh Sundararajan wrote:
> I am trying to use cryptsetup as part of my porgram encrypt a block
> devicewith a randomly generated master key that I intend to encrypt
> (with user password) and store on the device. I see that I could use
> the cryptsetup option '-d' to provide the key using a file on device
> but I don't want to store the unencrypted key file on device. Is
> there an option to "stream" the key file contents as input to
> cryptsetup?
You are talking about master key in luksFormat or about passphrase/keyfile
for keyslot?
Passphrase can be send through standad input but note this difference:
If passphrase is sent though standard input, it reads until newline is reached,
so here "xxx" without trailing newline is passphrase.
echo -e "xxx\n" | cryptsetup luksFormat /dev/sde
If you specify "-" as keyfile, no newline is stripped
echo -e "xxx\n" | cryptsetup luksFormat /dev/sde -
(see man page)
So if you want stream it, use something like this:
cat uuu | cryptsetup luksFormat /dev/sde -
cat uuu | cryptsetup luksOpen /dev/sde cdev -d -
(in recent version you can use -d for luksFormat too)
If you need stream master key, it is not possible, only output from file
is available (--master-key-file).
(In this case you can use libcryptsetup, it is easy to write such program.)
> BTW, I cannot use the -y option either
- y is passphrase verify if you stream through stdin, this is always switched off.
> - I am not running these from the console but through my program. Any suggestions?
Use libcryptsetup (from 1.1.x) then, much more easy than wrapping binary and
it allows all this magic (you simple provide buffer with passphrase in API call).
Milan
prev parent reply other threads:[~2010-11-16 11:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 9:09 [dm-crypt] Question on cryptsetup options Vinodh Sundararajan
2010-11-16 11:12 ` Milan Broz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CE2671A.5050407@redhat.com \
--to=mbroz@redhat.com \
--cc=dm-crypt@saout.de \
--cc=vsundara@sta.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox