[TUTORIAL] Get Fingerprint of Proxmox Backup Encryption Key in python

abma

Active Member
Feb 20, 2021
89
11
28
I wanted to calculate the fingerprint of the encrypton key in python, thats what works for me:

Code:
import base64
import hashlib
import hmac
import json
import sys

def get_fingerprint(encryptionkey):
        b = base64.b64decode(encryptionkey)
        id_key = hashlib.pbkdf2_hmac('sha256', b, b'_id_key', 10)
        prefix = hashlib.sha256(b"Proxmox Backup Encryption Key Fingerprint").digest()
        h = hashlib.sha256(prefix + id_key).hexdigest()
        return ':'.join(h[i:i+2] for i in range(0,len(h),2))

if len(sys.argv) != 2:
        print("Usage: %s /path/to/file.enc" %(sys.argv[0]))
        sys.exit(1)
f = open(sys.argv[1])
encfile = json.load(f)
print(get_fingerprint(encfile["data"]))

Maybe its useful for someone else!

Related code: https://git.proxmox.com/?p=proxmox-...e;hb=344db2d6f68946e7e8236c79f9c2b9acc28bf345
 
Many thanks, I had a storage with missing fingerprint line and just used your script to calculate it!