Skip to content

Commit

Permalink
Merge pull request miscreant#165 from Metalnem/master
Browse files Browse the repository at this point in the history
Target .NET Standard 1.3 instead of 2.0 for supporting more platforms
  • Loading branch information
tarcieri authored Apr 3, 2018
2 parents add84e2 + c2f85aa commit 61ad13a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 22 deletions.
5 changes: 4 additions & 1 deletion dotnet/Miscreant/Aead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public byte[] Seal(byte[] plaintext, byte[] nonce = null, byte[] data = null)
/// Open decrypts ciphertext, authenticates the decrypted plaintext
/// and the associated data and, if successful, returns the result.
/// In case of failed decryption, this method throws
/// <see cref="CryptographicException">.
/// <see cref="CryptographicException"/>.
/// </summary>
/// <param name="ciphertext">The ciphertext to decrypt.</param>
/// <param name="nonce">The nonce for encryption.</param>
Expand All @@ -100,6 +100,9 @@ public byte[] Open(byte[] ciphertext, byte[] nonce = null, byte[] data = null)
return siv.Open(ciphertext, data, nonce);
}

/// <summary>
/// Disposes this object.
/// </summary>
public void Dispose()
{
if (!disposed)
Expand Down
5 changes: 4 additions & 1 deletion dotnet/Miscreant/AesCmac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class AesCmac : IMac
/// <summary>
/// Initializes a new instance of the <see cref="AesCmac"/> class with the specified key.
/// </summary>
/// <param name="key">The secret key for <see cref="AesCmac"> authentication.</param>
/// <param name="key">The secret key for <see cref="AesCmac"/> authentication.</param>
public AesCmac(byte[] key)
{
if (key == null)
Expand Down Expand Up @@ -121,6 +121,9 @@ public byte[] HashFinal()
return encryptor.TransformFinalBlock(buffer, 0, BlockSize);
}

/// <summary>
/// Disposes this object.
/// </summary>
public void Dispose()
{
if (!disposed)
Expand Down
14 changes: 7 additions & 7 deletions dotnet/Miscreant/AesCtr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ internal sealed class AesCtr : IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="AesCtr"/> class with the specified key and initialization vector.
/// </summary>
/// <param name="key">The secret key for <see cref="AesCtr"> encryption.</param>
/// <param name="iv">The initialization vector for <see cref="AesCtr"> encryption.</param>
/// <param name="key">The secret key for <see cref="AesCtr"/> encryption.</param>
/// <param name="iv">The initialization vector for <see cref="AesCtr"/> encryption.</param>
public AesCtr(byte[] key, byte[] iv)
{
if (key == null)
Expand Down Expand Up @@ -53,9 +53,9 @@ public AesCtr(byte[] key, byte[] iv)
/// <summary>
/// Initializes a new instance of the <see cref="AesCtr"/> class with the
/// specified key. For internal use only. The initialization vector will
/// be set later by the <see cref="AesSiv"> object.
/// be set later by the <see cref="AesSiv"/> object.
/// </summary>
/// <param name="key">The secret key for <see cref="AesCtr"> encryption.</param>
/// <param name="key">The secret key for <see cref="AesCtr"/> encryption.</param>
internal AesCtr(byte[] key)
{
aes = Aes.Create();
Expand Down Expand Up @@ -112,10 +112,10 @@ public void Encrypt(byte[] input, int inputOffset, int inputCount, byte[] output
/// <summary>
/// Reset the initialization vector. For internal use only. This
/// method is needed in order to avoid creating heavyweight
/// <see cref="AesCtr"> object every time we call
/// <see cref="AesSiv.Seal"> or <see cref="AesSiv.Open"> methods.
/// <see cref="AesCtr"/> object every time we call
/// <see cref="AesSiv.Seal"/> or <see cref="AesSiv.Open"/> methods.
/// </summary>
/// <param name="iv">The initialization vector for <see cref="AesCtr"> encryption.</param>
/// <param name="iv">The initialization vector for <see cref="AesCtr"/> encryption.</param>
internal void Reset(byte[] iv)
{
counter = iv;
Expand Down
5 changes: 4 additions & 1 deletion dotnet/Miscreant/AesPmac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class AesPmac : IMac
/// <summary>
/// Initializes a new instance of the <see cref="AesPmac"/> class with the specified key.
/// </summary>
/// <param name="key">The secret key for <see cref="AesPmac"> authentication.</param>
/// <param name="key">The secret key for <see cref="AesPmac"/> authentication.</param>
public AesPmac(byte[] key)
{
if (key == null)
Expand Down Expand Up @@ -165,6 +165,9 @@ private void ProcessBuffer(int size)
}
}

/// <summary>
/// Disposes this object.
/// </summary>
public void Dispose()
{
if (!disposed)
Expand Down
5 changes: 4 additions & 1 deletion dotnet/Miscreant/AesSiv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public byte[] Seal(byte[] plaintext, params byte[][] data)
/// and the given associated data items and, if successful, returns
/// the result. For nonce-based encryption, the nonce should be the
/// last associated data item. In case of failed decryption, this
/// method throws <see cref="CryptographicException">.
/// method throws <see cref="CryptographicException"/>.
/// </summary>
/// <param name="ciphertext">The ciphertext to decrypt.</param>
/// <param name="data">Associated data items to authenticate.</param>
Expand Down Expand Up @@ -217,6 +217,9 @@ private void ZeroIvBits(byte[] iv)
iv[iv.Length - 4] &= 0x7f;
}

/// <summary>
/// Disposes this object.
/// </summary>
public void Dispose()
{
if (!disposed)
Expand Down
5 changes: 3 additions & 2 deletions dotnet/Miscreant/Miscreant.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard1.3</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>Miscreant</PackageId>
<Title>Miscreant</Title>
<PackageVersion>0.3.0</PackageVersion>
<PackageVersion>0.3.1</PackageVersion>
<Authors>Nemanja Mijailovic</Authors>
<PackageProjectUrl>https://miscreant.io/</PackageProjectUrl>
<RepositoryUrl>https://github.com/miscreant/miscreant</RepositoryUrl>
Expand Down
5 changes: 4 additions & 1 deletion dotnet/Miscreant/StreamDecryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static StreamDecryptor CreateAesPmacSivDecryptor(byte[] key, byte[] nonce
/// Open decrypts the next ciphertext in the STREAM, authenticates the
/// decrypted plaintext and the associated data and, if successful, returns
/// the result. In case of failed decryption, this method throws
/// <see cref="CryptographicException">.
/// <see cref="CryptographicException"/>.
/// </summary>
/// <param name="ciphertext">The ciphertext to decrypt.</param>
/// <param name="data">Associated data items to authenticate.</param>
Expand All @@ -74,6 +74,9 @@ public byte[] Open(byte[] ciphertext, byte[] data = null, bool last = false)
return siv.Open(ciphertext, data, nonce.Next(last));
}

/// <summary>
/// Disposes this object.
/// </summary>
public void Dispose()
{
if (!disposed)
Expand Down
3 changes: 3 additions & 0 deletions dotnet/Miscreant/StreamEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public byte[] Seal(byte[] plaintext, byte[] data = null, bool last = false)
return siv.Seal(plaintext, data, nonce.Next(last));
}

/// <summary>
/// Disposes this object.
/// </summary>
public void Dispose()
{
if (!disposed)
Expand Down
16 changes: 8 additions & 8 deletions dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ Use this library at your own risk.

## Requirements

This library is targeting .NET Standard 2.0. It was tested on .NET Framework 4.7.1
This library is targeting .NET Standard 1.3. It was tested on .NET Framework 4.7.1
and .NET Core 2.1.2, but it should also work on any of the following platforms:

- .NET Framework 4.6.1
- .NET Core 2.0
- Mono 5.4
- Xamarin.iOS 10.14
- Xamarin.Mac 3.8
- Xamarin.Android 7.5
- Universal Windows Platform 10.0.16299
- .NET Framework 4.6
- .NET Core 1.0
- Mono 4.6
- Xamarin.iOS 10.0
- Xamarin.Mac 3.0
- Xamarin.Android 7.0
- Universal Windows Platform 10.0

## Code of Conduct

Expand Down

0 comments on commit 61ad13a

Please sign in to comment.