OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_CRYPTO_QUIC_DECRYPTER_H_ | 5 #ifndef NET_QUIC_CRYPTO_QUIC_DECRYPTER_H_ |
6 #define NET_QUIC_CRYPTO_QUIC_DECRYPTER_H_ | 6 #define NET_QUIC_CRYPTO_QUIC_DECRYPTER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // | 49 // |
50 // If this function is called, neither |SetKey| nor |SetNoncePrefix| may be | 50 // If this function is called, neither |SetKey| nor |SetNoncePrefix| may be |
51 // called. | 51 // called. |
52 virtual bool SetPreliminaryKey(base::StringPiece key) = 0; | 52 virtual bool SetPreliminaryKey(base::StringPiece key) = 0; |
53 | 53 |
54 // SetDiversificationNonce uses |nonce| to derive final keys based on the | 54 // SetDiversificationNonce uses |nonce| to derive final keys based on the |
55 // input keying material given by calling |SetPreliminaryKey|. | 55 // input keying material given by calling |SetPreliminaryKey|. |
56 // | 56 // |
57 // Calling this function is a no-op if |SetPreliminaryKey| hasn't been | 57 // Calling this function is a no-op if |SetPreliminaryKey| hasn't been |
58 // called. | 58 // called. |
59 virtual bool SetDiversificationNonce(DiversificationNonce nonce) = 0; | 59 virtual bool SetDiversificationNonce(const DiversificationNonce& nonce) = 0; |
60 | 60 |
61 // Populates |output| with the decrypted |ciphertext| and populates | 61 // Populates |output| with the decrypted |ciphertext| and populates |
62 // |output_length| with the length. Returns 0 if there is an error. | 62 // |output_length| with the length. Returns 0 if there is an error. |
63 // |output| size is specified by |max_output_length| and must be | 63 // |output| size is specified by |max_output_length| and must be |
64 // at least as large as the ciphertext. |packet_number| is | 64 // at least as large as the ciphertext. |packet_number| is |
65 // appended to the |nonce_prefix| value provided in SetNoncePrefix() | 65 // appended to the |nonce_prefix| value provided in SetNoncePrefix() |
66 // to form the nonce. | 66 // to form the nonce. |
67 // TODO(wtc): add a way for DecryptPacket to report decryption failure due | 67 // TODO(wtc): add a way for DecryptPacket to report decryption failure due |
68 // to non-authentic inputs, as opposed to other reasons for failure. | 68 // to non-authentic inputs, as opposed to other reasons for failure. |
69 virtual bool DecryptPacket(QuicPathId path_id, | 69 virtual bool DecryptPacket(QuicPathId path_id, |
70 QuicPacketNumber packet_number, | 70 QuicPacketNumber packet_number, |
71 base::StringPiece associated_data, | 71 base::StringPiece associated_data, |
72 base::StringPiece ciphertext, | 72 base::StringPiece ciphertext, |
73 char* output, | 73 char* output, |
74 size_t* output_length, | 74 size_t* output_length, |
75 size_t max_output_length) = 0; | 75 size_t max_output_length) = 0; |
76 | 76 |
77 // The name of the cipher. | 77 // The name of the cipher. |
78 virtual const char* cipher_name() const = 0; | 78 virtual const char* cipher_name() const = 0; |
79 // The ID of the cipher. Return 0x03000000 ORed with the 'cryptographic suite | 79 // The ID of the cipher. Return 0x03000000 ORed with the 'cryptographic suite |
80 // selector'. | 80 // selector'. |
81 virtual uint32_t cipher_id() const = 0; | 81 virtual uint32_t cipher_id() const = 0; |
82 | 82 |
83 // For use by unit tests only. | 83 // For use by unit tests only. |
84 virtual base::StringPiece GetKey() const = 0; | 84 virtual base::StringPiece GetKey() const = 0; |
85 virtual base::StringPiece GetNoncePrefix() const = 0; | 85 virtual base::StringPiece GetNoncePrefix() const = 0; |
86 | 86 |
87 static void DiversifyPreliminaryKey(base::StringPiece preliminary_key, | 87 static void DiversifyPreliminaryKey(base::StringPiece preliminary_key, |
88 base::StringPiece nonce_prefix, | 88 base::StringPiece nonce_prefix, |
89 DiversificationNonce nonce, | 89 const DiversificationNonce& nonce, |
90 size_t key_size, | 90 size_t key_size, |
91 size_t nonce_prefix_size, | 91 size_t nonce_prefix_size, |
92 std::string* out_key, | 92 std::string* out_key, |
93 std::string* out_nonce_prefix); | 93 std::string* out_nonce_prefix); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace net | 96 } // namespace net |
97 | 97 |
98 #endif // NET_QUIC_CRYPTO_QUIC_DECRYPTER_H_ | 98 #endif // NET_QUIC_CRYPTO_QUIC_DECRYPTER_H_ |
OLD | NEW |