From mboxrd@z Thu Jan 1 00:00:00 1970 From: arvid.brodin@enea.com (Arvid Brodin) Date: Sat, 28 May 2011 00:03:10 +0200 Subject: How to use the cryptographic API (e.g. md5 checksum)? In-Reply-To: References: <4DDAE326.9030605@enea.com> Message-ID: <4DE01F9E.1070200@enea.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Peter Teoh wrote: > On Tue, May 24, 2011 at 6:43 AM, Arvid Brodin wrote: >> Hi, >> >> I want to perform an md5 checksum on a process' text segment (I create a file >> /proc//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 > > http://www.redhat.com/archives/dm-devel/2005-August/msg00058.html Thanks, that explains the CRYPTO_TFM_REQ_MAY_SLEEP flag! >> 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. > > http://www.linuxjournal.com/article/6451?page=0,0 This link is one I've found before, and it really does not explain anything about the usage of crypto_hash_{digest,init,update,final}() as far as I can see. So I'm still looking for help on this! Thanks, Arvid Brodin Enea Services Stockholm AB