1*3f41d2faStb.\" $OpenBSD: BIO_new_CMS.3,v 1.9 2023/05/01 07:28:11 tb Exp $ 254c85986Sschwarze.\" full merge up to: OpenSSL df75c2bfc Dec 9 01:02:36 2018 +0100 354c85986Sschwarze.\" 454c85986Sschwarze.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 554c85986Sschwarze.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved. 654c85986Sschwarze.\" 754c85986Sschwarze.\" Redistribution and use in source and binary forms, with or without 854c85986Sschwarze.\" modification, are permitted provided that the following conditions 954c85986Sschwarze.\" are met: 1054c85986Sschwarze.\" 1154c85986Sschwarze.\" 1. Redistributions of source code must retain the above copyright 1254c85986Sschwarze.\" notice, this list of conditions and the following disclaimer. 1354c85986Sschwarze.\" 1454c85986Sschwarze.\" 2. Redistributions in binary form must reproduce the above copyright 1554c85986Sschwarze.\" notice, this list of conditions and the following disclaimer in 1654c85986Sschwarze.\" the documentation and/or other materials provided with the 1754c85986Sschwarze.\" distribution. 1854c85986Sschwarze.\" 1954c85986Sschwarze.\" 3. All advertising materials mentioning features or use of this 2054c85986Sschwarze.\" software must display the following acknowledgment: 2154c85986Sschwarze.\" "This product includes software developed by the OpenSSL Project 2254c85986Sschwarze.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 2354c85986Sschwarze.\" 2454c85986Sschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 2554c85986Sschwarze.\" endorse or promote products derived from this software without 2654c85986Sschwarze.\" prior written permission. For written permission, please contact 2754c85986Sschwarze.\" openssl-core@openssl.org. 2854c85986Sschwarze.\" 2954c85986Sschwarze.\" 5. Products derived from this software may not be called "OpenSSL" 3054c85986Sschwarze.\" nor may "OpenSSL" appear in their names without prior written 3154c85986Sschwarze.\" permission of the OpenSSL Project. 3254c85986Sschwarze.\" 3354c85986Sschwarze.\" 6. Redistributions of any form whatsoever must retain the following 3454c85986Sschwarze.\" acknowledgment: 3554c85986Sschwarze.\" "This product includes software developed by the OpenSSL Project 3654c85986Sschwarze.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 3754c85986Sschwarze.\" 3854c85986Sschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 3954c85986Sschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4054c85986Sschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 4154c85986Sschwarze.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 4254c85986Sschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4354c85986Sschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 4454c85986Sschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 4554c85986Sschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4654c85986Sschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4754c85986Sschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 4854c85986Sschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 4954c85986Sschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE. 5054c85986Sschwarze.\" 51*3f41d2faStb.Dd $Mdocdate: May 1 2023 $ 5254c85986Sschwarze.Dt BIO_NEW_CMS 3 5354c85986Sschwarze.Os 5454c85986Sschwarze.Sh NAME 5554c85986Sschwarze.Nm BIO_new_CMS 5654c85986Sschwarze.Nd CMS streaming filter BIO 5754c85986Sschwarze.Sh SYNOPSIS 5854c85986Sschwarze.In openssl/cms.h 5954c85986Sschwarze.Ft BIO * 6054c85986Sschwarze.Fo BIO_new_CMS 6154c85986Sschwarze.Fa "BIO *out" 6254c85986Sschwarze.Fa "CMS_ContentInfo *cms" 6354c85986Sschwarze.Fc 6454c85986Sschwarze.Sh DESCRIPTION 6554c85986Sschwarze.Fn BIO_new_CMS 6654c85986Sschwarzereturns a streaming filter 6754c85986Sschwarze.Vt BIO 6854c85986Sschwarzechain based on 6954c85986Sschwarze.Fa cms . 7054c85986SschwarzeThe output of the filter is written to 7154c85986Sschwarze.Fa out . 7254c85986SschwarzeAny data written to the chain is automatically translated 7354c85986Sschwarzeto a BER format CMS structure of the appropriate type. 7454c85986Sschwarze.Pp 7554c85986SschwarzeThe chain returned by this function behaves like a standard filter 7654c85986Sschwarze.Vt BIO . 7754c85986SschwarzeIt supports non blocking I/O. 7854c85986SschwarzeContent is processed and streamed on the fly and not all held in memory 7954c85986Sschwarzeat once: so it is possible to encode very large structures. 8054c85986SschwarzeAfter all content has been written through the chain, 8154c85986Sschwarze.Xr BIO_flush 3 8254c85986Sschwarzemust be called to finalise the structure. 8354c85986Sschwarze.Pp 8454c85986SschwarzeThe 8554c85986Sschwarze.Dv CMS_STREAM 8654c85986Sschwarzeflag must be included in the corresponding 8754c85986Sschwarze.Fa flags 8854c85986Sschwarzeparameter of the 8954c85986Sschwarze.Fa cms 9054c85986Sschwarzecreation function. 9154c85986Sschwarze.Pp 9254c85986SschwarzeIf an application wishes to write additional data to 9354c85986Sschwarze.Fa out , 9454c85986SschwarzeBIOs should be removed from the chain using 9554c85986Sschwarze.Xr BIO_pop 3 9654c85986Sschwarzeand freed with 9754c85986Sschwarze.Xr BIO_free 3 9854c85986Sschwarzeuntil 9954c85986Sschwarze.Fa out 10054c85986Sschwarzeis reached. 10154c85986SschwarzeIf no additional data needs to be written, 10254c85986Sschwarze.Xr BIO_free_all 3 10354c85986Sschwarzecan be called to free up the whole chain. 10454c85986Sschwarze.Pp 10554c85986SschwarzeAny content written through the filter is used verbatim: 10654c85986Sschwarzeno canonical translation is performed. 10754c85986Sschwarze.Pp 10854c85986SschwarzeIt is possible to chain multiple BIOs to, for example, 10954c85986Sschwarzecreate a triple wrapped signed, enveloped, signed structure. 11054c85986SschwarzeIn this case it is the application's responsibility 11154c85986Sschwarzeto set the inner content type of any outer 11254c85986Sschwarze.Vt CMS_ContentInfo 11354c85986Sschwarzestructures. 11454c85986Sschwarze.Pp 11554c85986SschwarzeLarge numbers of small writes through the chain should be avoided as this 11654c85986Sschwarzewill produce an output consisting of lots of OCTET STRING structures. 11754c85986SschwarzePrepending a 11854c85986Sschwarze.Xr BIO_f_buffer 3 11954c85986Sschwarzebuffering BIO will prevent this. 12054c85986Sschwarze.Sh RETURN VALUES 12154c85986Sschwarze.Fn BIO_new_CMS 12254c85986Sschwarzereturns a 12354c85986Sschwarze.Vt BIO 12454c85986Sschwarzechain when successful or 12554c85986Sschwarze.Dv NULL 12654c85986Sschwarzeif an error occurred. 12754c85986SschwarzeThe error can be obtained from 12854c85986Sschwarze.Xr ERR_get_error 3 . 12954c85986Sschwarze.Sh SEE ALSO 13085bbda65Sschwarze.Xr BIO_new 3 , 13185bbda65Sschwarze.Xr CMS_ContentInfo_new 3 , 13254c85986Sschwarze.Xr CMS_encrypt 3 , 13354c85986Sschwarze.Xr CMS_sign 3 13454c85986Sschwarze.Sh HISTORY 13554c85986Sschwarze.Fn BIO_new_CMS 13666a3cb98Sschwarzefirst appeared in OpenSSL 1.0.0 13766a3cb98Sschwarzeand has been available since 138569a59c8Sschwarze.Ox 6.7 . 13954c85986Sschwarze.Sh BUGS 14054c85986SschwarzeThere is currently no corresponding inverse BIO 14154c85986Sschwarzewhich can decode a CMS structure on the fly. 142