Add SSL_SESSION_set1_master_key()
authorMatt Caswell <matt@openssl.org>
Mon, 12 Jun 2017 17:38:30 +0000 (18:38 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 21 Jun 2017 13:45:35 +0000 (14:45 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3670)

include/openssl/ssl.h
ssl/ssl_lib.c
util/libssl.num

index e4aa743..bf01f60 100644 (file)
@@ -1861,6 +1861,8 @@ __owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out,
                                     size_t outlen);
 __owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *ssl,
                                          unsigned char *out, size_t outlen);
+__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess, unsigned char *in,
+                                       size_t len);
 
 #define SSL_get_ex_new_index(l, p, newf, dupf, freef) \
     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)
index bcb012f..db14e22 100644 (file)
@@ -3725,6 +3725,19 @@ size_t SSL_SESSION_get_master_key(const SSL_SESSION *session,
     return outlen;
 }
 
+int SSL_SESSION_set1_master_key(SSL_SESSION *sess, unsigned char *in,
+                                size_t len)
+{
+    if (len > sizeof(sess->master_key))
+        return 0;
+
+    memcpy(sess->master_key, in, len);
+    sess->master_key_length = len;
+
+    return 1;
+}
+
+
 int SSL_set_ex_data(SSL *s, int idx, void *arg)
 {
     return (CRYPTO_set_ex_data(&s->ex_data, idx, arg));
index 959e134..25e0750 100644 (file)
@@ -456,3 +456,4 @@ SSL_set_psk_use_session_callback        456 1_1_1   EXIST::FUNCTION:
 SSL_CTX_set_psk_use_session_callback    457    1_1_1   EXIST::FUNCTION:
 SSL_CTX_set_psk_find_session_callback   458    1_1_1   EXIST::FUNCTION:
 SSL_CIPHER_get_handshake_digest         459    1_1_1   EXIST::FUNCTION:
+SSL_SESSION_set1_master_key             460    1_1_1   EXIST::FUNCTION: