13 #include <dds/DdsDcpsCoreTypeSupportImpl.h>    15 #include <openssl/evp.h>    16 #include <openssl/rand.h>    17 #include <openssl/err.h>    18 #include "../OpenSSL_legacy.h"      30 using DCPS::Serializer;
    48   std::vector<unsigned char> 
hash;
    51   if (result == 0 && hash.size() >= 6) {
    52     unsigned char* bytes = 
reinterpret_cast<unsigned char*
>(&dst);
    54     for (
size_t i = 0; i < 6; ++i) {  
    62     unsigned char hash2[EVP_MAX_MD_SIZE] = {0};
    63     unsigned int len = 0u;
    67       EVP_DigestInit_ex(hash_ctx, EVP_sha256(), 0);
    69       EVP_DigestFinal_ex(hash_ctx, hash2, &len);
    71         std::memcpy(bytes + 6, hash2, 6);
    83 template <
size_t Bits>
    88   unsigned char tmp[Bits / 8] = { 0 };
    90   if (RAND_bytes(tmp, 
sizeof tmp) == 1) {
    91     nonce.insert(nonce.begin(), tmp, tmp + 
sizeof tmp);
    96     unsigned long err = ERR_get_error();
    97     char msg[256] = { 0 };
    98     ERR_error_string_n(err, msg, 
sizeof(msg));
   101                ACE_TEXT(
"(%P|%t) SSL::make_nonce: ERROR '%C' returned by RAND_bytes(...)\n"),
   110   return make_nonce<256>(nonce);
   116   std::vector<unsigned char> tmp;
   117   int err = make_nonce<256>(tmp);
   119     nonce.length(static_cast<unsigned int>(tmp.size()));
   120     for (
size_t i = 0; i < tmp.size(); ++i) {
   121       nonce[
static_cast<unsigned int>(i)] = tmp[i];
   129   return (array[i] >> 1) | (i == 0 ? 0 : ((array[i - 1] & 1) ? 0x80 : 0));
   140   EVP_DigestInit_ex(hash_ctx, EVP_sha256(), 0);
   142   unsigned char hash[EVP_MAX_MD_SIZE] = { 0 };
   143   unsigned int len = 0u;
   145   std::vector<const DDS::OctetSeq*>::const_iterator i, n = src.end();
   146   for (i = src.begin(); i != n; ++i) {
   147     EVP_DigestUpdate(hash_ctx, (*i)->get_buffer(), (*i)->length());
   150   EVP_DigestFinal_ex(hash_ctx, hash, &len);
   153   std::memcpy(dst.get_buffer(), 
hash, len);
   182     EVP_DigestInit_ex(
hash_ctx, EVP_sha256(), 0);
   189     if (serializer << src) {
   192       dst.length(EVP_MAX_MD_SIZE);
   194       unsigned int newlen = 0u;
   195       EVP_DigestFinal_ex(
hash_ctx, dst.get_buffer(), &newlen);
   201                  ACE_TEXT(
"(%P|%t) SSL::hash_serialized_impl::operator(): ERROR, failed to "   202                           "serialize binary-property-sequence\n")));
   217   return hash(src, dst);
   228   tmp.length(static_cast<unsigned int>(size));
   232   if (!(serializer << src)) {
   234                ACE_TEXT(
"(%P|%t) SSL::sign_serialized: ERROR, failed to serialize "   235                         "binary-property-sequence\n")));
   240   std::vector<const DDS::OctetSeq*> sign_these;
   241   sign_these.push_back(&tmp);
   243   return key.
sign(sign_these, dst);
   255   tmp.length(static_cast<unsigned int>(size));
   259   if (!(serializer << src)) {
   261                ACE_TEXT(
"(%P|%t) SSL::verify_serialized: ERROR, failed to serialize binary-property-sequence\n")));
   266   std::vector<const DDS::OctetSeq*> verify_these;
   267   verify_these.push_back(&tmp);
 int make_adjusted_guid(const OpenDDS::DCPS::GUID_t &src, OpenDDS::DCPS::GUID_t &dst, const Certificate &target)
 
sequence< octet > OctetSeq
 
size_t length(void) const
 
#define OPENDDS_SSL_LOG_ERR(MSG)
 
int hash(const std::vector< const DDS::OctetSeq *> &src, DDS::OctetSeq &dst)
 
char * rd_ptr(void) const
 
int verify_serialized(const DDS::BinaryPropertySeq &src, const Certificate &key, const DDS::OctetSeq &signed_data)
 
int sign_serialized(const DDS::BinaryPropertySeq &src, const PrivateKey &key, DDS::OctetSeq &dst)
 
int verify_signature(const DDS::OctetSeq &src, const std::vector< const DDS::OctetSeq *> &expected_contents) const
 
void serialized_size(const Encoding &encoding, size_t &size, const XTypes::TypeLookup_getTypes_In &stru)
 
int sign(const std::vector< const DDS::OctetSeq *> &src, DDS::OctetSeq &dst) const
 
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
 
int make_nonce_256(std::vector< unsigned char > &nonce)
 
int make_nonce(std::vector< unsigned char > &nonce)
 
sequence< BinaryProperty_t > BinaryPropertySeq
 
int hash_serialized(const DDS::BinaryPropertySeq &src, DDS::OctetSeq &dst)
 
int subject_name_digest(std::vector< CORBA::Octet > &dst) const
 
unsigned char offset_1bit(const unsigned char array[], size_t i)
Gets byte from array as though it were shifted right one bit. 
 
The Internal API and Implementation of OpenDDS. 
 
Class to serialize and deserialize data for DDS. 
 
const DCPS::Encoding encoding(DCPS::Encoding::KIND_UNALIGNED_CDR, DCPS::ENDIAN_BIG)
 
const GUID_t GUID_UNKNOWN
Nil value for GUID. 
 
int operator()(const DDS::BinaryPropertySeq &src, DDS::OctetSeq &dst)