OpenDDS  Snapshot(2023/04/28-20:55)
Classes | Functions
OpenDDS::Security::CommonUtilities Namespace Reference

Classes

struct  URI
 This URI abstraction is currently naive and only separates the URI scheme on the LHS from the "everything-else" of the URI on the RHS. As such this may only handle the URI_FILE and URI_DATA cases properly. Further investigate into URI_PKCS11 should be completed. More...
 

Functions

int increment_handle (int &next)
 
bool set_security_error (DDS::Security::SecurityException &ex, int code, int minor_code, const char *message)
 
bool set_security_error (DDS::Security::SecurityException &ex, int code, int minor_code, const char *message, const unsigned char(&a1)[4], const unsigned char(&a2)[4])
 
const char * ctk_to_dds_string (const CryptoTransformKind &keyKind)
 
OPENDDS_STRING ctki_to_dds_string (const CryptoTransformKeyId &keyId)
 
OPENDDS_STRING to_dds_string (const KeyOctetSeq &keyData)
 
OPENDDS_STRING to_dds_string (const KeyMaterial_AES_GCM_GMAC &km)
 
OPENDDS_STRING to_dds_string (const CryptoTransformIdentifier &id)
 

Function Documentation

◆ ctk_to_dds_string()

const char * OpenDDS::Security::CommonUtilities::ctk_to_dds_string ( const CryptoTransformKind keyKind)

Definition at line 86 of file CommonUtilities.cpp.

References ACE_ERROR, ACE_TEXT(), OpenDDS::Security::CRYPTO_TRANSFORMATION_KIND_AES128_GCM, OpenDDS::Security::CRYPTO_TRANSFORMATION_KIND_AES128_GMAC, OpenDDS::Security::CRYPTO_TRANSFORMATION_KIND_AES256_GCM, OpenDDS::Security::CRYPTO_TRANSFORMATION_KIND_AES256_GMAC, OpenDDS::Security::CRYPTO_TRANSFORMATION_KIND_NONE, LM_ERROR, and OpenDDS::DCPS::to_hex_dds_string().

Referenced by OpenDDS::Security::CryptoBuiltInImpl::preprocess_secure_submsg(), and to_dds_string().

87 {
88  if (!keyKind[0] && !keyKind[1] && !keyKind[2]) {
89  switch (keyKind[3]) {
91  return "CRYPTO_TRANSFORMATION_KIND_NONE";
93  return "CRYPTO_TRANSFORMATION_KIND_AES128_GMAC";
95  return "CRYPTO_TRANSFORMATION_KIND_AES128_GCM";
97  return "CRYPTO_TRANSFORMATION_KIND_AES256_GMAC";
99  return "CRYPTO_TRANSFORMATION_KIND_AES256_GCM";
100  }
101  }
102  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Security::CommonUtilities::ctk_to_dds_string: ")
103  ACE_TEXT("%C is either invalid or not recognized.\n"),
104  to_hex_dds_string(keyKind, sizeof(keyKind), ' ').c_str()));
105  return "Invalid CryptoTransformKind";
106 }
const octet CRYPTO_TRANSFORMATION_KIND_AES256_GCM
#define ACE_ERROR(X)
const octet CRYPTO_TRANSFORMATION_KIND_NONE
const octet CRYPTO_TRANSFORMATION_KIND_AES128_GCM
const octet CRYPTO_TRANSFORMATION_KIND_AES128_GMAC
String to_hex_dds_string(const unsigned char *data, const size_t size, const char delim, const size_t delim_every)
const octet CRYPTO_TRANSFORMATION_KIND_AES256_GMAC
ACE_TEXT("TCP_Factory")

◆ ctki_to_dds_string()

OPENDDS_STRING OpenDDS::Security::CommonUtilities::ctki_to_dds_string ( const CryptoTransformKeyId keyId)

Definition at line 108 of file CommonUtilities.cpp.

References OpenDDS::DCPS::to_hex_dds_string().

Referenced by OpenDDS::Security::CryptoBuiltInImpl::preprocess_secure_submsg(), OpenDDS::Security::CryptoBuiltInImpl::register_local_datareader(), OpenDDS::Security::CryptoBuiltInImpl::register_local_datawriter(), and to_dds_string().

109 {
110  return to_hex_dds_string(keyId, sizeof(keyId), ' ');
111 }
String to_hex_dds_string(const unsigned char *data, const size_t size, const char delim, const size_t delim_every)

◆ increment_handle()

int OpenDDS::Security::CommonUtilities::increment_handle ( int &  next)

Definition at line 39 of file CommonUtilities.cpp.

References ACE_ERROR, and LM_ERROR.

Referenced by OpenDDS::Security::AccessControlBuiltInImpl::generate_handle(), OpenDDS::Security::CryptoBuiltInImpl::generate_handle_i(), and OpenDDS::Security::AuthenticationBuiltInImpl::get_next_handle().

40 {
41  // handles are 32-bit signed values (int on all supported platforms)
42  // the only special value is 0 for HANDLE_NIL, 'next' starts at 1
43  // signed increment is not guaranteed to roll over so we implement our own
44  static const int LAST_POSITIVE_HANDLE(0x7fffffff);
45  static const int FIRST_NEGATIVE_HANDLE(-LAST_POSITIVE_HANDLE);
46  if (next == 0) {
47  ACE_ERROR((LM_ERROR, "(%P|%t) OpenDDS::Security::CommonUtilities::"
48  "increment_handle ERROR - out of handles\n"));
49  return 0;
50  }
51  const int h = next;
52  if (next == LAST_POSITIVE_HANDLE) {
53  next = FIRST_NEGATIVE_HANDLE;
54  } else {
55  ++next;
56  }
57  return h;
58 }
#define ACE_ERROR(X)

◆ set_security_error() [1/2]

OpenDDS_Security_Export bool OpenDDS::Security::CommonUtilities::set_security_error ( DDS::Security::SecurityException ex,
int  code,
int  minor_code,
const char *  message 
)

Definition at line 60 of file CommonUtilities.cpp.

References code, DDS::Security::SecurityException::code, DDS::Security::SecurityException::message, and DDS::Security::SecurityException::minor_code.

Referenced by OpenDDS::Security::CryptoBuiltInImpl::authtag(), OpenDDS::Security::AuthenticationBuiltInImpl::begin_handshake_reply(), OpenDDS::Security::AuthenticationBuiltInImpl::begin_handshake_request(), OpenDDS::Security::AccessControlBuiltInImpl::check_create_datareader(), OpenDDS::Security::AccessControlBuiltInImpl::check_create_datawriter(), OpenDDS::Security::AccessControlBuiltInImpl::check_create_participant(), OpenDDS::Security::AccessControlBuiltInImpl::check_create_topic(), OpenDDS::Security::AccessControlBuiltInImpl::check_local_datareader_match(), OpenDDS::Security::AccessControlBuiltInImpl::check_local_datawriter_dispose_instance(), OpenDDS::Security::AccessControlBuiltInImpl::check_local_datawriter_match(), OpenDDS::Security::AccessControlBuiltInImpl::check_local_datawriter_register_instance(), OpenDDS::Security::AccessControlBuiltInImpl::check_remote_datareader(), OpenDDS::Security::AccessControlBuiltInImpl::check_remote_datawriter(), OpenDDS::Security::AccessControlBuiltInImpl::check_remote_datawriter_dispose_instance(), OpenDDS::Security::AccessControlBuiltInImpl::check_remote_datawriter_register_instance(), OpenDDS::Security::AccessControlBuiltInImpl::check_remote_participant(), OpenDDS::Security::AccessControlBuiltInImpl::check_remote_topic(), OpenDDS::Security::CryptoBuiltInImpl::create_local_datareader_crypto_tokens(), OpenDDS::Security::CryptoBuiltInImpl::create_local_datawriter_crypto_tokens(), OpenDDS::Security::CryptoBuiltInImpl::create_local_participant_crypto_tokens(), OpenDDS::Security::CryptoBuiltInImpl::decode_datareader_submessage(), OpenDDS::Security::CryptoBuiltInImpl::decode_datawriter_submessage(), OpenDDS::Security::CryptoBuiltInImpl::decode_rtps_message(), OpenDDS::Security::CryptoBuiltInImpl::decode_serialized_payload(), OpenDDS::Security::CryptoBuiltInImpl::decode_submessage(), OpenDDS::Security::CryptoBuiltInImpl::decrypt(), OpenDDS::Security::CryptoBuiltInImpl::encode_datareader_submessage(), OpenDDS::Security::CryptoBuiltInImpl::encode_datawriter_submessage(), OpenDDS::Security::CryptoBuiltInImpl::encode_rtps_message(), OpenDDS::Security::CryptoBuiltInImpl::encode_serialized_payload(), OpenDDS::Security::CryptoBuiltInImpl::encode_submessage(), OpenDDS::Security::CryptoBuiltInImpl::encrypt(), OpenDDS::Security::AuthenticationBuiltInImpl::get_authenticated_peer_credential_token(), OpenDDS::Security::AccessControlBuiltInImpl::get_datareader_sec_attributes(), OpenDDS::Security::AccessControlBuiltInImpl::get_datawriter_sec_attributes(), OpenDDS::Security::AuthenticationBuiltInImpl::get_identity_status_token(), OpenDDS::Security::AuthenticationBuiltInImpl::get_identity_token(), OpenDDS::Security::AccessControlBuiltInImpl::get_participant_sec_attributes(), OpenDDS::Security::AccessControlBuiltInImpl::get_permissions_credential_token(), OpenDDS::Security::AccessControlBuiltInImpl::get_permissions_token(), OpenDDS::Security::AccessControlBuiltInImpl::get_sec_attributes(), OpenDDS::Security::AuthenticationBuiltInImpl::get_shared_secret(), OpenDDS::Security::AccessControlBuiltInImpl::get_topic_sec_attributes(), OpenDDS::Security::LocalAccessCredentialData::load(), OpenDDS::Security::SSL::SignedDocument::load(), OpenDDS::Security::SSL::Certificate::load(), OpenDDS::Security::LocalAuthCredentialData::load_access_permissions(), OpenDDS::Security::LocalAuthCredentialData::load_credentials(), OpenDDS::Security::CryptoBuiltInImpl::preprocess_secure_submsg(), OpenDDS::Security::AuthenticationBuiltInImpl::process_final_handshake(), OpenDDS::Security::AuthenticationBuiltInImpl::process_handshake_reply(), OpenDDS::Security::CryptoBuiltInImpl::register_local_participant(), OpenDDS::Security::CryptoBuiltInImpl::register_matched_remote_datareader(), OpenDDS::Security::CryptoBuiltInImpl::register_matched_remote_datawriter(), OpenDDS::Security::CryptoBuiltInImpl::register_matched_remote_participant(), OpenDDS::Security::AuthenticationBuiltInImpl::return_handshake_handle(), OpenDDS::Security::AuthenticationBuiltInImpl::return_identity_handle(), OpenDDS::Security::AccessControlBuiltInImpl::return_permissions_handle(), OpenDDS::Security::AccessControlBuiltInImpl::search_permissions(), OpenDDS::Security::AuthenticationBuiltInImpl::set_listener(), OpenDDS::Security::AccessControlBuiltInImpl::set_listener(), OpenDDS::Security::AuthenticationBuiltInImpl::set_permissions_credential_and_token(), OpenDDS::Security::CryptoBuiltInImpl::set_remote_datareader_crypto_tokens(), OpenDDS::Security::CryptoBuiltInImpl::set_remote_datawriter_crypto_tokens(), OpenDDS::Security::CryptoBuiltInImpl::set_remote_participant_crypto_tokens(), set_security_error(), OpenDDS::Security::CryptoBuiltInImpl::unregister_datareader(), OpenDDS::Security::CryptoBuiltInImpl::unregister_datawriter(), OpenDDS::Security::CryptoBuiltInImpl::unregister_participant(), OpenDDS::Security::AccessControlBuiltInImpl::validate_date_time(), OpenDDS::Security::AuthenticationBuiltInImpl::validate_local_identity(), OpenDDS::Security::AccessControlBuiltInImpl::validate_local_permissions(), OpenDDS::Security::AuthenticationBuiltInImpl::validate_remote_identity(), OpenDDS::Security::AccessControlBuiltInImpl::validate_remote_permissions(), OpenDDS::Security::validate_topic_data_guid(), OpenDDS::Security::LocalAccessCredentialData::verify(), and OpenDDS::Security::CryptoBuiltInImpl::verify().

64 {
65  ex.code = code;
66  ex.minor_code = minor_code;
67  ex.message = message;
68  return false;
69 }
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused as reported by Andy Elvey and Dan Kosecki *resynced with Christopher Diggins s branch as it exists in tree building code is back Christopher Diggins *resynced codebase with Chris s branch *removed tree building code
Definition: CHANGELOG.txt:8

