summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore13
-rw-r--r--BouncyCastle-PCL.sln46
-rw-r--r--GitVersionConfig.yaml2
-rw-r--r--License.html39
-rw-r--r--Portable.BouncyCastle.nuspec109
-rw-r--r--README.md9
-rw-r--r--appveyor.yml23
-rw-r--r--crypto.tests.Net45/Properties/AssemblyInfo.cs36
-rw-r--r--crypto.tests.Net45/crypto.tests.Net45.csproj92
-rw-r--r--crypto.tests.Net45/packages.config5
-rw-r--r--crypto/BouncyCastle.snkbin0 -> 596 bytes
-rw-r--r--crypto/bzip2/src/CBZip2OutputStream.cs1
-rw-r--r--crypto/crypto.Net45.csproj54
-rw-r--r--crypto/crypto.dotnet.csproj96
-rw-r--r--crypto/crypto.dotnet.project.json17
-rw-r--r--crypto/crypto.pcl.csproj104
-rw-r--r--crypto/crypto.pcl2.csproj90
-rw-r--r--crypto/src/AssemblyInfo.cs4
-rw-r--r--crypto/src/asn1/Asn1Set.cs18
-rw-r--r--crypto/src/asn1/DerGeneralizedTime.cs5
-rw-r--r--crypto/src/asn1/DerUTCTime.cs4
-rw-r--r--crypto/src/asn1/x509/Time.cs2
-rw-r--r--crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs2
-rw-r--r--crypto/src/cms/CMSProcessableFile.cs8
-rw-r--r--crypto/src/cms/CMSSignedDataStreamGenerator.cs86
-rw-r--r--[-rwxr-xr-x]crypto/src/crypto/agreement/jpake/JPakeParticipant.cs0
-rw-r--r--[-rwxr-xr-x]crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroup.cs0
-rw-r--r--[-rwxr-xr-x]crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroups.cs0
-rw-r--r--[-rwxr-xr-x]crypto/src/crypto/agreement/jpake/JPakeRound1Payload.cs0
-rw-r--r--[-rwxr-xr-x]crypto/src/crypto/agreement/jpake/JPakeRound2Payload.cs0
-rw-r--r--[-rwxr-xr-x]crypto/src/crypto/agreement/jpake/JPakeRound3Payload.cs0
-rw-r--r--crypto/src/crypto/engines/NaccacheSternEngine.cs6
-rw-r--r--crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs8
-rw-r--r--crypto/src/crypto/prng/ThreadedSeedGenerator.cs132
-rw-r--r--crypto/src/crypto/tls/DtlsReliableHandshake.cs3
-rw-r--r--crypto/src/crypto/tls/HeartbeatMessage.cs2
-rw-r--r--crypto/src/crypto/tls/TlsProtocol.cs2
-rw-r--r--crypto/src/openpgp/PgpLiteralDataGenerator.cs2
-rw-r--r--crypto/src/openpgp/PgpUtilities.cs2
-rw-r--r--crypto/src/pkcs/Pkcs12Store.cs175
-rw-r--r--crypto/src/util/Enums.cs10
-rw-r--r--crypto/src/util/Platform.cs2
-rw-r--r--crypto/src/util/TypeExtensions.cs18
-rw-r--r--crypto/src/util/zlib/ZDeflaterOutputStream.cs2
-rw-r--r--crypto/test/src/asn1/test/AllTests.cs2
-rw-r--r--crypto/test/src/cms/test/AllTests.cs2
-rw-r--r--crypto/test/src/crypto/io/test/AllTests.cs2
-rw-r--r--crypto/test/src/crypto/test/AllTests.cs28
-rw-r--r--crypto/test/src/math/ec/test/AllTests.cs2
-rw-r--r--crypto/test/src/math/test/AllTests.cs2
-rw-r--r--crypto/test/src/ocsp/test/AllTests.cs2
-rw-r--r--crypto/test/src/openpgp/examples/test/AllTests.cs2
-rw-r--r--crypto/test/src/openpgp/test/PgpUnicodeTest.cs17
-rw-r--r--crypto/test/src/openssl/test/AllTests.cs2
-rw-r--r--crypto/test/src/tsp/test/AllTests.cs2
-rw-r--r--crypto/test/src/util/io/pem/test/AllTests.cs2
-rw-r--r--crypto/test/src/util/test/SimpleTest.cs4
-rw-r--r--csharp.sln29
58 files changed, 1034 insertions, 293 deletions
diff --git a/.gitignore b/.gitignore
index b804bc4a3..542f83c42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,8 +5,21 @@
 *.user
 *.vsp
 
+*.nupkg
+
 Backup/
 bin/
 dist/
 doc/
 obj/
+
+_Resharper.*/
+_Resharper*/
+*.ide/
+packages/
+.vs/
+
+*.nuget.props
+*.nuget.targets
+*.project.lock.json
+project.lock.json
\ No newline at end of file
diff --git a/BouncyCastle-PCL.sln b/BouncyCastle-PCL.sln
new file mode 100644
index 000000000..afd9396fa
--- /dev/null
+++ b/BouncyCastle-PCL.sln
@@ -0,0 +1,46 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.24606.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{43196EF9-B75F-4ABB-8967-DAFD621A7D05}"
+	ProjectSection(SolutionItems) = preProject
+		Portable.BouncyCastle.nuspec = Portable.BouncyCastle.nuspec
+		README.md = README.md
+	EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crypto.pcl", "Crypto\crypto.pcl.csproj", "{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crypto.tests.Net45", "crypto.tests.Net45\crypto.tests.Net45.csproj", "{45473847-8AF8-4BAF-B768-442C6875B8CE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crypto.pcl2", "crypto\crypto.pcl2.csproj", "{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crypto.dotnet", "crypto\crypto.dotnet.csproj", "{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A2}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{45473847-8AF8-4BAF-B768-442C6875B8CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{45473847-8AF8-4BAF-B768-442C6875B8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{45473847-8AF8-4BAF-B768-442C6875B8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{45473847-8AF8-4BAF-B768-442C6875B8CE}.Release|Any CPU.Build.0 = Release|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A2}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
diff --git a/GitVersionConfig.yaml b/GitVersionConfig.yaml
new file mode 100644
index 000000000..2829b7900
--- /dev/null
+++ b/GitVersionConfig.yaml
@@ -0,0 +1,2 @@
+next-version: 1.8.0-rc4
+legacy-semver-padding: 0
diff --git a/License.html b/License.html
new file mode 100644
index 000000000..0dae3a978
--- /dev/null
+++ b/License.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <meta content="text/html; charset=ISO-8859-1"
+ http-equiv="content-type">
+  <title>License</title>
+</head>
+<body>
+<h2>The Bouncy Castle Cryptographic C#&reg; API</h2>
+<h3>License:</h3>
+The Bouncy Castle License<br>
+Copyright (c) 2000-2011 The Legion Of The Bouncy Castle
+(http://www.bouncycastle.org)<br>
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sub license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<br>
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.<br>
+<span style="font-weight: bold;">THE SOFTWARE IS PROVIDED "AS IS",
+WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">PURPOSE AND NONINFRINGEMENT. IN NO
+EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">DEALINGS IN THE SOFTWARE.<br>
+<br>
+</span>
+</body>
+</html>
diff --git a/Portable.BouncyCastle.nuspec b/Portable.BouncyCastle.nuspec
new file mode 100644
index 000000000..c58a23a80
--- /dev/null
+++ b/Portable.BouncyCastle.nuspec
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+  <metadata>
+    <id>Portable.BouncyCastle</id>
+    <version>1.8.0-rc3</version>
+    <title>Bouncy Castle PCL</title>
+    <authors>Oren Novotny</authors>
+    <owners>onovotny</owners>
+    <projectUrl>https://github.com/onovotny/BouncyCastle-PCL</projectUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <description>BouncyCastle.Crypto is a cryptography API providing:
+ -Generation and parsing of PKCS#12 files.
+ -X.509: Generators and parsers for V1 and V3 certificates, V2 CRLs and attribute certificates.
+ -PBE algorithms supported by PBEUtil: PBEwithMD2andDES-CBC, PBEwithMD2andRC2-CBC, PBEwithMD5andDES-CBC, PBEwithMD5andRC2-CBC, PBEwithSHA1andDES-CBC, PBEwithSHA1andRC2-CBC, PBEwithSHA-1and128bitRC4, PBEwithSHA-1and40bitRC4, PBEwithSHA-1and3-keyDESEDE-CBC, PBEwithSHA-1and2-keyDESEDE-CBC, PBEwithSHA-1and128bitRC2-CBC, PBEwithSHA-1and40bitRC2-CBC, PBEwithHmacSHA-1, PBEwithHmacSHA-224, PBEwithHmacSHA-256, PBEwithHmacRIPEMD128, PBEwithHmacRIPEMD160, and PBEwithHmacRIPEMD256.
+ -Signature algorithms supported by SignerUtilities: MD2withRSA, MD4withRSA, MD5withRSA, RIPEMD128withRSA, RIPEMD160withRSA, RIPEMD256withRSA, SHA-1withRSA, SHA-224withRSA, SHA-256withRSAandMGF1, SHA-384withRSAandMGF1, SHA-512withRSAandMGF1, SHA-1withDSA, and SHA-1withECDSA.
+ -Symmetric key algorithms: AES, Blowfish, Camellia, CAST5, CAST6, DESede, DES, GOST28147, HC-128, HC-256, IDEA, NaccacheStern, RC2, RC4, RC5-32, RC5-64, RC6, Rijndael, Serpent, Skipjack, TEA/XTEA, Twofish, and VMPC.
+ -Symmetric key modes: CBC, CFB, CTS, GOFB, OFB, OpenPGPCFB, and SIC (or CTR).
+ -Symmetric key paddings: ISO10126d2, ISO7816d4, PKCS#5/7, TBC, X.923, and Zero Byte.
+ -Asymmetric key algorithms: RSA (with blinding), ElGamal, DSA, ECDSA.
+ -Asymmetric key paddings/encodings: ISO9796d1, OAEP, and PKCS#1.
+ -Digests: GOST3411, MD2, MD4, MD5, RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, Tiger, and Whirlpool.
+ -Signer mechanisms: DSA, ECDSA, ECGOST3410, GOST3410, ISO9796d2, PSS, RSA.
+ -Key Agreement: Diffie-Hellman and EC-DH.
+ -Macs: CBCBlockCipher, CFBBlockCipher, GOST28147, HMac, and ISO9797 Alg. 3.
+ -PBE generators: PKCS#12, and PKCS#5 - schemes 1 and 2.
+ -OpenPGP (RFC 2440)
+ -Cryptographic Message Syntax (CMS, RFC 3852), including streaming API.
+ -Online Certificate Status Protocol (OCSP, RFC 2560).
+ -Time Stamp Protocol (TSP, RFC 3161).
+ -TLS/SSL Client with support for client side authentication.
+ 
+        Support for .NET 4, Windows Phone 8, Windows Phone App 8.1, Windows 8, MonoTouch, MonoAndroid, Xamarin.iOS, Core CLR
+        </description>
+    <language>en-US</language>
+    <tags>bouncycastle, cryptography, encryption, security, PCL, wp8, wpa81, coreclr, dotnet, dnx, uwp, sl5, monotouch, monoandroid, xamarin, xamarin.ios</tags>
+    <dependencies>
+      <group targetFramework="dotnet">
+        <dependency id="System.Collections" version="4.0.10" />
+        <dependency id="System.Diagnostics.Debug" version="4.0.10" />
+        <dependency id="System.Globalization" version="4.0.10" />
+        <dependency id="System.IO" version="4.0.10" />
+        <dependency id="System.IO.FileSystem" version="4.0.0" />
+        <dependency id="System.IO.FileSystem.Primitives" version="4.0.0" />
+        <dependency id="System.Linq" version="4.0.0" />
+        <dependency id="System.Reflection" version="4.0.10" />
+        <dependency id="System.Reflection.Extensions" version="4.0.0" />
+        <dependency id="System.Runtime" version="4.0.20" />
+        <dependency id="System.Runtime.Extensions" version="4.0.10" />
+        <dependency id="System.Text.Encoding" version="4.0.10" />
+        <dependency id="System.Threading" version="4.0.10" />
+        <dependency id="System.Threading.Tasks" version="4.0.10" />
+      </group>
+      <group targetFramework="uap10.0">
+        <dependency id="System.Collections" version="4.0.10" />
+        <dependency id="System.Diagnostics.Debug" version="4.0.10" />
+        <dependency id="System.Globalization" version="4.0.10" />
+        <dependency id="System.IO" version="4.0.10" />
+        <dependency id="System.IO.FileSystem" version="4.0.0" />
+        <dependency id="System.IO.FileSystem.Primitives" version="4.0.0" />
+        <dependency id="System.Linq" version="4.0.0" />
+        <dependency id="System.Reflection" version="4.0.10" />
+        <dependency id="System.Reflection.Extensions" version="4.0.0" />
+        <dependency id="System.Runtime" version="4.0.20" />
+        <dependency id="System.Runtime.Extensions" version="4.0.10" />
+        <dependency id="System.Text.Encoding" version="4.0.10" />
+        <dependency id="System.Threading" version="4.0.10" />
+        <dependency id="System.Threading.Tasks" version="4.0.10" />
+      </group>
+      <group targetFramework="net46">
+        <dependency id="System.Collections" version="4.0.10" />
+        <dependency id="System.Diagnostics.Debug" version="4.0.10" />
+        <dependency id="System.Globalization" version="4.0.10" />
+        <dependency id="System.IO" version="4.0.10" />
+        <dependency id="System.IO.FileSystem" version="4.0.0" />
+        <dependency id="System.IO.FileSystem.Primitives" version="4.0.0" />
+        <dependency id="System.Linq" version="4.0.0" />
+        <dependency id="System.Reflection" version="4.0.10" />
+        <dependency id="System.Reflection.Extensions" version="4.0.0" />
+        <dependency id="System.Runtime" version="4.0.20" />
+        <dependency id="System.Runtime.Extensions" version="4.0.10" />
+        <dependency id="System.Text.Encoding" version="4.0.10" />
+        <dependency id="System.Threading" version="4.0.10" />
+        <dependency id="System.Threading.Tasks" version="4.0.10" />
+      </group>
+      <group targetFramework="net45" />
+      <group targetFramework="win8" />
+      <group targetFramework="wpa81" />
+      <group targetFramework="MonoTouch" />
+      <group targetFramework="MonoAndroid" />
+      <group targetFramework="XamarinMac" />
+      <group targetFramework="XamarinIos" />
+    </dependencies>
+  </metadata>
+  <files>
+    <file src="Crypto\Readme.html" target="Readme.html" />
+    <file src="Crypto\bin\pcl\Release\crypto.*" exclude="**\*.srcsrv" target="lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\portable-net45+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\net45" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\win8" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\wpa81" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\MonoTouch" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\MonoAndroid" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\XamarinMac" />
+    <file src="Crypto\bin\pcl2\Release\crypto.*" exclude="**\*.srcsrv" target="lib\XamarinIos" />
+    <file src="Crypto\bin\dotnet\Release\crypto.*" exclude="**\*.srcsrv" target="lib\dotnet" />
+    <file src="Crypto\bin\dotnet\Release\crypto.*" exclude="**\*.srcsrv" target="lib\uap10.0" />
+    <file src="Crypto\bin\dotnet\Release\crypto.*" exclude="**\*.srcsrv" target="lib\net46" />
+  </files>
+</package>
\ No newline at end of file
diff --git a/README.md b/README.md
index 0d741e136..05af7e35a 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,12 @@
+BouncyCastle-PCL
+================
+
+PCL Version of BouncyCastle targeting .NET Framework 4, Silverlight 5, Windows 8, Windows Phone App 8.1, MonoTouch, MonoAndroid
+
+This version also supports .NET Core and CoreCLR
+
+================
+
 # The Bouncy Castle Crypto Package For C Sharp
 
 The Bouncy Castle Crypto package is a C\# implementation of cryptographic algorithms and protocols, it was developed by the Legion of the Bouncy Castle, a registered Australian Charity, with a little help! The Legion, and the latest goings on with this package, can be found at [http://www.bouncycastle.org](http://www.bouncycastle.org). In additiion to providing basic cryptography algorithms, the package also provides support for CMS, TSP, X.509 certificate generation and a variety of other standards such as OpenPGP.
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 000000000..a80169c20
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,23 @@
+configuration: Release
+install:  
+  - cmd: appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
+  - cmd: nuget install gitlink -SolutionDir %APPVEYOR_BUILD_FOLDER% -Verbosity quiet -ExcludeVersion -pre
+  - cmd: nuget install GitVersion.CommandLine -SolutionDir %APPVEYOR_BUILD_FOLDER% -Verbosity quiet -ExcludeVersion -pre
+
+assembly_info:
+  patch: false
+      
+before_build:
+  
+  - cmd: nuget restore
+  - cmd: '.\packages\GitVersion.CommandLine\tools\GitVersion.exe /l console /output buildserver /updateAssemblyInfo'
+  
+build:
+  verbosity: normal
+  parallel: true
+  project: BouncyCastle-PCL.sln
+  
+after_build:
+  - cmd: '.\packages\gitlink\lib\net45\GitLink.exe . -f BouncyCastle-PCL.sln -u https://github.com/onovotny/BouncyCastle-PCL -s %APPVEYOR_REPO_COMMIT% -errorsaswarnings'  
+  - cmd: nuget pack Portable.BouncyCastle.nuspec -version "%GitVersion_NuGetVersion%-build%GitVersion_BuildMetadataPadded%" -prop "target=%CONFIGURATION%"
+  - ps: 'cmd /c "appveyor PushArtifact Portable.BouncyCastle.%GitVersion_NuGetVersion%-build%GitVersion_BuildMetadataPadded%.nupkg";if($lastexitcode -ne 0){$lastexitcode = 0}'
\ No newline at end of file
diff --git a/crypto.tests.Net45/Properties/AssemblyInfo.cs b/crypto.tests.Net45/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..52472faf8
--- /dev/null
+++ b/crypto.tests.Net45/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("crypto.tests.Net45")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("crypto.tests.Net45")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("22ae3209-5ce9-448c-9212-04b9e8f6361e")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// 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")]
diff --git a/crypto.tests.Net45/crypto.tests.Net45.csproj b/crypto.tests.Net45/crypto.tests.Net45.csproj
new file mode 100644
index 000000000..de668a83d
--- /dev/null
+++ b/crypto.tests.Net45/crypto.tests.Net45.csproj
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{45473847-8AF8-4BAF-B768-442C6875B8CE}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>crypto.tests</RootNamespace>
+    <AssemblyName>crypto.tests.Net45</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;LIB;PORTABLE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;LIB;PORTABLE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+      <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
+      <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\crypto\test\src\**\*.cs" Exclude="..\**\examples\*.cs">
+      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
+    </Compile>
+    <EmbeddedResource Include="..\crypto\test\data\**\*.*" Exclude="..\**\README.txt">
+      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Crypto\crypto.pcl.csproj">
+      <Project>{38872a5f-e87e-4fad-b109-8eb7b2e6a4a0}</Project>
+      <Name>crypto.pcl</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </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.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/crypto.tests.Net45/packages.config b/crypto.tests.Net45/packages.config
new file mode 100644
index 000000000..1f8800b2c
--- /dev/null
+++ b/crypto.tests.Net45/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="NUnit" version="2.6.4" targetFramework="net45" />
+  <package id="NUnitTestAdapter" version="2.0.0" targetFramework="net45" />
+</packages>
\ No newline at end of file
diff --git a/crypto/BouncyCastle.snk b/crypto/BouncyCastle.snk
new file mode 100644
index 000000000..b04ca9aae
--- /dev/null
+++ b/crypto/BouncyCastle.snk
Binary files differdiff --git a/crypto/bzip2/src/CBZip2OutputStream.cs b/crypto/bzip2/src/CBZip2OutputStream.cs
index ffac073fb..361592796 100644
--- a/crypto/bzip2/src/CBZip2OutputStream.cs
+++ b/crypto/bzip2/src/CBZip2OutputStream.cs
@@ -406,7 +406,6 @@ namespace Org.BouncyCastle.Apache.Bzip2
                 return;
 
             Finish();
-
             closed = true;
             Platform.Dispose(this.bsStream);
 
diff --git a/crypto/crypto.Net45.csproj b/crypto/crypto.Net45.csproj
new file mode 100644
index 000000000..14b3581f5
--- /dev/null
+++ b/crypto/crypto.Net45.csproj
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{45473847-8AF8-4BAF-B768-442C6875B8CF}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>crypto</RootNamespace>
+    <AssemblyName>crypto</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;LIB;PCL;SILVERLIGHT</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;LIB;PCL;SILVERLIGHT</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="src\**\*.cs" />
+    <Compile Include="bzip2\**\*.cs" />
+  </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.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/crypto/crypto.dotnet.csproj b/crypto/crypto.dotnet.csproj
new file mode 100644
index 000000000..dfb1d16cb
--- /dev/null
+++ b/crypto/crypto.dotnet.csproj
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+  <PropertyGroup>
+    <ProjectType>Local</ProjectType>
+    <ProductVersion>7.10.3077</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A2}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ApplicationIcon />
+    <AssemblyKeyContainerName />
+    <AssemblyName>crypto</AssemblyName>
+    <AssemblyOriginatorKeyFile>BouncyCastle.snk</AssemblyOriginatorKeyFile>
+    <DefaultClientScript>JScript</DefaultClientScript>
+    <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+    <DefaultTargetSchema>IE50</DefaultTargetSchema>
+    <DelaySign>false</DelaySign>
+    <OutputType>Library</OutputType>
+    <RootNamespace>crypto</RootNamespace>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+    <StartupObject />
+    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <OutputPath>bin\dotnet\Debug\</OutputPath>
+    <IntermediateOutputPath>obj\dotnet\Debug\</IntermediateOutputPath>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <BaseAddress>285212672</BaseAddress>
+    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+    <ConfigurationOverrideFile />
+    <DefineConstants>TRACE;DEBUG;PORTABLE;NO_THREADS;NEW_REFLECTION;SYS_RUNTIME;DOTNET</DefineConstants>
+    <DocumentationFile>doc\dotnet\crypto.xml</DocumentationFile>
+    <DebugSymbols>true</DebugSymbols>
+    <FileAlignment>4096</FileAlignment>
+    <NoStdLib>false</NoStdLib>
+    <NoWarn>1591</NoWarn>
+    <Optimize>false</Optimize>
+    <RegisterForComInterop>false</RegisterForComInterop>
+    <RemoveIntegerChecks>false</RemoveIntegerChecks>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>full</DebugType>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <OutputPath>bin\dotnet\Release\</OutputPath>
+    <IntermediateOutputPath>obj\dotnet\Release\</IntermediateOutputPath>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <BaseAddress>285212672</BaseAddress>
+    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+    <ConfigurationOverrideFile />
+    <DefineConstants>TRACE;PORTABLE;NO_THREADS;NEW_REFLECTION;SYS_RUNTIME;DOTNET</DefineConstants>
+    <DocumentationFile>doc\dotnet\crypto.xml</DocumentationFile>
+    <DebugSymbols>true</DebugSymbols>
+    <FileAlignment>4096</FileAlignment>
+    <NoStdLib>false</NoStdLib>
+    <NoWarn>1591</NoWarn>
+    <Optimize>true</Optimize>
+    <RegisterForComInterop>false</RegisterForComInterop>
+    <RemoveIntegerChecks>false</RemoveIntegerChecks>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>pdbonly</DebugType>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- NuSpec file must be specified as name does not match dll name -->
+    <NuSpecFile Include="$(SolutionDir)Portable.BouncyCastle.nuspec" />
+  </ItemGroup>
+  <PropertyGroup>
+    <!-- dotnet, uap10.0 & net46 tfms -->
+    <NuSpecTfm>dotnet;uap10.0;net46</NuSpecTfm>
+  </PropertyGroup>
+  <ItemGroup>
+    <None Include="BouncyCastle.snk" />
+    <None Include="crypto.dotnet.project.json" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="src\**\*.cs" />
+    <Compile Include="bzip2\**\*.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent />
+    <PostBuildEvent />
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/crypto/crypto.dotnet.project.json b/crypto/crypto.dotnet.project.json
new file mode 100644
index 000000000..e80002612
--- /dev/null
+++ b/crypto/crypto.dotnet.project.json
@@ -0,0 +1,17 @@
+{
+  "supports": {
+    "net46.app": {},
+    "uwp.10.0.app": {},
+    "dnxcore50.app": {}
+  },
+  "dependencies": {
+    "Microsoft.NETCore": "5.0.0",
+    "Microsoft.NETCore.Portable.Compatibility": "1.0.0",
+    "NuSpec.ReferenceGenerator": "1.3.4"
+  },
+  "frameworks": {
+    "dotnet": {
+      "imports": "portable-net452+win81"
+    }
+  }
+}
\ No newline at end of file
diff --git a/crypto/crypto.pcl.csproj b/crypto/crypto.pcl.csproj
new file mode 100644
index 000000000..30413b51e
--- /dev/null
+++ b/crypto/crypto.pcl.csproj
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+  <PropertyGroup>
+    <ProjectType>Local</ProjectType>
+    <ProductVersion>7.10.3077</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ApplicationIcon />
+    <AssemblyKeyContainerName />
+    <AssemblyName>crypto</AssemblyName>
+    <AssemblyOriginatorKeyFile>BouncyCastle.snk</AssemblyOriginatorKeyFile>
+    <DefaultClientScript>JScript</DefaultClientScript>
+    <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+    <DefaultTargetSchema>IE50</DefaultTargetSchema>
+    <DelaySign>false</DelaySign>
+    <OutputType>Library</OutputType>
+    <RootNamespace>crypto</RootNamespace>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+    <StartupObject />
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <UpgradeBackupLocation>
+    </UpgradeBackupLocation>
+    <OldToolsVersion>12.0</OldToolsVersion>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile328</TargetFrameworkProfile>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <OutputPath>bin\pcl\Debug\</OutputPath>
+    <IntermediateOutputPath>obj\pcl\Debug\</IntermediateOutputPath>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <BaseAddress>285212672</BaseAddress>
+    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+    <ConfigurationOverrideFile />
+    <DefineConstants>TRACE;DEBUG;PORTABLE;NO_THREADS</DefineConstants>
+    <DocumentationFile>doc\pcl\crypto.xml</DocumentationFile>
+    <DebugSymbols>true</DebugSymbols>
+    <FileAlignment>4096</FileAlignment>
+    <NoStdLib>false</NoStdLib>
+    <NoWarn>1591</NoWarn>
+    <Optimize>false</Optimize>
+    <RegisterForComInterop>false</RegisterForComInterop>
+    <RemoveIntegerChecks>false</RemoveIntegerChecks>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>full</DebugType>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <OutputPath>bin\pcl\Release\</OutputPath>
+    <IntermediateOutputPath>obj\pcl\Release\</IntermediateOutputPath>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <BaseAddress>285212672</BaseAddress>
+    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+    <ConfigurationOverrideFile />
+    <DefineConstants>TRACE;PORTABLE;NO_THREADS</DefineConstants>
+    <DocumentationFile>doc\pcl\crypto.xml</DocumentationFile>
+    <DebugSymbols>true</DebugSymbols>
+    <FileAlignment>4096</FileAlignment>
+    <NoStdLib>false</NoStdLib>
+    <NoWarn>1591</NoWarn>
+    <Optimize>true</Optimize>
+    <RegisterForComInterop>false</RegisterForComInterop>
+    <RemoveIntegerChecks>false</RemoveIntegerChecks>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>pdbonly</DebugType>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="src\**\*.cs" />
+    <Compile Include="bzip2\**\*.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="BouncyCastle.snk" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent />
+    <PostBuildEvent />
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/crypto/crypto.pcl2.csproj b/crypto/crypto.pcl2.csproj
new file mode 100644
index 000000000..62e76ee40
--- /dev/null
+++ b/crypto/crypto.pcl2.csproj
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+  <PropertyGroup>
+    <ProjectType>Local</ProjectType>
+    <ProductVersion>7.10.3077</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A1}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ApplicationIcon />
+    <AssemblyKeyContainerName />
+    <AssemblyName>crypto</AssemblyName>
+    <AssemblyOriginatorKeyFile>BouncyCastle.snk</AssemblyOriginatorKeyFile>
+    <DefaultClientScript>JScript</DefaultClientScript>
+    <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
+    <DefaultTargetSchema>IE50</DefaultTargetSchema>
+    <DelaySign>false</DelaySign>
+    <OutputType>Library</OutputType>
+    <RootNamespace>crypto</RootNamespace>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+    <StartupObject />
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <OutputPath>bin\pcl2\Debug\</OutputPath>
+    <IntermediateOutputPath>obj\pcl2\Debug\</IntermediateOutputPath>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <BaseAddress>285212672</BaseAddress>
+    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+    <ConfigurationOverrideFile />
+    <DefineConstants>TRACE;DEBUG;PORTABLE;NO_THREADS;NEW_REFLECTION;SYS_RUNTIME</DefineConstants>
+    <DocumentationFile>doc\pcl2\crypto.xml</DocumentationFile>
+    <DebugSymbols>true</DebugSymbols>
+    <FileAlignment>4096</FileAlignment>
+    <NoStdLib>false</NoStdLib>
+    <NoWarn>1591</NoWarn>
+    <Optimize>false</Optimize>
+    <RegisterForComInterop>false</RegisterForComInterop>
+    <RemoveIntegerChecks>false</RemoveIntegerChecks>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>full</DebugType>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <OutputPath>bin\pcl2\Release\</OutputPath>
+    <IntermediateOutputPath>obj\pcl2\Release\</IntermediateOutputPath>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <BaseAddress>285212672</BaseAddress>
+    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
+    <ConfigurationOverrideFile />
+    <DefineConstants>TRACE;PORTABLE;NO_THREADS;NEW_REFLECTION;SYS_RUNTIME</DefineConstants>
+    <DocumentationFile>doc\pcl2\crypto.xml</DocumentationFile>
+    <DebugSymbols>true</DebugSymbols>
+    <FileAlignment>4096</FileAlignment>
+    <NoStdLib>false</NoStdLib>
+    <NoWarn>1591</NoWarn>
+    <Optimize>true</Optimize>
+    <RegisterForComInterop>false</RegisterForComInterop>
+    <RemoveIntegerChecks>false</RemoveIntegerChecks>
+    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+    <WarningLevel>4</WarningLevel>
+    <DebugType>pdbonly</DebugType>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- NuSpec file must be specified as name does not match dll name -->
+    <NuSpecFile Include="$(SolutionDir)Portable.BouncyCastle.nuspec" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="BouncyCastle.snk" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="src\**\*.cs" />
+    <Compile Include="bzip2\**\*.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent />
+    <PostBuildEvent />
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/crypto/src/AssemblyInfo.cs b/crypto/src/AssemblyInfo.cs
index cfddb17b9..cd951d282 100644
--- a/crypto/src/AssemblyInfo.cs
+++ b/crypto/src/AssemblyInfo.cs
@@ -33,7 +33,9 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Revision and Build Numbers
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.8.*")]
+[assembly: AssemblyVersion("1.8.0.0")]
+[assembly: AssemblyFileVersion("1.8.0.0")]
+[assembly: AssemblyInformationalVersion("1.8.0.0")]
 
 //
 // In order to sign your assembly you must specify a key to use. Refer to the
diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs
index 18f8020f2..58e7e26f8 100644
--- a/crypto/src/asn1/Asn1Set.cs
+++ b/crypto/src/asn1/Asn1Set.cs
@@ -75,8 +75,8 @@ namespace Org.BouncyCastle.Asn1
          *          be converted.
          */
         public static Asn1Set GetInstance(
-            Asn1TaggedObject	obj,
-            bool				explicitly)
+            Asn1TaggedObject obj,
+            bool explicitly)
         {
             Asn1Object inner = obj.GetObject();
 
@@ -85,7 +85,7 @@ namespace Org.BouncyCastle.Asn1
                 if (!obj.IsExplicit())
                     throw new ArgumentException("object implicit - explicit expected.");
 
-                return (Asn1Set) inner;
+                return (Asn1Set)inner;
             }
 
             //
@@ -100,7 +100,7 @@ namespace Org.BouncyCastle.Asn1
 
             if (inner is Asn1Set)
             {
-                return (Asn1Set) inner;
+                return (Asn1Set)inner;
             }
 
             //
@@ -110,7 +110,7 @@ namespace Org.BouncyCastle.Asn1
             if (inner is Asn1Sequence)
             {
                 Asn1EncodableVector v = new Asn1EncodableVector();
-                Asn1Sequence s = (Asn1Sequence) inner;
+                Asn1Sequence s = (Asn1Sequence)inner;
 
                 foreach (Asn1Encodable ae in s)
                 {
@@ -149,14 +149,14 @@ namespace Org.BouncyCastle.Asn1
          */
         public virtual Asn1Encodable this[int index]
         {
-            get { return (Asn1Encodable) _set[index]; }
+            get { return (Asn1Encodable)_set[index]; }
         }
 
         [Obsolete("Use 'object[index]' syntax instead")]
         public Asn1Encodable GetObjectAt(
             int index)
         {
-             return this[index];
+            return this[index];
         }
 
         [Obsolete("Use 'Count' property instead")]
@@ -207,8 +207,8 @@ namespace Org.BouncyCastle.Asn1
                     return ((Asn1Set)obj).Parser;
 
                 // NB: Asn1OctetString implements Asn1OctetStringParser directly
-//				if (obj is Asn1OctetString)
-//					return ((Asn1OctetString)obj).Parser;
+                //				if (obj is Asn1OctetString)
+                //					return ((Asn1OctetString)obj).Parser;
 
                 return obj;
             }
diff --git a/crypto/src/asn1/DerGeneralizedTime.cs b/crypto/src/asn1/DerGeneralizedTime.cs
index 152596678..4de0feaa6 100644
--- a/crypto/src/asn1/DerGeneralizedTime.cs
+++ b/crypto/src/asn1/DerGeneralizedTime.cs
@@ -83,7 +83,7 @@ namespace Org.BouncyCastle.Asn1
         public DerGeneralizedTime(
             DateTime time)
         {
-            this.time = time.ToString(@"yyyyMMddHHmmss\Z");
+            this.time = time.ToUniversalTime().ToString(@"yyyyMMddHHmmss\Z");
         }
 
         internal DerGeneralizedTime(
@@ -259,9 +259,6 @@ namespace Org.BouncyCastle.Asn1
 
         private DateTime ParseDateString(string	s, string format, bool makeUniversal)
         {
-            /*
-             * NOTE: DateTime.Kind and DateTimeStyles.AssumeUniversal not available in .NET 1.1
-             */
             DateTimeStyles style = DateTimeStyles.None;
             if (format.EndsWith("Z"))
             {
diff --git a/crypto/src/asn1/DerUTCTime.cs b/crypto/src/asn1/DerUTCTime.cs
index ab8ca792d..ebf57198f 100644
--- a/crypto/src/asn1/DerUTCTime.cs
+++ b/crypto/src/asn1/DerUTCTime.cs
@@ -86,10 +86,10 @@ namespace Org.BouncyCastle.Asn1
         public DerUtcTime(
             DateTime time)
         {
-            this.time = time.ToString("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+            this.time = time.ToUniversalTime().ToString("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
         }
 
-        internal DerUtcTime(
+		internal DerUtcTime(
             byte[] bytes)
         {
             //
diff --git a/crypto/src/asn1/x509/Time.cs b/crypto/src/asn1/x509/Time.cs
index 8350339bb..770d59d46 100644
--- a/crypto/src/asn1/x509/Time.cs
+++ b/crypto/src/asn1/x509/Time.cs
@@ -34,7 +34,7 @@ namespace Org.BouncyCastle.Asn1.X509
         public Time(
             DateTime date)
         {
-            string d = date.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+            string d = date.ToUniversalTime().ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
 
             int year = int.Parse(d.Substring(0, 4));
 
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index bde8d9926..0a9e5bece 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -287,7 +287,7 @@ namespace Org.BouncyCastle.Cms
 
                 // TODO Parent context(s) should really be closed explicitly
 
-				_eiGen.Close();
+                _eiGen.Close();
 
                 if (_outer.unprotectedAttributeGenerator != null)
                 {
diff --git a/crypto/src/cms/CMSProcessableFile.cs b/crypto/src/cms/CMSProcessableFile.cs
index b514bdbda..5494b238a 100644
--- a/crypto/src/cms/CMSProcessableFile.cs
+++ b/crypto/src/cms/CMSProcessableFile.cs
@@ -1,4 +1,4 @@
-#if !PORTABLE
+#if !PORTABLE || DOTNET
 using System;
 using System.IO;
 
@@ -15,7 +15,7 @@ namespace Org.BouncyCastle.Cms
 	{
 		private const int DefaultBufSize = 32 * 1024;
 
-        private readonly FileInfo	_file;
+		private readonly FileInfo	_file;
 		private readonly int		_bufSize;
 
         public CmsProcessableFile(FileInfo file)
@@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Cms
 			_bufSize = bufSize;
 		}
 
-        public virtual Stream GetInputStream()
+		public virtual Stream GetInputStream()
 		{
 			return new FileStream(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize);
 		}
@@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Cms
             Platform.Dispose(inStr);
 		}
 
-        /// <returns>The file handle</returns>
+		/// <returns>The file handle</returns>
 		[Obsolete]
 		public virtual object GetContent()
 		{
diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
index 1477d884f..59837e397 100644
--- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
@@ -834,61 +834,61 @@ namespace Org.BouncyCastle.Cms
 
                 _eiGen.Close();
 
-				outer._digests.Clear();    // clear the current preserved digest state
+                outer._digests.Clear();    // clear the current preserved digest state
 
-				if (outer._certs.Count > 0)
-				{
-					Asn1Set certs = CmsUtilities.CreateBerSetFromList(outer._certs);
+                if (outer._certs.Count > 0)
+                {
+                    Asn1Set certs = CmsUtilities.CreateBerSetFromList(outer._certs);
 
-					WriteToGenerator(_sigGen, new BerTaggedObject(false, 0, certs));
-				}
+                    WriteToGenerator(_sigGen, new BerTaggedObject(false, 0, certs));
+                }
 
-				if (outer._crls.Count > 0)
-				{
-					Asn1Set crls = CmsUtilities.CreateBerSetFromList(outer._crls);
+                if (outer._crls.Count > 0)
+                {
+                    Asn1Set crls = CmsUtilities.CreateBerSetFromList(outer._crls);
 
-					WriteToGenerator(_sigGen, new BerTaggedObject(false, 1, crls));
-				}
+                    WriteToGenerator(_sigGen, new BerTaggedObject(false, 1, crls));
+                }
 
-				//
-				// Calculate the digest hashes
-				//
-				foreach (DictionaryEntry de in outer._messageDigests)
-				{
-					outer._messageHashes.Add(de.Key, DigestUtilities.DoFinal((IDigest)de.Value));
-				}
+                //
+                // Calculate the digest hashes
+                //
+                foreach (DictionaryEntry de in outer._messageDigests)
+                {
+                    outer._messageHashes.Add(de.Key, DigestUtilities.DoFinal((IDigest)de.Value));
+                }
 
-				// TODO If the digest OIDs for precalculated signers weren't mixed in with
-				// the others, we could fill in outer._digests here, instead of SignerInfoGenerator.Generate
+                // TODO If the digest OIDs for precalculated signers weren't mixed in with
+                // the others, we could fill in outer._digests here, instead of SignerInfoGenerator.Generate
 
-				//
-				// collect all the SignerInfo objects
-				//
+                //
+                // collect all the SignerInfo objects
+                //
                 Asn1EncodableVector signerInfos = new Asn1EncodableVector();
 
-				//
+                //
                 // add the generated SignerInfo objects
                 //
-				{
-					foreach (DigestAndSignerInfoGeneratorHolder holder in outer._signerInfs)
-					{
-						AlgorithmIdentifier digestAlgorithm = holder.DigestAlgorithm;
+                {
+                    foreach (DigestAndSignerInfoGeneratorHolder holder in outer._signerInfs)
+                    {
+                        AlgorithmIdentifier digestAlgorithm = holder.DigestAlgorithm;
 
-						byte[] calculatedDigest = (byte[])outer._messageHashes[
-							Helper.GetDigestAlgName(holder.digestOID)];
-						outer._digests[holder.digestOID] = calculatedDigest.Clone();
+                        byte[] calculatedDigest = (byte[])outer._messageHashes[
+                            Helper.GetDigestAlgName(holder.digestOID)];
+                        outer._digests[holder.digestOID] = calculatedDigest.Clone();
 
-						signerInfos.Add(holder.signerInf.Generate(_contentOID, digestAlgorithm, calculatedDigest));
-	                }
-				}
+                        signerInfos.Add(holder.signerInf.Generate(_contentOID, digestAlgorithm, calculatedDigest));
+                    }
+                }
 
-				//
+                //
                 // add the precalculated SignerInfo objects.
                 //
-				{
-					foreach (SignerInformation signer in outer._signers)
-					{
-						// TODO Verify the content type and calculated digest match the precalculated SignerInfo
+                {
+                    foreach (SignerInformation signer in outer._signers)
+                    {
+                        // TODO Verify the content type and calculated digest match the precalculated SignerInfo
 //						if (!signer.ContentType.Equals(_contentOID))
 //						{
 //							// TODO The precalculated content type did not match - error?
@@ -907,11 +907,11 @@ namespace Org.BouncyCastle.Cms
 //							}
 //						}
 
-						signerInfos.Add(signer.ToSignerInfo());
-	                }
-				}
+                        signerInfos.Add(signer.ToSignerInfo());
+                    }
+                }
 
-				WriteToGenerator(_sigGen, new DerSet(signerInfos));
+                WriteToGenerator(_sigGen, new DerSet(signerInfos));
 
 				_sigGen.Close();
                 _sGen.Close();
diff --git a/crypto/src/crypto/agreement/jpake/JPakeParticipant.cs b/crypto/src/crypto/agreement/jpake/JPakeParticipant.cs
index 794284866..794284866 100755..100644
--- a/crypto/src/crypto/agreement/jpake/JPakeParticipant.cs
+++ b/crypto/src/crypto/agreement/jpake/JPakeParticipant.cs
diff --git a/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroup.cs b/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroup.cs
index 08ffe1a55..08ffe1a55 100755..100644
--- a/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroup.cs
+++ b/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroup.cs
diff --git a/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroups.cs b/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroups.cs
index 192cd2b51..192cd2b51 100755..100644
--- a/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroups.cs
+++ b/crypto/src/crypto/agreement/jpake/JPakePrimeOrderGroups.cs
diff --git a/crypto/src/crypto/agreement/jpake/JPakeRound1Payload.cs b/crypto/src/crypto/agreement/jpake/JPakeRound1Payload.cs
index 9e4ab7a5f..9e4ab7a5f 100755..100644
--- a/crypto/src/crypto/agreement/jpake/JPakeRound1Payload.cs
+++ b/crypto/src/crypto/agreement/jpake/JPakeRound1Payload.cs
diff --git a/crypto/src/crypto/agreement/jpake/JPakeRound2Payload.cs b/crypto/src/crypto/agreement/jpake/JPakeRound2Payload.cs
index 47962cb3f..47962cb3f 100755..100644
--- a/crypto/src/crypto/agreement/jpake/JPakeRound2Payload.cs
+++ b/crypto/src/crypto/agreement/jpake/JPakeRound2Payload.cs
diff --git a/crypto/src/crypto/agreement/jpake/JPakeRound3Payload.cs b/crypto/src/crypto/agreement/jpake/JPakeRound3Payload.cs
index 767702f23..767702f23 100755..100644
--- a/crypto/src/crypto/agreement/jpake/JPakeRound3Payload.cs
+++ b/crypto/src/crypto/agreement/jpake/JPakeRound3Payload.cs
diff --git a/crypto/src/crypto/engines/NaccacheSternEngine.cs b/crypto/src/crypto/engines/NaccacheSternEngine.cs
index 64665c1d4..fe2d78da6 100644
--- a/crypto/src/crypto/engines/NaccacheSternEngine.cs
+++ b/crypto/src/crypto/engines/NaccacheSternEngine.cs
@@ -20,7 +20,7 @@ namespace Org.BouncyCastle.Crypto.Engines
 
 		private IList[] lookup = null;
 
-        public string AlgorithmName
+		public string AlgorithmName
 		{
 			get { return "NaccacheStern"; }
 		}
@@ -78,7 +78,7 @@ namespace Org.BouncyCastle.Crypto.Engines
 			set {}
 		}
 
-        /**
+		/**
 		* Returns the input block size of this algorithm.
 		*
 		* @see org.bouncycastle.crypto.AsymmetricBlockCipher#GetInputBlockSize()
@@ -261,7 +261,7 @@ namespace Org.BouncyCastle.Crypto.Engines
 			BigInteger m1m2Crypt = m1Crypt.Multiply(m2Crypt);
 			m1m2Crypt = m1m2Crypt.Mod(key.Modulus);
 
-            //byte[] output = key.Modulus.ToByteArray();
+			//byte[] output = key.Modulus.ToByteArray();
 			//Array.Clear(output, 0, output.Length);
 			byte[] output = new byte[key.Modulus.BitLength / 8 + 1];
 
diff --git a/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs b/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs
index 618ca9a1c..d68106844 100644
--- a/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs
+++ b/crypto/src/crypto/generators/NaccacheSternKeyPairGenerator.cs
@@ -52,7 +52,7 @@ namespace Org.BouncyCastle.Crypto.Generators
 			SecureRandom rand = param.Random;
 			int certainty = param.Certainty;
 
-            IList smallPrimes = findFirstPrimes(param.CountSmallPrimes);
+			IList smallPrimes = findFirstPrimes(param.CountSmallPrimes);
 
 			smallPrimes = permuteList(smallPrimes, rand);
 
@@ -87,7 +87,7 @@ namespace Org.BouncyCastle.Crypto.Generators
 
 			long tries = 0;
 
-            BigInteger _2au = a.Multiply(u).ShiftLeft(1);
+			BigInteger _2au = a.Multiply(u).ShiftLeft(1);
 			BigInteger _2bv = b.Multiply(v).ShiftLeft(1);
 
 			for (;;)
@@ -132,7 +132,7 @@ namespace Org.BouncyCastle.Crypto.Generators
 			BigInteger g;
 			tries = 0;
 
-            for (;;)
+			for (;;)
 			{
 				// TODO After the first loop, just regenerate one randomly-selected gPart each time?
 				IList gParts = Platform.CreateArrayList();
@@ -205,7 +205,7 @@ namespace Org.BouncyCastle.Crypto.Generators
 				break;
 			}
 
-            return new AsymmetricCipherKeyPair(new NaccacheSternKeyParameters(false, g, n, sigma.BitLength),
+			return new AsymmetricCipherKeyPair(new NaccacheSternKeyParameters(false, g, n, sigma.BitLength),
 				new NaccacheSternPrivateKeyParameters(g, n, sigma.BitLength, smallPrimes, phi_n));
 		}
 
diff --git a/crypto/src/crypto/prng/ThreadedSeedGenerator.cs b/crypto/src/crypto/prng/ThreadedSeedGenerator.cs
index 0a38e5f5a..499aab267 100644
--- a/crypto/src/crypto/prng/ThreadedSeedGenerator.cs
+++ b/crypto/src/crypto/prng/ThreadedSeedGenerator.cs
@@ -7,16 +7,16 @@ using System.Threading.Tasks;
 
 namespace Org.BouncyCastle.Crypto.Prng
 {
-    /**
-     * A thread based seed generator - one source of randomness.
-     * <p>
-     * Based on an idea from Marcus Lippert.
-     * </p>
-     */
-    public class ThreadedSeedGenerator
-    {
-        private class SeedGenerator
-        {
+	/**
+	 * A thread based seed generator - one source of randomness.
+	 * <p>
+	 * Based on an idea from Marcus Lippert.
+	 * </p>
+	 */
+	public class ThreadedSeedGenerator
+	{
+		private class SeedGenerator
+		{
 #if NETCF_1_0
 			// No volatile keyword, but all fields implicitly volatile anyway
 			private int		counter = 0;
@@ -26,18 +26,18 @@ namespace Org.BouncyCastle.Crypto.Prng
             private volatile bool stop = false;
 #endif
 
-            private void Run(object ignored)
-            {
-                while (!this.stop)
-                {
-                    this.counter++;
-                }
-            }
+			private void Run(object ignored)
+			{
+				while (!this.stop)
+				{
+					this.counter++;
+				}
+			}
 
-            public byte[] GenerateSeed(
+			public byte[] GenerateSeed(
                 int numBytes,
                 bool fast)
-            {
+			{
 #if SILVERLIGHT || PORTABLE
                 return DoGenerateSeed(numBytes, fast);
 #else
@@ -59,71 +59,71 @@ namespace Org.BouncyCastle.Crypto.Prng
                 bool fast)
             {
                 this.counter = 0;
-                this.stop = false;
+				this.stop = false;
 
-                byte[] result = new byte[numBytes];
-                int last = 0;
-                int end = fast ? numBytes : numBytes * 8;
+				byte[] result = new byte[numBytes];
+				int last = 0;
+				int end = fast ? numBytes : numBytes * 8;
 
 #if NO_THREADS
                 Task.Factory.StartNew(() => Run(null), TaskCreationOptions.None);
 #else
-                ThreadPool.QueueUserWorkItem(new WaitCallback(Run));
+				ThreadPool.QueueUserWorkItem(new WaitCallback(Run));
 #endif
 
-                for (int i = 0; i < end; i++)
-                {
-                    while (this.counter == last)
-                    {
-                        try
-                        {
+				for (int i = 0; i < end; i++)
+				{
+					while (this.counter == last)
+					{
+						try
+						{
 #if PORTABLE
                             new AutoResetEvent(false).WaitOne(1);
 #else
-                            Thread.Sleep(1);
+ 							Thread.Sleep(1);
 #endif
-                        }
-                        catch (Exception)
-                        {
-                            // ignore
-                        }
-                    }
+						}
+						catch (Exception)
+						{
+							// ignore
+						}
+					}
 
-                    last = this.counter;
+					last = this.counter;
 
-                    if (fast)
-                    {
+					if (fast)
+					{
                         result[i] = (byte)last;
-                    }
-                    else
-                    {
-                        int bytepos = i / 8;
+					}
+					else
+					{
+						int bytepos = i / 8;
                         result[bytepos] = (byte)((result[bytepos] << 1) | (last & 1));
-                    }
-                }
+					}
+				}
 
-                this.stop = true;
+				this.stop = true;
 
-                return result;
-            }
-        }
+				return result;
+			}
+		}
 
-        /**
-         * Generate seed bytes. Set fast to false for best quality.
-         * <p>
-         * If fast is set to true, the code should be round about 8 times faster when
-         * generating a long sequence of random bytes. 20 bytes of random values using
-         * the fast mode take less than half a second on a Nokia e70. If fast is set to false,
-         * it takes round about 2500 ms.
-         * </p>
-         * @param numBytes the number of bytes to generate
-         * @param fast true if fast mode should be used
-         */
-        public byte[] GenerateSeed(
+		/**
+		 * Generate seed bytes. Set fast to false for best quality.
+		 * <p>
+		 * If fast is set to true, the code should be round about 8 times faster when
+		 * generating a long sequence of random bytes. 20 bytes of random values using
+		 * the fast mode take less than half a second on a Nokia e70. If fast is set to false,
+		 * it takes round about 2500 ms.
+		 * </p>
+		 * @param numBytes the number of bytes to generate
+		 * @param fast true if fast mode should be used
+		 */
+		public byte[] GenerateSeed(
             int numBytes,
             bool fast)
-        {
-            return new SeedGenerator().GenerateSeed(numBytes, fast);
-        }
-    }
+		{
+			return new SeedGenerator().GenerateSeed(numBytes, fast);
+		}
+	}
 }
diff --git a/crypto/src/crypto/tls/DtlsReliableHandshake.cs b/crypto/src/crypto/tls/DtlsReliableHandshake.cs
index 7f3f832a1..c45e15f66 100644
--- a/crypto/src/crypto/tls/DtlsReliableHandshake.cs
+++ b/crypto/src/crypto/tls/DtlsReliableHandshake.cs
@@ -419,7 +419,8 @@ namespace Org.BouncyCastle.Crypto.Tls
 
             internal void SendToRecordLayer(DtlsRecordLayer recordLayer)
             {
-                recordLayer.Send(GetBuffer(), 0, (int)Length);
+                byte[] buffer = ToArray();
+                recordLayer.Send(buffer, 0, buffer.Length);
                 Platform.Dispose(this);
             }
         }
diff --git a/crypto/src/crypto/tls/HeartbeatMessage.cs b/crypto/src/crypto/tls/HeartbeatMessage.cs
index f64a7baa4..daf366ed1 100644
--- a/crypto/src/crypto/tls/HeartbeatMessage.cs
+++ b/crypto/src/crypto/tls/HeartbeatMessage.cs
@@ -95,7 +95,7 @@ namespace Org.BouncyCastle.Crypto.Tls
                 int minimumCount = payloadLength + 16;
                 if (Length < minimumCount)
                     return null;
-                return Arrays.CopyOf(GetBuffer(), payloadLength);
+                return Arrays.CopyOf(ToArray(), payloadLength);
             }
         }
     }
diff --git a/crypto/src/crypto/tls/TlsProtocol.cs b/crypto/src/crypto/tls/TlsProtocol.cs
index 51178a473..c3a7572c6 100644
--- a/crypto/src/crypto/tls/TlsProtocol.cs
+++ b/crypto/src/crypto/tls/TlsProtocol.cs
@@ -1310,7 +1310,7 @@ namespace Org.BouncyCastle.Crypto.Tls
                 TlsUtilities.CheckUint24(length);
                 this.Position = 1;
                 TlsUtilities.WriteUint24((int)length, this);
-                protocol.WriteHandshakeMessage(GetBuffer(), 0, (int)Length);
+                protocol.WriteHandshakeMessage(ToArray(), 0, (int)Length);
                 Platform.Dispose(this);
             }
         }
diff --git a/crypto/src/openpgp/PgpLiteralDataGenerator.cs b/crypto/src/openpgp/PgpLiteralDataGenerator.cs
index 17a6eeef2..96078bf3e 100644
--- a/crypto/src/openpgp/PgpLiteralDataGenerator.cs
+++ b/crypto/src/openpgp/PgpLiteralDataGenerator.cs
@@ -141,7 +141,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 			return new WrappedGeneratorStream(this, pkOut);
 		}
 
-#if !PORTABLE
+#if !PORTABLE || DOTNET
 		/// <summary>
 		/// <p>
 		/// Open a literal data packet for the passed in <c>FileInfo</c> object, returning
diff --git a/crypto/src/openpgp/PgpUtilities.cs b/crypto/src/openpgp/PgpUtilities.cs
index 9238edcfc..055f99636 100644
--- a/crypto/src/openpgp/PgpUtilities.cs
+++ b/crypto/src/openpgp/PgpUtilities.cs
@@ -347,7 +347,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
             return MakeKey(algorithm, keyBytes);
         }
 
-#if !PORTABLE
+#if !PORTABLE || DOTNET
         /// <summary>Write out the passed in file as a literal data packet.</summary>
         public static void WriteFileToLiteralData(
             Stream		output,
diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs
index e4fe29401..a024bcd6b 100644
--- a/crypto/src/pkcs/Pkcs12Store.cs
+++ b/crypto/src/pkcs/Pkcs12Store.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections;
+using System.Diagnostics;
 using System.IO;
 using System.Text;
 
@@ -113,88 +114,88 @@ namespace Org.BouncyCastle.Pkcs
         {
             AsymmetricKeyParameter privKey = PrivateKeyFactory.CreateKey(privKeyInfo);
 
-            IDictionary attributes = Platform.CreateHashtable();
+                                IDictionary attributes = Platform.CreateHashtable();
             AsymmetricKeyEntry keyEntry = new AsymmetricKeyEntry(privKey, attributes);
 
-            string alias = null;
-            Asn1OctetString localId = null;
+                                string alias = null;
+                                Asn1OctetString localId = null;
 
             if (bagAttributes != null)
-            {
+                                {
                 foreach (Asn1Sequence sq in bagAttributes)
-                {
+                                    {
                     DerObjectIdentifier aOid = DerObjectIdentifier.GetInstance(sq[0]);
                     Asn1Set attrSet = Asn1Set.GetInstance(sq[1]);
-                    Asn1Encodable attr = null;
-
-                    if (attrSet.Count > 0)
-                    {
-                        // TODO We should be adding all attributes in the set
-                        attr = attrSet[0];
-
-                        // TODO We might want to "merge" attribute sets with
-                        // the same OID - currently, differing values give an error
-                        if (attributes.Contains(aOid.Id))
-                        {
-                            // OK, but the value has to be the same
-                            if (!attributes[aOid.Id].Equals(attr))
-                                throw new IOException("attempt to add existing attribute with different value");
-                        }
-                        else
-                        {
-                            attributes.Add(aOid.Id, attr);
-                        }
-
-                        if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtFriendlyName))
-                        {
-                            alias = ((DerBmpString)attr).GetString();
-                            // TODO Do these in a separate loop, just collect aliases here
+                                        Asn1Encodable attr = null;
+
+                                        if (attrSet.Count > 0)
+                                        {
+                                            // TODO We should be adding all attributes in the set
+                                            attr = attrSet[0];
+
+                                            // TODO We might want to "merge" attribute sets with
+                                            // the same OID - currently, differing values give an error
+                                            if (attributes.Contains(aOid.Id))
+                                            {
+                                                // OK, but the value has to be the same
+                                                if (!attributes[aOid.Id].Equals(attr))
+                                                    throw new IOException("attempt to add existing attribute with different value");
+                                                }
+                                            else
+                                            {
+                                                attributes.Add(aOid.Id, attr);
+                                            }
+
+                                            if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtFriendlyName))
+                                            {
+                                                alias = ((DerBmpString)attr).GetString();
+                                                // TODO Do these in a separate loop, just collect aliases here
                             keys[alias] = keyEntry;
-                        }
-                        else if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtLocalKeyID))
-                        {
-                            localId = (Asn1OctetString)attr;
-                        }
-                    }
-                }
-            }
+                                            }
+                                            else if (aOid.Equals(PkcsObjectIdentifiers.Pkcs9AtLocalKeyID))
+                                            {
+                                                localId = (Asn1OctetString)attr;
+                                            }
+                                        }
+                                    }
+                                }
 
-            if (localId != null)
-            {
-                string name = Hex.ToHexString(localId.GetOctets());
+                                if (localId != null)
+                                {
+                                    string name = Hex.ToHexString(localId.GetOctets());
 
-                if (alias == null)
-                {
+                                    if (alias == null)
+                                    {
                     keys[name] = keyEntry;
-                }
-                else
-                {
-                    // TODO There may have been more than one alias
-                    localIds[alias] = name;
-                }
-            }
-            else
-            {
+                                    }
+                                    else
+                                    {
+                                        // TODO There may have been more than one alias
+                                        localIds[alias] = name;
+                                    }
+                                }
+                                else
+                                {
                 unmarkedKeyEntry = keyEntry;
-            }
-        }
+                                }
+                            }
 
         protected virtual void LoadPkcs8ShroudedKeyBag(EncryptedPrivateKeyInfo encPrivKeyInfo, Asn1Set bagAttributes,
             char[] password, bool wrongPkcs12Zero)
-        {
+                            {
             if (password != null)
-            {
+                            {
                 PrivateKeyInfo privInfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(
                     password, wrongPkcs12Zero, encPrivKeyInfo);
 
                 LoadKeyBag(privInfo, bagAttributes);
-            }
-        }
+                            }
+                        }
 
         public void Load(
             Stream	input,
             char[]	password)
-        {
+                        {
             if (input == null)
                 throw new ArgumentNullException("input");
 
@@ -204,7 +205,7 @@ namespace Org.BouncyCastle.Pkcs
             bool wrongPkcs12Zero = false;
 
             if (password != null && bag.MacData != null) // check the mac code
-            {
+                            {
                 MacData mData = bag.MacData;
                 DigestInfo dInfo = mData.Mac;
                 AlgorithmIdentifier algId = dInfo.AlgorithmID;
@@ -217,7 +218,7 @@ namespace Org.BouncyCastle.Pkcs
                 byte[] dig = dInfo.GetDigest();
 
                 if (!Arrays.ConstantTimeAreEqual(mac, dig))
-                {
+                                    {
                     if (password.Length > 0)
                         throw new IOException("PKCS12 key store MAC invalid - wrong password or corrupted file.");
 
@@ -228,8 +229,8 @@ namespace Org.BouncyCastle.Pkcs
                         throw new IOException("PKCS12 key store MAC invalid - wrong password or corrupted file.");
 
                     wrongPkcs12Zero = true;
-                }
-            }
+                                        }
+                                        }
 
             keys.Clear();
             localIds.Clear();
@@ -238,37 +239,37 @@ namespace Org.BouncyCastle.Pkcs
             IList certBags = Platform.CreateArrayList();
 
             if (info.ContentType.Equals(PkcsObjectIdentifiers.Data))
-            {
+                            {
                 byte[] octs = ((Asn1OctetString)info.Content).GetOctets();
                 AuthenticatedSafe authSafe = new AuthenticatedSafe(
                     (Asn1Sequence) Asn1OctetString.FromByteArray(octs));
                 ContentInfo[] cis = authSafe.GetContentInfo();
 
                 foreach (ContentInfo ci in cis)
-                {
+                                {
                     DerObjectIdentifier oid = ci.ContentType;
 
                     byte[] octets = null;
                     if (oid.Equals(PkcsObjectIdentifiers.Data))
-                    {
+                                    {
                         octets = ((Asn1OctetString)ci.Content).GetOctets();
                     }
                     else if (oid.Equals(PkcsObjectIdentifiers.EncryptedData))
-                    {
+                                        {
                         if (password != null)
-                        {
+                                            {
                             EncryptedData d = EncryptedData.GetInstance(ci.Content);
                             octets = CryptPbeData(false, d.EncryptionAlgorithm,
                                 password, wrongPkcs12Zero, d.Content.GetOctets());
-                        }
-                    }
-                    else
-                    {
+                                            }
+                                        }
+                                        else
+                                        {
                         // TODO Other data types
-                    }
+                                        }
 
                     if (octets != null)
-                    {
+                                        {
                         Asn1Sequence seq = (Asn1Sequence)Asn1Object.FromByteArray(octets);
 
                         foreach (Asn1Sequence subSeq in seq)
@@ -276,14 +277,14 @@ namespace Org.BouncyCastle.Pkcs
                             SafeBag b = new SafeBag(subSeq);
 
                             if (b.BagID.Equals(PkcsObjectIdentifiers.CertBag))
-                            {
+                                {
                                 certBags.Add(b);
-                            }
+                                }
                             else if (b.BagID.Equals(PkcsObjectIdentifiers.Pkcs8ShroudedKeyBag))
-                            {
+                                {
                                 LoadPkcs8ShroudedKeyBag(EncryptedPrivateKeyInfo.GetInstance(b.BagValue),
                                     b.BagAttributes, password, wrongPkcs12Zero);
-                            }
+                                }
                             else if (b.BagID.Equals(PkcsObjectIdentifiers.KeyBag))
                             {
                                 LoadKeyBag(PrivateKeyInfo.GetInstance(b.BagValue), b.BagAttributes);
@@ -291,9 +292,9 @@ namespace Org.BouncyCastle.Pkcs
                             else
                             {
                                 // TODO Other bag types
-                            }
                         }
                     }
+                    }
                 }
             }
 
@@ -732,7 +733,7 @@ namespace Org.BouncyCastle.Pkcs
                 {
                     bagOid = PkcsObjectIdentifiers.Pkcs8ShroudedKeyBag;
                     bagData = EncryptedPrivateKeyInfoFactory.CreateEncryptedPrivateKeyInfo(
-                        keyAlgorithm, password, kSalt, MinIterations, privKey.Key);
+                    keyAlgorithm, password, kSalt, MinIterations, privKey.Key);
                 }
 
                 Asn1EncodableVector kName = new Asn1EncodableVector();
@@ -942,7 +943,7 @@ namespace Org.BouncyCastle.Pkcs
             else
             {
                 byte[] certBytes = CryptPbeData(true, cAlgId, password, false, certBagsEncoding);
-                EncryptedData cInfo = new EncryptedData(PkcsObjectIdentifiers.Data, cAlgId, new BerOctetString(certBytes));
+            EncryptedData cInfo = new EncryptedData(PkcsObjectIdentifiers.Data, cAlgId, new BerOctetString(certBytes));
                 certsInfo = new ContentInfo(PkcsObjectIdentifiers.EncryptedData, cInfo.ToAsn1Object());
             }
 
@@ -959,15 +960,15 @@ namespace Org.BouncyCastle.Pkcs
             MacData macData = null;
             if (password != null)
             {
-                byte[] mSalt = new byte[20];
-                random.NextBytes(mSalt);
+            byte[] mSalt = new byte[20];
+            random.NextBytes(mSalt);
 
-                byte[] mac = CalculatePbeMac(OiwObjectIdentifiers.IdSha1,
-                    mSalt, MinIterations, password, false, data);
+            byte[] mac = CalculatePbeMac(OiwObjectIdentifiers.IdSha1,
+                mSalt, MinIterations, password, false, data);
 
-                AlgorithmIdentifier algId = new AlgorithmIdentifier(
-                    OiwObjectIdentifiers.IdSha1, DerNull.Instance);
-                DigestInfo dInfo = new DigestInfo(algId, mac);
+            AlgorithmIdentifier algId = new AlgorithmIdentifier(
+                OiwObjectIdentifiers.IdSha1, DerNull.Instance);
+            DigestInfo dInfo = new DigestInfo(algId, mac);
 
                 macData = new MacData(dInfo, mSalt, MinIterations);
             }
diff --git a/crypto/src/util/Enums.cs b/crypto/src/util/Enums.cs
index 25b218667..20b978c22 100644
--- a/crypto/src/util/Enums.cs
+++ b/crypto/src/util/Enums.cs
@@ -14,7 +14,11 @@ namespace Org.BouncyCastle.Utilities
     {
         internal static Enum GetEnumValue(System.Type enumType, string s)
         {
+#if NEW_REFLECTION
+            if (!enumType.GetTypeInfo().IsEnum)
+#else
             if (!enumType.IsEnum)
+#endif
                 throw new ArgumentException("Not an enumeration type", "enumType");
 
             // We only want to parse single named constants
@@ -39,10 +43,14 @@ namespace Org.BouncyCastle.Utilities
 
         internal static Array GetEnumValues(System.Type enumType)
         {
+#if NEW_REFLECTION
+            if(!enumType.GetTypeInfo().IsEnum)
+#else
             if (!enumType.IsEnum)
+#endif
                 throw new ArgumentException("Not an enumeration type", "enumType");
 
-#if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE
+#if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT && !PORTABLE
             IList result = Platform.CreateArrayList();
             FieldInfo[] fields = enumType.GetFields(BindingFlags.Static | BindingFlags.Public);
             foreach (FieldInfo field in fields)
diff --git a/crypto/src/util/Platform.cs b/crypto/src/util/Platform.cs
index 82446b296..d4b18f182 100644
--- a/crypto/src/util/Platform.cs
+++ b/crypto/src/util/Platform.cs
@@ -34,6 +34,8 @@ namespace Org.BouncyCastle.Utilities
         {
 #if SILVERLIGHT
             return String.Compare(a, b, StringComparison.InvariantCultureIgnoreCase);
+#elif SYS_RUNTIME
+            return String.Compare(a, b, StringComparison.OrdinalIgnoreCase);
 #elif PORTABLE
             return String.Compare(a, b, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase);
 #else
diff --git a/crypto/src/util/TypeExtensions.cs b/crypto/src/util/TypeExtensions.cs
new file mode 100644
index 000000000..c7ce807a0
--- /dev/null
+++ b/crypto/src/util/TypeExtensions.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Reflection;
+
+#if NEW_REFLECTION
+
+namespace Org.BouncyCastle
+{
+    internal static class TypeExtensions
+    {
+        public static bool IsInstanceOfType(this Type type, object instance)
+        {
+            return instance != null && type.GetTypeInfo().IsAssignableFrom(instance.GetType().GetTypeInfo());
+        }
+    }
+
+}
+
+#endif
\ No newline at end of file
diff --git a/crypto/src/util/zlib/ZDeflaterOutputStream.cs b/crypto/src/util/zlib/ZDeflaterOutputStream.cs
index d0f0bcb8d..d0978942a 100644
--- a/crypto/src/util/zlib/ZDeflaterOutputStream.cs
+++ b/crypto/src/util/zlib/ZDeflaterOutputStream.cs
@@ -135,7 +135,7 @@ namespace Org.BouncyCastle.Utilities.Zlib {
             z.free();
             z=null;
         }
-        
+
 #if PORTABLE
         protected override void Dispose(bool disposing)
         {
diff --git a/crypto/test/src/asn1/test/AllTests.cs b/crypto/test/src/asn1/test/AllTests.cs
index ad2f90362..981b5a4df 100644
--- a/crypto/test/src/asn1/test/AllTests.cs
+++ b/crypto/test/src/asn1/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -28,3 +29,4 @@ namespace Org.BouncyCastle.Asn1.Tests
         }
     }
 }
+#endif
diff --git a/crypto/test/src/cms/test/AllTests.cs b/crypto/test/src/cms/test/AllTests.cs
index b7ac7644b..b47374914 100644
--- a/crypto/test/src/cms/test/AllTests.cs
+++ b/crypto/test/src/cms/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -32,3 +33,4 @@ namespace Org.BouncyCastle.Cms.Tests
         }
     }
 }
+#endif
diff --git a/crypto/test/src/crypto/io/test/AllTests.cs b/crypto/test/src/crypto/io/test/AllTests.cs
index 5c8c759f9..2634b4ab1 100644
--- a/crypto/test/src/crypto/io/test/AllTests.cs
+++ b/crypto/test/src/crypto/io/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -24,3 +25,4 @@ namespace Org.BouncyCastle.Crypto.IO.Tests
         }
 	}
 }
+#endif
diff --git a/crypto/test/src/crypto/test/AllTests.cs b/crypto/test/src/crypto/test/AllTests.cs
index 3d8ef5602..d5feec500 100644
--- a/crypto/test/src/crypto/test/AllTests.cs
+++ b/crypto/test/src/crypto/test/AllTests.cs
@@ -1,6 +1,8 @@
 using System;
 
+#if !LIB
 using NUnit.Core;
+#endif
 using NUnit.Framework;
 
 using Org.BouncyCastle.Utilities.Test;
@@ -10,24 +12,26 @@ namespace Org.BouncyCastle.Crypto.Tests
 	[TestFixture]
 	public class AllTests
 	{
+#if !LIB
         public static void Main(string[] args)
         {
             Suite.Run(new NullListener(), NUnit.Core.TestFilter.Empty);
         }
 
-        [Suite]
-        public static TestSuite Suite
-        {
-            get
-            {
-                TestSuite suite = new TestSuite("Lightweight Crypto Tests");
-                suite.Add(new AllTests());
-                suite.Add(new GcmReorderTest());
-                return suite;
-            }
-        }
+		[Suite]
+		public static TestSuite Suite
+		{
+			get
+			{
+				TestSuite suite = new TestSuite("Lightweight Crypto Tests");
+				suite.Add(new AllTests());
+		        suite.Add(new GcmReorderTest());
+				return suite;
+			}
+		}
+#endif
 
-        [Test]
+		[Test]
 		public void TestCrypto()
 		{
 			foreach (Org.BouncyCastle.Utilities.Test.ITest test in RegressionTest.tests)
diff --git a/crypto/test/src/math/ec/test/AllTests.cs b/crypto/test/src/math/ec/test/AllTests.cs
index 3e014ffd2..0517ac713 100644
--- a/crypto/test/src/math/ec/test/AllTests.cs
+++ b/crypto/test/src/math/ec/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -25,3 +26,4 @@ namespace Org.BouncyCastle.Math.EC.Tests
         }
     }
 }
+#endif
diff --git a/crypto/test/src/math/test/AllTests.cs b/crypto/test/src/math/test/AllTests.cs
index 2bcc129ea..53feff954 100644
--- a/crypto/test/src/math/test/AllTests.cs
+++ b/crypto/test/src/math/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -25,3 +26,4 @@ namespace Org.BouncyCastle.Math.Tests
         }
     }
 }
+#endif
diff --git a/crypto/test/src/ocsp/test/AllTests.cs b/crypto/test/src/ocsp/test/AllTests.cs
index 5e919fd91..5e799cd09 100644
--- a/crypto/test/src/ocsp/test/AllTests.cs
+++ b/crypto/test/src/ocsp/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -26,3 +27,4 @@ namespace Org.BouncyCastle.Ocsp.Tests
         }
 	}
 }
+#endif
diff --git a/crypto/test/src/openpgp/examples/test/AllTests.cs b/crypto/test/src/openpgp/examples/test/AllTests.cs
index 9a515ea15..3403a4fdc 100644
--- a/crypto/test/src/openpgp/examples/test/AllTests.cs
+++ b/crypto/test/src/openpgp/examples/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 using System.IO;
 
@@ -434,3 +435,4 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Examples.Tests
         }
 	}
 }
+#endif
diff --git a/crypto/test/src/openpgp/test/PgpUnicodeTest.cs b/crypto/test/src/openpgp/test/PgpUnicodeTest.cs
index 534e8a471..c9f2e0ca2 100644
--- a/crypto/test/src/openpgp/test/PgpUnicodeTest.cs
+++ b/crypto/test/src/openpgp/test/PgpUnicodeTest.cs
@@ -2,7 +2,6 @@
 using System.IO;
 using System.Text;
 
-using NUnit.Core;
 using NUnit.Framework;
 
 using Org.BouncyCastle.Math;
@@ -122,21 +121,5 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
         {
             return new PgpSecretKeyRingBundle(SimpleTest.GetTestDataAsStream("openpgp.unicode." + keyName));
         }
-
-        public static void Main(string[] args)
-        {
-            Suite.Run(new NullListener(), NUnit.Core.TestFilter.Empty);
-        }
-
-        [Suite]
-        public static TestSuite Suite
-        {
-            get
-            {
-                TestSuite suite = new TestSuite("Unicode Password Tests");
-                suite.Add(new PgpUnicodeTest());
-                return suite;
-            }
-        }
     }
 }
diff --git a/crypto/test/src/openssl/test/AllTests.cs b/crypto/test/src/openssl/test/AllTests.cs
index f843d0479..871b926b8 100644
--- a/crypto/test/src/openssl/test/AllTests.cs
+++ b/crypto/test/src/openssl/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 using System.IO;
 using System.Text;
@@ -128,3 +129,4 @@ namespace Org.BouncyCastle.OpenSsl.Tests
 		}
 	}
 }
+#endif
diff --git a/crypto/test/src/tsp/test/AllTests.cs b/crypto/test/src/tsp/test/AllTests.cs
index 3e8b0cd5e..58d096d54 100644
--- a/crypto/test/src/tsp/test/AllTests.cs
+++ b/crypto/test/src/tsp/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 
 using NUnit.Core;
