Skip to content

Instantly share code, notes, and snippets.

@shuax
Created July 31, 2020 06:37
Show Gist options
  • Save shuax/8e7d0132a549e6cfc2e10a94d8bfe918 to your computer and use it in GitHub Desktop.
Save shuax/8e7d0132a549e6cfc2e10a94d8bfe918 to your computer and use it in GitHub Desktop.
from Crypto.PublicKey import ECC
from Crypto.Hash import SHA256
from Crypto.Signature import DSS
text = b"123456"
h = SHA256.new(text)
print(h)
key = ECC.generate(curve='P-256')
# print(key)
print(key.export_key(format="PEM"))
# print()
# print(key.public_key().export_key(format="PEM"))
# print()
# print(dir(key))
signer = DSS.new(key, 'fips-186-3')
signature = signer.sign(h)
print(signature)
text = b"123456"
h = SHA256.new(text)
verifier = DSS.new(key.public_key(), 'fips-186-3')
print(verifier.verify(h, signature))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment