versioning fix

This commit is contained in:
Dimitrij
2024-06-11 14:11:52 +01:00
parent 0b7ce92af8
commit 3039b25a66
5 changed files with 23 additions and 23 deletions

View File

@@ -12,10 +12,6 @@ public class PuttyKeyFileGenerator
private const string keyType = "ssh-rsa";
private const string encryptionType = "none";
// source from
// https://gist.github.com/canton7/5670788?permalink_comment_id=3240331
// https://gist.github.com/bosima/ee6630d30b533c7d7b2743a849e9b9d0
public static string ToPuttyPrivateKey(RSACryptoServiceProvider cryptoServiceProvider, string Comment = "imported-openssh-key")
{
var publicParameters = cryptoServiceProvider.ExportParameters(false);
@@ -24,7 +20,7 @@ public class PuttyKeyFileGenerator
using (var bw = new BinaryWriter(new MemoryStream(publicBuffer)))
{
bw.Write(new byte[] { 0x00, 0x00, 0x00 });
bw.Write(keyType);
bw.Write(Encoding.ASCII.GetBytes(keyType));
PutPrefixed(bw, publicParameters.Exponent, CheckIsNeddPadding(publicParameters.Exponent));
PutPrefixed(bw, publicParameters.Modulus, CheckIsNeddPadding(publicParameters.Modulus));
}
@@ -37,20 +33,19 @@ public class PuttyKeyFileGenerator
using (var bw = new BinaryWriter(new MemoryStream(privateBuffer)))
{
PutPrefixed(bw, privateParameters.D, true);
PutPrefixed(bw, privateParameters.P, true);
PutPrefixed(bw, privateParameters.P!, true);
PutPrefixed(bw, privateParameters.Q, true);
PutPrefixed(bw, privateParameters.InverseQ, true);
}
var privateBlob = System.Convert.ToBase64String(privateBuffer);
HMACSHA1 hmacSha1 = new(SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes("putty-private-key-file-mac-key")));
//byte[] bytesToHash = new byte[4 + 7 + 4 + 4 + 4 + Comment.Length + 4 + publicBuffer.Length + 4 + privateBuffer.Length];
byte[] bytesToHash = new byte[prefixSize + keyType.Length + prefixSize + encryptionType.Length + prefixSize + Comment.Length + prefixSize + publicBuffer.Length + prefixSize + privateBuffer.Length];
using (var bw = new BinaryWriter(new MemoryStream(bytesToHash)))
{
PutPrefixed(bw, Encoding.ASCII.GetBytes("ssh-rsa"));
PutPrefixed(bw, Encoding.ASCII.GetBytes("none"));
PutPrefixed(bw, Encoding.ASCII.GetBytes(keyType));
PutPrefixed(bw, Encoding.ASCII.GetBytes(encryptionType));
PutPrefixed(bw, Encoding.ASCII.GetBytes(Comment));
PutPrefixed(bw, publicBuffer);
PutPrefixed(bw, privateBuffer);
@@ -89,21 +84,26 @@ public class PuttyKeyFileGenerator
bw.Write(new byte[] { 0x00 });
bw.Write(bytes);
}
private static string[] SpliceText(string text, int lineLength)
{
return Regex.Matches(text, ".{1," + lineLength + "}").Cast<Match>().Select(m => m.Value).ToArray();
}
private static int GetPrefixSize(byte[] bytes)
private static int GetPrefixSize(byte[]? bytes)
{
if (bytes is null)
return 0;
return CheckIsNeddPadding(bytes) ? paddedPrefixSize : prefixSize;
}
private static bool CheckIsNeddPadding(byte[] bytes)
{
if (bytes is null || bytes.Length == 0)
return false;
// 128 == 10000000
// This means that the number of bits can be divided by 8.
// According to the algorithm in putty, you need to add a padding.
return bytes[0] >= 128;
}
}
}

View File

