Commit da0573cd authored by Juan Jose Lopez Jaimez's avatar Juan Jose Lopez Jaimez Committed by Commit Bot

Modify Create method of QuicEncrypter and QuicDecrypter to return a unique_ptr

Bug: 479898
Change-Id: I4c2030c8e38532a7de391360daf758dfcd1bc530
Reviewed-on: https://chromium-review.googlesource.com/820563Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523644}
parent bdae5196
...@@ -94,8 +94,8 @@ bool CryptoUtils::DeriveKeys(QuicStringPiece premaster_secret, ...@@ -94,8 +94,8 @@ bool CryptoUtils::DeriveKeys(QuicStringPiece premaster_secret,
Diversification diversification, Diversification diversification,
CrypterPair* crypters, CrypterPair* crypters,
string* subkey_secret) { string* subkey_secret) {
crypters->encrypter.reset(QuicEncrypter::Create(aead)); crypters->encrypter = QuicEncrypter::Create(aead);
crypters->decrypter.reset(QuicDecrypter::Create(aead)); crypters->decrypter = QuicDecrypter::Create(aead);
size_t key_bytes = crypters->encrypter->GetKeySize(); size_t key_bytes = crypters->encrypter->GetKeySize();
size_t nonce_prefix_bytes = crypters->encrypter->GetNoncePrefixSize(); size_t nonce_prefix_bytes = crypters->encrypter->GetNoncePrefixSize();
size_t subkey_secret_bytes = size_t subkey_secret_bytes =
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
namespace net { namespace net {
// static // static
QuicDecrypter* QuicDecrypter::Create(QuicTag algorithm) { std::unique_ptr<QuicDecrypter> QuicDecrypter::Create(QuicTag algorithm) {
switch (algorithm) { switch (algorithm) {
case kAESG: case kAESG:
return new Aes128Gcm12Decrypter(); return std::make_unique<Aes128Gcm12Decrypter>();
case kCC20: case kCC20:
return new ChaCha20Poly1305Decrypter(); return std::make_unique<ChaCha20Poly1305Decrypter>();
default: default:
QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm; QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm;
return nullptr; return nullptr;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <memory>
#include "net/quic/core/quic_packets.h" #include "net/quic/core/quic_packets.h"
#include "net/quic/platform/api/quic_export.h" #include "net/quic/platform/api/quic_export.h"
...@@ -18,7 +19,7 @@ class QUIC_EXPORT_PRIVATE QuicDecrypter { ...@@ -18,7 +19,7 @@ class QUIC_EXPORT_PRIVATE QuicDecrypter {
public: public:
virtual ~QuicDecrypter() {} virtual ~QuicDecrypter() {}
static QuicDecrypter* Create(QuicTag algorithm); static std::unique_ptr<QuicDecrypter> Create(QuicTag algorithm);
// Creates an IETF QuicDecrypter based on |cipher_suite| which must be an id // Creates an IETF QuicDecrypter based on |cipher_suite| which must be an id
// returned by SSL_CIPHER_get_id. The caller is responsible for taking // returned by SSL_CIPHER_get_id. The caller is responsible for taking
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
namespace net { namespace net {
// static // static
QuicEncrypter* QuicEncrypter::Create(QuicTag algorithm) { std::unique_ptr<QuicEncrypter> QuicEncrypter::Create(QuicTag algorithm) {
switch (algorithm) { switch (algorithm) {
case kAESG: case kAESG:
return new Aes128Gcm12Encrypter(); return std::make_unique<Aes128Gcm12Encrypter>();
case kCC20: case kCC20:
return new ChaCha20Poly1305Encrypter(); return std::make_unique<ChaCha20Poly1305Encrypter>();
default: default:
QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm; QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm;
return nullptr; return nullptr;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define NET_QUIC_CORE_CRYPTO_QUIC_ENCRYPTER_H_ #define NET_QUIC_CORE_CRYPTO_QUIC_ENCRYPTER_H_
#include <cstddef> #include <cstddef>
#include <memory>
#include "net/quic/core/quic_packets.h" #include "net/quic/core/quic_packets.h"
#include "net/quic/platform/api/quic_export.h" #include "net/quic/platform/api/quic_export.h"
...@@ -17,7 +18,7 @@ class QUIC_EXPORT_PRIVATE QuicEncrypter { ...@@ -17,7 +18,7 @@ class QUIC_EXPORT_PRIVATE QuicEncrypter {
public: public:
virtual ~QuicEncrypter() {} virtual ~QuicEncrypter() {}
static QuicEncrypter* Create(QuicTag algorithm); static std::unique_ptr<QuicEncrypter> Create(QuicTag algorithm);
// Creates an IETF QuicEncrypter based on |cipher_suite| which must be an id // Creates an IETF QuicEncrypter based on |cipher_suite| which must be an id
// returned by SSL_CIPHER_get_id. The caller is responsible for taking // returned by SSL_CIPHER_get_id. The caller is responsible for taking
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment