Skip to content

Commit

Permalink
src: remove KeyObjectData::symmetric_key_len_
Browse files Browse the repository at this point in the history
symmetric_key_len_ is always equal to symmetric_key_.size(). Storing it
separately is redundant and has no significant benefit.
  • Loading branch information
tniessen committed Aug 22, 2022
1 parent a5671e2 commit 961051b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
4 changes: 1 addition & 3 deletions src/crypto/crypto_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -843,15 +843,13 @@ KeyObjectData::KeyObjectData(
ByteSource symmetric_key)
: key_type_(KeyType::kKeyTypeSecret),
symmetric_key_(std::move(symmetric_key)),
symmetric_key_len_(symmetric_key_.size()),
asymmetric_key_() {}

KeyObjectData::KeyObjectData(
KeyType type,
const ManagedEVPPKey& pkey)
: key_type_(type),
symmetric_key_(),
symmetric_key_len_(0),
asymmetric_key_{pkey} {}

void KeyObjectData::MemoryInfo(MemoryTracker* tracker) const {
Expand Down Expand Up @@ -896,7 +894,7 @@ const char* KeyObjectData::GetSymmetricKey() const {

size_t KeyObjectData::GetSymmetricKeySize() const {
CHECK_EQ(key_type_, kKeyTypeSecret);
return symmetric_key_len_;
return symmetric_key_.size();
}

v8::Local<v8::Function> KeyObjectHandle::Initialize(Environment* env) {
Expand Down
1 change: 0 additions & 1 deletion src/crypto/crypto_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class KeyObjectData : public MemoryRetainer {

const KeyType key_type_;
const ByteSource symmetric_key_;
const unsigned int symmetric_key_len_;
const ManagedEVPPKey asymmetric_key_;
};

Expand Down

0 comments on commit 961051b

Please sign in to comment.