@@ -13,15 +13,15 @@ using System.Resources;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("mRemoteNG")]
[assembly: AssemblyProduct("mRemoteNG Connection Manager")]
[assembly: AssemblyCopyright("(c) 2023 mRemoteNG")]
[assembly: AssemblyCopyright("(c) 2024 mRemoteNG")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information
[assembly: AssemblyVersion("1.77.3.1764")]
[assembly: AssemblyFileVersion("1.77.3.1764")]
[assembly: AssemblyVersion("1.77.3.1765")]
[assembly: AssemblyFileVersion("1.77.3.1765")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
[assembly: AssemblyInformationalVersion("1.77.3 (Nightly Build 1764)")]
[assembly: AssemblyInformationalVersion("1.77.3 (Nightly Build 1765)")]
// Logging
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config")]

View File

@@ -15,7 +15,7 @@ using System.Resources;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("mRemoteNG")]
[assembly: AssemblyProduct("mRemoteNG Connection Manager")]
[assembly: AssemblyCopyright("(c) 2023 mRemoteNG")]
[assembly: AssemblyCopyright("(c) 2024 mRemoteNG")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -29,7 +29,7 @@ using System.Resources;
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config")]
<#+
//build is a days from date of last release + curent hour + curent minute of build
//build is a number of days from date of last release + curent hour + curent minute of build
int major = 1;
int minor = 77;
int revision = 3;

View File

@@ -36,7 +36,7 @@ namespace mRemoteNG.UI.Tabs
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern uint SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
//[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
protected override void WndProc(ref Message m)
{
int WM_NCLBUTTONDOWN = 0x00A1;
@@ -53,9 +53,9 @@ namespace mRemoteNG.UI.Tabs
if ((uint)m.WParam == 8) // Check if button down occured in minimize box
{
if (WindowState == FormWindowState.Minimized)
FloatWindowNG.SendMessage(Handle, (int)WM_SYSCOMMAND, (uint)SC_RESTORE, 0);
_ = FloatWindowNG.SendMessage(Handle, (int)WM_SYSCOMMAND, (uint)SC_RESTORE, 0);
else
FloatWindowNG.SendMessage(Handle, (int)WM_SYSCOMMAND, (uint)SC_MINIMIZE, 0);
_ = FloatWindowNG.SendMessage(Handle, (int)WM_SYSCOMMAND, (uint)SC_MINIMIZE, 0);
return;
}

View File

@@ -491,7 +491,7 @@
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="echo $(ConfigurationName) &gt; buildenv.tmp&#xD;&#xA;powershell.exe -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -Command &quot;$InfoText='[Pre-Build-Event-Info]';'{0} PowerShell Version: {1}' -f $InfoText,$PSVersionTable.PSVersion.toString(); $VSToolsDir=(. '$(SolutionDir)Tools\find_vstool.ps1' -FileName 'devenv.exe'); $Env:DevEnvDir = Split-Path -Path $VSToolsDir -Parent; '{0} VS tools dir found: {1}' -f $InfoText,$Env:DevEnvDir;if ($Env:APPVEYOR) {'{0} AppVeyor (cloud based CI/CD) environment detected' -f $InfoText; &amp;'$(DevEnvDir)TextTransform.exe' -a !!BuildConfiguration!'$(Configuration)' '$(ProjectDir)Properties\AssemblyInfo.tt'} else {'{0} None AppVeyor (cloud based CI/CD) environment detected, continue' -f $InfoText;}&quot;" />
<Exec Command="echo $(ConfigurationName) &gt; buildenv.tmp&#xD;&#xA;powershell.exe -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -Command &quot;$InfoText='[Pre-Build-Event-Info]';'{0} PowerShell Version: {1}' -f $InfoText,$PSVersionTable.PSVersion.toString(); $VSToolsDir=(. '$(SolutionDir)Tools\find_vstool.ps1' -FileName 'devenv.exe'); $Env:DevEnvDir = Split-Path -Path $VSToolsDir -Parent; '{0} VS tools dir found: {1}' -f $InfoText,$Env:DevEnvDir;if ($Env:APPVEYOR) {'{0} AppVeyor (cloud based CI/CD) environment detected' -f $InfoText; &amp;'$(DevEnvDir)TextTransform.exe' -a !!BuildConfiguration!'$(Configuration)' '$(ProjectDir)Properties\AssemblyInfo.tt'} else {'{0} None AppVeyor (cloud based CI/CD) environment detected, continue' -f $InfoText; &amp;'$(DevEnvDir)TextTransform.exe' -a !!BuildConfiguration!'$(Configuration)' '$(ProjectDir)Properties\AssemblyInfo.tt'}&quot;" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command=":: When passing paths to powershell scripts, check if the path ends with a backslash &quot;\&quot;&#xD;&#xA;:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.&#xD;&#xA;&#xD;&#xA;powershell -noprofile -command &quot;sleep 2&quot;&#xD;&#xA;&#xD;&#xA;set /p buildenv=&lt;buildenv.tmp&#xD;&#xA;&#xD;&#xA;:: Manual builds, set the cert password and uncomment below.&#xD;&#xA;:: IF &quot;%25APPVEYOR_BUILD_FOLDER&quot;==&quot;&quot; ( set cert_pwd= )&#xD;&#xA;&#xD;&#xA;:: Call the post build powershell script&#xD;&#xA;powershell.exe -ExecutionPolicy Bypass -File &quot;$(SolutionDir)Tools\postbuild.ps1&quot; -SolutionDir &quot;$(SolutionDir)\&quot; -TargetDir &quot;$(TargetDir)\&quot; -TargetFileName &quot;mRemoteNG.exe&quot; -ConfigurationName &quot;%25buildenv%25&quot; -CertificatePath &quot;$(CertPath)&quot; -CertificatePassword &quot;$(CertPassword)&quot; -ExcludeFromSigning &quot;putty.exe&quot;" />