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

Feb 20, 2021
87
9
13
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
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!