Blame doc/man3/SSL_get_client_random.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
SSL_get_client_random,
Packit c4476c
SSL_get_server_random,
Packit c4476c
SSL_SESSION_get_master_key,
Packit c4476c
SSL_SESSION_set1_master_key
Packit c4476c
- get internal TLS/SSL random values and get/set master key
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/ssl.h>
Packit c4476c
Packit c4476c
 size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, size_t outlen);
Packit c4476c
 size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, size_t outlen);
Packit c4476c
 size_t SSL_SESSION_get_master_key(const SSL_SESSION *session,
Packit c4476c
                                   unsigned char *out, size_t outlen);
Packit c4476c
 int SSL_SESSION_set1_master_key(SSL_SESSION *sess, const unsigned char *in,
Packit c4476c
                                 size_t len);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
SSL_get_client_random() extracts the random value sent from the client
Packit c4476c
to the server during the initial SSL/TLS handshake.  It copies as many
Packit c4476c
bytes as it can of this value into the buffer provided in B<out>,
Packit c4476c
which must have at least B<outlen> bytes available. It returns the
Packit c4476c
total number of bytes that were actually copied.  If B<outlen> is
Packit c4476c
zero, SSL_get_client_random() copies nothing, and returns the
Packit c4476c
total size of the client_random value.
Packit c4476c
Packit c4476c
SSL_get_server_random() behaves the same, but extracts the random value
Packit c4476c
sent from the server to the client during the initial SSL/TLS handshake.
Packit c4476c
Packit c4476c
SSL_SESSION_get_master_key() behaves the same, but extracts the master
Packit c4476c
secret used to guarantee the security of the SSL/TLS session.  This one
Packit c4476c
can be dangerous if misused; see NOTES below.
Packit c4476c
Packit c4476c
SSL_SESSION_set1_master_key() sets the master key value associated with the
Packit c4476c
SSL_SESSION B<sess>. For example, this could be used to set up a session based
Packit c4476c
PSK (see L<SSL_CTX_set_psk_use_session_callback(3)>). The master key of length
Packit c4476c
B<len> should be provided at B<in>. The supplied master key is copied by the
Packit c4476c
function, so the caller is responsible for freeing and cleaning any memory
Packit c4476c
associated with B<in>. The caller must ensure that the length of the key is
Packit c4476c
suitable for the ciphersuite associated with the SSL_SESSION.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
You probably shouldn't use these functions.
Packit c4476c
Packit c4476c
These functions expose internal values from the TLS handshake, for
Packit c4476c
use in low-level protocols.  You probably should not use them, unless
Packit c4476c
you are implementing something that needs access to the internal protocol
Packit c4476c
details.
Packit c4476c
Packit c4476c
Despite the names of SSL_get_client_random() and SSL_get_server_random(), they
Packit c4476c
ARE NOT random number generators.  Instead, they return the mostly-random values that
Packit c4476c
were already generated and used in the TLS protocol.  Using them
Packit c4476c
in place of RAND_bytes() would be grossly foolish.
Packit c4476c
Packit c4476c
The security of your TLS session depends on keeping the master key secret:
Packit c4476c
do not expose it, or any information about it, to anybody.
Packit c4476c
If you need to calculate another secret value that depends on the master
Packit c4476c
secret, you should probably use SSL_export_keying_material() instead, and
Packit c4476c
forget that you ever saw these functions.
Packit c4476c
Packit c4476c
In current versions of the TLS protocols, the length of client_random
Packit c4476c
(and also server_random) is always SSL3_RANDOM_SIZE bytes. Support for
Packit c4476c
other outlen arguments to the SSL_get_*_random() functions is provided
Packit c4476c
in case of the unlikely event that a future version or variant of TLS
Packit c4476c
uses some other length there.
Packit c4476c
Packit c4476c
Finally, though the "client_random" and "server_random" values are called
Packit c4476c
"random", many TLS implementations will generate four bytes of those
Packit c4476c
values based on their view of the current time.
Packit c4476c
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
SSL_SESSION_set1_master_key() returns 1 on success or 0 on failure.
Packit c4476c
Packit c4476c
For the other functions, if B<outlen> is greater than 0 then these functions
Packit c4476c
return the number of bytes actually copied, which will be less than or equal to
Packit c4476c
B<outlen>. If B<outlen> is 0 then these functions return the maximum number
Packit c4476c
of bytes they would copy -- that is, the length of the underlying field.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<ssl(7)>,
Packit c4476c
L<RAND_bytes(3)>,
Packit c4476c
L<SSL_export_keying_material(3)>,
Packit c4476c
L<SSL_CTX_set_psk_use_session_callback(3)>
Packit c4476c
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut