File: ssl_cipher_suite_names.h

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (84 lines) | stat: -rw-r--r-- 3,382 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_SSL_SSL_CIPHER_SUITE_NAMES_H_
#define NET_SSL_SSL_CIPHER_SUITE_NAMES_H_

#include <stdint.h>

#include <string>

#include "net/base/net_export.h"

namespace net {

// SSLCipherSuiteToStrings returns three strings for a given cipher suite
// number, the name of the key exchange algorithm, the name of the cipher and
// the name of the MAC. The cipher suite number is the number as sent on the
// wire and recorded at
// http://www.iana.org/assignments/tls-parameters/tls-parameters.xml
// If the cipher suite is unknown, the strings are set to "???".
// In the case of an AEAD cipher suite, *mac_str is nullptr and *is_aead is
// true.
// In the case of a TLS 1.3 AEAD-only cipher suite, *key_exchange_str is nullptr
// and *is_tls13 is true.
NET_EXPORT void SSLCipherSuiteToStrings(const char** key_exchange_str,
                                        const char** cipher_str,
                                        const char** mac_str,
                                        bool* is_aead,
                                        bool* is_tls13,
                                        uint16_t cipher_suite);

// SSLVersionToString returns the name of the SSL protocol version
// specified by |ssl_version|, which is defined in
// net/ssl/ssl_connection_status_flags.h.
// If the version is unknown, |name| is set to "???".
NET_EXPORT void SSLVersionToString(const char** name, int ssl_version);

// Parses a string literal that represents a SSL/TLS cipher suite.
//
// Supported literal forms:
//   0xAABB, where AA is cipher_suite[0] and BB is cipher_suite[1], as
//     defined in RFC 2246, Section 7.4.1.2. Unrecognized but parsable cipher
//     suites in this form will not return an error.
//
// Returns true if the cipher suite was successfully parsed, storing the
// result in |cipher_suite|.
//
// TODO(rsleevi): Support the full strings defined in the IANA TLS parameters
// list.
NET_EXPORT bool ParseSSLCipherString(const std::string& cipher_string,
                                     uint16_t* cipher_suite);

// Mask definitions for an integer that holds obsolete SSL setting details.
enum ObsoleteSSLMask {
  OBSOLETE_SSL_NONE = 0,  // Modern SSL
  OBSOLETE_SSL_MASK_PROTOCOL = 1 << 0,
  OBSOLETE_SSL_MASK_KEY_EXCHANGE = 1 << 1,
  OBSOLETE_SSL_MASK_CIPHER = 1 << 2,
  OBSOLETE_SSL_MASK_SIGNATURE = 1 << 3,
};

// Takes the given |connection_status| and |signature_algorithm| and returns a
// bitmask indicating which settings do not meet modern best-practice security
// standards - that is, which ones are "obsolete".
//
// Currently, this function uses the following criteria to determine what is
// obsolete:
//
// - Protocol: less than TLS 1.2
// - Key exchange: Does not use ECDHE-based key exchanges authenticated by a
//   certificate
// - Cipher: not an AEAD cipher
// - Signature algorithm: MD5 or SHA-1
NET_EXPORT int ObsoleteSSLStatus(int connection_status,
                                 uint16_t signature_algorithm);

// Returns true if |cipher_suite| is suitable for use with HTTP/2. See
// https://http2.github.io/http2-spec/#rfc.section.9.2.2.
NET_EXPORT bool IsTLSCipherSuiteAllowedByHTTP2(uint16_t cipher_suite);

}  // namespace net

#endif  // NET_SSL_SSL_CIPHER_SUITE_NAMES_H_