xref: /openbsd-src/lib/libcrypto/man/BIO_dump.3 (revision 4e1ee0786f11cc571bd0be17d38e46f635c719fc)
1.\" $OpenBSD: BIO_dump.3,v 1.2 2021/07/11 20:18:07 beck Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: July 11 2021 $
18.Dt BIO_DUMP 3
19.Os
20.Sh NAME
21.Nm BIO_dump ,
22.Nm BIO_dump_indent ,
23.Nm BIO_dump_fp ,
24.Nm BIO_dump_indent_fp
25.Nd hexadecimal printout of arbitrary byte arrays
26.Sh SYNOPSIS
27.In openssl/bio.h
28.Ft int
29.Fo BIO_dump
30.Fa "BIO *b"
31.Fa "const char *s"
32.Fa "int len"
33.Fc
34.Ft int
35.Fo BIO_dump_indent
36.Fa "BIO *b"
37.Fa "const char *s"
38.Fa "int len"
39.Fa "int indent"
40.Fc
41.Ft int
42.Fo BIO_dump_fp
43.Fa "FILE *fp"
44.Fa "const char *s"
45.Fa "int len"
46.Fc
47.Ft int
48.Fo BIO_dump_indent_fp
49.Fa "FILE *fp"
50.Fa "const char *s"
51.Fa "int len"
52.Fa "int indent"
53.Fc
54.Sh DESCRIPTION
55.Fn BIO_dump
56prints
57.Fa len
58bytes starting at
59.Fa s
60to
61.Fa bio
62in hexadecimal format.
63.Pp
64The first column of output contains the index, in the byte array starting at
65.Fa s ,
66of the first byte shown on the respective output line, expressed as a
67four-digit hexadecimal number starting at 0000, followed by a dash.
68After the dash, sixteen bytes of data are printed as two-digit
69hexadecimal numbers, respecting the order in which they appear in
70the array
71.Fa s .
72Another dash is printed after the eighth column.
73.Pp
74To the right of the hexadecimal representation of the bytes,
75the same bytes are printed again, this time as ASCII characters.
76Non-printable ASCII characters are replaced with dots.
77.Pp
78Trailing space characters and NUL bytes are omitted from the main table.
79If there are any, an additional line is printed, constisting of the
80.Fa len
81argument as a four-digit hexadecimal number, a dash, and the fixed string
82.Qq <SPACES/NULS> .
83.Pp
84.Fn BIO_dump_indent
85is similar except that
86.Fa indent
87space characters are prepended to each output line.
88If
89.Fa indent
90is 7 or more, the number of data columns is reduced such that the
91total width of the output does not exceed 79 characters per line.
92.Pp
93.Fn BIO_dump_fp
94and
95.Fn BIO_dump_indent_fp
96are similar except that
97.Xr fwrite 3
98is used instead of
99.Xr BIO_write 3 .
100.Sh RETURN VALUES
101On success these functions return the total number of bytes written by
102.Xr BIO_write 3
103or
104.Xr fwrite 3 .
105If a failure occurs at any point when writing, these
106functions will stop after having potentially written out partial results,
107and return -1.
108.Sh SEE ALSO
109.Xr hexdump 1 ,
110.Xr BIO_new 3 ,
111.Xr BIO_write 3
112.Sh HISTORY
113.Fn BIO_dump
114first appeared in SSLeay 0.6.5 and has been available since
115.Ox 2.4 .
116.Pp
117.Fn BIO_dump_indent
118first appeared in OpenSSL 0.9.6 and has been available since
119.Ox 2.9 .
120.Pp
121.Fn BIO_dump_fp
122and
123.Fn BIO_dump_indent_fp
124first appeared in OpenSSL 0.9.8 and have been available since
125.Ox 4.5 .
126