Results 1 to 1 of 1
Hi,
I am new in using Linux kernel apis for cryptographic purposes. Recently, I have an urgent requirement of calculating MD5 of a message (which is not available as its ...
- 03-06-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
MD5 chksum computation in linux kernel version 2.6.31 and above
Hi,
I am new in using Linux kernel apis for cryptographic purposes. Recently, I have an urgent requirement of calculating MD5 of a message (which is not available as its entirely and will come in chunks). I have used the following APIs, but without success.
But, the messages are made available to me in synchronous way. I am providing the code snippet from my own kernel module.
================================================== ========
char md5ChkSum[16];
char buffer1[2];
char buffer2[3];
struct crypto_shash *md5_shash = crypto_alloc_shash("md5", 0, 0);
if (md5_shash == NULL) {
printk("Error: crypto_alloc_shash failed for MD5\n");
}
else {
struct crypto_tfm *tfm = crypto_shash_tfm(Head->md5_shash);
struct shash_desc *md5_desc = crypto_tfm_ctx(tfm);
if (md5_desc == NULL) {
printk("Error: Failed to initialize md5_desc structure for kernel 2.6.31 and above\n");
}
}
crypto_shash_init(md5_desc);
strcpy(buffer1, "a");
strcpy(buffer2, "bc");
crypto_shash_update(md5_desc, buffer1, 1);
crypto_shash_update(md5_desc, buffer2, 2);
crypto_shash_final (md5_desc, md5ChkSum);
================================================== ========
This is what I have done. And at the end I want the MD5 checksum of the message "abc" into the array md5ChkSum. But, my program is crashing in crypto_shash_init. What kernel module I need to insmod in order to be able to make this work. Am I correct in my understanding of this way of computing md5 checksum.
I am successful though in doing the same for linux version 2.6.7.
Can anybody please provide some way out of how to make this done as well in linux kernel version 2.6.31 and above.


Reply With Quote