Andy Polyakov wrote:
> 
> > > >> I am using a partly modified PKCS7 enc.c and dec.c for
> > > >> encrypting and decrypting documents.
> > > >> When encrypting an 8,5MB file it takes about 1 minute,
> > > >> however when decrypting it the time runs up to 20  minutes.
> > > >Which platform? Which compiler? What does './config -t' say?
> > > './config -t' says:
> > >   Operating system: sun4u-sun-solaris2
> > >   gcc version egcs-2.90.x
> > >   Configuring for solaris-usparc-oldgcc
> > I managed to reproduce it on 0.9.3[a] as this's what you must have. This
> > -oldgcc thing was fixed and usparc was changed to sparcv9 in 0.9.4. I
> > experience much bigger differences in execution times. I managed to
> > ./crypto/pkc7/enc 12MB file in 8 seconds, while dec took over 8 minutes.
> Well, what can I say? Here is the scenario:
> 
> - dec sucks the whole file into the memory!
> - then it copies 4K to another buffer and *moves* the rest of the file
> buffer allocated in the first step to the beginning of the buffer, i.e.
> where those 4K just were;
> - it then deciphers the 4K and writes clear text to the output;
> - last two steps are executed in loop till data in the buffer is
> exhausted;
> 
> What's the catch? Say file buffer is XMB. At first iteration it'll copy
> XMB-4K or data, at second - XMB-8K, third - XMB-12K, and so on resulting
> in what? 128*X*XMB moved around? So program spends ~96% (I profiled with
> 6MB large data file) doing nothing but exercising interface between CPU
> and primary memory and ~3% - performing DES. Beautiful, huh?
> 
> Conclusion. crypto/pkc7/dec.c is probably not the way to do it. If they
> insist it is, then crypto/bio/bss_mem.c:mem_read() is not the way to do
> it.
> 
> > Did you try it with 0.9.4?
> 0.9.4 exhibits same behavior so don't bother...
> 
> Cheers. I.e. if you find anything cheerful about this:-) Andy.
> 
> P.S. All this bio code is dark forest for me. At least for this very
> moment. If it needs to be fixed, I'm not the first in the queue.

Hmmm I'll have a look into it, time permitting. I didn't do too many
checks on the S/MIME code, I just fixed it!

It shouldn't be doing that and I recall horrible overuse of memory
allocation. This is partly the way it did things and partly the way
memory BIOs (don't) work.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to