Skip to content

Commit d89c44e

Browse files
committed
Drop DSA
DSA is removed at compile time from OpenSSH 9.8 and higher. That means we can no longer test it in our integration tests. It seems like a good time to remove it. From the OpenSSH release notes: DSA, as specified in the SSHv2 protocol, is inherently weak - being limited to a 160 bit private key and use of the SHA1 digest. Its estimated security level is only 80 bits symmetric equivalent. OpenSSH has disabled DSA keys by default since 2015 but has retained run-time optional support for them. DSA was the only mandatory-to- implement algorithm in the SSHv2 RFCs, mostly because alternative algorithms were encumbered by patents when the SSHv2 protocol was specified. This has not been the case for decades at this point and better algorithms are well supported by all actively-maintained SSH implementations. We do not consider the costs of maintaining DSA in OpenSSH to be justified and hope that removing it from OpenSSH can accelerate its wider deprecation in supporting cryptography libraries.
1 parent 29997ae commit d89c44e

25 files changed

+6
-749
lines changed

src/Renci.SshNet/ConnectionInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
404404
hostAlgs.Add("rsa-sha2-512", data => { var key = new RsaKey(new SshKeyData(data)); return new KeyHostAlgorithm("rsa-sha2-512", key, new RsaDigitalSignature(key, HashAlgorithmName.SHA512)); });
405405
hostAlgs.Add("rsa-sha2-256", data => { var key = new RsaKey(new SshKeyData(data)); return new KeyHostAlgorithm("rsa-sha2-256", key, new RsaDigitalSignature(key, HashAlgorithmName.SHA256)); });
406406
hostAlgs.Add("ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(new SshKeyData(data))));
407-
hostAlgs.Add("ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(new SshKeyData(data))));
408407
#pragma warning restore SA1107 // Code should not contain multiple statements on one line
409408
HostKeyAlgorithms = hostAlgs;
410409

src/Renci.SshNet/PrivateKeyFile.PKCS1.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ public Key Parse()
8383
{
8484
case "RSA PRIVATE KEY":
8585
return new RsaKey(decryptedData);
86-
case "DSA PRIVATE KEY":
87-
return new DsaKey(decryptedData);
8886
case "EC PRIVATE KEY":
8987
return new EcdsaKey(decryptedData);
9088
default:

src/Renci.SshNet/PrivateKeyFile.PKCS8.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,6 @@ public Key Parse()
5454
return new RsaKey(key);
5555
}
5656

57-
if (algorithmOid.Equals(X9ObjectIdentifiers.IdDsa))
58-
{
59-
var parameters = privateKeyInfo.PrivateKeyAlgorithm.Parameters.GetDerEncoded();
60-
var parametersReader = new AsnReader(parameters, AsnEncodingRules.BER);
61-
var sequenceReader = parametersReader.ReadSequence();
62-
parametersReader.ThrowIfNotEmpty();
63-
64-
var p = sequenceReader.ReadInteger();
65-
var q = sequenceReader.ReadInteger();
66-
var g = sequenceReader.ReadInteger();
67-
sequenceReader.ThrowIfNotEmpty();
68-
69-
var keyReader = new AsnReader(key, AsnEncodingRules.BER);
70-
var x = keyReader.ReadInteger();
71-
keyReader.ThrowIfNotEmpty();
72-
73-
var y = BigInteger.ModPow(g, x, p);
74-
75-
return new DsaKey(p, q, g, y, x);
76-
}
77-
7857
if (algorithmOid.Equals(X9ObjectIdentifiers.IdECPublicKey))
7958
{
8059
var parameters = privateKeyInfo.PrivateKeyAlgorithm.Parameters.GetDerEncoded();

src/Renci.SshNet/PrivateKeyFile.PuTTY.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,12 @@ public Key Parse()
184184
var prv = privateKeyReader.ReadBignum2();
185185
parsedKey = new EcdsaKey(curve, pub, prv);
186186
break;
187-
case "ssh-dss":
188-
var p = publicKeyReader.ReadBignum();
189-
var q = publicKeyReader.ReadBignum();
190-
var g = publicKeyReader.ReadBignum();
191-
var y = publicKeyReader.ReadBignum();
192-
var x = privateKeyReader.ReadBignum();
193-
parsedKey = new DsaKey(p, q, g, y, x);
194-
break;
195187
case "ssh-rsa":
196188
var exponent = publicKeyReader.ReadBignum(); // e
197189
var modulus = publicKeyReader.ReadBignum(); // n
198190
var d = privateKeyReader.ReadBignum(); // d
199-
p = privateKeyReader.ReadBignum(); // p
200-
q = privateKeyReader.ReadBignum(); // q
191+
var p = privateKeyReader.ReadBignum(); // p
192+
var q = privateKeyReader.ReadBignum(); // q
201193
var inverseQ = privateKeyReader.ReadBignum(); // iqmp
202194
parsedKey = new RsaKey(modulus, exponent, d, p, q, inverseQ);
203195
break;

src/Renci.SshNet/PrivateKeyFile.SSHCOM.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,6 @@ public Key Parse()
8282
var p = reader.ReadBigIntWithBits(); // q
8383
return new RsaKey(modulus, exponent, d, p, q, inverseQ);
8484
}
85-
else if (keyType.Contains("dsa"))
86-
{
87-
var zero = reader.ReadUInt32();
88-
if (zero != 0)
89-
{
90-
throw new SshException("Invalid private key");
91-
}
92-
93-
var p = reader.ReadBigIntWithBits();
94-
var g = reader.ReadBigIntWithBits();
95-
var q = reader.ReadBigIntWithBits();
96-
var y = reader.ReadBigIntWithBits();
97-
var x = reader.ReadBigIntWithBits();
98-
return new DsaKey(p, q, g, y, x);
99-
}
10085

10186
throw new NotSupportedException(string.Format("Key type '{0}' is not supported.", keyType));
10287
}

src/Renci.SshNet/PrivateKeyFile.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,6 @@ private void Open(Stream privateKey, string? passPhrase)
384384
_hostAlgorithms.Add(new KeyHostAlgorithm("rsa-sha2-256", _key, new RsaDigitalSignature(rsaKey, HashAlgorithmName.SHA256)));
385385
#pragma warning restore CA2000 // Dispose objects before losing scope
386386
}
387-
else if (_key is DsaKey)
388-
{
389-
_hostAlgorithms.Add(new KeyHostAlgorithm("ssh-dss", _key));
390-
}
391387
else
392388
{
393389
_hostAlgorithms.Add(new KeyHostAlgorithm(_key.ToString(), _key));

src/Renci.SshNet/Security/Certificate.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,6 @@ private Key ReadPublicKey(out SshKeyData keyData)
348348
349349
keyData = new SshKeyData("ssh-rsa", LoadPublicKeys(2));
350350
return new RsaKey(keyData);
351-
352-
keyData = new SshKeyData("ssh-dss", LoadPublicKeys(4));
353-
return new DsaKey(keyData);
354351
355352
356353

src/Renci.SshNet/Security/Cryptography/DsaDigitalSignature.cs

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)