Skip to content

Commit

Permalink
update.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Aug 31, 2023
1 parent a1c7145 commit 677bec5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions api/crypto/frame_crypto_transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ class ParticipantKeyHandler {
have_valid_key = true;
}

private:
void SetKeyFromMaterial(std::vector<uint8_t> password, int key_index) {
if (key_index >= 0) {
current_key_index_ = key_index % crypto_key_ring_.size();
std::vector<uint8_t> RatchetKeyMaterial(
std::vector<uint8_t> current_material) {
std::vector<uint8_t> new_material;
if (DerivePBKDF2KeyFromRawKey(current_material, key_provider_->options().ratchet_salt, 256,
&new_material) != 0) {
return std::vector<uint8_t>();
}
crypto_key_ring_[current_key_index_] =
DeriveKeys(password, key_provider_->options().ratchet_salt, 128);
return new_material;
}

std::shared_ptr<KeySet> DeriveKeys(std::vector<uint8_t> password,
Expand All @@ -136,15 +137,13 @@ class ParticipantKeyHandler {
return nullptr;
}

std::vector<uint8_t> RatchetKeyMaterial(
std::vector<uint8_t> current_material) {
webrtc::MutexLock lock(&mutex_);
std::vector<uint8_t> new_material;
if (DerivePBKDF2KeyFromRawKey(current_material, key_provider_->options().ratchet_salt, 256,
&new_material) != 0) {
return std::vector<uint8_t>();
private:
void SetKeyFromMaterial(std::vector<uint8_t> 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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 677bec5

Please sign in to comment.