@@ -250,11 +250,11 @@ private void Open(Stream privateKey, string passPhrase)
250250 case "RSA" :
251251 var rsaKey = new RsaKey ( decryptedData ) ;
252252 _key = rsaKey ;
253+ _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
253254#pragma warning disable CA2000 // Dispose objects before losing scope
254255 _hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-512" , _key , new RsaDigitalSignature ( rsaKey , HashAlgorithmName . SHA512 ) ) ) ;
255256 _hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-256" , _key , new RsaDigitalSignature ( rsaKey , HashAlgorithmName . SHA256 ) ) ) ;
256257#pragma warning restore CA2000 // Dispose objects before losing scope
257- _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
258258 break ;
259259 case "DSA" :
260260 _key = new DsaKey ( decryptedData ) ;
@@ -268,11 +268,11 @@ private void Open(Stream privateKey, string passPhrase)
268268 _key = ParseOpenSshV1Key ( decryptedData , passPhrase ) ;
269269 if ( _key is RsaKey parsedRsaKey )
270270 {
271+ _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
271272#pragma warning disable CA2000 // Dispose objects before losing scope
272273 _hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-512" , _key , new RsaDigitalSignature ( parsedRsaKey , HashAlgorithmName . SHA512 ) ) ) ;
273274 _hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-256" , _key , new RsaDigitalSignature ( parsedRsaKey , HashAlgorithmName . SHA256 ) ) ) ;
274275#pragma warning restore CA2000 // Dispose objects before losing scope
275- _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
276276 }
277277 else
278278 {
@@ -337,11 +337,11 @@ private void Open(Stream privateKey, string passPhrase)
337337 var p = reader . ReadBigIntWithBits ( ) ; // q
338338 var decryptedRsaKey = new RsaKey ( modulus , exponent , d , p , q , inverseQ ) ;
339339 _key = decryptedRsaKey ;
340+ _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
340341#pragma warning disable CA2000 // Dispose objects before losing scope
341342 _hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-512" , _key , new RsaDigitalSignature ( decryptedRsaKey , HashAlgorithmName . SHA512 ) ) ) ;
342343 _hostAlgorithms . Add ( new KeyHostAlgorithm ( "rsa-sha2-256" , _key , new RsaDigitalSignature ( decryptedRsaKey , HashAlgorithmName . SHA256 ) ) ) ;
343344#pragma warning restore CA2000 // Dispose objects before losing scope
344- _hostAlgorithms . Add ( new KeyHostAlgorithm ( "ssh-rsa" , _key ) ) ;
345345 }
346346 else if ( keyType == "dl-modp{sign{dsa-nist-sha1},dh{plain}}" )
347347 {
0 commit comments