diff --git a/api/crypto/frame_crypto_transformer.h b/api/crypto/frame_crypto_transformer.h index 1f7fc3bc21..8f358f8d48 100644 --- a/api/crypto/frame_crypto_transformer.h +++ b/api/crypto/frame_crypto_transformer.h @@ -116,13 +116,14 @@ class ParticipantKeyHandler { have_valid_key = true; } -private: - void SetKeyFromMaterial(std::vector password, int key_index) { - if (key_index >= 0) { - current_key_index_ = key_index % crypto_key_ring_.size(); + std::vector RatchetKeyMaterial( + std::vector current_material) { + std::vector new_material; + if (DerivePBKDF2KeyFromRawKey(current_material, key_provider_->options().ratchet_salt, 256, + &new_material) != 0) { + return std::vector(); } - crypto_key_ring_[current_key_index_] = - DeriveKeys(password, key_provider_->options().ratchet_salt, 128); + return new_material; } std::shared_ptr DeriveKeys(std::vector password, @@ -136,15 +137,13 @@ class ParticipantKeyHandler { return nullptr; } - std::vector RatchetKeyMaterial( - std::vector current_material) { - webrtc::MutexLock lock(&mutex_); - std::vector new_material; - if (DerivePBKDF2KeyFromRawKey(current_material, key_provider_->options().ratchet_salt, 256, - &new_material) != 0) { - return std::vector(); +private: + void SetKeyFromMaterial(std::vector password, int key_index) { + if (key_index >= 0) { + current_key_index_ = key_index % crypto_key_ring_.size(); } - return new_material; + crypto_key_ring_[current_key_index_] = + DeriveKeys(password, key_provider_->options().ratchet_salt, 128); } protected: bool have_valid_key = false; @@ -191,7 +190,7 @@ class DefaultKeyProviderImpl : public KeyProvider { const std::string participant_id) const override { webrtc::MutexLock lock(&mutex_); - if(options_.shared_key && keys_.find(participant_id) != keys_.end()) { + if(options_.shared_key && keys_.find("shared") != keys_.end()) { return keys_.find("shared")->second; }