Skip to content

Commit 8c228ca

Browse files
committed
Lock cryptography requirement to <41
Introduced deprecation notice
1 parent cd58114 commit 8c228ca

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
Python package for managing OpenSSH keypairs and certificates ([protocol.CERTKEYS](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys)). Supported functionality includes:
44

55
# Notice
6+
The DSA algorithm has been deprecated and is removed in pyca/cryptography 41.x, meaning **version 0.9.* of this package will be the last to support DSA keys and certificates** for SSH. If there is any demand to reintroduce DSA support, please open an issue regarding this and we'll look into it.
7+
8+
For now, **0.9.* will be restricted to version <41.1 of the cryptography package** and **0.10 will have its DSA support removed**. We've introduced a deprecation notice in version 0.9.3.
9+
10+
## Background
611
The DSA algorithm is considered deprecated and will be removed in a future version. If possible, use RSA, [(ECDSA)](https://billatnapier.medium.com/ecdsa-weakness-where-nonces-are-reused-2be63856a01a) or ED25519 as a first-hand choice.
712

8-
Notice from OpenSSH:
13+
## Notice from OpenSSH:
914
```
1015
OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostKeyAlgorithms configuration option: sshd_config(5) HostKeyAlgorithms
1116
```
1217

1318
[ECDSA has some flaws](https://billatnapier.medium.com/ecdsa-weakness-where-nonces-are-reused-2be63856a01a), especially when using short nonces or re-using nonces, it can still be used but exercise some caution in regards to nonces/re-signing identical data multiple times.
1419

15-
1620
# Features
1721
### SSH Keys
1822
- Supports RSA, DSA (Note: Deprecated), ECDSA and ED25519 keys

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
click
2-
cryptography
2+
cryptography<41.0.0
33
bcrypt
44
enum34
55
PrettyTable

src/sshkey_tools/cert.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
_EX.NoPrivateKeyException: The certificate contains no private key
99
_EX.NotSignedException: The certificate is not signed and cannot be exported
1010
"""
11+
import warnings
1112
from base64 import b64decode, b64encode
1213
from dataclasses import dataclass
1314
from typing import Tuple, Union
@@ -577,9 +578,16 @@ class RsaCertificate(SSHCertificate):
577578

578579

579580
class DsaCertificate(SSHCertificate):
580-
"""The DSA Certificate class"""
581+
"""The DSA Certificate class (DEPRECATED)"""
581582

582583
DEFAULT_KEY_TYPE = "[email protected]"
584+
585+
def __post_init__(self):
586+
"""Display the deprecation notice"""
587+
warnings.warn(
588+
"SSH DSA keys and certificates are deprecated and will be removed in version 0.10 of sshkey-tools",
589+
stacklevel=2,
590+
)
583591

584592

585593
class EcdsaCertificate(SSHCertificate):

src/sshkey_tools/keys.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Classes for handling SSH public/private keys
33
"""
4+
import warnings
45
from base64 import b64decode
56
from enum import Enum
67
from struct import unpack
@@ -613,6 +614,11 @@ def __init__(
613614
serialized=serialized,
614615
)
615616
self.parameters = key.parameters().parameter_numbers()
617+
618+
warnings.warn(
619+
"SSH DSA keys and certificates are deprecated and will be removed in version 0.10 of sshkey-tools",
620+
stacklevel=2,
621+
)
616622

617623
@classmethod
618624
# pylint: disable=invalid-name
@@ -665,6 +671,11 @@ def __init__(self, key: _DSA.DSAPrivateKey):
665671
public_key=DsaPublicKey(key.public_key()),
666672
private_numbers=key.private_numbers(),
667673
)
674+
675+
warnings.warn(
676+
"SSH DSA keys and certificates are deprecated and will be removed in version 0.10 of sshkey-tools",
677+
stacklevel=2,
678+
)
668679

669680
@classmethod
670681
# pylint: disable=invalid-name,too-many-arguments

0 commit comments

Comments
 (0)