Reputation: 470
I have been trying to use the crypto api in the linux kernel, what i need to do is sha a file that is being opened. I am using the LSM to catch those file opens.
What I have so far is creating a struct crypto_shash using
struct crypto_shash *tfm;
struct shash_desc desc;
tfm = crypto_alloc_shash("sha1", 0, CRYPTO_ALG_ASYNC);
and i assume i am supposed to init it after that using
desc.tfm = tfm;
desc.flags = 0;
err = crypto_shash_init(&desc);
that all works fine, but then i want to use
crypto_shash_digest(&desc, ??, ??, sha_hash);
and i realize that it expects a scatterlist as its second argument and the length of that scatter list as the third argument. What i cant figure out is how I am supposed to load the file into a scatterlist in order to give it to the crypto system.
I have done quite a bit of reading but have thus far been unable to find any details about getting a files contents loaded into a scatterlist. So any pointers in the right direction would be appreciated.
Thanks
Upvotes: 2
Views: 1969
Reputation: 3055
I have done something similar some time ago. The only difference is that I calculated a hash of ELF sections.
Upvotes: 2