I have to verify a signature using DSA FIPS 186-2 (I know it is not used anymore, but I need to make it work for a legacy system). My problem is I have the "y" DSA value, but I cannot work out how I can feed that into the Python code to create my own public key from the "y" value and then apply the verify.
For example below is what I have, but instead of generating a NEW key, I need to use my existing value?
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import dsa
from cryptography.exceptions import InvalidSignature
private_key = dsa.generate_private_key(
key_size=1024,
backend=default_backend()
)
data = b"this is some data I'd like to sign"
signature = private_key.sign(
data,
hashes.SHA1()
)
public_key = private_key.public_key()
try:
public_key.verify(
signature,
data,
hashes.SHA1())
except InvalidSignature:
print ("Invalid")