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_ |
Definition at line 252 of file CryptoBuiltInImpl.h.
void OpenDDS::Security::CryptoBuiltInImpl::Session::create_key | ( | const KeyMaterial & | master | ) |
Definition at line 854 of file CryptoBuiltInImpl.cpp.
References counter_, derive_key(), id_, and iv_suffix_.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::encauth_setup().
00855 { 00856 RAND_bytes(id_, sizeof id_); 00857 RAND_bytes(iv_suffix_, sizeof iv_suffix_); 00858 derive_key(master); 00859 counter_ = 0; 00860 }
void OpenDDS::Security::CryptoBuiltInImpl::Session::derive_key | ( | const KeyMaterial & | master | ) |
Definition at line 1349 of file CryptoBuiltInImpl.cpp.
References id_, key_, OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_salt, and OpenDDS::Security::KeyMaterial_AES_GCM_GMAC::master_sender_key.
Referenced by create_key(), get_key(), and next_id().
01350 { 01351 PrivateKey pkey(master.master_sender_key); 01352 DigestContext ctx; 01353 const EVP_MD* md = EVP_get_digestbyname("SHA256"); 01354 01355 if (EVP_DigestInit_ex(ctx, md, 0) < 1) { 01356 return; 01357 } 01358 01359 if (EVP_DigestSignInit(ctx, 0, md, 0, pkey) < 1) { 01360 return; 01361 } 01362 01363 static const char cookie[] = "SessionKey"; // DDSSEC12-53: NUL excluded 01364 if (EVP_DigestSignUpdate(ctx, cookie, (sizeof cookie) - 1) < 1) { 01365 return; 01366 } 01367 01368 const KeyOctetSeq& salt = master.master_salt; 01369 if (EVP_DigestSignUpdate(ctx, salt.get_buffer(), salt.length()) < 1) { 01370 return; 01371 } 01372 01373 if (EVP_DigestSignUpdate(ctx, id_, sizeof id_) < 1) { 01374 return; 01375 } 01376 01377 size_t req = 0; 01378 if (EVP_DigestSignFinal(ctx, 0, &req) < 1) { 01379 return; 01380 } 01381 01382 key_.length(static_cast<unsigned int>(req)); 01383 if (EVP_DigestSignFinal(ctx, key_.get_buffer(), &req) < 1) { 01384 key_.length(0); 01385 } 01386 }
KeyOctetSeq OpenDDS::Security::CryptoBuiltInImpl::Session::get_key | ( | const KeyMaterial & | master, | |
const CryptoHeader & | header | |||
) |
Definition at line 1337 of file CryptoBuiltInImpl.cpp.
References derive_key(), id_, key_, and OpenDDS::Security::CryptoHeader::session_id.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::decrypt(), and OpenDDS::Security::CryptoBuiltInImpl::verify().
01339 { 01340 if (key_.length() && 0 == std::memcmp(&id_, &header.session_id, sizeof id_)) { 01341 return key_; 01342 } 01343 std::memcpy(&id_, &header.session_id, sizeof id_); 01344 key_.length(0); 01345 derive_key(master); 01346 return key_; 01347 }
void OpenDDS::Security::CryptoBuiltInImpl::Session::inc_iv | ( | ) |
Definition at line 871 of file CryptoBuiltInImpl.cpp.
References iv_suffix_.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::encauth_setup().
00872 { 00873 if (inc32(iv_suffix_)) { 00874 inc32(iv_suffix_ + 4); 00875 } 00876 }
void OpenDDS::Security::CryptoBuiltInImpl::Session::next_id | ( | const KeyMaterial & | master | ) |
Definition at line 862 of file CryptoBuiltInImpl.cpp.
References counter_, derive_key(), id_, iv_suffix_, and key_.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::encauth_setup().
00863 { 00864 inc32(id_); 00865 RAND_bytes(iv_suffix_, sizeof iv_suffix_); 00866 key_.length(0); 00867 derive_key(master); 00868 counter_ = 0; 00869 }
Definition at line 256 of file CryptoBuiltInImpl.h.
Referenced by create_key(), OpenDDS::Security::CryptoBuiltInImpl::encauth_setup(), and next_id().
Definition at line 253 of file CryptoBuiltInImpl.h.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::authtag(), create_key(), derive_key(), OpenDDS::Security::CryptoBuiltInImpl::encauth_setup(), OpenDDS::Security::CryptoBuiltInImpl::encrypt(), get_key(), and next_id().
Definition at line 254 of file CryptoBuiltInImpl.h.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::authtag(), create_key(), OpenDDS::Security::CryptoBuiltInImpl::encauth_setup(), OpenDDS::Security::CryptoBuiltInImpl::encrypt(), inc_iv(), and next_id().
Definition at line 255 of file CryptoBuiltInImpl.h.
Referenced by OpenDDS::Security::CryptoBuiltInImpl::authtag(), derive_key(), OpenDDS::Security::CryptoBuiltInImpl::encauth_setup(), OpenDDS::Security::CryptoBuiltInImpl::encrypt(), get_key(), and next_id().