From 1ab31bd9cc49bf5968b51e4fcbadac211a2278d6 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Wed, 13 Dec 2023 13:26:20 +0100 Subject: [PATCH] Fix SSH key fingerprint. --- bark_core/signatures.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bark_core/signatures.py b/bark_core/signatures.py index a8e456e..48c1de3 100644 --- a/bark_core/signatures.py +++ b/bark_core/signatures.py @@ -38,7 +38,7 @@ from cryptography.hazmat.primitives.serialization import SSHPublicKeyTypes from cryptography.hazmat.primitives.hashes import Hash, SHA1, SHA256, SHA384, SHA512 from typing import Any, Union, Optional, Tuple -from base64 import b64decode +from base64 import b64decode, b64encode from abc import ABC, abstractmethod import warnings @@ -334,8 +334,9 @@ def type(self) -> str: @property def fingerprint(self) -> str: - # TODO: fingerprint - return str(self._key) + md = Hash(SHA256()) + md.update(self._key) + return b64encode(md.finalize()).decode().rstrip("=") def verify_signature(self, email: str, signature: bytes, subject: bytes) -> bool: if email not in self._emails: