| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_AEAD_BASE_DECRYPTER_H_ | 5 #ifndef NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_ |
| 6 #define NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_ | 6 #define NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "net/quic/crypto/quic_decrypter.h" | 9 #include "net/quic/crypto/quic_decrypter.h" |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 PK11_DecryptFunction pk11_decrypt, | 35 PK11_DecryptFunction pk11_decrypt, |
| 36 size_t key_size, | 36 size_t key_size, |
| 37 size_t auth_tag_size, | 37 size_t auth_tag_size, |
| 38 size_t nonce_prefix_size); | 38 size_t nonce_prefix_size); |
| 39 #endif | 39 #endif |
| 40 ~AeadBaseDecrypter() override; | 40 ~AeadBaseDecrypter() override; |
| 41 | 41 |
| 42 // QuicDecrypter implementation | 42 // QuicDecrypter implementation |
| 43 bool SetKey(base::StringPiece key) override; | 43 bool SetKey(base::StringPiece key) override; |
| 44 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; | 44 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; |
| 45 bool Decrypt(base::StringPiece nonce, | |
| 46 base::StringPiece associated_data, | |
| 47 base::StringPiece ciphertext, | |
| 48 unsigned char* output, | |
| 49 size_t* output_length) override; | |
| 50 QuicData* DecryptPacket(QuicPacketSequenceNumber sequence_number, | 45 QuicData* DecryptPacket(QuicPacketSequenceNumber sequence_number, |
| 51 base::StringPiece associated_data, | 46 base::StringPiece associated_data, |
| 52 base::StringPiece ciphertext) override; | 47 base::StringPiece ciphertext) override; |
| 53 base::StringPiece GetKey() const override; | 48 base::StringPiece GetKey() const override; |
| 54 base::StringPiece GetNoncePrefix() const override; | 49 base::StringPiece GetNoncePrefix() const override; |
| 55 | 50 |
| 56 protected: | 51 protected: |
| 57 // Make these constants available to the subclasses so that the subclasses | 52 // Make these constants available to the subclasses so that the subclasses |
| 58 // can assert at compile time their key_size_ and nonce_prefix_size_ do not | 53 // can assert at compile time their key_size_ and nonce_prefix_size_ do not |
| 59 // exceed the maximum. | 54 // exceed the maximum. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 } data; | 68 } data; |
| 74 }; | 69 }; |
| 75 | 70 |
| 76 virtual void FillAeadParams(base::StringPiece nonce, | 71 virtual void FillAeadParams(base::StringPiece nonce, |
| 77 base::StringPiece associated_data, | 72 base::StringPiece associated_data, |
| 78 size_t auth_tag_size, | 73 size_t auth_tag_size, |
| 79 AeadParams* aead_params) const = 0; | 74 AeadParams* aead_params) const = 0; |
| 80 #endif // !defined(USE_OPENSSL) | 75 #endif // !defined(USE_OPENSSL) |
| 81 | 76 |
| 82 private: | 77 private: |
| 78 bool Decrypt(base::StringPiece nonce, |
| 79 base::StringPiece associated_data, |
| 80 base::StringPiece ciphertext, |
| 81 unsigned char* output, |
| 82 size_t* output_length); |
| 83 |
| 83 #if defined(USE_OPENSSL) | 84 #if defined(USE_OPENSSL) |
| 84 const EVP_AEAD* const aead_alg_; | 85 const EVP_AEAD* const aead_alg_; |
| 85 #else | 86 #else |
| 86 const CK_MECHANISM_TYPE aead_mechanism_; | 87 const CK_MECHANISM_TYPE aead_mechanism_; |
| 87 const PK11_DecryptFunction pk11_decrypt_; | 88 const PK11_DecryptFunction pk11_decrypt_; |
| 88 #endif | 89 #endif |
| 89 const size_t key_size_; | 90 const size_t key_size_; |
| 90 const size_t auth_tag_size_; | 91 const size_t auth_tag_size_; |
| 91 const size_t nonce_prefix_size_; | 92 const size_t nonce_prefix_size_; |
| 92 | 93 |
| 93 // The key. | 94 // The key. |
| 94 unsigned char key_[kMaxKeySize]; | 95 unsigned char key_[kMaxKeySize]; |
| 95 // The nonce prefix. | 96 // The nonce prefix. |
| 96 unsigned char nonce_prefix_[kMaxNoncePrefixSize]; | 97 unsigned char nonce_prefix_[kMaxNoncePrefixSize]; |
| 97 | 98 |
| 98 #if defined(USE_OPENSSL) | 99 #if defined(USE_OPENSSL) |
| 99 ScopedEVPAEADCtx ctx_; | 100 ScopedEVPAEADCtx ctx_; |
| 100 #endif | 101 #endif |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(AeadBaseDecrypter); | 103 DISALLOW_COPY_AND_ASSIGN(AeadBaseDecrypter); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 } // namespace net | 106 } // namespace net |
| 106 | 107 |
| 107 #endif // NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_ | 108 #endif // NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_ |
| OLD | NEW |