Re: [xml] Question about memory constraints when using SAX parser

Yes, I know about Aleksey's library. My library (libdigidoc) does
approximately the same but is more concerned with XAdES (ETSI TS 901103)
standard. XAdES is an add-on standard to XML-DSIG and defines additional
signature atributes. XAdES is supposed to be the European standard. 
I'm not quite
sure, but last time I looked I got the impression that Alesey's 
library handled only pure XML-DSIG. Also I think Aleksey's library uses
DOM parser. I use SAX (and I've had quite a headache because of this...)
but there are some customers who want to sign, verify, encrypt and
decrypt huge documents. For example some use this library to encrypt
database backups. I tested that it can encrypt an 800 MB file in
something like 2 minutes (P4, 2,4 GHz, 512 MB RAM). So there are uses
for both librarys. This one can be downloaded from There you'll find
the library, a GTK-- userinterface (gdigidoc) and some smartcard
infrastructure modules (developed by other folks but packaged by me
because my program needs them). Ohh, yes the use of smartcards and
PKCS#11 is another case for my library. Offcourse Aleksey's library is
a fine pice of software. I've often looked at it to find out how he
does it and compare the results.


Ãhel kenal pÃeval (esmaspÃev, 22. november 2004, 12:50+0100), kirjutas
Stefan Kost:
Isn't there already Aleksey Sanins xmlsec lib at:


Veiko Sinivee wrote:

I'm writing a digital signature and xml encryption library. I want
to support encryption & decryption of very large files too. Well
encryption goes fine because I read, encrypt, base64 encode and write
data to the file in blocks of 8 KB or so. For decryption I choose to use
the SAX interface because it's probably the fastest and requires the 
least amount of memory. Now I found, that xmlCharaters() callback
function is still called with a lot of data. Earlier versions of libxml2
used to return data in blocks of x KB. Now If I have something like:

700 MB of base64 encoded data here

then the parser attempts to collect all of that data and return it
in one event to my callback function. This obviously doesn't work.
How can I switch it out and tell the parser to return at most x KB
in any event ?


Veiko Sinivee

xml mailing list, project page
xml gnome org

xml mailing list, project page
xml gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]