-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EC2: Add support for ED25519 SSH key pairs (#6904)
- Loading branch information
1 parent
e594430
commit 760e28b
Showing
6 changed files
with
104 additions
and
52 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
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 |
---|---|---|
@@ -1,14 +1,23 @@ | ||
from cryptography.hazmat.backends import default_backend | ||
from cryptography.hazmat.primitives import serialization | ||
from cryptography.hazmat.primitives.asymmetric import rsa | ||
from cryptography.hazmat.primitives.asymmetric import rsa, ed25519 | ||
|
||
|
||
def rsa_check_private_key(private_key_material): | ||
def check_private_key(private_key_material, key_type): | ||
assert isinstance(private_key_material, str) | ||
|
||
private_key = serialization.load_pem_private_key( | ||
data=private_key_material.encode("ascii"), | ||
backend=default_backend(), | ||
password=None, | ||
) | ||
assert isinstance(private_key, rsa.RSAPrivateKey) | ||
if key_type == "rsa": | ||
private_key = serialization.load_pem_private_key( | ||
data=private_key_material.encode("ascii"), | ||
backend=default_backend(), | ||
password=None, | ||
) | ||
assert isinstance(private_key, rsa.RSAPrivateKey) | ||
elif key_type == "ed25519": | ||
private_key = serialization.load_ssh_private_key( | ||
data=private_key_material.encode("ascii"), | ||
password=None, | ||
) | ||
assert isinstance(private_key, ed25519.Ed25519PrivateKey) | ||
else: | ||
raise AssertionError("Bad private key") |
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