Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: net/quic/crypto/quic_encrypter.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/crypto/quic_decrypter.cc ('k') | net/quic/crypto/quic_encrypter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #ifndef NET_QUIC_CRYPTO_QUIC_ENCRYPTER_H_
6 #define NET_QUIC_CRYPTO_QUIC_ENCRYPTER_H_
7
8 #include <stddef.h>
9
10 #include "net/base/net_export.h"
11 #include "net/quic/quic_protocol.h"
12
13 namespace net {
14
15 class NET_EXPORT_PRIVATE QuicEncrypter {
16 public:
17 virtual ~QuicEncrypter() {}
18
19 static QuicEncrypter* Create(QuicTag algorithm);
20
21 // Sets the encryption key. Returns true on success, false on failure.
22 //
23 // NOTE: The key is the client_write_key or server_write_key derived from
24 // the master secret.
25 virtual bool SetKey(base::StringPiece key) = 0;
26
27 // Sets the fixed initial bytes of the nonce. Returns true on success,
28 // false on failure.
29 //
30 // NOTE: The nonce prefix is the client_write_iv or server_write_iv
31 // derived from the master secret. A 64-bit packet number will
32 // be appended to form the nonce.
33 //
34 // <------------ 64 bits ----------->
35 // +---------------------+----------------------------------+
36 // | Fixed prefix | packet number |
37 // +---------------------+----------------------------------+
38 // Nonce format
39 //
40 // The security of the nonce format requires that QUIC never reuse a
41 // packet number, even when retransmitting a lost packet.
42 virtual bool SetNoncePrefix(base::StringPiece nonce_prefix) = 0;
43
44 // Writes encrypted |plaintext| and a MAC over |plaintext| and
45 // |associated_data| into output. Sets |output_length| to the number of
46 // bytes written. Returns true on success or false if there was an error.
47 // |packet_number| is appended to the |nonce_prefix| value provided in
48 // SetNoncePrefix() to form the nonce. |output| must not overlap with
49 // |associated_data|. If |output| overlaps with |plaintext| then
50 // |plaintext| must be <= |output|.
51 virtual bool EncryptPacket(QuicPathId path_id,
52 QuicPacketNumber packet_number,
53 base::StringPiece associated_data,
54 base::StringPiece plaintext,
55 char* output,
56 size_t* output_length,
57 size_t max_output_length) = 0;
58
59 // GetKeySize() and GetNoncePrefixSize() tell the HKDF class how many bytes
60 // of key material needs to be derived from the master secret.
61 // NOTE: the sizes returned by GetKeySize() and GetNoncePrefixSize() are
62 // also correct for the QuicDecrypter of the same algorithm. So only
63 // QuicEncrypter has these two methods.
64
65 // Returns the size in bytes of a key for the algorithm.
66 virtual size_t GetKeySize() const = 0;
67 // Returns the size in bytes of the fixed initial part of the nonce.
68 virtual size_t GetNoncePrefixSize() const = 0;
69
70 // Returns the maximum length of plaintext that can be encrypted
71 // to ciphertext no larger than |ciphertext_size|.
72 virtual size_t GetMaxPlaintextSize(size_t ciphertext_size) const = 0;
73
74 // Returns the length of the ciphertext that would be generated by encrypting
75 // to plaintext of size |plaintext_size|.
76 virtual size_t GetCiphertextSize(size_t plaintext_size) const = 0;
77
78 // For use by unit tests only.
79 virtual base::StringPiece GetKey() const = 0;
80 virtual base::StringPiece GetNoncePrefix() const = 0;
81 };
82
83 } // namespace net
84
85 #endif // NET_QUIC_CRYPTO_QUIC_ENCRYPTER_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_decrypter.cc ('k') | net/quic/crypto/quic_encrypter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698