Coverage Report

Created: 2025-11-03 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boringssl/ssl/s3_lib.cc
Line
Count
Source
1
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2
// Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
3
// Copyright 2005 Nokia. All rights reserved.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
//     https://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#include <openssl/ssl.h>
18
19
#include <assert.h>
20
#include <string.h>
21
22
#include <openssl/digest.h>
23
#include <openssl/err.h>
24
#include <openssl/md5.h>
25
#include <openssl/mem.h>
26
#include <openssl/nid.h>
27
28
#include "../crypto/internal.h"
29
#include "internal.h"
30
31
32
BSSL_NAMESPACE_BEGIN
33
34
SSL3_STATE::SSL3_STATE()
35
118k
    : skip_early_data(false),
36
118k
      v2_hello_done(false),
37
118k
      is_v2_hello(false),
38
118k
      has_message(false),
39
118k
      initial_handshake_complete(false),
40
118k
      session_reused(false),
41
118k
      send_connection_binding(false),
42
118k
      channel_id_valid(false),
43
118k
      key_update_pending(false),
44
118k
      early_data_accepted(false),
45
118k
      alert_dispatch(false),
46
118k
      renegotiate_pending(false),
47
118k
      used_hello_retry_request(false),
48
118k
      was_key_usage_invalid(false) {}
49
50
118k
SSL3_STATE::~SSL3_STATE() {}
51
52
118k
bool tls_new(SSL *ssl) {
53
118k
  UniquePtr<SSL3_STATE> s3 = MakeUnique<SSL3_STATE>();
54
118k
  if (!s3) {
55
0
    return false;
56
0
  }
57
58
  // TODO(crbug.com/368805255): Fields that aren't used in DTLS should not be
59
  // allocated at all.
60
  // TODO(crbug.com/371998381): Don't create these in QUIC either, once the
61
  // placeholder QUIC ones for subsequent epochs are removed.
62
118k
  if (!SSL_is_dtls(ssl)) {
63
77.2k
    s3->aead_read_ctx = SSLAEADContext::CreateNullCipher();
64
77.2k
    s3->aead_write_ctx = SSLAEADContext::CreateNullCipher();
65
77.2k
    if (!s3->aead_read_ctx || !s3->aead_write_ctx) {
66
0
      return false;
67
0
    }
68
77.2k
  }
69
70
118k
  s3->hs = ssl_handshake_new(ssl);
71
118k
  if (!s3->hs) {
72
0
    return false;
73
0
  }
74
75
118k
  ssl->s3 = s3.release();
76
118k
  return true;
77
118k
}
78
79
118k
void tls_free(SSL *ssl) {
80
118k
  if (ssl->s3 == nullptr) {
81
0
    return;
82
0
  }
83
84
118k
  Delete(ssl->s3);
85
118k
  ssl->s3 = nullptr;
86
118k
}
87
88
BSSL_NAMESPACE_END