Skip to content

Commit

Permalink
Fix #1031 & #764 - androguard sign asn1crypto(...).fingerprint removed
Browse files Browse the repository at this point in the history
This commit replaces the outdated:
`asn1crypto.keys.PublicKeyInfo().fingerprint` call

With the new:
`oscrypto.asymmetric.PublicKey().fingerprint` call

ValueError/ve is properly excepted and when printed, it shows "Only DSA keys are generated using a hash algorithm, this key is RSA" for RSA signed apk's.

This commit satisfies the:
`asn1crypto._errors.APIException: asn1crypto.keys.PublicKeyInfo().fingerprint has been removed, please use oscrypto.asymmetric.PublicKey().fingerprint instead`
while still keeping the original behavior.
  • Loading branch information
olokos committed Apr 22, 2024
1 parent 72e29ad commit bd0204a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions androguard/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters.terminal import TerminalFormatter
from oscrypto import asymmetric

# internal modules
from androguard.core import androconf
Expand Down Expand Up @@ -360,14 +361,14 @@ def androsign_main(args_apk, args_hash, args_all, show):

for public_key in pkeys:
if show:
x509_public_key = keys.PublicKeyInfo.load(public_key)
x509_public_key = asymmetric.load_public_key(public_key)
print("PublicKey Algorithm:", x509_public_key.algorithm)
print("Bit Size:", x509_public_key.bit_size)
print("Fingerprint:", binascii.hexlify(x509_public_key.fingerprint))
try:
print("Hash Algorithm:", x509_public_key.hash_algo)
print("Hash Algorithm:", x509_public_key.asn1.hash_algo)
except ValueError as ve:
# RSA pkey does not have an hash algorithm
# RSA pkey does not have a hash algorithm
pass
print()

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ matplotlib
networkx
PyQt5
pyyaml
oscrypto>=1.3.0

0 comments on commit bd0204a

Please sign in to comment.