Skip to content

Commit 37f7858

Browse files
author
Roland Hedberg
committed
New function that checks if two RSA keys are actually the same.
1 parent c7b6f4f commit 37f7858

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/saml2/sigver.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,14 @@ def rsa_loads(key):
479479
M2Crypto.util.no_passphrase_callback)
480480

481481

482+
def rsa_eq(key1, key2):
483+
# Check if two RSA keys are in fact the same
484+
if key1.n == key2.n and key1.e == key2.e:
485+
return True
486+
else:
487+
return False
488+
489+
482490
def x509_rsa_loads(string):
483491
cert = M2Crypto.X509.load_cert_string(string)
484492
return cert.get_pubkey().get_rsa()
@@ -901,6 +909,10 @@ def security_context(conf, debug=None):
901909
debug=debug, only_use_keys_in_metadata=_only_md)
902910

903911

912+
# How to get a rsa pub key fingerprint from a certificate
913+
# openssl x509 -inform pem -noout -in server.crt -pubkey > publickey.pem
914+
# openssl rsa -inform pem -noout -in publickey.pem -pubin -modulus
915+
904916
class SecurityContext(object):
905917
def __init__(self, crypto, key_file="", key_type="pem",
906918
cert_file="", cert_type="pem", metadata=None,

0 commit comments

Comments
 (0)