Skip to content

Commit 6fd930e

Browse files
Merge pull request #12 from SendSafely/v3.0.9
v3.0.9
2 parents c7309f3 + 042ae1d commit 6fd930e

8 files changed

Lines changed: 56 additions & 35 deletions

File tree

SampleConsoleApplication/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("SendSafelyConsoleApplication")]
13-
[assembly: AssemblyCopyright("Copyright © 2014")]
13+
[assembly: AssemblyCopyright("Copyright © 2024")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.0.1")]
36+
[assembly: AssemblyFileVersion("1.0.1")]

SampleConsoleApplication/SendSafelyConsoleApplication.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@
3636
<Prefer32Bit>false</Prefer32Bit>
3737
</PropertyGroup>
3838
<ItemGroup>
39-
<Reference Include="SendsafelyAPI, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
39+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
40+
<HintPath>..\SendsafelyAPI\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
41+
</Reference>
42+
<Reference Include="SendsafelyAPI, Version=3.0.9.0, Culture=neutral, processorArchitecture=MSIL">
4043
<SpecificVersion>False</SpecificVersion>
41-
<HintPath>..\SendsafelyAPI\bin\Debug\SendsafelyAPI.dll</HintPath>
44+
<HintPath>..\SendsafelyAPI\SendsafelyAPI\bin\Debug\SendsafelyAPI.dll</HintPath>
4245
</Reference>
4346
<Reference Include="System" />
4447
<Reference Include="System.Core" />
@@ -53,13 +56,14 @@
5356
<Compile Include="Properties\AssemblyInfo.cs" />
5457
</ItemGroup>
5558
<ItemGroup>
56-
<ProjectReference Include="..\SendsafelyAPI\SendsafelyAPI.csproj">
59+
<ProjectReference Include="..\SendsafelyAPI\SendsafelyAPI\SendsafelyAPI.csproj">
5760
<Project>{9BDEB9EC-7B8C-44DD-A3A1-9EF4F2B2499E}</Project>
5861
<Name>SendsafelyAPI</Name>
5962
</ProjectReference>
6063
</ItemGroup>
6164
<ItemGroup>
6265
<None Include="app.config" />
66+
<None Include="packages.config" />
6367
</ItemGroup>
6468
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6569
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
4+
</packages>

SendsafelyAPI/Objects/Connection.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -239,23 +239,24 @@ private void Initialize(String host, String privateKey, String apiKey)
239239

240240
private String SendRequest(Endpoint p, Object request)
241241
{
242-
Stream objStream = CallServer(p, request);
243-
244-
StreamReader objReader = new StreamReader(objStream);
245-
246-
String sLine = "";
247-
String response = "";
248-
while (sLine != null)
242+
using (var objStream = CallServer(p, request))
249243
{
250-
sLine = objReader.ReadLine();
251-
if (sLine != null)
244+
StreamReader objReader = new StreamReader(objStream);
245+
246+
String sLine = "";
247+
String response = "";
248+
while (sLine != null)
252249
{
253-
response += sLine;
254-
Logger.Log(sLine);
250+
sLine = objReader.ReadLine();
251+
if (sLine != null)
252+
{
253+
response += sLine;
254+
Logger.Log(sLine);
255+
}
255256
}
256-
}
257257

258-
return response;
258+
return response;
259+
}
259260
}
260261

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

294295
req.ContentLength = reqData.Length;
295-
Stream dataStream = req.GetRequestStream();
296-
dataStream.Write(reqData, 0, reqData.Length);
296+
297+
using (var dataStream = req.GetRequestStream()) {
298+
dataStream.Write(reqData, 0, reqData.Length);
299+
}
297300
}
298301

299302
private void SetTlsProtocol()

SendsafelyAPI/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("SendSafely Windows Client API")]
13-
[assembly: AssemblyCopyright("Copyright © 2023")]
13+
[assembly: AssemblyCopyright("Copyright © 2024")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,7 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.8")]
36-
[assembly: AssemblyFileVersion("3.0.8")]
37-
38-
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("APITests")]
35+
[assembly: AssemblyVersion("3.0.9")]
36+
[assembly: AssemblyFileVersion("3.0.9")]

