diff --git a/src/System.Security.Cryptography.Primitives/pkg/System.Security.Cryptography.Primitives.pkgproj b/src/System.Security.Cryptography.Primitives/pkg/System.Security.Cryptography.Primitives.pkgproj
index 1b208f27f49b..11ddde4e5e3b 100644
--- a/src/System.Security.Cryptography.Primitives/pkg/System.Security.Cryptography.Primitives.pkgproj
+++ b/src/System.Security.Cryptography.Primitives/pkg/System.Security.Cryptography.Primitives.pkgproj
@@ -2,7 +2,7 @@
-
+
net463;netcoreapp1.1;$(AllXamarinFrameworks)
@@ -16,4 +16,4 @@
-
\ No newline at end of file
+
diff --git a/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.builds b/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.builds
new file mode 100644
index 000000000000..ccf56d6c0615
--- /dev/null
+++ b/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.builds
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+ netcoreapp1.1
+
+
+
+
diff --git a/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.cs b/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.cs
index b2c086fa363f..3d16b625a224 100644
--- a/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.cs
+++ b/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.cs
@@ -44,6 +44,9 @@ public CryptographicUnexpectedOperationException(string format, string insert) {
public partial class CryptoStream : System.IO.Stream, System.IDisposable
{
public CryptoStream(System.IO.Stream stream, System.Security.Cryptography.ICryptoTransform transform, System.Security.Cryptography.CryptoStreamMode mode) { }
+#if netcoreapp11
+ public CryptoStream(System.IO.Stream stream, System.Security.Cryptography.ICryptoTransform transform, System.Security.Cryptography.CryptoStreamMode mode, bool leaveOpen) { }
+#endif
public override bool CanRead { get { throw null; } }
public override bool CanSeek { get { throw null; } }
public override bool CanWrite { get { throw null; } }
diff --git a/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.csproj b/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.csproj
index 8d3c6e0a3775..ce2107915c61 100644
--- a/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.csproj
+++ b/src/System.Security.Cryptography.Primitives/ref/System.Security.Cryptography.Primitives.csproj
@@ -3,7 +3,8 @@
Library
- .NETStandard,Version=v1.7
+ .NETStandard,Version=v1.7
+ $(DefineConstants);netcoreapp11
@@ -12,4 +13,4 @@
-
\ No newline at end of file
+
diff --git a/src/System.Security.Cryptography.Primitives/ref/project.json b/src/System.Security.Cryptography.Primitives/ref/project.json
index 0fb177a70a05..d4cc523c4762 100644
--- a/src/System.Security.Cryptography.Primitives/ref/project.json
+++ b/src/System.Security.Cryptography.Primitives/ref/project.json
@@ -5,10 +5,7 @@
"System.Threading.Tasks": "4.4.0-beta-24615-03"
},
"frameworks": {
- "netstandard1.7": {
- "imports": [
- "dotnet5.8"
- ]
- }
+ "netstandard1.7": {},
+ "netcoreapp1.1": {}
}
}
diff --git a/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStream.cs b/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStream.cs
index db81acde2f9f..d51ec1e9bdca 100644
--- a/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStream.cs
+++ b/src/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CryptoStream.cs
@@ -25,15 +25,22 @@ public class CryptoStream : Stream, IDisposable
private bool _canWrite;
private bool _finalBlockTransformed;
private SemaphoreSlim _lazyAsyncActiveSemaphore;
-
+ private readonly bool _leaveOpen;
+
// Constructors
public CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode)
+ : this(stream, transform, mode, false)
+ {
+ }
+
+ public CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode, bool leaveOpen)
{
_stream = stream;
_transformMode = mode;
_transform = transform;
+ _leaveOpen = leaveOpen;
switch (_transformMode)
{
case CryptoStreamMode.Read:
@@ -523,7 +530,10 @@ protected override void Dispose(bool disposing)
{
FlushFinalBlock();
}
- _stream.Dispose();
+ if (!_leaveOpen)
+ {
+ _stream.Dispose();
+ }
}
}
finally
diff --git a/src/System.Security.Cryptography.Primitives/tests/CryptoStream.cs b/src/System.Security.Cryptography.Primitives/tests/CryptoStream.cs
index e99e7891dd21..1dcdb3aeebbb 100644
--- a/src/System.Security.Cryptography.Primitives/tests/CryptoStream.cs
+++ b/src/System.Security.Cryptography.Primitives/tests/CryptoStream.cs
@@ -162,11 +162,38 @@ public static void NestedCryptoStreams()
public static void MultipleDispose()
{
ICryptoTransform encryptor = new IdentityTransform(1, 1, true);
+
+ using (MemoryStream output = new MemoryStream())
+ {
+ using (CryptoStream encryptStream = new CryptoStream(output, encryptor, CryptoStreamMode.Write))
+ {
+ encryptStream.Dispose();
+ }
+
+ Assert.Equal(false, output.CanRead);
+ }
+
+#if netcoreapp11
+ using (MemoryStream output = new MemoryStream())
+ {
+ using (CryptoStream encryptStream = new CryptoStream(output, encryptor, CryptoStreamMode.Write, leaveOpen: false))
+ {
+ encryptStream.Dispose();
+ }
+
+ Assert.Equal(false, output.CanRead);
+ }
+
using (MemoryStream output = new MemoryStream())
- using (CryptoStream encryptStream = new CryptoStream(output, encryptor, CryptoStreamMode.Write))
{
- encryptStream.Dispose();
+ using (CryptoStream encryptStream = new CryptoStream(output, encryptor, CryptoStreamMode.Write, leaveOpen: true))
+ {
+ encryptStream.Dispose();
+ }
+
+ Assert.Equal(true, output.CanRead);
}
+#endif
}
private const string LoremText =
diff --git a/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.builds b/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.builds
index c14835b4f50c..8d8aae0cba92 100644
--- a/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.builds
+++ b/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.builds
@@ -8,6 +8,10 @@
Windows_NT
netcoreapp1.0
+
+ netcoreapp1.1
+ netcoreapp1.1
+
diff --git a/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.csproj b/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.csproj
index 7b51198943ef..e725167b5224 100644
--- a/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.csproj
+++ b/src/System.Security.Cryptography.Primitives/tests/System.Security.Cryptography.Primitives.Tests.csproj
@@ -10,6 +10,7 @@
System.Security.Cryptography.Primitives.Tests
System.Security.Cryptography.Primitives.Tests
.NETStandard,Version=v1.7
+ $(DefineConstants);netcoreapp11