xref: /openbsd-src/lib/libssl/man/SSL_get_client_random.3 (revision 20b9f7f9dd2c6852e6eb5dd8d347c9bd8e1f4ed0)
1*20b9f7f9Sschwarze.\" $OpenBSD: SSL_get_client_random.3,v 1.2 2018/03/24 00:55:37 schwarze Exp $
2795d247bSschwarze.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3795d247bSschwarze.\"
4795d247bSschwarze.\" This file was written by Nick Mathewson <nickm@torproject.org>
5795d247bSschwarze.\" Copyright (c) 2015 The OpenSSL Project.  All rights reserved.
6795d247bSschwarze.\"
7795d247bSschwarze.\" Redistribution and use in source and binary forms, with or without
8795d247bSschwarze.\" modification, are permitted provided that the following conditions
9795d247bSschwarze.\" are met:
10795d247bSschwarze.\"
11795d247bSschwarze.\" 1. Redistributions of source code must retain the above copyright
12795d247bSschwarze.\"    notice, this list of conditions and the following disclaimer.
13795d247bSschwarze.\"
14795d247bSschwarze.\" 2. Redistributions in binary form must reproduce the above copyright
15795d247bSschwarze.\"    notice, this list of conditions and the following disclaimer in
16795d247bSschwarze.\"    the documentation and/or other materials provided with the
17795d247bSschwarze.\"    distribution.
18795d247bSschwarze.\"
19795d247bSschwarze.\" 3. All advertising materials mentioning features or use of this
20795d247bSschwarze.\"    software must display the following acknowledgment:
21795d247bSschwarze.\"    "This product includes software developed by the OpenSSL Project
22795d247bSschwarze.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23795d247bSschwarze.\"
24795d247bSschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25795d247bSschwarze.\"    endorse or promote products derived from this software without
26795d247bSschwarze.\"    prior written permission. For written permission, please contact
27795d247bSschwarze.\"    openssl-core@openssl.org.
28795d247bSschwarze.\"
29795d247bSschwarze.\" 5. Products derived from this software may not be called "OpenSSL"
30795d247bSschwarze.\"    nor may "OpenSSL" appear in their names without prior written
31795d247bSschwarze.\"    permission of the OpenSSL Project.
32795d247bSschwarze.\"
33795d247bSschwarze.\" 6. Redistributions of any form whatsoever must retain the following
34795d247bSschwarze.\"    acknowledgment:
35795d247bSschwarze.\"    "This product includes software developed by the OpenSSL Project
36795d247bSschwarze.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37795d247bSschwarze.\"
38795d247bSschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39795d247bSschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40795d247bSschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41795d247bSschwarze.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42795d247bSschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43795d247bSschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44795d247bSschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45795d247bSschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46795d247bSschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47795d247bSschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48795d247bSschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49795d247bSschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50795d247bSschwarze.\"
51*20b9f7f9Sschwarze.Dd $Mdocdate: March 24 2018 $
52795d247bSschwarze.Dt SSL_GET_CLIENT_RANDOM 3
53795d247bSschwarze.Os
54795d247bSschwarze.Sh NAME
55795d247bSschwarze.Nm SSL_get_client_random ,
56795d247bSschwarze.Nm SSL_get_server_random ,
57795d247bSschwarze.Nm SSL_SESSION_get_master_key
58795d247bSschwarze.Nd get internal TLS handshake random values and master key
59795d247bSschwarze.Sh SYNOPSIS
60795d247bSschwarze.In openssl/ssl.h
61795d247bSschwarze.Ft size_t
62795d247bSschwarze.Fo SSL_get_client_random
63795d247bSschwarze.Fa "const SSL *ssl"
64795d247bSschwarze.Fa "unsigned char *out"
65795d247bSschwarze.Fa "size_t outlen"
66795d247bSschwarze.Fc
67795d247bSschwarze.Ft size_t
68795d247bSschwarze.Fo SSL_get_server_random
69795d247bSschwarze.Fa "const SSL *ssl"
70795d247bSschwarze.Fa "unsigned char *out"
71795d247bSschwarze.Fa "size_t outlen"
72795d247bSschwarze.Fc
73795d247bSschwarze.Ft size_t
74795d247bSschwarze.Fo SSL_SESSION_get_master_key
75795d247bSschwarze.Fa "const SSL_SESSION *session"
76795d247bSschwarze.Fa "unsigned char *out"
77795d247bSschwarze.Fa "size_t outlen"
78795d247bSschwarze.Fc
79795d247bSschwarze.Sh DESCRIPTION
80795d247bSschwarze.Fn SSL_get_client_random
81795d247bSschwarzeextracts the random value that was sent from the client to the server
82795d247bSschwarzeduring the initial TLS handshake.
83795d247bSschwarzeIt copies at most
84795d247bSschwarze.Fa outlen
85795d247bSschwarzebytes of this value into the buffer
86795d247bSschwarze.Fa out .
87795d247bSschwarzeIf
88795d247bSschwarze.Fa outlen
89795d247bSschwarzeis zero, nothing is copied.
90795d247bSschwarze.Pp
91795d247bSschwarze.Fn SSL_get_server_random
92795d247bSschwarzebehaves the same, but extracts the random value that was sent
93795d247bSschwarzefrom the server to the client during the initial TLS handshake.
94795d247bSschwarze.Pp
95795d247bSschwarze.Fn SSL_SESSION_get_master_key
96795d247bSschwarzebehaves the same, but extracts the master secret used to guarantee the
97795d247bSschwarzesecurity of the TLS session.
98795d247bSschwarzeThe security of the TLS session depends on keeping the master key
99795d247bSschwarzesecret: do not expose it, or any information about it, to anybody.
100795d247bSschwarzeTo calculate another secret value that depends on the master secret,
101795d247bSschwarzeuse
102795d247bSschwarze.Xr SSL_export_keying_material 3
103795d247bSschwarzeinstead.
104795d247bSschwarze.Pp
105795d247bSschwarzeAll these functions expose internal values from the TLS handshake,
106795d247bSschwarzefor use in low-level protocols.
107795d247bSschwarzeAvoid using them unless implementing a feature
108795d247bSschwarzethat requires access to the internal protocol details.
109795d247bSschwarze.Pp
110795d247bSschwarzeDespite the names of
111795d247bSschwarze.Fn SSL_get_client_random
112795d247bSschwarzeand
113795d247bSschwarze.Fn SSL_get_server_random ,
114795d247bSschwarzethey are not random number generators.
115795d247bSschwarzeInstead, they return the mostly-random values that were already
116795d247bSschwarzegenerated and used in the TLS protocol.
117795d247bSschwarze.Pp
118795d247bSschwarzeIn current versions of the TLS protocols,
119795d247bSschwarzethe length of client_random and server_random is always
120795d247bSschwarze.Dv SSL3_RANDOM_SIZE
121795d247bSschwarzebytes.
122795d247bSschwarzeSupport for other
123795d247bSschwarze.Fa outlen
124795d247bSschwarzearguments is provided for the unlikely event that a future
125795d247bSschwarzeversion or variant of TLS uses some other length.
126795d247bSschwarze.Pp
127795d247bSschwarzeFinally, though the client_random and server_random values are called
128795d247bSschwarze.Dq random ,
129795d247bSschwarzemany TLS implementations generate four bytes of those values
130795d247bSschwarzebased on their view of the current time.
131795d247bSschwarze.Sh RETURN VALUES
132795d247bSschwarzeIf
133795d247bSschwarze.Fa outlen
134795d247bSschwarzeis greater than 0, these functions return the number of bytes
135795d247bSschwarzeactually copied, which is less than or equal to
136795d247bSschwarze.Fa outlen .
137795d247bSschwarzeIf
138795d247bSschwarze.Fa outlen
139795d247bSschwarzeis 0, these functions return the maximum number of bytes they would
140795d247bSschwarzecopy \(em that is, the length of the underlying field.
141795d247bSschwarze.Sh SEE ALSO
142795d247bSschwarze.Xr ssl 3 ,
143795d247bSschwarze.Xr SSL_export_keying_material 3 ,
144795d247bSschwarze.Xr SSL_SESSION_get_id 3 ,
145795d247bSschwarze.Xr SSL_SESSION_get_time 3 ,
146795d247bSschwarze.Xr SSL_SESSION_new 3
147*20b9f7f9Sschwarze.Sh HISTORY
148*20b9f7f9SschwarzeThese functions first appeared in OpenSSL 1.1.0
149*20b9f7f9Sschwarzeand have been available since
150*20b9f7f9Sschwarze.Ox 6.3 .
151