Re: [xml] Using the encoders

Date view Thread view Subject view Author view

From: Lutz Behnke (behnke@trustcenter.de)
Date: Wed Feb 09 2000 - 12:16:52 EST


Daniel Veillard wrote:
>
> Hi Lutz,
>
> On Wed, Feb 09, 2000 at 03:34:57PM +0100, Lutz Behnke wrote:
> > Hi there,
> >
> > I am currently trying to write a DOMHASH signing and verification implementation
> > for libxml. Now I have some questions:
>
> Good ! BTW doesn't this requires having an implementation of canonical XML ?
> c.f. http://www.w3.org/TR/xml-c14n which is in Last Call at the moment.
> If yes working on this part could be done now ... c.f. the following.

I am not quite sure with regards to the actual TEXT contents. But for
the layout of the individual elements, DOMHASH does not care as it digests the
DOM structure rather than the surface string of the XML document.

This may not be the actual standard anymore, but I have the requirement for a
given project to generate signatures based on the paper by Hiroshi Maruyama et.al.

As for the TEXT elements I have to investigate that when I get there. Possibly sync
the project requirements as well.

>
> > b) if not, how can I use the encoding functions from libxml. I need to get the
> > names and contents of the elements in UTF-16BE. I currently would understand the code
> > to be something like (for the name of the element):
> >
> > xmlCharEncodingHandler utf16_handler = xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF16BE);
> >
> > utf16_handler->xmlCharEncodingOutputFunc(node->name, strlen(node->name),
> > (utf16_name, some_guessed_value);
>
> yes, that what it is designed for. But this is not thoroughtly tested
> (euthemism !!) and subject to changes.
<wild-eyes>change? what change</wild-eyes> Change to the implementation or the
'API' itself?

>
> > c) How can I compute the neccesary lenght of the output buffer. Wouldn't be a good thing
> > for the function to return the _needed_ bytes if I call it with a output buffer of NULL.
>
> I think the best (CPU wise) is to also return the number of bytes read
> from the buffer, if different from the value given, this may mean:
> - that a larger output buffer is needed
> - that the input didn't end-up on a character boundary

having read the message you mentioned I would also support putting the length of the
used/needed bytes into the output buffer len, supplying that parameter as a reference.
(as this is widely used in the PKCS area where I live most of the days)

thus:
  int (*xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
                                   unsigned char *in, int inlen);

if the function is called with out == NULL it returns true, and *outlen is set with the
required size of the buffer. If the buffer was of sufficient size, *outlen is set with
the used number of bytes. That leaves the return value for more fine grained and possibly
more unified error checking (e.g. all functions in libxml return values from a global set
of error codes)

It is not nessecarily the fastest solution, but allows for easy checking and querying
of the buffer lengths without changing the out

mfg lutz

-- 
Lutz Behnke, TC TrustCenter GmbH
Sonninstrasse 24-28, D-20097 Hamburg, Germany
Tel:040/80 80 26-0  Fax:040/80 80 26-1 26   http://www.trustcenter.de
-----BEGIN GEEK CODE BLOCK-----
 Version: 3.1  
GCS/IT d- s+:+ a C++ ULS+++$ P+++ L+++ E+++ W++ !N o? k? !w@++ !O
!M !V PS+ PE Y+ PGP t+ 5+ X R+ tv+ b+++ DI+++ D G++ e++ h* r y+  
------END GEEK CODE BLOCK------

----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:01 EDT