@@ -29,3 +30,4 @@ namespace Org.BouncyCastle.Tsp.Tests
         }
     }
 }
+#endif
diff --git a/crypto/test/src/util/io/pem/test/AllTests.cs b/crypto/test/src/util/io/pem/test/AllTests.cs
index c36f79304..5f0c12c10 100644
--- a/crypto/test/src/util/io/pem/test/AllTests.cs
+++ b/crypto/test/src/util/io/pem/test/AllTests.cs
@@ -1,3 +1,4 @@
+#if !LIB
 using System;
 using System.Collections;
 using System.Collections.Specialized;
@@ -72,3 +73,4 @@ namespace Org.BouncyCastle.Utilities.IO.Pem.Tests
 		}
 	}
 }
+#endif
diff --git a/crypto/test/src/util/test/SimpleTest.cs b/crypto/test/src/util/test/SimpleTest.cs
index 84a7ce02b..d759674ea 100644
--- a/crypto/test/src/util/test/SimpleTest.cs
+++ b/crypto/test/src/util/test/SimpleTest.cs
@@ -119,7 +119,7 @@ namespace Org.BouncyCastle.Utilities.Test
 #if BC_BUILD_MONODEVELOP
 			return "test.data." + name;
 #else
-			return "crypto.test.data." + name;
+			return "crypto.tests." + name;
 #endif
 		}
 
@@ -130,7 +130,7 @@ namespace Org.BouncyCastle.Utilities.Test
 #if BC_BUILD_MONODEVELOP
 			return fullName.Substring("test.data.".Length);
 #else
-			return fullName.Substring("crypto.test.data.".Length);
+			return fullName.Substring("crypto.tests.".Length);
 #endif
 		}
 
diff --git a/csharp.sln b/csharp.sln
deleted file mode 100644
index ce64a084a..000000000
--- a/csharp.sln
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crypto", "crypto\crypto.csproj", "{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crypto-test", "crypto-test\crypto-test.csproj", "{C857AD68-8F1B-4C7A-A76B-3DC03CBE4FB0}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Debug.ActiveCfg = Debug|.NET
-		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Debug.Build.0 = Debug|.NET
-		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Release.ActiveCfg = Release|.NET
-		{38872A5F-E87E-4FAD-B109-8EB7B2E6A4A0}.Release.Build.0 = Release|.NET
-		{C857AD68-8F1B-4C7A-A76B-3DC03CBE4FB0}.Debug.ActiveCfg = Debug|.NET
-		{C857AD68-8F1B-4C7A-A76B-3DC03CBE4FB0}.Debug.Build.0 = Debug|.NET
-		{C857AD68-8F1B-4C7A-A76B-3DC03CBE4FB0}.Release.ActiveCfg = Release|.NET
-		{C857AD68-8F1B-4C7A-A76B-3DC03CBE4FB0}.Release.Build.0 = Release|.NET
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal