|
3 | 3 | import io
|
4 | 4 |
|
5 | 5 | from cryptography.hazmat.primitives import serialization, asymmetric
|
6 |
| -import paramiko |
| 6 | +from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey |
| 7 | + |
7 | 8 | from jinja2 import Environment, FileSystemLoader
|
8 | 9 | from .util import templates_path, ROOT_DIR
|
9 | 10 |
|
@@ -68,20 +69,20 @@ def init(wd: Path, project_name: str):
|
68 | 69 | )
|
69 | 70 |
|
70 | 71 |
|
71 |
| -def generate_deploy_keys() -> Tuple[bytes, bytes, paramiko.Ed25519Key]: |
72 |
| - c_ed25519key = asymmetric.ed25519.Ed25519PrivateKey.generate() # type: ignore |
73 |
| - privpem = c_ed25519key.private_bytes( |
| 72 | +def generate_deploy_keys() -> Tuple[bytes, bytes]: |
| 73 | + private_key = Ed25519PrivateKey.generate() |
| 74 | + |
| 75 | + public_key = private_key.public_key() |
| 76 | + |
| 77 | + private_bytes = private_key.private_bytes( |
74 | 78 | encoding=serialization.Encoding.PEM,
|
75 |
| - format=serialization.PrivateFormat.OpenSSH, |
| 79 | + format=serialization.PrivateFormat.PKCS8, |
76 | 80 | encryption_algorithm=serialization.NoEncryption(),
|
77 | 81 | )
|
78 |
| - priv_obj = io.StringIO(privpem.decode()) |
79 |
| - p_ed25519key = paramiko.Ed25519Key.from_private_key(priv_obj) |
80 | 82 |
|
81 |
| - pub = c_ed25519key.public_key() |
82 |
| - openssh_pub = pub.public_bytes( |
83 |
| - encoding=serialization.Encoding.OpenSSH, |
84 |
| - format=serialization.PublicFormat.OpenSSH, |
| 83 | + public_bytes = public_key.public_bytes( |
| 84 | + encoding=serialization.Encoding.PEM, |
| 85 | + format=serialization.PublicFormat.SubjectPublicKeyInfo, |
85 | 86 | )
|
86 | 87 |
|
87 |
| - return privpem, openssh_pub, p_ed25519key |
| 88 | + return private_bytes, public_bytes |
0 commit comments