1.\" $OpenBSD: SMIME_crlf_copy.3,v 1.3 2023/05/01 07:28:11 tb 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: May 1 2023 $ 18.Dt SMIME_CRLF_COPY 3 19.Os 20.Sh NAME 21.Nm SMIME_crlf_copy 22.Nd buffered copy between BIOs 23.Sh SYNOPSIS 24.Ft int 25.Fo SMIME_crlf_copy 26.Fa "BIO *in_bio" 27.Fa "BIO *out_bio" 28.Fa "int flags" 29.Fc 30.Sh DESCRIPTION 31.Fn SMIME_crlf_copy 32copies data from 33.Fa in_bio 34to 35.Fa out_bio . 36To avoid many small write operations on 37.Fa out_bio , 38a buffering BIO created with 39.Xr BIO_f_buffer 3 40is temporarily prepended to it. 41.Pp 42If the bit 43.Dv SMIME_BINARY 44is set in the 45.Fa flags 46argument, all the data is copied verbatim using 47.Xr BIO_read 3 48and 49.Xr BIO_write 3 . 50.Pp 51Otherwise, the data is read as text. 52All trailing carriage return and newline characters are discarded 53from every input line and a single pair of carriage return and 54newline characters is appended to mark the end of every output line, 55except that the last output line will end without such a pair if 56the last input line does not have a newline character at the end. 57.Pp 58If the bit 59.Dv SMIME_TEXT 60is set in the 61.Fa flags 62argument and the bit 63.Dv SMIME_BINARY 64is not set, the line 65.Qq Content-Type: text/plain 66is prepended to the output 67with two pairs of carriage return and newline characters after it. 68.Pp 69In any case, 70.Xr BIO_flush 3 71is called on the output at the end of the function. 72.Sh RETURN VALUES 73.Fn SMIME_crlf_copy 74is intended to return 1 on success or 0 on failure. 75.Sh SEE ALSO 76.Xr BIO_f_buffer 3 , 77.Xr BIO_flush 3 , 78.Xr BIO_new 3 , 79.Xr BIO_push 3 , 80.Xr BIO_read 3 , 81.Xr SMIME_text 3 , 82.Xr SMIME_write_ASN1 3 83.Sh HISTORY 84.Fn SMIME_crlf_copy 85first appeared in OpenSSL 1.0.0 and has been available since 86.Ox 4.9 . 87.Sh BUGS 88.Fn SMIME_crlf_copy 89silently ignores most errors and may return 1 90even if it lost part or all of the data in transit. 91.Pp 92Only blocking BIOs are supported. 93If any of the 94.Vt BIO 95arguments is non-blocking, part or all of the data is likely 96to be silently lost in transit. 97