SendsafelyAPI/SendsafelyAPI.csproj

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AppDesignerFolder>Properties</AppDesignerFolder>
1212
<RootNamespace>SendSafely</RootNamespace>
1313
<AssemblyName>SendsafelyAPI</AssemblyName>
14-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
14+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1515
<FileAlignment>512</FileAlignment>
1616
<TargetFrameworkProfile />
1717
</PropertyGroup>
@@ -20,6 +20,7 @@
2020
<DebugType>full</DebugType>
2121
<Optimize>false</Optimize>
2222
<OutputPath>bin\Debug\</OutputPath>
23+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
2324
<DefineConstants>DEBUG;TRACE</DefineConstants>
2425
<ErrorReport>prompt</ErrorReport>
2526
<WarningLevel>4</WarningLevel>
@@ -30,19 +31,22 @@
3031
<DebugType>pdbonly</DebugType>
3132
<Optimize>true</Optimize>
3233
<OutputPath>bin\Release\</OutputPath>
34+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
3335
<DefineConstants>TRACE</DefineConstants>
3436
<ErrorReport>prompt</ErrorReport>
3537
<WarningLevel>4</WarningLevel>
3638
<DocumentationFile>bin\Release\SendsafelyAPI.XML</DocumentationFile>
3739
<Prefer32Bit>false</Prefer32Bit>
3840
</PropertyGroup>
3941
<ItemGroup>
40-
<Reference Include="BouncyCastle.Crypto">
41-
<HintPath>ThirdParty\BouncyCastle.Crypto.dll</HintPath>
42+
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938">
43+
<HintPath>..\packages\BouncyCastle.Cryptography.2.3.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
44+
<Private>True</Private>
4245
</Reference>
4346
<Reference Include="Microsoft.CSharp" />
44-
<Reference Include="Newtonsoft.Json">
45-
<HintPath>ThirdParty\Newtonsoft.Json.dll</HintPath>
47+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
48+
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
49+
<Private>True</Private>
4650
</Reference>
4751
<Reference Include="System" />
4852
<Reference Include="System.configuration" />
@@ -180,10 +184,13 @@
180184
<ItemGroup>
181185
<Folder Include="dll\" />
182186
<Folder Include="Enums\" />
183-
<Content Include="LICENSE.txt">
187+
<Content Include="LICENSE.txt">
184188
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
185189
</Content>
186190
</ItemGroup>
191+
<ItemGroup>
192+
<None Include="packages.config" />
193+
</ItemGroup>
187194
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
188195
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
189196
Other similar extension points exist, see Microsoft.Common.targets.

SendsafelyAPI/Utilities/CryptUtility.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void EncryptFile(FileInfo encryptedFile, FileInfo inputFile, String filen
3030
using (FileStream outStream = encryptedFile.OpenWrite())
3131
{
3232
PgpEncryptedDataGenerator cPk = new PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag.Aes256, true);
33-
cPk.AddMethod(passPhrase);
33+
cPk.AddMethod(passPhrase,HashAlgorithmTag.Sha256);
3434
using (Stream cOut = cPk.Open(outStream, new byte[1 << 16]))
3535
{
3636
WriteFileToLiteralData(cOut, PgpLiteralData.Binary, inputFile, filename, inputFile.Length);
@@ -157,7 +157,7 @@ public String EncryptMessage(String unencryptedMessage, char[] passPhrase)
157157
lData.Close();
158158

159159
PgpEncryptedDataGenerator cPk = new PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag.Aes256, true);
160-
cPk.AddMethod(passPhrase);
160+
cPk.AddMethod(passPhrase, HashAlgorithmTag.Sha256);
161161

162162
byte[] bytes = bOut.ToArray();
163163

@@ -307,7 +307,7 @@ private Keypair Armor(AsymmetricCipherKeyPair keyPair, String email)
307307

308308
AsymmetricCipherKeyPair subKeyPair = generateAsymmetricCipherKeyPair();
309309
PgpSignatureSubpacketGenerator subPackets = new PgpSignatureSubpacketGenerator();
310-
subPackets.SetKeyFlags(false,KeyFlags.Authentication | KeyFlags.CertifyOther | KeyFlags.SignData);
310+
subPackets.SetKeyFlags(false,KeyFlags.CertifyOther | KeyFlags.SignData);
311311
subPackets.SetKeyExpirationTime(false, 0);
312312

313313
PgpKeyPair pgpMasterKey = new PgpKeyPair(PublicKeyAlgorithmTag.RsaGeneral, publicKey, privateKey, DateTime.Now);

SendsafelyAPI/packages.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="BouncyCastle.Cryptography" version="2.3.0" targetFramework="net461" />
4+
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net461" />
5+
</packages>

0 commit comments

Comments
 (0)