1 .\" $OpenBSD: d2i_SSL_SESSION.3,v 1.3 2017/04/10 16:11:50 schwarze Exp $
2 .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4 .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
5 .\" Copyright (c) 2001, 2005, 2014 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in
16 .\" the documentation and/or other materials provided with the
19 .\" 3. All advertising materials mentioning features or use of this
20 .\" software must display the following acknowledgment:
21 .\" "This product includes software developed by the OpenSSL Project
22 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\" endorse or promote products derived from this software without
26 .\" prior written permission. For written permission, please contact
27 .\" openssl-core@openssl.org.
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\" nor may "OpenSSL" appear in their names without prior written
31 .\" permission of the OpenSSL Project.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
51 .Dd $Mdocdate: April 10 2017 $
57 .Nd convert SSL_SESSION object from/to ASN1 representation
61 .Fn d2i_SSL_SESSION "SSL_SESSION **a" "const unsigned char **pp" "long length"
63 .Fn i2d_SSL_SESSION "SSL_SESSION *in" "unsigned char **pp"
66 transforms the external ASN1 representation of an SSL/TLS session,
67 stored as binary data at location
81 into the ASN1 representation and stores it into the memory location pointed to
84 The length of the resulting ASN1 representation is returned.
89 pointer, only the length is calculated and returned.
93 object is built from several
95 -ed parts; it can therefore not be moved, copied or stored directly.
96 In order to store session data on disk or into a database,
97 it must be transformed into a binary ASN1 representation.
100 .Fn d2i_SSL_SESSION ,
103 object is automatically allocated.
104 The reference count is 1, so that the session must be explicitly removed using
105 .Xr SSL_SESSION_free 3 ,
108 object is completely taken over, when being called inside the
111 .Xr SSL_CTX_sess_set_get_cb 3 .
114 objects keep internal link information about the session cache list when being
117 object's session cache.
120 object, regardless of its reference count, must therefore only be used with one
124 objects created from this
129 .Fn i2d_SSL_SESSION ,
130 the memory location pointed to by
132 must be large enough to hold the binary representation of the session.
133 There is no known limit on the size of the created ASN1 representation,
134 so the necessary amount of space should be obtained by first calling
140 and obtain the size needed, then allocate the memory and call
143 Note that this will advance the value contained in
145 so it is necessary to save a copy of the original allocation.
152 i = i2d_SSL_SESSION(sess, NULL);
153 p = temp = malloc(i);
155 j = i2d_SSL_SESSION(sess, &temp);
157 assert(p + i == temp);
162 returns a pointer to the newly allocated
167 pointer is returned and the error message can be retrieved from the error
171 returns the size of the ASN1 representation in bytes.
172 When the session is not valid, 0 is returned and no operation is performed.
176 .Xr SSL_CTX_sess_set_get_cb 3 ,
177 .Xr SSL_SESSION_free 3