Skip to content

Commit

Permalink
ensure secret hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-martin committed Jan 22, 2024
1 parent 26ef5f4 commit cff9735
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/aspera/keychain/encrypted_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class EncryptedHash
CIPHER_NAME = 'aes-256-cbc'
CONTENT_KEYS = %i[label username password url description].freeze
def initialize(path, current_password)
assert_type(path, String){'path to vault file'}
@path = path
self.password = current_password
assert_type(@path, String){'path to vault file'}
@all_secrets = File.exist?(@path) ? YAML.load_stream(@cipher.decrypt(File.read(@path))).first : {}
end

Expand All @@ -25,7 +25,7 @@ def password=(new_password)
key_bytes = CIPHER_NAME.split('-')[1].to_i / Environment::BITS_PER_BYTE
# derive key from passphrase, add trailing zeros
key = "#{new_password}#{"\x0" * key_bytes}"[0..(key_bytes - 1)]
Log.log.debug{"key=[#{key}],#{key.length}"}
Log.log.trace1{"secret=[#{key}],#{key.length}"}
SymmetricEncryption.cipher = @cipher = SymmetricEncryption::Cipher.new(cipher_name: CIPHER_NAME, key: key, encoding: :none)
end

Expand Down

0 comments on commit cff9735

Please sign in to comment.