-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signature validation for file now working
- Loading branch information
1 parent
d4a6bbd
commit fc2d5dc
Showing
7 changed files
with
214 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,4 +155,6 @@ core | |
/id_dsa* | ||
/id_ed25519* | ||
hello.txt | ||
hello.txt.sig | ||
hello.txt.sig | ||
|
||
/testkeys |
This file was deleted.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
#!/bin/bash | ||
ssh-keygen -t rsa -b 4096 -f id_rsa -N '' | ||
echo "Hello World" > hello.txt | ||
ssh-keygen -Y sign -n hello@world -f id_rsa hello.txt | ||
ssh-keygen -t ecdsa -f id_ecdsa -N '' | ||
ssh-keygen -t ed25519 -f id_ed25519 -N '' | ||
echo "Hello World" | tee rsa.txt | tee ecdsa.txt | tee ed25519.txt | ||
|
||
ssh-keygen -Y sign -n hello@world -f id_rsa rsa.txt | ||
ssh-keygen -Y sign -n hello@world -f id_ecdsa ecdsa.txt | ||
ssh-keygen -Y sign -n hello@world -f id_ed25519 ed25519.txt |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from src.sshkey_tools import ( | ||
fields as _F, | ||
keys as _K, | ||
exceptions as _E, | ||
signatures as _S | ||
) | ||
|
||
|
||
# Validate files created with ssh-keygen (WORKS!) | ||
rsa_pub = _K.PublicKey.from_file('testkeys/id_rsa.pub') | ||
ecdsa_pub = _K.PublicKey.from_file('testkeys/id_ecdsa.pub') | ||
ed25519_pub = _K.PublicKey.from_file('testkeys/id_ed25519.pub') | ||
|
||
rsa_sign = _S.SSHSignature.from_file('testkeys/rsa.txt.sig') | ||
ecdsa_sign = _S.SSHSignature.from_file('testkeys/ecdsa.txt.sig') | ||
ed25519_sign = _S.SSHSignature.from_file('testkeys/ed25519.txt.sig') | ||
|
||
rsa_data = open('rsa.txt', 'rb').read() | ||
ecdsa_data = open('ecdsa.txt', 'rb').read() | ||
ed25519_data = open('ed25519.txt', 'rb').read() | ||
|
||
rsa_signable = rsa_sign.get_signable(rsa_data) | ||
ecdsa_signable = ecdsa_sign.get_signable(ecdsa_data) | ||
ed25519_signable = ed25519_sign.get_signable(ed25519_data) | ||
|
||
try: | ||
rsa_pub.verify(rsa_signable, rsa_sign.fields.signature.value) | ||
except: | ||
print("RSA validation failed") | ||
|
||
try: | ||
ecdsa_pub.verify(ecdsa_signable, ecdsa_sign.fields.signature.value) | ||
except: | ||
print("ECDSA validation failed") | ||
|
||
try: | ||
ed25519_pub.verify(ed25519_signable, ed25519_sign.fields.signature.value) | ||
except: | ||
print("Ed25519 validation failed") | ||
|
||
print() |