@@ -250,11 +250,11 @@ private void Open(Stream privateKey, string passPhrase)
250
250
case "RSA" :
251
251
var rsaKey = new RsaKey ( decryptedData ) ;
252
252
_key = rsaKey ;
253
+ _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
253
254
#pragma warning disable CA2000 // Dispose objects before losing scope
254
255
_hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-512" , _key , new RsaDigitalSignature ( rsaKey , HashAlgorithmName . SHA512 ) ) ) ;
255
256
_hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-256" , _key , new RsaDigitalSignature ( rsaKey , HashAlgorithmName . SHA256 ) ) ) ;
256
257
#pragma warning restore CA2000 // Dispose objects before losing scope
257
- _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
258
258
break ;
259
259
case "DSA" :
260
260
_key = new DsaKey ( decryptedData ) ;
@@ -268,11 +268,11 @@ private void Open(Stream privateKey, string passPhrase)
268
268
_key = ParseOpenSshV1Key ( decryptedData , passPhrase ) ;
269
269
if ( _key is RsaKey parsedRsaKey )
270
270
{
271
+ _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
271
272
#pragma warning disable CA2000 // Dispose objects before losing scope
272
273
_hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-512" , _key , new RsaDigitalSignature ( parsedRsaKey , HashAlgorithmName . SHA512 ) ) ) ;
273
274
_hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-256" , _key , new RsaDigitalSignature ( parsedRsaKey , HashAlgorithmName . SHA256 ) ) ) ;
274
275
#pragma warning restore CA2000 // Dispose objects before losing scope
275
- _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
276
276
}
277
277
else
278
278
{
@@ -337,11 +337,11 @@ private void Open(Stream privateKey, string passPhrase)
337
337
var p = reader . ReadBigIntWithBits ( ) ; // q
338
338
var decryptedRsaKey = new RsaKey ( modulus , exponent , d , p , q , inverseQ ) ;
339
339
_key = decryptedRsaKey ;
340
+ _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
340
341
#pragma warning disable CA2000 // Dispose objects before losing scope
341
342
_hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-512" , _key , new RsaDigitalSignature ( decryptedRsaKey , HashAlgorithmName . SHA512 ) ) ) ;
342
343
_hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-256" , _key , new RsaDigitalSignature ( decryptedRsaKey , HashAlgorithmName . SHA256 ) ) ) ;
343
344
#pragma warning restore CA2000 // Dispose objects before losing scope
344
- _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
345
345
}
346
346
else if ( keyType == "dl-modp{sign{dsa-nist-sha1},dh{plain}}" )
347
347
{
0 commit comments