OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Public Attributes | List of all members
OpenDDS::Security::CryptoBuiltInImpl::Session Struct Reference

Public Member Functions

KeyOctetSeq get_key (const KeyMaterial &master, const CryptoHeader &header)
 
void create_key (const KeyMaterial &master)
 
void derive_key (const KeyMaterial &master)
 
void next_id (const KeyMaterial &master)
 
void inc_iv ()
 

Public Attributes

SessionIdType id_
 
IV_SuffixType iv_suffix_
 
KeyOctetSeq key_
 
ACE_UINT64 counter_
 

Detailed Description

Definition at line 284 of file CryptoBuiltInImpl.h.

Member Function Documentation

◆ create_key()

void OpenDDS::Security::CryptoBuiltInImpl::Session::create_key ( const KeyMaterial master)

Definition at line 1179 of file CryptoBuiltInImpl.cpp.

Referenced by OpenDDS::Security::CryptoBuiltInImpl::encauth_setup().

1180 {
1181  RAND_bytes(id_, sizeof id_);
1182  RAND_bytes(iv_suffix_, sizeof iv_suffix_);
1183  derive_key(master);
1184  counter_ = 0;
1185 }

◆ derive_key()

void OpenDDS::Security::CryptoBuiltInImpl::Session::derive_key ( const KeyMaterial master)

Definition at line 1787 of file CryptoBuiltInImpl.cpp.

References OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_salt, and OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_sender_key.

1788 {
1789  PrivateKey pkey(master.master_sender_key);
1790  DigestContext ctx;
1791  const EVP_MD* md = EVP_get_digestbyname("SHA256");
1792 
1793  if (EVP_DigestInit_ex(ctx, md, 0) < 1) {
1794  return;
1795  }
1796 
1797  if (EVP_DigestSignInit(ctx, 0, md, 0, pkey) < 1) {
1798  return;
1799  }
1800 
1801  static const char cookie[] = "SessionKey"; // DDSSEC12-53: NUL excluded
1802  if (EVP_DigestSignUpdate(ctx, cookie, (sizeof cookie) - 1) < 1) {
1803  return;
1804  }
1805 
1806  const KeyOctetSeq& salt = master.master_salt;
1807  if (EVP_DigestSignUpdate(ctx, salt.get_buffer(), salt.length()) < 1) {
1808  return;
1809  }
1810 
1811  if (EVP_DigestSignUpdate(ctx, id_, sizeof id_) < 1) {
1812  return;
1813  }
1814 
1815  size_t req = 0;
1816  if (EVP_DigestSignFinal(ctx, 0, &req) < 1) {
1817  return;
1818  }
1819 
1820  key_.length(static_cast<unsigned int>(req));
1821  if (EVP_DigestSignFinal(ctx, key_.get_buffer(), &req) < 1) {
1822  key_.length(0);
1823  }
1824 }
sequence< octet, 32 > KeyOctetSeq

◆ get_key()

KeyOctetSeq OpenDDS::Security::CryptoBuiltInImpl::Session::get_key ( const KeyMaterial master,
const CryptoHeader header 
)

Definition at line 1775 of file CryptoBuiltInImpl.cpp.

References OpenDDS::Security::CryptoHeader::session_id.

Referenced by OpenDDS::Security::CryptoBuiltInImpl::decrypt(), and OpenDDS::Security::CryptoBuiltInImpl::verify().

1777 {
1778  if (key_.length() && 0 == std::memcmp(&id_, &header.session_id, sizeof id_)) {
1779  return key_;
1780  }
1781  std::memcpy(&id_, &header.session_id, sizeof id_);
1782  key_.length(0);
1783  derive_key(master);
1784  return key_;
1785 }
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused header
Definition: CHANGELOG.txt:8

◆ inc_iv()

void OpenDDS::Security::CryptoBuiltInImpl::Session::inc_iv ( )

Definition at line 1196 of file CryptoBuiltInImpl.cpp.

Referenced by OpenDDS::Security::CryptoBuiltInImpl::encauth_setup().

1197 {
1198  if (inc32(iv_suffix_)) {
1199  inc32(iv_suffix_ + 4);
1200  }
1201 }

◆ next_id()

void OpenDDS::Security::CryptoBuiltInImpl::Session::next_id ( const KeyMaterial master)

Member Data Documentation

◆ counter_

ACE_UINT64 OpenDDS::Security::CryptoBuiltInImpl::Session::counter_

◆ id_

SessionIdType OpenDDS::Security::CryptoBuiltInImpl::Session::id_

◆ iv_suffix_

IV_SuffixType OpenDDS::Security::CryptoBuiltInImpl::Session::iv_suffix_

◆ key_

KeyOctetSeq OpenDDS::Security::CryptoBuiltInImpl::Session::key_

The documentation for this struct was generated from the following files: