MCPcopy
hub / github.com/borgbackup/borg / encrypt_key_file_pbkdf2

Method encrypt_key_file_pbkdf2

src/borg/crypto/key.py:512–519  ·  view source on GitHub ↗
(self, data, passphrase)

Source from the content-addressed store, hash-verified

510 raise ValueError(f"Unexpected algorithm: {algorithm}")
511
512 def encrypt_key_file_pbkdf2(self, data, passphrase):
513 salt = os.urandom(32)
514 iterations = PBKDF2_ITERATIONS
515 key = self.pbkdf2(passphrase, salt, iterations, 32)
516 hash = hmac_sha256(key, data)
517 cdata = AES(key, b"\0" * 16).encrypt(data)
518 enc_key = EncryptedKey(version=1, salt=salt, iterations=iterations, algorithm="sha256", hash=hash, data=cdata)
519 return msgpack.packb(enc_key.as_dict())
520
521 def encrypt_key_file_argon2(self, data, passphrase):
522 salt = os.urandom(ARGON2_SALT_BYTES)

Callers 1

encrypt_key_fileMethod · 0.95

Calls 3

pbkdf2Method · 0.95
as_dictMethod · 0.80
encryptMethod · 0.45

Tested by

no test coverage detected