1 Content-type: text/html
3 <HTML><HEAD><TITLE>Manpage of IPSEC_TTODATA</TITLE>
6 Section: C Library Functions (3)<BR>Updated: 15 Feb 2001<BR><A HREF="#index">Index</A>
7 <A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
10 <A NAME="lbAB"> </A>
13 ipsec ttodata, datatot - convert binary data bytes from and to text formats
14 <A NAME="lbAC"> </A>
17 <B>#include <<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>></B>
20 <B>const char *ttodata(const char *src, size_t srclen,</B>
24 <B>int base, char *dst, size_t dstlen, size_t *lenp);</B>
28 <B>size_t datatot(const char *src, size_t srclen,</B>
32 <B>int format, char *dst, size_t dstlen);</B>
34 <A NAME="lbAD"> </A>
42 convert arbitrary binary data (e.g. encryption or authentication keys)
43 from and to more-or-less human-readable text formats.
46 Currently supported formats are hexadecimal, base64, and characters.
49 A hexadecimal text value begins with a
55 prefix and continues with two-digit groups
56 of hexadecimal digits (0-9, and a-f or A-F),
57 each group encoding the value of one binary byte, high-order digit first.
62 between consecutive groups is ignored, permitting punctuation to improve
63 readability; doing this every eight digits seems about right.
66 A base64 text value begins with a
73 and continues with four-digit groups of base64 digits (A-Z, a-z, 0-9, +, and /),
74 each group encoding the value of three binary bytes as described in
75 section 6.8 of RFC 2045.
76 Note that the last one or two digits of a base64 group can be
79 to indicate that fewer than three binary bytes are encoded.
82 A character text value begins with a
89 and continues with text characters, each being the value of one binary byte.
92 All these functions basically copy data from
95 (whose size is specified by
101 (whose size is specified by
104 doing the conversion en route.
105 If the result will not fit in
109 under no circumstances are more than
112 bytes of result written to
117 can be zero, in which case
120 need not be valid and no result bytes are written at all.
129 specifies what format the input is in;
130 normally it should be
133 to signify that this gets figured out from the prefix.
142 respectively signify hexadecimal, base64, and character-text formats
152 a single character used as a type code,
153 specifies which text format is wanted.
160 but a zero value) specifies a reasonable default.
161 Other currently-supported values are:
167 continuous lower-case hexadecimal with a
174 lower-case hexadecimal with a
184 lower-case hexadecimal with no prefix or
190 continuous base64 with a
197 continuous base64 with no prefix
203 The default format is currently
210 returns NULL for success and
211 a pointer to a string-literal error message for failure;
220 is set to the number of bytes required to contain the full untruncated result.
221 It is the caller's responsibility to check this against
224 to determine whether he has obtained a complete result.
228 value is correct even if
231 is zero, which offers a way to determine how much space would be needed
232 before having to allocate any.
235 The normal return value of
238 is the number of bytes required
239 to contain the full untruncated result.
240 It is the caller's responsibility to check this against
243 to determine whether he has obtained a complete result.
244 The return value is correct even if
247 is zero, which offers a way to determine how much space would be needed
248 before having to allocate any.
252 signals a fatal error of some kind
274 must not include the terminating NUL.
281 the result supplied by
284 is always NUL-terminated,
285 and its needed-size return value includes space for the terminating NUL.
288 Several obsolete variants of these functions
298 are temporarily also supported.
299 <A NAME="lbAE"> </A>
302 <A HREF="sprintf.3.html">sprintf</A>(3), <A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A>(3)
303 <A NAME="lbAF"> </A>
310 unknown characters in the input;
311 unknown or missing prefix;
313 incomplete digit group;
314 non-zero padding in a base64 less-than-three-bytes digit group;
324 <A NAME="lbAG"> </A>
327 Written for the FreeS/WAN project by Henry Spencer.
328 <A NAME="lbAH"> </A>
333 should have a format code to produce character-text output.
342 prefixes are the author's inventions and are not a standard
344 They have been chosen to avoid collisions with existing practice
345 (some C implementations use
349 and possible confusion with unprefixed hexadecimal.
355 error reports to literal strings
356 (so that callers don't need to worry about freeing them or copying them)
357 does limit the precision of error reporting.
361 <A NAME="index"> </A><H2>Index</H2>
363 <DT><A HREF="#lbAB">NAME</A><DD>
364 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
365 <DT><A HREF="#lbAD">DESCRIPTION</A><DD>
366 <DT><A HREF="#lbAE">SEE ALSO</A><DD>
367 <DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
368 <DT><A HREF="#lbAG">HISTORY</A><DD>
369 <DT><A HREF="#lbAH">BUGS</A><DD>
372 This document was created by
373 <A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
374 using the manual pages.<BR>
375 Time: 05:09:34 GMT, June 19, 2001