-
-
Save qs-wang/24d1fb32b2c149072081ffc68da9daa6 to your computer and use it in GitHub Desktop.
Revisions
-
cevaris revised this gist
Mar 3, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,4 +26,5 @@ # Load public key and verify message verifier = PKCS1_v1_5.new(private_key.publickey()) verified = verifier.verify(digest, sig) assert verified, 'Signature verification failed' print 'Successfully verified message' -
cevaris revised this gist
Mar 2, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ #!/usr/bin/env python from base64 import ( b64encode, b64decode, @@ -18,7 +16,7 @@ # Read shared key from file private_key = False with open ("private_key.pem", "r") as myfile: private_key = RSA.importKey(myfile.read()) # Load private key and sign message -
cevaris revised this gist
Mar 2, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ pycrypto==2.6.1 -
cevaris revised this gist
Mar 2, 2015 . 1 changed file with 15 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,31 @@ #!/usr/bin/env python #!/usr/bin/env python from base64 import ( b64encode, b64decode, ) from Crypto.Hash import SHA256 from Crypto.Signature import PKCS1_v1_5 from Crypto.PublicKey import RSA message = "I want this stream signed" digest = SHA256.new() digest.update(message) # Read shared key from file private_key = False with open ("/tmp/gpg/private_key.pem", "r") as myfile: private_key = RSA.importKey(myfile.read()) # Load private key and sign message signer = PKCS1_v1_5.new(private_key) sig = signer.sign(digest) # Load public key and verify message verifier = PKCS1_v1_5.new(private_key.publickey()) verified = verifier.verify(digest, sig) assert verified -
cevaris revised this gist
Mar 2, 2015 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,17 +4,14 @@ from Crypto.Hash import SHA256 from Crypto.Signature import PKCS1_v1_5 from Crypto.PublicKey import RSA message = "I want this stream signed" digest = SHA256.new() digest.update(message) secret_key = False with open ("/tmp/gpg/private_key.pem", "r") as myfile: secret_key = RSA.importKey(myfile.read()) signer = PKCS1_v1_5.new(secret_key) @@ -25,4 +22,6 @@ verifier = PKCS1_v1_5.new(secret_key.publickey()) verified = verifier.verify(digest, sig) assert verified import ipdb; ipdb.set_trace() -
cevaris created this gist
Mar 2, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ #!/usr/bin/env bash # Generate RSA private key openssl genrsa -out private_key.pem 1024 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/usr/bin/env python from base64 import b64encode from Crypto.Hash import SHA256 from Crypto.Signature import PKCS1_v1_5 from Crypto.PublicKey import RSA import hashlib message = "I want this stream signed" message_sha256 = hashlib.sha256(message).digest() digest = SHA256.new() digest.update(message) secret_key = False with open ("private_key.pem", "r") as myfile: secret_key = RSA.importKey(myfile.read()) signer = PKCS1_v1_5.new(secret_key) sig = signer.sign(digest) sig_encode = b64encode(sig) verifier = PKCS1_v1_5.new(secret_key.publickey()) verified = verifier.verify(digest, sig) assert verified