Skip to content

Commit 63c88a3

Browse files
authored
Add support for pystandalone key_fingerprint (#235)
1 parent a9f83f2 commit 63c88a3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

acquire/crypt.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import io
55
import os
66
from datetime import datetime, timezone
7-
from typing import BinaryIO
7+
from typing import Any, BinaryIO
88

99
from dissect.cstruct import cstruct
1010

@@ -151,9 +151,11 @@ def finalize(self) -> None:
151151
self.cipher.clean()
152152

153153

154-
def key_fingerprint(pkey: PKCS1_OAEP.PKCS1OAEP_Cipher) -> bytes:
155-
if isinstance(pkey, PKCS1_OAEP.PKCS1OAEP_Cipher):
156-
pkey = pkey._key
157-
der = pkey.export_key("DER")
158-
154+
def key_fingerprint(pkey: PKCS1_OAEP.PKCS1OAEP_Cipher | Any) -> bytes:
155+
if HAS_PYSTANDALONE:
156+
der = pkey.der()
157+
else:
158+
if isinstance(pkey, PKCS1_OAEP.PKCS1OAEP_Cipher):
159+
pkey = pkey._key
160+
der = pkey.export_key("DER")
159161
return hashlib.sha256(der).digest()

0 commit comments

Comments
 (0)