1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_
6 #define NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_
11 #include "base/logging.h"
12 #include "base/stl_util.h"
13 #include "base/strings/string_piece.h"
14 #include "net/base/net_export.h"
15 #include "net/quic/crypto/crypto_protocol.h"
19 // QuicServerConfigProtobuf contains QUIC server config block and the private
20 // keys needed to prove ownership.
21 // TODO(rch): sync with server more rationally.
22 class NET_EXPORT_PRIVATE QuicServerConfigProtobuf
{
24 // PrivateKey contains a QUIC tag of a key exchange algorithm and a
25 // serialised private key for that algorithm. The format of the serialised
26 // private key is specific to the algorithm in question.
27 class NET_EXPORT_PRIVATE PrivateKey
{
32 void set_tag(QuicTag tag
) {
35 std::string
private_key() const {
38 void set_private_key(std::string key
) {
44 std::string private_key_
;
47 QuicServerConfigProtobuf();
48 ~QuicServerConfigProtobuf();
50 size_t key_size() const {
54 const PrivateKey
& key(size_t i
) const {
55 DCHECK_GT(keys_
.size(), i
);
59 std::string
config() const {
63 void set_config(base::StringPiece config
) {
64 config_
= config
.as_string();
67 QuicServerConfigProtobuf::PrivateKey
* add_key() {
68 keys_
.push_back(new PrivateKey
);
73 STLDeleteElements(&keys_
);
76 bool has_primary_time() const {
77 return primary_time_
> 0;
80 int64
primary_time() const {
84 void set_primary_time(int64 primary_time
) {
85 primary_time_
= primary_time
;
88 bool has_priority() const {
92 int64
priority() const {
96 void set_priority(int64 priority
) {
101 std::vector
<PrivateKey
*> keys_
;
103 // config_ is a serialised config in QUIC wire format.
106 // primary_time_ contains a UNIX epoch seconds value that indicates when this
107 // config should become primary.
110 // Relative priority of this config vs other configs with the same
111 // primary time. For use as a secondary sort key when selecting the
118 #endif // NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_PROTOBUF_H_