DSA === DSA_ is a widespread public key signature algorithm. Its security is based on the discrete logarithm problem (DLP_). Given a cyclic group, a generator *g*, and an element *h*, it is hard to find an integer *x* such that :math:`g^x = h`. The problem is believed to be difficult, and it has been proved such (and therefore secure) for more than 30 years. The group is actually a sub-group over the integers modulo *p*, with *p* prime. The sub-group order is *q*, which is prime too; it always holds that *(p-1)* is a multiple of *q*. The cryptographic strength is linked to the magnitude of *p* and *q*. The signer holds a value *x* (*0>> from Crypto.PublicKey import DSA >>> from Crypto.Signature import DSS >>> from Crypto.Hash import SHA256 >>> >>> # Create a new DSA key >>> key = DSA.generate(2048) >>> f = open("public_key.pem", "w") >>> f.write(key.publickey().export_key()) >>> f.close() >>> >>> # Sign a message >>> message = b"Hello" >>> hash_obj = SHA256.new(message) >>> signer = DSS.new(key, 'fips-186-3') >>> signature = signer.sign(hash_obj) >>> >>> # Load the public key >>> f = open("public_key.pem", "r") >>> hash_obj = SHA256.new(message) >>> pub_key = DSA.import_key(f.read()) >>> verifier = DSS.new(pub_key, 'fips-186-3') >>> >>> # Verify the authenticity of the message >>> try: >>> verifier.verify(hash_obj, signature) >>> print "The message is authentic." >>> except ValueError: >>> print "The message is not authentic." .. _DSA: http://en.wikipedia.org/wiki/Digital_Signature_Algorithm .. _DLP: http://www.cosic.esat.kuleuven.be/publications/talk-78.pdf .. _ECRYPT: http://www.ecrypt.eu.org/documents/D.SPA.17.pdf .. automodule:: Crypto.PublicKey.DSA :members: