Skip to content

Commit 60f3cd8

Browse files
authored
Drop DSA (#1558)
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 2e68828 commit 60f3cd8

25 files changed

+6
-749
lines changed

src/Renci.SshNet/ConnectionInfo.cs

-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy
407407
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)); });
408408
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)); });
409409
hostAlgs.Add("ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(new SshKeyData(data))));
410-
hostAlgs.Add("ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(new SshKeyData(data))));
411410
#pragma warning restore SA1107 // Code should not contain multiple statements on one line
412411
HostKeyAlgorithms = hostAlgs;
413412

src/Renci.SshNet/PrivateKeyFile.PKCS1.cs

-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public Key Parse()
8080
{
8181
case "RSA PRIVATE KEY":
8282
return new RsaKey(decryptedData);
83-
case "DSA PRIVATE KEY":
84-
return new DsaKey(decryptedData);
8583
case "EC PRIVATE KEY":
8684
return new EcdsaKey(decryptedData);
8785
default:

src/Renci.SshNet/PrivateKeyFile.PKCS8.cs

-21
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

+2-10
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

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

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

src/Renci.SshNet/PrivateKeyFile.cs

-4
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,6 @@ private void Open(Stream privateKey, string? passPhrase)
381381
_hostAlgorithms.Add(new KeyHostAlgorithm("rsa-sha2-256", _key, new RsaDigitalSignature(rsaKey, HashAlgorithmName.SHA256)));
382382
#pragma warning restore CA2000 // Dispose objects before losing scope
383383
}
384-
else if (_key is DsaKey)
385-
{
386-
_hostAlgorithms.Add(new KeyHostAlgorithm("ssh-dss", _key));
387-
}
388384
else
389385
{
390386
_hostAlgorithms.Add(new KeyHostAlgorithm(_key.ToString(), _key));

src/Renci.SshNet/Security/Certificate.cs

-3
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

-86
This file was deleted.

0 commit comments

Comments
 (0)