Class: Kdf

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Overview

Kdf from prelogin

Key Derivation Function for Bitwarden Account

In Bitwarden accounts can use multiple KDFs to derive their master key from their password. This Enum represents all the possible KDFs.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



707
708
709
710
711
712
713
# File 'lib/schemas.rb', line 707

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    p_bkdf2:   d["pBKDF2"] ? PBKDF2.from_dynamic!(d["pBKDF2"]) : nil,
    argon2_id: d["argon2id"] ? Argon2ID.from_dynamic!(d["argon2id"]) : nil,
  )
end

.from_json!(json) ⇒ Object



715
716
717
# File 'lib/schemas.rb', line 715

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



719
720
721
722
723
724
# File 'lib/schemas.rb', line 719

def to_dynamic
  {
    "pBKDF2"   => p_bkdf2&.to_dynamic,
    "argon2id" => argon2_id&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



726
727
728
# File 'lib/schemas.rb', line 726

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end