Re: [Ocf-linux-users] question about a custom HW crypto driver
Brought to you by:
david-m
From: David M. <Dav...@se...> - 2009-08-05 14:06:41
|
Jivin Amir Tsvitov lays it down ... > Hello, > > I finished writing a Linux device driver for a custom crypto accelerator > and after testing it am now in the process of adapting it to work with > OCF Linux. > > I would greatly appreciate some pointers on some problems I encountered. > > 1. The driver uses DMA to fetch the input and then write the output > after the crypto operation has completed. In my test version I put the call > to sleep on a wait queue which then gets woken up by the DMA done ISR. > I tried a similar approach with my OCF version but get scheduling panic > messages from the kernel. What is the proper way to suspend the call > until the DMA transfer has completed? You don't :-) Both the safei, hifn7751 and talitos drivers use DMA in much the same way. They are reasonable drivers to use as an example. Here is the basic idea for your driver: mydriver_process(..) ... set up DMA fetch to send data to HW signal chip to do it ... return OK mydriver_interrupt() ... request is complete do callback with status You don't need to wait anywhere as OCF is asynchronous, you just have your interrupt routine call back one the crypto processing is complete. Now a real drover will be much more complex and involved, but if you look at the other drivers you should be able to get the idea, > 2. As a temporary hack until I figure out #1 I am currently polling > to see when the operation has completed. Using openssl (with an OCF patch) > I ran the following commands: > > openssl aes-128-cbc -a -salt -in test.txt -out test.txt.enc -pass pass:amir123 > > openssl aes-128-cbc -d -a -in test.txt.enc -out test.txt.dec -k amir123 > > where test.txt is: > > This is a test 123456789 line 1 > > This is a test 123456789 line 2 > > This is a test 123456789 line 3 > > …. > > This is a test 123456789 line 18 > > This is a test 123456789 line 19 > > This is a test 123456789 line 20 > > > > I get the following error: > > bad decrypt > > 1023:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:evp_enc.c:461: > > > > And the contents of the resulting test.txt.dec are: > > &£f64˜ uyVֳue23456789 line 1 > > This is a test 123456789 line 2 > > This is a test 123456789 line 3 > > ... > > This is a test 123456789 line 18 > > This is a test 123456789 line 19 > > This is a test 123456 > > > > So for some reason I am getting garbage in the beginning of the > decrypted message and missing other data at the end of it? Hard to say really, use cryptotest to debug, it is much easier to follow than the SSL code, Cheers, Davidm -- David McCullough, dav...@se..., Ph:+61 734352815 McAfee - SnapGear http://www.snapgear.com http://www.uCdot.org |