-
Using Scatterlist
Hello,
I am trying to implement some encryption in the kernel space. I need to use crypto api, which requires the use of scatterlist. I need to simple encrypt a string of characters and the store the encrypted string. I think I have most of my code right, but I seem to have a problem when extracting the string back from the scatterlist. Lets say I do the following:
Code:
char p[4] = "abc";
char *t;
dst.page = virt_to_page(p);
dst.offset = offset_in_page(p);
dst.length = 3;
t = kmap (dst.page + dst.offset);
*(t+3) = '\0';
printk("%s\n",t);
I am expecting my code to print "abc" but it doesn't. It prints some junk. How can I get a pointer to my string back once I put it into the scatterlist?
Thank you for any suggestions you might have.
-George
-
As far as I can tell, kmap() returns a page-address, which means an address with the low 12 bits set to zero. So you would need to calculate the offset-within-page to to the new virtual address.
--
Mats
-
Thanks, I think I managed to figure it out. I think skatterlist only acts as a pointer, it doesn't store any data, and I thought it would store it. All should be sorted out.