1 Content-type: text/html
3 <HTML><HEAD><TITLE>Manpage of IPSEC_TTODATA
</TITLE>
6 Section: C Library Functions (
3)
<BR>Updated:
16 August
2003<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>const char *ttodatav(const char *src, size_t srclen,
</B>
32 <B>int base, char *dst, size_t dstlen, size_t *lenp,
</B>
36 <B>char *errp, size_t errlen, int flags);
</B>
40 <B>size_t datatot(const char *src, size_t srclen,
</B>
44 <B>int format, char *dst, size_t dstlen);
</B>
46 <A NAME=
"lbAD"> </A>
56 convert arbitrary binary data (e.g. encryption or authentication keys)
57 from and to more-or-less human-readable text formats.
60 Currently supported formats are hexadecimal, base64, and characters.
63 A hexadecimal text value begins with a
69 prefix and continues with two-digit groups
70 of hexadecimal digits (
0-
9, and a-f or A-F),
71 each group encoding the value of one binary byte, high-order digit first.
76 between consecutive groups is ignored, permitting punctuation to improve
77 readability; doing this every eight digits seems about right.
80 A base64 text value begins with a
87 and continues with four-digit groups of base64 digits (A-Z, a-z,
0-
9, +, and /),
88 each group encoding the value of three binary bytes as described in
89 section
6.8 of RFC
2045.
94 <B>TTODATAV_IGNORESPACE
</B>
96 bit on, blanks are ignore (after the prefix).
97 Note that the last one or two digits of a base64 group can be
100 to indicate that fewer than three binary bytes are encoded.
103 A character text value begins with a
110 and continues with text characters, each being the value of one binary byte.
113 All these functions basically copy data from
116 (whose size is specified by
122 (whose size is specified by
125 doing the conversion en route.
126 If the result will not fit in
130 under no circumstances are more than
133 bytes of result written to
138 can be zero, in which case
141 need not be valid and no result bytes are written at all.
153 specifies what format the input is in;
154 normally it should be
157 to signify that this gets figured out from the prefix.
166 respectively signify hexadecimal, base64, and character-text formats
176 a single character used as a type code,
177 specifies which text format is wanted.
184 but a zero value) specifies a reasonable default.
185 Other currently-supported values are:
191 continuous lower-case hexadecimal with a
198 lower-case hexadecimal with a
208 lower-case hexadecimal with no prefix and a
211 (colon) every two digits
215 lower-case hexadecimal with no prefix or
221 continuous base64 with a
228 continuous base64 with no prefix
234 The default format is currently
241 returns NULL for success and
242 a pointer to a string-literal error message for failure;
251 is set to the number of bytes required to contain the full untruncated result.
252 It is the caller's responsibility to check this against
255 to determine whether he has obtained a complete result.
259 value is correct even if
262 is zero, which offers a way to determine how much space would be needed
263 before having to allocate any.
271 except that in certain cases,
276 the buffer pointed to by
279 (whose length is given by
282 is used to hold a more detailed error message.
283 The return value is NULL for success,
287 or a pointer to a string literal for failure.
288 If the size of the error-message buffer is
289 inadequate for the desired message,
292 will fall back on returning a pointer to a literal string instead.
296 header file defines a constant
299 which is the size of a buffer large enough for worst-case results.
302 The normal return value of
305 is the number of bytes required
306 to contain the full untruncated result.
307 It is the caller's responsibility to check this against
310 to determine whether he has obtained a complete result.
311 The return value is correct even if
314 is zero, which offers a way to determine how much space would be needed
315 before having to allocate any.
319 signals a fatal error of some kind
341 must not include the terminating NUL.
348 the result supplied by
351 is always NUL-terminated,
352 and its needed-size return value includes space for the terminating NUL.
355 Several obsolete variants of these functions
365 are temporarily also supported.
366 <A NAME=
"lbAE"> </A>
369 <A HREF=
"sprintf.3.html">sprintf
</A>(
3),
<A HREF=
"ipsec_atoaddr.3.html">ipsec_atoaddr
</A>(
3)
370 <A NAME=
"lbAF"> </A>
380 unknown characters in the input;
381 unknown or missing prefix;
383 incomplete digit group;
384 non-zero padding in a base64 less-than-three-bytes digit group;
394 <A NAME=
"lbAG"> </A>
397 Written for the FreeS/WAN project by Henry Spencer.
398 <A NAME=
"lbAH"> </A>
403 should have a format code to produce character-text output.
412 prefixes are the author's inventions and are not a standard
414 They have been chosen to avoid collisions with existing practice
415 (some C implementations use
419 and possible confusion with unprefixed hexadecimal.
423 <A NAME=
"index"> </A><H2>Index
</H2>
425 <DT><A HREF=
"#lbAB">NAME
</A><DD>
426 <DT><A HREF=
"#lbAC">SYNOPSIS
</A><DD>
427 <DT><A HREF=
"#lbAD">DESCRIPTION
</A><DD>
428 <DT><A HREF=
"#lbAE">SEE ALSO
</A><DD>
429 <DT><A HREF=
"#lbAF">DIAGNOSTICS
</A><DD>
430 <DT><A HREF=
"#lbAG">HISTORY
</A><DD>
431 <DT><A HREF=
"#lbAH">BUGS
</A><DD>
434 This document was created by
435 <A HREF=
"http://localhost/cgi-bin/man/man2html">man2html
</A>,
436 using the manual pages.
<BR>
437 Time:
21:
40:
18 GMT, November
11,
2003