kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: arvid.brodin@enea.com (Arvid Brodin)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to use the cryptographic API (e.g. md5 checksum)?
Date: Tue, 24 May 2011 00:43:50 +0200	[thread overview]
Message-ID: <4DDAE326.9030605@enea.com> (raw)

Hi,

I want to perform an md5 checksum on a process' text segment (I create a file
/proc/<pid>/text_checksum that, when read, should give the md5sum).

The crypto api documentation (Documentation/crypto/api-intro.txt) seems to be
quite lacking. The only example is:

	tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
	if (IS_ERR(tfm))
		fail();
                
        /* ... set up the scatterlists ... */

	desc.tfm = tfm;
	desc.flags = 0;
        
	if (crypto_hash_digest(&desc, sg, 2, result))
		fail();
        
	crypto_free_hash(tfm);

Looking at some existing code, I see usage of crypto_hash_init(),
crypto_hash_final(), desc.flag set to CRYPTO_TFM_REQ_MAY_SLEEP,
... (e.g. in fs/ecryptfs/crypto.c). Does anybody know what they do? Do I need
to, or should I, use them? The functions are are declared in include/linux/crypto.h
as some kind of wrapper functions, but lack documentation. Also, Google has not
been my friend here.

Thanks,
Arvid Brodin
Enea Services Stockholm AB

             reply	other threads:[~2011-05-23 22:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 22:43 Arvid Brodin [this message]
     [not found] ` <BANLkTikOxAvGQFiXxGXsDQvpHefO1EtVMA@mail.gmail.com>
2011-05-27 22:03   ` How to use the cryptographic API (e.g. md5 checksum)? Arvid Brodin
2011-05-28  2:22     ` Peter Teoh
2011-05-28  2:42       ` Peter Teoh

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=4DDAE326.9030605@enea.com \
    --to=arvid.brodin@enea.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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;
as well as URLs for NNTP newsgroup(s).