OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Attributes | List of all members
OpenDDS::Security::SSL::hash_serialized_impl Class Reference

Public Member Functions

 hash_serialized_impl ()
 
 ~hash_serialized_impl ()
 
int operator() (const DDS::BinaryPropertySeq &src, DDS::OctetSeq &dst)
 

Private Attributes

EVP_MD_CTX * hash_ctx
 

Detailed Description

Definition at line 160 of file security/SSL/Utils.cpp.

Constructor & Destructor Documentation

◆ hash_serialized_impl()

OpenDDS::Security::SSL::hash_serialized_impl::hash_serialized_impl ( )
inline

Definition at line 163 of file security/SSL/Utils.cpp.

References hash_ctx, and OPENDDS_SSL_LOG_ERR.

165  {
166  if (!hash_ctx) {
167  OPENDDS_SSL_LOG_ERR("EVP_MD_CTX_new failed");
168  }
169  }
#define EVP_MD_CTX_new
#define OPENDDS_SSL_LOG_ERR(MSG)
Definition: Err.h:12

◆ ~hash_serialized_impl()

OpenDDS::Security::SSL::hash_serialized_impl::~hash_serialized_impl ( )
inline

Definition at line 171 of file security/SSL/Utils.cpp.

References EVP_MD_CTX_free, and hash_ctx.

172  {
173  if (hash_ctx) {
175  }
176  }
#define EVP_MD_CTX_free

Member Function Documentation

◆ operator()()

int OpenDDS::Security::SSL::hash_serialized_impl::operator() ( const DDS::BinaryPropertySeq &  src,
DDS::OctetSeq dst 
)
inline

Definition at line 178 of file security/SSL/Utils.cpp.

References ACE_ERROR, ACE_TEXT(), OpenDDS::STUN::encoding(), hash_ctx, ACE_Message_Block::length(), LM_ERROR, ACE_Message_Block::rd_ptr(), and OpenDDS::DCPS::serialized_size().

179  {
180  if (!hash_ctx) return 1;
181 
182  EVP_DigestInit_ex(hash_ctx, EVP_sha256(), 0);
183 
184  const Encoding encoding = get_common_encoding();
185  size_t size = 0;
186  serialized_size(encoding, size, src);
187  ACE_Message_Block buffer(size);
188  Serializer serializer(&buffer, encoding);
189  if (serializer << src) {
190  EVP_DigestUpdate(hash_ctx, buffer.rd_ptr(), buffer.length());
191 
192  dst.length(EVP_MAX_MD_SIZE);
193 
194  unsigned int newlen = 0u;
195  EVP_DigestFinal_ex(hash_ctx, dst.get_buffer(), &newlen);
196 
197  dst.length(newlen);
198 
199  } else {
200  ACE_ERROR((LM_ERROR,
201  ACE_TEXT("(%P|%t) SSL::hash_serialized_impl::operator(): ERROR, failed to "
202  "serialize binary-property-sequence\n")));
203 
204  return 1;
205  }
206 
207  return 0;
208  }
#define ACE_ERROR(X)
void serialized_size(const Encoding &encoding, size_t &size, const SequenceNumber &)
ACE_TEXT("TCP_Factory")
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)

Member Data Documentation

◆ hash_ctx

EVP_MD_CTX* OpenDDS::Security::SSL::hash_serialized_impl::hash_ctx
private

Definition at line 211 of file security/SSL/Utils.cpp.

Referenced by hash_serialized_impl(), operator()(), and ~hash_serialized_impl().


The documentation for this class was generated from the following file: