diffie-hellman group exchange sha256 support - WeOnlyDo Discussion board

diffie-hellman group exchange sha256 support (wodSSH / wodSSH.NET)

by Piotr, Tuesday, March 22, 2016, 08:41 (2956 days ago) @ Jasmine

Hi Jasmine,
we have applied the 2.6.4.160 version of SSH.NET in our software. Unfortunately, we have met an issue with loading this library: WeOnlyDo.Security.Cryptography.KeyManager.dll. The older version of this library (from 2.5.0.130) is working fine. We are able the new version of the library by adding useLegacyV2RuntimeActivationPolicy="true" to App.config, but we would like to avoid it.

Our program is compiled against .NET Framework 4.5.
Code to reproduce:

using System;
using WeOnlyDo.Security.Cryptography;

namespace WeOnlyDoKeyManagmentTest
{
    class Program
    {
        // Program does not work,
        // it can be fixed by adding useLegacyV2RuntimeActivationPolicy="true" to App.config (ref. http://stackoverflow.com/questions/1604663/what-does-uselegacyv2runtimeactivationpolicy-do-in-the-net-4-config)
        // ex: System.IO.FileLoadException
        // message: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
        static void Main()
        {
            const string key = @"-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
";
            var decrypted = DecryptCertificateFile(key, String.Empty, "RSA");

            Console.WriteLine(decrypted);
        }

        public static string DecryptCertificateFile(string content, string password, string keyType)
        {
            SSHKeyTypes sshKeyType;
            switch (keyType.ToLowerInvariant())
            {
                case "rsa":
                    sshKeyType = SSHKeyTypes.RSAKey;
                    break;
                case "dsa":
                    sshKeyType = SSHKeyTypes.DSAKey;
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(keyType));
            }

            try
            {
                var manager = new KeyManager();
                manager.Load(content, password);
                return Convert.ToBase64String(manager.PrivateKey(sshKeyType));
            }
            catch (Exception exception)
            {
                throw new Exception("Can't load private key.", exception);
            }
        }

    }
}

Could you please provide working version? The best option is to compile you library against .net 4.5 (please remember for FIPS version).

Regards,
Piotr


Complete thread: