Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / quic / crypto / ephemeral_key_source.h
blob2700be0fe1b289f18b2843f9ba2d41348615431c
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_EPHEMERAL_KEY_SOURCE_H_
6 #define NET_QUIC_CRYPTO_EPHEMERAL_KEY_SOURCE_H_
8 #include <string>
10 #include "base/strings/string_piece.h"
11 #include "net/base/net_export.h"
12 #include "net/quic/quic_time.h"
14 namespace net {
16 class KeyExchange;
17 class QuicRandom;
19 // EphemeralKeySource manages and rotates ephemeral keys as they can be reused
20 // for several connections in a short space of time. Since the implementation
21 // of this may involve locking or thread-local data, this interface abstracts
22 // that away.
23 class NET_EXPORT_PRIVATE EphemeralKeySource {
24 public:
25 virtual ~EphemeralKeySource() {}
27 // CalculateForwardSecureKey generates an ephemeral public/private key pair
28 // using the algorithm |key_exchange|, sets |*public_value| to the public key
29 // and returns the shared key between |peer_public_value| and the private
30 // key. |*public_value| will be sent to the peer to be used with the peer's
31 // private key.
32 virtual std::string CalculateForwardSecureKey(
33 const KeyExchange* key_exchange,
34 QuicRandom* rand,
35 QuicTime now,
36 base::StringPiece peer_public_value,
37 std::string* public_value) = 0;
40 } // namespace net
42 #endif // NET_QUIC_CRYPTO_EPHEMERAL_KEY_SOURCE_H_