◆ set_security_error() [2/2]

OpenDDS_Security_Export bool OpenDDS::Security::CommonUtilities::set_security_error ( DDS::Security::SecurityException ex,
int  code,
int  minor_code,
const char *  message,
const unsigned char(&)  a1[4],
const unsigned char(&)  a2[4] 
)

Definition at line 71 of file CommonUtilities.cpp.

References set_security_error().

77 {
78  std::string full(message);
79  const size_t i = full.size();
80  full.resize(i + 25);
81  std::sprintf(&full[i], " %.2x %.2x %.2x %.2x, %.2x %.2x %.2x %.2x",
82  a1[0], a1[1], a1[2], a1[3], a2[0], a2[1], a2[2], a2[3]);
83  return set_security_error(ex, code, minor_code, full.c_str());
84 }
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused as reported by Andy Elvey and Dan Kosecki *resynced with Christopher Diggins s branch as it exists in tree building code is back Christopher Diggins *resynced codebase with Chris s branch *removed tree building code
Definition: CHANGELOG.txt:8
bool set_security_error(DDS::Security::SecurityException &ex, int code, int minor_code, const char *message, const unsigned char(&a1)[4], const unsigned char(&a2)[4])

◆ to_dds_string() [1/3]

OPENDDS_STRING OpenDDS::Security::CommonUtilities::to_dds_string ( const KeyOctetSeq keyData)

Definition at line 113 of file CommonUtilities.cpp.

References OpenDDS::DCPS::to_hex_dds_string().

Referenced by to_dds_string().

114 {
115  if (keyData.length()) {
116  return to_hex_dds_string(&keyData[0], keyData.length(), '\n', 8);
117  }
118  return "";
119 }
String to_hex_dds_string(const unsigned char *data, const size_t size, const char delim, const size_t delim_every)

◆ to_dds_string() [2/3]

OPENDDS_STRING OpenDDS::Security::CommonUtilities::to_dds_string ( const KeyMaterial_AES_GCM_GMAC km)

Definition at line 121 of file CommonUtilities.cpp.

References ctk_to_dds_string(), ctki_to_dds_string(), OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_receiver_specific_key, OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_salt, OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_sender_key, OPENDDS_STRING, OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::receiver_specific_key_id, OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::sender_key_id, to_dds_string(), and OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::transformation_kind.

122 {
123  return
124  OPENDDS_STRING("transformation_kind: ") +
125  ctk_to_dds_string(km.transformation_kind) +
126  OPENDDS_STRING("\nmaster_salt:\n") +
127  to_dds_string(km.master_salt) +
128  OPENDDS_STRING("\nsender_key_id: ") +
129  ctki_to_dds_string(km.sender_key_id) +
130  OPENDDS_STRING("\nmaster_sender_key:\n") +
131  to_dds_string(km.master_sender_key) +
132  OPENDDS_STRING("\nreceiver_specific_key_id: ") +
133  ctki_to_dds_string(km.receiver_specific_key_id) +
134  OPENDDS_STRING("\nmaster_receiver_specific_key:\n") +
135  to_dds_string(km.master_receiver_specific_key) +
136  OPENDDS_STRING("\n");
137 }
const char * ctk_to_dds_string(const CryptoTransformKind &keyKind)
#define OPENDDS_STRING
OPENDDS_STRING to_dds_string(const CryptoTransformIdentifier &id)
OPENDDS_STRING ctki_to_dds_string(const CryptoTransformKeyId &keyId)

◆ to_dds_string() [3/3]

OPENDDS_STRING OpenDDS::Security::CommonUtilities::to_dds_string ( const CryptoTransformIdentifier id)

Definition at line 139 of file CommonUtilities.cpp.

References ctk_to_dds_string(), ctki_to_dds_string(), OPENDDS_END_VERSIONED_NAMESPACE_DECL, and OPENDDS_STRING.

140 {
141  return
142  OPENDDS_STRING("transformation_kind: ") +
143  ctk_to_dds_string(id.transformation_kind) +
144  OPENDDS_STRING("\ntransformation_key_id: ") +
145  ctki_to_dds_string(id.transformation_key_id) +
146  OPENDDS_STRING("\n");
147 }
const char * ctk_to_dds_string(const CryptoTransformKind &keyKind)
#define OPENDDS_STRING
OPENDDS_STRING ctki_to_dds_string(const CryptoTransformKeyId &keyId)