Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject the stream socket's data pool into the encryption mechanism for it to use when allocating blob buffers #213

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions groups/ntc/ntcd/ntcd_encryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,18 @@ ntsa::Error EncryptionClient::createEncryption(
return ntsa::Error();
}

ntsa::Error EncryptionClient::createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
const bsl::shared_ptr<ntci::DataPool>& dataPool,
bslma::Allocator* basicAllocator)
{
NTCCFG_WARNING_UNUSED(result);
NTCCFG_WARNING_UNUSED(dataPool);
NTCCFG_WARNING_UNUSED(basicAllocator);

return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

EncryptionServer::EncryptionServer(
const ntca::EncryptionServerOptions& options,
bslma::Allocator* basicAllocator)
Expand Down Expand Up @@ -1804,6 +1816,18 @@ ntsa::Error EncryptionServer::createEncryption(
return ntsa::Error();
}

ntsa::Error EncryptionServer::createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
const bsl::shared_ptr<ntci::DataPool>& dataPool,
bslma::Allocator* basicAllocator)
{
NTCCFG_WARNING_UNUSED(result);
NTCCFG_WARNING_UNUSED(dataPool);
NTCCFG_WARNING_UNUSED(basicAllocator);

return ntsa::Error(ntsa::Error::e_NOT_IMPLEMENTED);
}

EncryptionDriver::EncryptionDriver(bslma::Allocator* basicAllocator)
: d_allocator_p(bslma::Default::allocator(basicAllocator))
{
Expand Down
20 changes: 20 additions & 0 deletions groups/ntc/ntcd/ntcd_encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,16 @@ class EncryptionClient : public ntci::EncryptionClient
ntsa::Error createEncryption(bsl::shared_ptr<ntci::Encryption>* result,
bslma::Allocator* basicAllocator = 0)
BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'result' a new client-side encryption session.
/// Allocate blob buffers from the specified 'dataPool'. Optionally specify
/// a 'basicAllocator' used to supply memory. If 'basicAllocator' is 0, the
/// currently installed default allocator is used. Return the error.
ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
const bsl::shared_ptr<ntci::DataPool>& dataPool,
bslma::Allocator* basicAllocator = 0)
BSLS_KEYWORD_OVERRIDE;
};

/// @internal @brief
Expand Down Expand Up @@ -754,6 +764,16 @@ class EncryptionServer : public ntci::EncryptionServer
virtual ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
bslma::Allocator* basicAllocator = 0) BSLS_KEYWORD_OVERRIDE;

/// Load into the specified 'result' a new server-side encryption session.
/// Allocate blob buffers from the specified 'dataPool'. Optionally specify
/// a 'basicAllocator' used to supply memory. If 'basicAllocator' is 0, the
/// currently installed default allocator is used. Return the error.
ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
const bsl::shared_ptr<ntci::DataPool>& dataPool,
bslma::Allocator* basicAllocator = 0)
BSLS_KEYWORD_OVERRIDE;
};

/// @internal @brief
Expand Down
10 changes: 10 additions & 0 deletions groups/ntc/ntci/ntci_encryptionclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
BSLS_IDENT("$Id: $")

#include <ntccfg_platform.h>
#include <ntci_datapool.h>
#include <ntci_encryption.h>
#include <ntcscm_version.h>
#include <bsl_iosfwd.h>
Expand Down Expand Up @@ -54,6 +55,15 @@ class EncryptionClient
virtual ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
bslma::Allocator* basicAllocator = 0) = 0;

/// Load into the specified 'result' a new client-side encryption session.
/// Allocate blob buffers from the specified 'dataPool'. Optionally specify
/// a 'basicAllocator' used to supply memory. If 'basicAllocator' is 0, the
/// currently installed default allocator is used. Return the error.
virtual ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
const bsl::shared_ptr<ntci::DataPool>& dataPool,
bslma::Allocator* basicAllocator = 0) = 0;
};

} // end namespace ntci
Expand Down
12 changes: 11 additions & 1 deletion groups/ntc/ntci/ntci_encryptionserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
BSLS_IDENT("$Id: $")

#include <ntccfg_platform.h>
#include <ntci_datapool.h>
#include <ntci_encryption.h>
#include <ntcscm_version.h>
#include <bsl_memory.h>
Expand Down Expand Up @@ -47,13 +48,22 @@ class EncryptionServer
/// Destroy this object.
virtual ~EncryptionServer();

/// Load into the specified 'result' a new client-side encryption
/// Load into the specified 'result' a new server-side encryption
/// session. Optionally specify a 'basicAllocator' used to supply
/// memory. If 'basicAllocator' is 0, the currently installed default
/// allocator is used. Return the error.
virtual ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
bslma::Allocator* basicAllocator = 0) = 0;

/// Load into the specified 'result' a new server-side encryption session.
/// Allocate blob buffers from the specified 'dataPool'. Optionally specify
/// a 'basicAllocator' used to supply memory. If 'basicAllocator' is 0, the
/// currently installed default allocator is used. Return the error.
virtual ntsa::Error createEncryption(
bsl::shared_ptr<ntci::Encryption>* result,
const bsl::shared_ptr<ntci::DataPool>& dataPool,
bslma::Allocator* basicAllocator = 0) = 0;
};

} // end namespace ntci
Expand Down
6 changes: 4 additions & 2 deletions groups/ntc/ntcp/ntcp_streamsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4192,7 +4192,8 @@ ntsa::Error StreamSocket::upgrade(
ntsa::Error error;

bsl::shared_ptr<ntci::Encryption> encryption;
error = encryptionClient->createEncryption(&encryption, d_allocator_p);
error = encryptionClient->createEncryption(
&encryption, d_dataPool_sp, d_allocator_p);
if (error) {
return error;
}
Expand All @@ -4218,7 +4219,8 @@ ntsa::Error StreamSocket::upgrade(
ntsa::Error error;

bsl::shared_ptr<ntci::Encryption> encryption;
error = encryptionServer->createEncryption(&encryption, d_allocator_p);
error = encryptionServer->createEncryption(
&encryption, d_dataPool_sp, d_allocator_p);
if (error) {
return error;
}
Expand Down
6 changes: 4 additions & 2 deletions groups/ntc/ntcr/ntcr_streamsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5258,7 +5258,8 @@ ntsa::Error StreamSocket::upgrade(
ntsa::Error error;

bsl::shared_ptr<ntci::Encryption> encryption;
error = encryptionClient->createEncryption(&encryption, d_allocator_p);
error = encryptionClient->createEncryption(
&encryption, d_dataPool_sp, d_allocator_p);
if (error) {
return error;
}
Expand All @@ -5284,7 +5285,8 @@ ntsa::Error StreamSocket::upgrade(
ntsa::Error error;

bsl::shared_ptr<ntci::Encryption> encryption;
error = encryptionServer->createEncryption(&encryption, d_allocator_p);
error = encryptionServer->createEncryption(
&encryption, d_dataPool_sp, d_allocator_p);
if (error) {
return error;
}
Expand Down
Loading