diff options
Diffstat (limited to 'src/lib/libssl/doc/d2i_SSL_SESSION.3')
-rw-r--r-- | src/lib/libssl/doc/d2i_SSL_SESSION.3 | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/d2i_SSL_SESSION.3 b/src/lib/libssl/doc/d2i_SSL_SESSION.3 new file mode 100644 index 0000000000..3a40c32e69 --- /dev/null +++ b/src/lib/libssl/doc/d2i_SSL_SESSION.3 | |||
@@ -0,0 +1,126 @@ | |||
1 | .Dd $Mdocdate: October 12 2014 $ | ||
2 | .Dt D2I_SSL_SESSION 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm d2i_SSL_SESSION , | ||
6 | .Nm i2d_SSL_SESSION | ||
7 | .Nd convert SSL_SESSION object from/to ASN1 representation | ||
8 | .Sh SYNOPSIS | ||
9 | .In openssl/ssl.h | ||
10 | .Ft SSL_SESSION * | ||
11 | .Fn d2i_SSL_SESSION "SSL_SESSION **a" "const unsigned char **pp" "long length" | ||
12 | .Ft int | ||
13 | .Fn i2d_SSL_SESSION "SSL_SESSION *in" "unsigned char **pp" | ||
14 | .Sh DESCRIPTION | ||
15 | .Fn d2i_SSL_SESSION | ||
16 | transforms the external ASN1 representation of an SSL/TLS session, | ||
17 | stored as binary data at location | ||
18 | .Fa pp | ||
19 | with length | ||
20 | .Fa length , | ||
21 | into | ||
22 | an | ||
23 | .Vt SSL_SESSION | ||
24 | object. | ||
25 | .Pp | ||
26 | .Fn i2d_SSL_SESSION | ||
27 | transforms the | ||
28 | .Vt SSL_SESSION | ||
29 | object | ||
30 | .Fa in | ||
31 | into the ASN1 representation and stores it into the memory location pointed to | ||
32 | by | ||
33 | .Fa pp . | ||
34 | The length of the resulting ASN1 representation is returned. | ||
35 | If | ||
36 | .Fa pp | ||
37 | is the | ||
38 | .Dv NULL | ||
39 | pointer, only the length is calculated and returned. | ||
40 | .Sh NOTES | ||
41 | The | ||
42 | .Vt SSL_SESSION | ||
43 | object is built from several | ||
44 | .Xr malloc 3 Ns | ||
45 | -ed parts; it can therefore not be moved, copied or stored directly. | ||
46 | In order to store session data on disk or into a database, | ||
47 | it must be transformed into a binary ASN1 representation. | ||
48 | .Pp | ||
49 | When using | ||
50 | .Fn d2i_SSL_SESSION , | ||
51 | the | ||
52 | .Vt SSL_SESSION | ||
53 | object is automatically allocated. | ||
54 | The reference count is 1, so that the session must be explicitly removed using | ||
55 | .Xr SSL_SESSION_free 3 , | ||
56 | unless the | ||
57 | .Vt SSL_SESSION | ||
58 | object is completely taken over, when being called inside the | ||
59 | .Xr get_session_cb 3 | ||
60 | (see | ||
61 | .Xr SSL_CTX_sess_set_get_cb 3 ) . | ||
62 | .Pp | ||
63 | .Vt SSL_SESSION | ||
64 | objects keep internal link information about the session cache list when being | ||
65 | inserted into one | ||
66 | .Vt SSL_CTX | ||
67 | object's session cache. | ||
68 | One | ||
69 | .Vt SSL_SESSION | ||
70 | object, regardless of its reference count, must therefore only be used with one | ||
71 | .Vt SSL_CTX | ||
72 | object (and the | ||
73 | .Vt SSL | ||
74 | objects created from this | ||
75 | .Vt SSL_CTX | ||
76 | object). | ||
77 | .Pp | ||
78 | When using | ||
79 | .Fn i2d_SSL_SESSION , | ||
80 | the memory location pointed to by | ||
81 | .Fa pp | ||
82 | must be large enough to hold the binary representation of the session. | ||
83 | There is no known limit on the size of the created ASN1 representation, | ||
84 | so the necessary amount of space should be obtained by first calling | ||
85 | .Fn i2d_SSL_SESSION | ||
86 | with | ||
87 | .Fa pp Ns | ||
88 | = Ns | ||
89 | .Dv NULL , | ||
90 | and obtain the size needed, then allocate the memory and call | ||
91 | .Fn i2d_SSL_SESSION | ||
92 | again. | ||
93 | Note that this will advance the value contained in | ||
94 | .Fa *pp | ||
95 | so it is necessary to save a copy of the original allocation. | ||
96 | For example: | ||
97 | .Bd -literal | ||
98 | int i, j; | ||
99 | |||
100 | char *p, *temp; | ||
101 | |||
102 | i = i2d_SSL_SESSION(sess, NULL); | ||
103 | p = temp = malloc(i); | ||
104 | if (temp != NULL) { | ||
105 | j = i2d_SSL_SESSION(sess, &temp); | ||
106 | assert(i == j); | ||
107 | assert(p + i == temp); | ||
108 | } | ||
109 | .Ed | ||
110 | .Sh RETURN VALUES | ||
111 | .Fn d2i_SSL_SESSION | ||
112 | returns a pointer to the newly allocated | ||
113 | .Vt SSL_SESSION | ||
114 | object. | ||
115 | In case of failure a | ||
116 | .Dv NULL | ||
117 | pointer is returned and the error message can be retrieved from the error | ||
118 | stack. | ||
119 | .Pp | ||
120 | .Fn i2d_SSL_SESSION | ||
121 | returns the size of the ASN1 representation in bytes. | ||
122 | When the session is not valid, 0 is returned and no operation is performed. | ||
123 | .Sh SEE ALSO | ||
124 | .Xr ssl 3 , | ||
125 | .Xr SSL_CTX_sess_set_get_cb 3 , | ||
126 | .Xr SSL_SESSION_free 3 | ||