Add SSL_SESSION_set1_id.

This matches the OpenSSL 1.1.0 spelling. I'd thought we could hide
SSL_SESSION this pass, but I missed one test that messed with session
IDs!

Bug: 6
Change-Id: I84ea113353eb0eaa2b06b68dec71cb9061c047ca
Reviewed-on: https://boringssl-review.googlesource.com/28866
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/ssl_session.cc b/ssl/ssl_session.cc
index e31df68..edf08b2 100644
--- a/ssl/ssl_session.cc
+++ b/ssl/ssl_session.cc
@@ -901,6 +901,19 @@
   return session->session_id;
 }
 
+int SSL_SESSION_set1_id(SSL_SESSION *session, const uint8_t *sid,
+                        size_t sid_len) {
+  if (sid_len > SSL_MAX_SSL_SESSION_ID_LENGTH) {
+    OPENSSL_PUT_ERROR(SSL, SSL_R_SSL_SESSION_ID_TOO_LONG);
+    return 0;
+  }
+
+  // Use memmove in case someone passes in the output of |SSL_SESSION_get_id|.
+  OPENSSL_memmove(session->session_id, sid, sid_len);
+  session->session_id_length = sid_len;
+  return 1;
+}
+
 uint32_t SSL_SESSION_get_timeout(const SSL_SESSION *session) {
   return session->timeout;
 }