Skip to content

Commit

Permalink
Merge pull request #12 from SendSafely/v3.0.9
Browse files Browse the repository at this point in the history
v3.0.9
  • Loading branch information
SendSafely-GitHub authored May 2, 2024
2 parents c7309f3 + 042ae1d commit 6fd930e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 35 deletions.
6 changes: 3 additions & 3 deletions SampleConsoleApplication/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SendSafelyConsoleApplication")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1")]
[assembly: AssemblyFileVersion("1.0.1")]
10 changes: 7 additions & 3 deletions SampleConsoleApplication/SendSafelyConsoleApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="SendsafelyAPI, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\SendsafelyAPI\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SendsafelyAPI, Version=3.0.9.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SendsafelyAPI\bin\Debug\SendsafelyAPI.dll</HintPath>
<HintPath>..\SendsafelyAPI\SendsafelyAPI\bin\Debug\SendsafelyAPI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -53,13 +56,14 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SendsafelyAPI\SendsafelyAPI.csproj">
<ProjectReference Include="..\SendsafelyAPI\SendsafelyAPI\SendsafelyAPI.csproj">
<Project>{9BDEB9EC-7B8C-44DD-A3A1-9EF4F2B2499E}</Project>
<Name>SendsafelyAPI</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
4 changes: 4 additions & 0 deletions SampleConsoleApplication/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
</packages>
33 changes: 18 additions & 15 deletions SendsafelyAPI/Objects/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,24 @@ private void Initialize(String host, String privateKey, String apiKey)

private String SendRequest(Endpoint p, Object request)
{
Stream objStream = CallServer(p, request);

StreamReader objReader = new StreamReader(objStream);

String sLine = "";
String response = "";
while (sLine != null)
using (var objStream = CallServer(p, request))
{
sLine = objReader.ReadLine();
if (sLine != null)
StreamReader objReader = new StreamReader(objStream);

String sLine = "";
String response = "";
while (sLine != null)
{
response += sLine;
Logger.Log(sLine);
sLine = objReader.ReadLine();
if (sLine != null)
{
response += sLine;
Logger.Log(sLine);
}
}
}

return response;
return response;
}
}

private String generateUserAgent()
Expand Down Expand Up @@ -292,8 +293,10 @@ private void WriteOutput(WebRequest req, String requestString)
byte[] reqData = System.Text.Encoding.UTF8.GetBytes(requestString);

req.ContentLength = reqData.Length;
Stream dataStream = req.GetRequestStream();
dataStream.Write(reqData, 0, reqData.Length);

using (var dataStream = req.GetRequestStream()) {
dataStream.Write(reqData, 0, reqData.Length);
}
}

private void SetTlsProtocol()
Expand Down
8 changes: 3 additions & 5 deletions SendsafelyAPI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SendSafely Windows Client API")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,7 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.8")]
[assembly: AssemblyFileVersion("3.0.8")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("APITests")]
[assembly: AssemblyVersion("3.0.9")]
[assembly: AssemblyFileVersion("3.0.9")]
19 changes: 13 additions & 6 deletions SendsafelyAPI/SendsafelyAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SendSafely</RootNamespace>
<AssemblyName>SendsafelyAPI</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -20,6 +20,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -30,19 +31,22 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\SendsafelyAPI.XML</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto">
<HintPath>ThirdParty\BouncyCastle.Crypto.dll</HintPath>
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938">
<HintPath>..\packages\BouncyCastle.Cryptography.2.3.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json">
<HintPath>ThirdParty\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
Expand Down Expand Up @@ -180,10 +184,13 @@
<ItemGroup>
<Folder Include="dll\" />
<Folder Include="Enums\" />
<Content Include="LICENSE.txt">
<Content Include="LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
6 changes: 3 additions & 3 deletions SendsafelyAPI/Utilities/CryptUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void EncryptFile(FileInfo encryptedFile, FileInfo inputFile, String filen
using (FileStream outStream = encryptedFile.OpenWrite())
{
PgpEncryptedDataGenerator cPk = new PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag.Aes256, true);
cPk.AddMethod(passPhrase);
cPk.AddMethod(passPhrase,HashAlgorithmTag.Sha256);
using (Stream cOut = cPk.Open(outStream, new byte[1 << 16]))
{
WriteFileToLiteralData(cOut, PgpLiteralData.Binary, inputFile, filename, inputFile.Length);
Expand Down Expand Up @@ -157,7 +157,7 @@ public String EncryptMessage(String unencryptedMessage, char[] passPhrase)
lData.Close();

PgpEncryptedDataGenerator cPk = new PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag.Aes256, true);
cPk.AddMethod(passPhrase);
cPk.AddMethod(passPhrase, HashAlgorithmTag.Sha256);

byte[] bytes = bOut.ToArray();

Expand Down Expand Up @@ -307,7 +307,7 @@ private Keypair Armor(AsymmetricCipherKeyPair keyPair, String email)

AsymmetricCipherKeyPair subKeyPair = generateAsymmetricCipherKeyPair();
PgpSignatureSubpacketGenerator subPackets = new PgpSignatureSubpacketGenerator();
subPackets.SetKeyFlags(false,KeyFlags.Authentication | KeyFlags.CertifyOther | KeyFlags.SignData);
subPackets.SetKeyFlags(false,KeyFlags.CertifyOther | KeyFlags.SignData);
subPackets.SetKeyExpirationTime(false, 0);

PgpKeyPair pgpMasterKey = new PgpKeyPair(PublicKeyAlgorithmTag.RsaGeneral, publicKey, privateKey, DateTime.Now);
Expand Down
5 changes: 5 additions & 0 deletions SendsafelyAPI/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle.Cryptography" version="2.3.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
</packages>

0 comments on commit 6fd930e

Please sign in to comment.