Blog | G5 Cyber Security

RSA Fingerprint Variations

TL;DR

Yes, you can generate multiple different fingerprints from a single RSA public key using different hashing algorithms and formats. This isn’t a problem in itself, but it’s important to understand the differences when comparing keys or checking for consistency.

How to Generate Multiple RSA Key Fingerprints

  1. Understand Fingerprinting Basics
  • Using OpenSSL
  • OpenSSL is a common tool for working with cryptography. Here’s how to generate various RSA key fingerprints:

  • Fingerprint Formats
  • Comparing Fingerprints
  • Practical Example – SSH Key Verification
  • When adding an SSH key to a server, you’ll typically get a fingerprint displayed. Verify this fingerprint matches the one generated by your local machine using OpenSSL (using SHA256 is best practice).

  • Using Python (with cryptography library)
  • You can also generate fingerprints programmatically using Python:

    from cryptography.hazmat.primitives import hashes
    from cryptography.hazmat.backends import default_backend
    import binascii
    
    def fingerprint(public_key):
      hasher = hashes.SHA256()
      hasher.update(public_key)
      digest = hasher.finalize()
      return binascii.hexlify(digest).decode('utf-8')
    
    # Example (assuming you have the public key in bytes format):
    public_key_bytes = b'...' # Replace with your actual public key data
    sha256_fingerprint = fingerprint(public_key_bytes)
    print(f"SHA256 Fingerprint: {sha256_fingerprint}")
    Exit mobile version