From d032037615fb28980f2d92dbe500fc2fcfdd37ee Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 11:33:33 +0700
Subject: http://www.bouncycastle.org/jira/browse/BMA-90
- Make CmsReadable public
- Make a few methods virtual
---
crypto/src/cms/CMSProcessableByteArray.cs | 10 +++++-----
crypto/src/cms/CMSProcessableFile.cs | 19 +++++++------------
crypto/src/cms/CMSProcessableInputStream.cs | 22 +++++++++++-----------
crypto/src/cms/CMSReadable.cs | 2 +-
4 files changed, 24 insertions(+), 29 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/cms/CMSProcessableByteArray.cs b/crypto/src/cms/CMSProcessableByteArray.cs
index 4bee4f8bd..a6ab9b6a2 100644
--- a/crypto/src/cms/CMSProcessableByteArray.cs
+++ b/crypto/src/cms/CMSProcessableByteArray.cs
@@ -11,23 +11,23 @@ namespace Org.BouncyCastle.Cms
{
private readonly byte[] bytes;
- public CmsProcessableByteArray(
- byte[] bytes)
+ public CmsProcessableByteArray(byte[] bytes)
{
this.bytes = bytes;
}
- public Stream GetInputStream()
+ public virtual Stream GetInputStream()
{
return new MemoryStream(bytes, false);
}
- public virtual void Write(Stream zOut)
+ public virtual void Write(Stream zOut)
{
zOut.Write(bytes, 0, bytes.Length);
}
- /// A clone of the byte array
+ /// A clone of the byte array
+ [Obsolete]
public virtual object GetContent()
{
return bytes.Clone();
diff --git a/crypto/src/cms/CMSProcessableFile.cs b/crypto/src/cms/CMSProcessableFile.cs
index cbc74f44b..01020df11 100644
--- a/crypto/src/cms/CMSProcessableFile.cs
+++ b/crypto/src/cms/CMSProcessableFile.cs
@@ -13,38 +13,33 @@ 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)
+ public CmsProcessableFile(FileInfo file)
: this(file, DefaultBufSize)
{
}
- public CmsProcessableFile(
- FileInfo file,
- int bufSize)
+ public CmsProcessableFile(FileInfo file, int bufSize)
{
_file = file;
_bufSize = bufSize;
}
- public virtual Stream GetInputStream()
+ public virtual Stream GetInputStream()
{
- return new FileStream(
- _file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize);
+ return new FileStream(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize);
}
- public virtual void Write(
- Stream zOut)
+ public virtual void Write(Stream zOut)
{
Stream inStr = GetInputStream();
Streams.PipeAll(inStr, zOut);
inStr.Close();
}
- /// The file handle
+ /// The file handle
[Obsolete]
public virtual object GetContent()
{
diff --git a/crypto/src/cms/CMSProcessableInputStream.cs b/crypto/src/cms/CMSProcessableInputStream.cs
index 7fdd1dfef..6dff7c212 100644
--- a/crypto/src/cms/CMSProcessableInputStream.cs
+++ b/crypto/src/cms/CMSProcessableInputStream.cs
@@ -8,23 +8,23 @@ namespace Org.BouncyCastle.Cms
public class CmsProcessableInputStream
: CmsProcessable, CmsReadable
{
- private Stream input;
- private bool used = false;
+ private readonly Stream input;
- public CmsProcessableInputStream(
- Stream input)
+ private bool used = false;
+
+ public CmsProcessableInputStream(Stream input)
{
this.input = input;
}
- public Stream GetInputStream()
+ public virtual Stream GetInputStream()
{
CheckSingleUsage();
- return input;
+ return input;
}
- public void Write(Stream output)
+ public virtual void Write(Stream output)
{
CheckSingleUsage();
@@ -32,20 +32,20 @@ namespace Org.BouncyCastle.Cms
input.Close();
}
- [Obsolete]
- public object GetContent()
+ [Obsolete]
+ public virtual object GetContent()
{
return GetInputStream();
}
- private void CheckSingleUsage()
+ protected virtual void CheckSingleUsage()
{
lock (this)
{
if (used)
throw new InvalidOperationException("CmsProcessableInputStream can only be used once");
- used = true;
+ used = true;
}
}
}
diff --git a/crypto/src/cms/CMSReadable.cs b/crypto/src/cms/CMSReadable.cs
index 9507b920c..ad83ba068 100644
--- a/crypto/src/cms/CMSReadable.cs
+++ b/crypto/src/cms/CMSReadable.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.Cms
{
- internal interface CmsReadable
+ public interface CmsReadable
{
Stream GetInputStream();
}
--
cgit 1.5.1
From 37c281d2026660c5123782774e5029c86f2e0639 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 12:21:22 +0700
Subject: SIC renamed to CTR, minimum IV length check added
---
crypto/src/crypto/modes/SicBlockCipher.cs | 48 +++++++++++++++----------------
1 file changed, 24 insertions(+), 24 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/crypto/modes/SicBlockCipher.cs b/crypto/src/crypto/modes/SicBlockCipher.cs
index da7ed7859..3e2b8deba 100644
--- a/crypto/src/crypto/modes/SicBlockCipher.cs
+++ b/crypto/src/crypto/modes/SicBlockCipher.cs
@@ -3,6 +3,8 @@ using System;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Utilities;
+
namespace Org.BouncyCastle.Crypto.Modes
{
/**
@@ -14,10 +16,11 @@ namespace Org.BouncyCastle.Crypto.Modes
{
private readonly IBlockCipher cipher;
private readonly int blockSize;
- private readonly byte[] IV;
private readonly byte[] counter;
private readonly byte[] counterOut;
+ private byte[] IV = null;
+
/**
* Basic constructor.
*
@@ -27,7 +30,6 @@ namespace Org.BouncyCastle.Crypto.Modes
{
this.cipher = cipher;
this.blockSize = cipher.GetBlockSize();
- this.IV = new byte[blockSize];
this.counter = new byte[blockSize];
this.counterOut = new byte[blockSize];
}
@@ -37,51 +39,49 @@ namespace Org.BouncyCastle.Crypto.Modes
*
* @return the underlying block cipher that we are wrapping.
*/
- public IBlockCipher GetUnderlyingCipher()
+ public virtual IBlockCipher GetUnderlyingCipher()
{
return cipher;
}
- public void Init(
+ public virtual void Init(
bool forEncryption, //ignored by this CTR mode
ICipherParameters parameters)
{
- if (parameters is ParametersWithIV)
- {
- ParametersWithIV ivParam = (ParametersWithIV) parameters;
- byte[] iv = ivParam.GetIV();
- Array.Copy(iv, 0, IV, 0, IV.Length);
+ ParametersWithIV ivParam = parameters as ParametersWithIV;
+ if (ivParam == null)
+ throw new ArgumentException("CTR mode requires ParametersWithIV", "parameters");
- Reset();
+ this.IV = Arrays.Clone(ivParam.GetIV());
- // if null it's an IV changed only.
- if (ivParam.Parameters != null)
- {
- cipher.Init(true, ivParam.Parameters);
- }
- }
- else
+ if (blockSize - IV.Length > 8)
+ throw new ArgumentException("CTR mode requires IV of at least: " + (blockSize - 8) + " bytes.");
+
+ Reset();
+
+ // if null it's an IV changed only.
+ if (ivParam.Parameters != null)
{
- throw new ArgumentException("SIC mode requires ParametersWithIV", "parameters");
+ cipher.Init(true, ivParam.Parameters);
}
}
- public string AlgorithmName
+ public virtual string AlgorithmName
{
- get { return cipher.AlgorithmName + "/SIC"; }
+ get { return cipher.AlgorithmName + "/CTR"; }
}
- public bool IsPartialBlockOkay
+ public virtual bool IsPartialBlockOkay
{
get { return true; }
}
- public int GetBlockSize()
+ public virtual int GetBlockSize()
{
return cipher.GetBlockSize();
}
- public int ProcessBlock(
+ public virtual int ProcessBlock(
byte[] input,
int inOff,
byte[] output,
@@ -106,7 +106,7 @@ namespace Org.BouncyCastle.Crypto.Modes
return counter.Length;
}
- public void Reset()
+ public virtual void Reset()
{
Array.Copy(IV, 0, counter, 0, counter.Length);
cipher.Reset();
--
cgit 1.5.1
From f5f9f85725225dd98b511ba2c789aeb47293a18c Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 12:22:01 +0700
Subject: Switch to Strings.ToByteArray as is used in the Java API
---
crypto/src/crypto/PbeParametersGenerator.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/crypto/PbeParametersGenerator.cs b/crypto/src/crypto/PbeParametersGenerator.cs
index 21679d45e..97d23df90 100644
--- a/crypto/src/crypto/PbeParametersGenerator.cs
+++ b/crypto/src/crypto/PbeParametersGenerator.cs
@@ -130,7 +130,7 @@ namespace Org.BouncyCastle.Crypto
if (password == null)
return new byte[0];
- return Strings.ToAsciiByteArray(password);
+ return Strings.ToByteArray(password);
}
[Obsolete("Use version taking 'char[]' instead")]
@@ -140,7 +140,7 @@ namespace Org.BouncyCastle.Crypto
if (password == null)
return new byte[0];
- return Strings.ToAsciiByteArray(password);
+ return Strings.ToByteArray(password);
}
/**
--
cgit 1.5.1
From 72bc65bf9af227d835cfc04e43b4a51b5ac343d6 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 12:22:25 +0700
Subject: Add CalculateMac utility method
---
crypto/src/security/MacUtilities.cs | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'crypto/src')
diff --git a/crypto/src/security/MacUtilities.cs b/crypto/src/security/MacUtilities.cs
index d1f8c89b4..d7fe91142 100644
--- a/crypto/src/security/MacUtilities.cs
+++ b/crypto/src/security/MacUtilities.cs
@@ -230,6 +230,14 @@ namespace Org.BouncyCastle.Security
return (string) algorithms[oid.Id];
}
+ public static byte[] CalculateMac(string algorithm, ICipherParameters cp, byte[] input)
+ {
+ IMac mac = GetMac(algorithm);
+ mac.Init(cp);
+ mac.BlockUpdate(input, 0, input.Length);
+ return DoFinal(mac);
+ }
+
public static byte[] DoFinal(IMac mac)
{
byte[] b = new byte[mac.GetMacSize()];
--
cgit 1.5.1
From 6631312ae9e239fb62a7ec0f8573c275c5743dda Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 12:51:13 +0700
Subject: Followups for the SicBlockCipher changes
---
crypto/src/crypto/modes/SicBlockCipher.cs | 7 ++++---
crypto/test/src/test/BlockCipherTest.cs | 1 +
2 files changed, 5 insertions(+), 3 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/crypto/modes/SicBlockCipher.cs b/crypto/src/crypto/modes/SicBlockCipher.cs
index 3e2b8deba..17f86ee10 100644
--- a/crypto/src/crypto/modes/SicBlockCipher.cs
+++ b/crypto/src/crypto/modes/SicBlockCipher.cs
@@ -18,8 +18,7 @@ namespace Org.BouncyCastle.Crypto.Modes
private readonly int blockSize;
private readonly byte[] counter;
private readonly byte[] counterOut;
-
- private byte[] IV = null;
+ private byte[] IV;
/**
* Basic constructor.
@@ -32,6 +31,7 @@ namespace Org.BouncyCastle.Crypto.Modes
this.blockSize = cipher.GetBlockSize();
this.counter = new byte[blockSize];
this.counterOut = new byte[blockSize];
+ this.IV = new byte[blockSize];
}
/**
@@ -108,7 +108,8 @@ namespace Org.BouncyCastle.Crypto.Modes
public virtual void Reset()
{
- Array.Copy(IV, 0, counter, 0, counter.Length);
+ Arrays.Fill(counter, (byte)0);
+ Array.Copy(IV, 0, counter, 0, System.Math.Min(IV.Length, counter.Length));
cipher.Reset();
}
}
diff --git a/crypto/test/src/test/BlockCipherTest.cs b/crypto/test/src/test/BlockCipherTest.cs
index 2e8e8b0b8..93cf2b0a5 100644
--- a/crypto/test/src/test/BlockCipherTest.cs
+++ b/crypto/test/src/test/BlockCipherTest.cs
@@ -438,6 +438,7 @@ namespace Org.BouncyCastle.Tests
{
// TODO Examine short IV handling for these FIPS-compliant modes in Java build
if (mode.StartsWith("CFB")
+ || mode.StartsWith("CTR")
|| mode.StartsWith("GOFB")
|| mode.StartsWith("OFB")
|| mode.StartsWith("OPENPGPCFB"))
--
cgit 1.5.1
From 1df5b7dd9235428140ae8725e0004072b13e8f99 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 13:01:33 +0700
Subject: http://www.bouncycastle.org/jira/browse/BMA-128
- Cater for future X.509 versions
---
crypto/src/x509/X509Certificate.cs | 2 +-
crypto/src/x509/X509Crl.cs | 2 +-
crypto/test/src/asn1/test/CertificateTest.cs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index 4487232f0..c323fc8f1 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -376,7 +376,7 @@ namespace Org.BouncyCastle.X509
protected override X509Extensions GetX509Extensions()
{
- return c.Version == 3
+ return c.Version >= 3
? c.TbsCertificate.Extensions
: null;
}
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs
index 1746960fb..0679cb240 100644
--- a/crypto/src/x509/X509Crl.cs
+++ b/crypto/src/x509/X509Crl.cs
@@ -64,7 +64,7 @@ namespace Org.BouncyCastle.X509
protected override X509Extensions GetX509Extensions()
{
- return Version == 2
+ return c.Version >= 2
? c.TbsCertList.Extensions
: null;
}
diff --git a/crypto/test/src/asn1/test/CertificateTest.cs b/crypto/test/src/asn1/test/CertificateTest.cs
index 532e81aba..7fcb1fffa 100644
--- a/crypto/test/src/asn1/test/CertificateTest.cs
+++ b/crypto/test/src/asn1/test/CertificateTest.cs
@@ -212,7 +212,7 @@ namespace Org.BouncyCastle.Asn1.Tests
+ " got " + tbsCert.Subject.ToString());
}
- if (tbsCert.Version == 3)
+ if (tbsCert.Version >= 3)
{
X509Extensions ext = tbsCert.Extensions;
if (ext != null)
--
cgit 1.5.1
From 460c3811712e3005f268c1d48d582cb65f6e0e78 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 13:37:35 +0700
Subject: http://www.bouncycastle.org/jira/browse/BMA-113
- Convert DateTime to string using InvariantCulture
---
crypto/src/asn1/DerUTCTime.cs | 4 ++--
crypto/src/asn1/cms/Time.cs | 17 ++++++-----------
crypto/src/asn1/x509/Time.cs | 18 +++++++-----------
crypto/src/crypto/parameters/SkeinParameters.cs | 3 ++-
4 files changed, 17 insertions(+), 25 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/asn1/DerUTCTime.cs b/crypto/src/asn1/DerUTCTime.cs
index 56fabeb47..ab8ca792d 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") + "Z";
+ this.time = time.ToString("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
}
- internal DerUtcTime(
+ internal DerUtcTime(
byte[] bytes)
{
//
diff --git a/crypto/src/asn1/cms/Time.cs b/crypto/src/asn1/cms/Time.cs
index d113bfa2e..e5730245e 100644
--- a/crypto/src/asn1/cms/Time.cs
+++ b/crypto/src/asn1/cms/Time.cs
@@ -1,8 +1,6 @@
using System;
using System.Globalization;
-using Org.BouncyCastle.Asn1;
-
namespace Org.BouncyCastle.Asn1.Cms
{
public class Time
@@ -20,13 +18,12 @@ namespace Org.BouncyCastle.Asn1.Cms
public Time(
Asn1Object time)
{
- if (!(time is DerUtcTime)
- && !(time is DerGeneralizedTime))
- {
+ if (time == null)
+ throw new ArgumentNullException("time");
+ if (!(time is DerUtcTime) && !(time is DerGeneralizedTime))
throw new ArgumentException("unknown object passed to Time");
- }
- this.time = time;
+ this.time = time;
}
/**
@@ -37,7 +34,7 @@ namespace Org.BouncyCastle.Asn1.Cms
public Time(
DateTime date)
{
- string d = date.ToString("yyyyMMddHHmmss") + "Z";
+ string d = date.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
int year = int.Parse(d.Substring(0, 4));
@@ -56,14 +53,12 @@ namespace Org.BouncyCastle.Asn1.Cms
{
if (obj == null || obj is Time)
return (Time)obj;
-
if (obj is DerUtcTime)
return new Time((DerUtcTime)obj);
-
if (obj is DerGeneralizedTime)
return new Time((DerGeneralizedTime)obj);
- throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
+ throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
}
public string TimeString
diff --git a/crypto/src/asn1/x509/Time.cs b/crypto/src/asn1/x509/Time.cs
index 0f2511e6d..8350339bb 100644
--- a/crypto/src/asn1/x509/Time.cs
+++ b/crypto/src/asn1/x509/Time.cs
@@ -1,11 +1,12 @@
using System;
+using System.Globalization;
namespace Org.BouncyCastle.Asn1.X509
{
public class Time
: Asn1Encodable, IAsn1Choice
{
- internal Asn1Object time;
+ private readonly Asn1Object time;
public static Time GetInstance(
Asn1TaggedObject obj,
@@ -19,11 +20,8 @@ namespace Org.BouncyCastle.Asn1.X509
{
if (time == null)
throw new ArgumentNullException("time");
-
if (!(time is DerUtcTime) && !(time is DerGeneralizedTime))
- {
throw new ArgumentException("unknown object passed to Time");
- }
this.time = time;
}
@@ -36,9 +34,9 @@ namespace Org.BouncyCastle.Asn1.X509
public Time(
DateTime date)
{
- string d = date.ToString("yyyyMMddHHmmss") + "Z";
+ string d = date.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
- int year = Int32.Parse(d.Substring(0, 4));
+ int year = int.Parse(d.Substring(0, 4));
if (year < 1950 || year > 2049)
{
@@ -54,13 +52,11 @@ namespace Org.BouncyCastle.Asn1.X509
object obj)
{
if (obj == null || obj is Time)
- return (Time) obj;
-
+ return (Time)obj;
if (obj is DerUtcTime)
- return new Time((DerUtcTime) obj);
-
+ return new Time((DerUtcTime)obj);
if (obj is DerGeneralizedTime)
- return new Time((DerGeneralizedTime) obj);
+ return new Time((DerGeneralizedTime)obj);
throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
}
diff --git a/crypto/src/crypto/parameters/SkeinParameters.cs b/crypto/src/crypto/parameters/SkeinParameters.cs
index a4e3e8e2a..9e621c09d 100644
--- a/crypto/src/crypto/parameters/SkeinParameters.cs
+++ b/crypto/src/crypto/parameters/SkeinParameters.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Globalization;
using System.IO;
using Org.BouncyCastle.Utilities;
@@ -234,7 +235,7 @@ namespace Org.BouncyCastle.Crypto.Parameters
{
MemoryStream bout = new MemoryStream();
StreamWriter outBytes = new StreamWriter(bout, System.Text.Encoding.UTF8);
- outBytes.Write(date.ToString("YYYYMMDD"));
+ outBytes.Write(date.ToString("YYYYMMDD", CultureInfo.InvariantCulture));
outBytes.Write(" ");
outBytes.Write(emailAddress);
outBytes.Write(" ");
--
cgit 1.5.1
From fded4c6c754034cc28b012bea9b3f06c7f074133 Mon Sep 17 00:00:00 2001
From: David Hook
Date: Sun, 18 Oct 2015 18:09:00 +1100
Subject: BMA-132 added support for ISignatureCalculator interface
---
crypto/src/ocsp/BasicOCSPRespGenerator.cs | 73 ++++++++++++++-----------------
1 file changed, 34 insertions(+), 39 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/ocsp/BasicOCSPRespGenerator.cs b/crypto/src/ocsp/BasicOCSPRespGenerator.cs
index 5ff4bd9cc..a7d5f3da5 100644
--- a/crypto/src/ocsp/BasicOCSPRespGenerator.cs
+++ b/crypto/src/ocsp/BasicOCSPRespGenerator.cs
@@ -6,11 +6,11 @@ using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Security.Certificates;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;
+using Org.BouncyCastle.Crypto.Operators;
namespace Org.BouncyCastle.Ocsp
{
@@ -185,21 +185,12 @@ namespace Org.BouncyCastle.Ocsp
}
private BasicOcspResp GenerateResponse(
- string signatureName,
- AsymmetricKeyParameter privateKey,
+ ISignatureCalculator signatureCalculator,
X509Certificate[] chain,
- DateTime producedAt,
- SecureRandom random)
+ DateTime producedAt)
{
- DerObjectIdentifier signingAlgorithm;
- try
- {
- signingAlgorithm = OcspUtilities.GetAlgorithmOid(signatureName);
- }
- catch (Exception e)
- {
- throw new ArgumentException("unknown signing algorithm specified", e);
- }
+ AlgorithmIdentifier signingAlgID = (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails;
+ DerObjectIdentifier signingAlgorithm = signingAlgID.Algorithm;
Asn1EncodableVector responses = new Asn1EncodableVector();
@@ -216,35 +207,19 @@ namespace Org.BouncyCastle.Ocsp
}
ResponseData tbsResp = new ResponseData(responderID.ToAsn1Object(), new DerGeneralizedTime(producedAt), new DerSequence(responses), responseExtensions);
-
- ISigner sig = null;
+ DerBitString bitSig = null;
try
{
- sig = SignerUtilities.GetSigner(signatureName);
+ IStreamCalculator streamCalculator = signatureCalculator.CreateCalculator();
- if (random != null)
- {
- sig.Init(true, new ParametersWithRandom(privateKey, random));
- }
- else
- {
- sig.Init(true, privateKey);
- }
- }
- catch (Exception e)
- {
- throw new OcspException("exception creating signature: " + e, e);
- }
+ byte[] encoded = tbsResp.GetDerEncoded();
- DerBitString bitSig = null;
+ streamCalculator.Stream.Write(encoded, 0, encoded.Length);
- try
- {
- byte[] encoded = tbsResp.GetDerEncoded();
- sig.BlockUpdate(encoded, 0, encoded.Length);
+ streamCalculator.Stream.Close();
- bitSig = new DerBitString(sig.GenerateSignature());
+ bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).DoFinal());
}
catch (Exception e)
{
@@ -302,15 +277,35 @@ namespace Org.BouncyCastle.Ocsp
throw new ArgumentException("no signing algorithm specified");
}
- return GenerateResponse(signingAlgorithm, privateKey, chain, producedAt, random);
+ return GenerateResponse(new Asn1SignatureCalculator(signingAlgorithm, privateKey, random), chain, producedAt);
}
- /**
+ ///
+ /// Generate the signed response using the passed in signature calculator.
+ ///
+ /// Implementation of signing calculator.
+ /// The certificate chain associated with the response signer.
+ /// "produced at" date.
+ ///
+ public BasicOcspResp Generate(
+ ISignatureCalculator signatureCalculator,
+ X509Certificate[] chain,
+ DateTime producedAt)
+ {
+ if (signatureCalculator == null)
+ {
+ throw new ArgumentException("no signature calculator specified");
+ }
+
+ return GenerateResponse(signatureCalculator, chain, producedAt);
+ }
+
+ /**
* Return an IEnumerable of the signature names supported by the generator.
*
* @return an IEnumerable containing recognised names.
*/
- public IEnumerable SignatureAlgNames
+ public IEnumerable SignatureAlgNames
{
get { return OcspUtilities.AlgNames; }
}
--
cgit 1.5.1
From 088e423b20074f3483b8c255ffcb724e3fdf4d6a Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 14:22:53 +0700
Subject: http://www.bouncycastle.org/jira/browse/BMA-82
- use SecureRandom to generate "arbitrary" values
---
crypto/src/math/BigInteger.cs | 8 +++++++-
crypto/src/math/ec/ECCurve.cs | 3 +--
crypto/src/math/ec/ECFieldElement.cs | 3 +--
crypto/src/math/raw/Mod.cs | 6 ++++--
4 files changed, 13 insertions(+), 7 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs
index f302f077e..f31e2d5f2 100644
--- a/crypto/src/math/BigInteger.cs
+++ b/crypto/src/math/BigInteger.cs
@@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Text;
+using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Math
@@ -179,7 +180,7 @@ namespace Org.BouncyCastle.Math
private const int chunk2 = 1, chunk8 = 1, chunk10 = 19, chunk16 = 16;
private static readonly BigInteger radix2, radix2E, radix8, radix8E, radix10, radix10E, radix16, radix16E;
- private static readonly Random RandomSource = new Random();
+ private static readonly SecureRandom RandomSource = new SecureRandom();
/*
* These are the threshold bit-lengths (of an exponent) where we increase the window size.
@@ -246,6 +247,11 @@ namespace Org.BouncyCastle.Math
return (nBits + BitsPerByte - 1) / BitsPerByte;
}
+ internal static BigInteger Arbitrary(int sizeInBits)
+ {
+ return new BigInteger(sizeInBits, RandomSource);
+ }
+
private BigInteger(
int signum,
int[] mag,
diff --git a/crypto/src/math/ec/ECCurve.cs b/crypto/src/math/ec/ECCurve.cs
index 40b46ce72..fa2c72570 100644
--- a/crypto/src/math/ec/ECCurve.cs
+++ b/crypto/src/math/ec/ECCurve.cs
@@ -760,10 +760,9 @@ namespace Org.BouncyCastle.Math.EC
ECFieldElement gamma, z, zeroElement = FromBigInteger(BigInteger.Zero);
int m = FieldSize;
- Random rand = new Random();
do
{
- ECFieldElement t = FromBigInteger(new BigInteger(m, rand));
+ ECFieldElement t = FromBigInteger(BigInteger.Arbitrary(m));
z = zeroElement;
ECFieldElement w = beta;
for (int i = 1; i < m; i++)
diff --git a/crypto/src/math/ec/ECFieldElement.cs b/crypto/src/math/ec/ECFieldElement.cs
index 4d4fb3e4d..d0e008aab 100644
--- a/crypto/src/math/ec/ECFieldElement.cs
+++ b/crypto/src/math/ec/ECFieldElement.cs
@@ -306,13 +306,12 @@ namespace Org.BouncyCastle.Math.EC
BigInteger k = legendreExponent.Add(BigInteger.One), qMinusOne = q.Subtract(BigInteger.One);
BigInteger U, V;
- Random rand = new Random();
do
{
BigInteger P;
do
{
- P = new BigInteger(q.BitLength, rand);
+ P = BigInteger.Arbitrary(q.BitLength);
}
while (P.CompareTo(q) >= 0
|| !ModReduce(P.Multiply(P).Subtract(fourX)).ModPow(legendreExponent, q).Equals(qMinusOne));
diff --git a/crypto/src/math/raw/Mod.cs b/crypto/src/math/raw/Mod.cs
index 63467e668..8d9e8fd21 100644
--- a/crypto/src/math/raw/Mod.cs
+++ b/crypto/src/math/raw/Mod.cs
@@ -2,12 +2,15 @@
using System.Diagnostics;
using Org.BouncyCastle.Crypto.Utilities;
+using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Math.Raw
{
internal abstract class Mod
{
+ private static readonly SecureRandom RandomSource = new SecureRandom();
+
public static void Invert(uint[] p, uint[] x, uint[] z)
{
int len = p.Length;
@@ -77,7 +80,6 @@ namespace Org.BouncyCastle.Math.Raw
public static uint[] Random(uint[] p)
{
int len = p.Length;
- Random rand = new Random();
uint[] s = Nat.Create(len);
uint m = p[len - 1];
@@ -90,7 +92,7 @@ namespace Org.BouncyCastle.Math.Raw
do
{
byte[] bytes = new byte[len << 2];
- rand.NextBytes(bytes);
+ RandomSource.NextBytes(bytes);
Pack.BE_To_UInt32(bytes, 0, s);
s[len - 1] &= m;
}
--
cgit 1.5.1
From 9ae0b1807893ff07a7a0bb42c8e4957d7c9fedb5 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 14:23:56 +0700
Subject: More SIC changes for consistency with Java API
---
crypto/src/crypto/modes/SicBlockCipher.cs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/crypto/modes/SicBlockCipher.cs b/crypto/src/crypto/modes/SicBlockCipher.cs
index 17f86ee10..239f99478 100644
--- a/crypto/src/crypto/modes/SicBlockCipher.cs
+++ b/crypto/src/crypto/modes/SicBlockCipher.cs
@@ -50,12 +50,14 @@ namespace Org.BouncyCastle.Crypto.Modes
{
ParametersWithIV ivParam = parameters as ParametersWithIV;
if (ivParam == null)
- throw new ArgumentException("CTR mode requires ParametersWithIV", "parameters");
+ throw new ArgumentException("CTR/SIC mode requires ParametersWithIV", "parameters");
this.IV = Arrays.Clone(ivParam.GetIV());
+ if (blockSize < IV.Length)
+ throw new ArgumentException("CTR/SIC mode requires IV no greater than: " + blockSize + " bytes.");
if (blockSize - IV.Length > 8)
- throw new ArgumentException("CTR mode requires IV of at least: " + (blockSize - 8) + " bytes.");
+ throw new ArgumentException("CTR/SIC mode requires IV of at least: " + (blockSize - 8) + " bytes.");
Reset();
@@ -68,7 +70,7 @@ namespace Org.BouncyCastle.Crypto.Modes
public virtual string AlgorithmName
{
- get { return cipher.AlgorithmName + "/CTR"; }
+ get { return cipher.AlgorithmName + "/SIC"; }
}
public virtual bool IsPartialBlockOkay
@@ -109,7 +111,7 @@ namespace Org.BouncyCastle.Crypto.Modes
public virtual void Reset()
{
Arrays.Fill(counter, (byte)0);
- Array.Copy(IV, 0, counter, 0, System.Math.Min(IV.Length, counter.Length));
+ Array.Copy(IV, 0, counter, 0, IV.Length);
cipher.Reset();
}
}
--
cgit 1.5.1
From 4ce46775ce424f01f0fc65f2af382908ce409544 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 14:44:08 +0700
Subject: No SerializableAttribute in PCL
---
crypto/src/asn1/Asn1Exception.cs | 2 +-
crypto/src/asn1/Asn1ParsingException.cs | 2 +-
crypto/src/cms/CMSAttributeTableGenerationException.cs | 2 +-
crypto/src/cms/CMSException.cs | 2 +-
crypto/src/cms/CMSStreamException.cs | 2 +-
crypto/src/crypto/CryptoException.cs | 2 +-
crypto/src/crypto/DataLengthException.cs | 2 +-
crypto/src/crypto/InvalidCipherTextException.cs | 2 +-
crypto/src/crypto/MaxBytesExceededException.cs | 2 +-
crypto/src/crypto/OutputLengthException.cs | 2 +-
crypto/src/math/BigInteger.cs | 2 +-
crypto/src/ocsp/OCSPException.cs | 2 +-
crypto/src/openpgp/PgpDataValidationException.cs | 2 +-
crypto/src/openpgp/PgpException.cs | 2 +-
crypto/src/openpgp/PgpKeyValidationException.cs | 2 +-
crypto/src/openssl/EncryptionException.cs | 2 +-
crypto/src/openssl/PEMException.cs | 2 +-
crypto/src/openssl/PasswordException.cs | 2 +-
crypto/src/pkix/PkixCertPathBuilderException.cs | 2 +-
crypto/src/pkix/PkixCertPathValidatorException.cs | 2 +-
crypto/src/pkix/PkixNameConstraintValidatorException.cs | 2 +-
crypto/src/security/GeneralSecurityException.cs | 2 +-
crypto/src/security/InvalidKeyException.cs | 2 +-
crypto/src/security/InvalidParameterException.cs | 2 +-
crypto/src/security/KeyException.cs | 2 +-
crypto/src/security/NoSuchAlgorithmException.cs | 2 +-
crypto/src/security/SecurityUtilityException.cs | 2 +-
crypto/src/security/SignatureException.cs | 2 +-
crypto/src/security/cert/CertificateEncodingException.cs | 2 +-
crypto/src/security/cert/CertificateException.cs | 2 +-
crypto/src/security/cert/CertificateExpiredException.cs | 2 +-
crypto/src/security/cert/CertificateNotYetValidException.cs | 2 +-
crypto/src/security/cert/CertificateParsingException.cs | 2 +-
crypto/src/security/cert/CrlException.cs | 2 +-
crypto/src/tsp/TSPException.cs | 2 +-
crypto/src/tsp/TSPValidationException.cs | 2 +-
crypto/src/util/io/StreamOverflowException.cs | 2 +-
crypto/src/util/io/pem/PemGenerationException.cs | 2 +-
crypto/src/x509/store/NoSuchStoreException.cs | 2 +-
crypto/src/x509/store/X509StoreException.cs | 2 +-
crypto/test/src/util/test/TestFailedException.cs | 2 +-
41 files changed, 41 insertions(+), 41 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/asn1/Asn1Exception.cs b/crypto/src/asn1/Asn1Exception.cs
index 806cc95d5..1dfe1732c 100644
--- a/crypto/src/asn1/Asn1Exception.cs
+++ b/crypto/src/asn1/Asn1Exception.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.Asn1
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class Asn1Exception
diff --git a/crypto/src/asn1/Asn1ParsingException.cs b/crypto/src/asn1/Asn1ParsingException.cs
index 40e5da480..84cdb780d 100644
--- a/crypto/src/asn1/Asn1ParsingException.cs
+++ b/crypto/src/asn1/Asn1ParsingException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Asn1
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class Asn1ParsingException
diff --git a/crypto/src/cms/CMSAttributeTableGenerationException.cs b/crypto/src/cms/CMSAttributeTableGenerationException.cs
index 31b06d6dd..87dad9929 100644
--- a/crypto/src/cms/CMSAttributeTableGenerationException.cs
+++ b/crypto/src/cms/CMSAttributeTableGenerationException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Cms
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CmsAttributeTableGenerationException
diff --git a/crypto/src/cms/CMSException.cs b/crypto/src/cms/CMSException.cs
index 5a6e33502..29fe0a6c0 100644
--- a/crypto/src/cms/CMSException.cs
+++ b/crypto/src/cms/CMSException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Cms
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CmsException
diff --git a/crypto/src/cms/CMSStreamException.cs b/crypto/src/cms/CMSStreamException.cs
index bf0a6adf4..68a8be017 100644
--- a/crypto/src/cms/CMSStreamException.cs
+++ b/crypto/src/cms/CMSStreamException.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.Cms
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CmsStreamException
diff --git a/crypto/src/crypto/CryptoException.cs b/crypto/src/crypto/CryptoException.cs
index 67f0d86f2..73d450be1 100644
--- a/crypto/src/crypto/CryptoException.cs
+++ b/crypto/src/crypto/CryptoException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Crypto
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CryptoException
diff --git a/crypto/src/crypto/DataLengthException.cs b/crypto/src/crypto/DataLengthException.cs
index e9efc0bd3..447ff2a17 100644
--- a/crypto/src/crypto/DataLengthException.cs
+++ b/crypto/src/crypto/DataLengthException.cs
@@ -8,7 +8,7 @@ namespace Org.BouncyCastle.Crypto
* insufficient input. In general this exception will Get thrown rather
* than an ArrayOutOfBounds exception.
*/
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class DataLengthException
diff --git a/crypto/src/crypto/InvalidCipherTextException.cs b/crypto/src/crypto/InvalidCipherTextException.cs
index 4d2252654..0fe540d96 100644
--- a/crypto/src/crypto/InvalidCipherTextException.cs
+++ b/crypto/src/crypto/InvalidCipherTextException.cs
@@ -6,7 +6,7 @@ namespace Org.BouncyCastle.Crypto
* this exception is thrown whenever we find something we don't expect in a
* message.
*/
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class InvalidCipherTextException
diff --git a/crypto/src/crypto/MaxBytesExceededException.cs b/crypto/src/crypto/MaxBytesExceededException.cs
index be078cb13..8992c45da 100644
--- a/crypto/src/crypto/MaxBytesExceededException.cs
+++ b/crypto/src/crypto/MaxBytesExceededException.cs
@@ -6,7 +6,7 @@ namespace Org.BouncyCastle.Crypto
/// This exception is thrown whenever a cipher requires a change of key, iv
/// or similar after x amount of bytes enciphered
///
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class MaxBytesExceededException
diff --git a/crypto/src/crypto/OutputLengthException.cs b/crypto/src/crypto/OutputLengthException.cs
index e1cf44925..437589f47 100644
--- a/crypto/src/crypto/OutputLengthException.cs
+++ b/crypto/src/crypto/OutputLengthException.cs
@@ -2,7 +2,7 @@
namespace Org.BouncyCastle.Crypto
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class OutputLengthException
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs
index f31e2d5f2..ebeb78788 100644
--- a/crypto/src/math/BigInteger.cs
+++ b/crypto/src/math/BigInteger.cs
@@ -9,7 +9,7 @@ using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Math
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class BigInteger
diff --git a/crypto/src/ocsp/OCSPException.cs b/crypto/src/ocsp/OCSPException.cs
index db53e559a..d7b14ddc7 100644
--- a/crypto/src/ocsp/OCSPException.cs
+++ b/crypto/src/ocsp/OCSPException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Ocsp
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class OcspException
diff --git a/crypto/src/openpgp/PgpDataValidationException.cs b/crypto/src/openpgp/PgpDataValidationException.cs
index aab5165b2..d06833c16 100644
--- a/crypto/src/openpgp/PgpDataValidationException.cs
+++ b/crypto/src/openpgp/PgpDataValidationException.cs
@@ -5,7 +5,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
///
/// Thrown if the IV at the start of a data stream indicates the wrong key is being used.
///
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PgpDataValidationException
diff --git a/crypto/src/openpgp/PgpException.cs b/crypto/src/openpgp/PgpException.cs
index 378b16a56..230dab86e 100644
--- a/crypto/src/openpgp/PgpException.cs
+++ b/crypto/src/openpgp/PgpException.cs
@@ -3,7 +3,7 @@ using System;
namespace Org.BouncyCastle.Bcpg.OpenPgp
{
/// Generic exception class for PGP encoding/decoding problems.
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PgpException
diff --git a/crypto/src/openpgp/PgpKeyValidationException.cs b/crypto/src/openpgp/PgpKeyValidationException.cs
index d6419b27b..383ae57a2 100644
--- a/crypto/src/openpgp/PgpKeyValidationException.cs
+++ b/crypto/src/openpgp/PgpKeyValidationException.cs
@@ -5,7 +5,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
///
/// Thrown if the key checksum is invalid.
///
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PgpKeyValidationException
diff --git a/crypto/src/openssl/EncryptionException.cs b/crypto/src/openssl/EncryptionException.cs
index c4a6ec02f..043e90234 100644
--- a/crypto/src/openssl/EncryptionException.cs
+++ b/crypto/src/openssl/EncryptionException.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class EncryptionException
diff --git a/crypto/src/openssl/PEMException.cs b/crypto/src/openssl/PEMException.cs
index 4d33a2a1f..6b3e51065 100644
--- a/crypto/src/openssl/PEMException.cs
+++ b/crypto/src/openssl/PEMException.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.OpenSsl
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PemException
diff --git a/crypto/src/openssl/PasswordException.cs b/crypto/src/openssl/PasswordException.cs
index fba958aa0..38e679bb1 100644
--- a/crypto/src/openssl/PasswordException.cs
+++ b/crypto/src/openssl/PasswordException.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PasswordException
diff --git a/crypto/src/pkix/PkixCertPathBuilderException.cs b/crypto/src/pkix/PkixCertPathBuilderException.cs
index 5a4944dd8..0f10179dd 100644
--- a/crypto/src/pkix/PkixCertPathBuilderException.cs
+++ b/crypto/src/pkix/PkixCertPathBuilderException.cs
@@ -7,7 +7,7 @@ namespace Org.BouncyCastle.Pkix
///
/// Summary description for PkixCertPathBuilderException.
///
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PkixCertPathBuilderException : GeneralSecurityException
diff --git a/crypto/src/pkix/PkixCertPathValidatorException.cs b/crypto/src/pkix/PkixCertPathValidatorException.cs
index 35522c6f8..a477f7dc4 100644
--- a/crypto/src/pkix/PkixCertPathValidatorException.cs
+++ b/crypto/src/pkix/PkixCertPathValidatorException.cs
@@ -27,7 +27,7 @@ namespace Org.BouncyCastle.Pkix
*
* @see CertPathValidator
**/
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PkixCertPathValidatorException
diff --git a/crypto/src/pkix/PkixNameConstraintValidatorException.cs b/crypto/src/pkix/PkixNameConstraintValidatorException.cs
index 432d7bd6b..b187525e0 100644
--- a/crypto/src/pkix/PkixNameConstraintValidatorException.cs
+++ b/crypto/src/pkix/PkixNameConstraintValidatorException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Pkix
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PkixNameConstraintValidatorException
diff --git a/crypto/src/security/GeneralSecurityException.cs b/crypto/src/security/GeneralSecurityException.cs
index 2c3f2a555..d4ab38cae 100644
--- a/crypto/src/security/GeneralSecurityException.cs
+++ b/crypto/src/security/GeneralSecurityException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class GeneralSecurityException
diff --git a/crypto/src/security/InvalidKeyException.cs b/crypto/src/security/InvalidKeyException.cs
index 4d4488ef2..ebad9e32f 100644
--- a/crypto/src/security/InvalidKeyException.cs
+++ b/crypto/src/security/InvalidKeyException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class InvalidKeyException : KeyException
diff --git a/crypto/src/security/InvalidParameterException.cs b/crypto/src/security/InvalidParameterException.cs
index 57a912d03..48172f470 100644
--- a/crypto/src/security/InvalidParameterException.cs
+++ b/crypto/src/security/InvalidParameterException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class InvalidParameterException : KeyException
diff --git a/crypto/src/security/KeyException.cs b/crypto/src/security/KeyException.cs
index 9304c1c4d..e19fa8961 100644
--- a/crypto/src/security/KeyException.cs
+++ b/crypto/src/security/KeyException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class KeyException : GeneralSecurityException
diff --git a/crypto/src/security/NoSuchAlgorithmException.cs b/crypto/src/security/NoSuchAlgorithmException.cs
index d120c5f77..c56ec651e 100644
--- a/crypto/src/security/NoSuchAlgorithmException.cs
+++ b/crypto/src/security/NoSuchAlgorithmException.cs
@@ -3,7 +3,7 @@ using System;
namespace Org.BouncyCastle.Security
{
[Obsolete("Never thrown")]
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class NoSuchAlgorithmException : GeneralSecurityException
diff --git a/crypto/src/security/SecurityUtilityException.cs b/crypto/src/security/SecurityUtilityException.cs
index 02a3e806e..8a1953008 100644
--- a/crypto/src/security/SecurityUtilityException.cs
+++ b/crypto/src/security/SecurityUtilityException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class SecurityUtilityException
diff --git a/crypto/src/security/SignatureException.cs b/crypto/src/security/SignatureException.cs
index cea3c59cd..3ad617dfd 100644
--- a/crypto/src/security/SignatureException.cs
+++ b/crypto/src/security/SignatureException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class SignatureException : GeneralSecurityException
diff --git a/crypto/src/security/cert/CertificateEncodingException.cs b/crypto/src/security/cert/CertificateEncodingException.cs
index a2909b0d5..ab9024fc7 100644
--- a/crypto/src/security/cert/CertificateEncodingException.cs
+++ b/crypto/src/security/cert/CertificateEncodingException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security.Certificates
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CertificateEncodingException : CertificateException
diff --git a/crypto/src/security/cert/CertificateException.cs b/crypto/src/security/cert/CertificateException.cs
index 441c598e4..4bbaccfc1 100644
--- a/crypto/src/security/cert/CertificateException.cs
+++ b/crypto/src/security/cert/CertificateException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security.Certificates
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CertificateException : GeneralSecurityException
diff --git a/crypto/src/security/cert/CertificateExpiredException.cs b/crypto/src/security/cert/CertificateExpiredException.cs
index c893c07ee..864fb85c1 100644
--- a/crypto/src/security/cert/CertificateExpiredException.cs
+++ b/crypto/src/security/cert/CertificateExpiredException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security.Certificates
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CertificateExpiredException : CertificateException
diff --git a/crypto/src/security/cert/CertificateNotYetValidException.cs b/crypto/src/security/cert/CertificateNotYetValidException.cs
index a0081ce23..02112be98 100644
--- a/crypto/src/security/cert/CertificateNotYetValidException.cs
+++ b/crypto/src/security/cert/CertificateNotYetValidException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security.Certificates
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CertificateNotYetValidException : CertificateException
diff --git a/crypto/src/security/cert/CertificateParsingException.cs b/crypto/src/security/cert/CertificateParsingException.cs
index 8d8ed1e92..ae909ca40 100644
--- a/crypto/src/security/cert/CertificateParsingException.cs
+++ b/crypto/src/security/cert/CertificateParsingException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security.Certificates
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CertificateParsingException : CertificateException
diff --git a/crypto/src/security/cert/CrlException.cs b/crypto/src/security/cert/CrlException.cs
index 0df007b1e..fe9807e79 100644
--- a/crypto/src/security/cert/CrlException.cs
+++ b/crypto/src/security/cert/CrlException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Security.Certificates
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class CrlException : GeneralSecurityException
diff --git a/crypto/src/tsp/TSPException.cs b/crypto/src/tsp/TSPException.cs
index 3917e96a7..0f29b1299 100644
--- a/crypto/src/tsp/TSPException.cs
+++ b/crypto/src/tsp/TSPException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Tsp
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class TspException
diff --git a/crypto/src/tsp/TSPValidationException.cs b/crypto/src/tsp/TSPValidationException.cs
index 8ef2ec6cf..80f64203b 100644
--- a/crypto/src/tsp/TSPValidationException.cs
+++ b/crypto/src/tsp/TSPValidationException.cs
@@ -8,7 +8,7 @@ namespace Org.BouncyCastle.Tsp
* If a failure code is associated with the exception it can be retrieved using
* the getFailureCode() method.
*/
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class TspValidationException
diff --git a/crypto/src/util/io/StreamOverflowException.cs b/crypto/src/util/io/StreamOverflowException.cs
index d8fcb558c..36d21e23e 100644
--- a/crypto/src/util/io/StreamOverflowException.cs
+++ b/crypto/src/util/io/StreamOverflowException.cs
@@ -3,7 +3,7 @@ using System.IO;
namespace Org.BouncyCastle.Utilities.IO
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class StreamOverflowException
diff --git a/crypto/src/util/io/pem/PemGenerationException.cs b/crypto/src/util/io/pem/PemGenerationException.cs
index b8edc622b..6b3958577 100644
--- a/crypto/src/util/io/pem/PemGenerationException.cs
+++ b/crypto/src/util/io/pem/PemGenerationException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Utilities.IO.Pem
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class PemGenerationException
diff --git a/crypto/src/x509/store/NoSuchStoreException.cs b/crypto/src/x509/store/NoSuchStoreException.cs
index 02c593245..28b18892a 100644
--- a/crypto/src/x509/store/NoSuchStoreException.cs
+++ b/crypto/src/x509/store/NoSuchStoreException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.X509.Store
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class NoSuchStoreException
diff --git a/crypto/src/x509/store/X509StoreException.cs b/crypto/src/x509/store/X509StoreException.cs
index f781291e2..ea7e51e79 100644
--- a/crypto/src/x509/store/X509StoreException.cs
+++ b/crypto/src/x509/store/X509StoreException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.X509.Store
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class X509StoreException
diff --git a/crypto/test/src/util/test/TestFailedException.cs b/crypto/test/src/util/test/TestFailedException.cs
index ecd7e7d7a..54dc840bc 100644
--- a/crypto/test/src/util/test/TestFailedException.cs
+++ b/crypto/test/src/util/test/TestFailedException.cs
@@ -2,7 +2,7 @@ using System;
namespace Org.BouncyCastle.Utilities.Test
{
-#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT)
+#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || PORTABLE)
[Serializable]
#endif
public class TestFailedException
--
cgit 1.5.1
From f0c658a6d112912f819dced69348573f2a529c05 Mon Sep 17 00:00:00 2001
From: Peter Dettman
Date: Sun, 18 Oct 2015 16:13:07 +0700
Subject: PCL: Various non-IO changes
---
crypto/src/AssemblyInfo.cs | 2 ++
crypto/src/asn1/DerGeneralizedTime.cs | 2 +-
crypto/src/asn1/cms/AttributeTable.cs | 4 ++--
crypto/src/asn1/smime/SMIMECapabilities.cs | 2 +-
crypto/src/asn1/util/Dump.cs | 4 ++--
crypto/src/asn1/x509/AttributeTable.cs | 4 ++--
crypto/src/asn1/x509/ExtendedKeyUsage.cs | 4 ++--
crypto/src/asn1/x509/NameConstraints.cs | 2 +-
crypto/src/asn1/x509/PolicyMappings.cs | 2 +-
crypto/src/asn1/x509/SubjectDirectoryAttributes.cs | 2 +-
crypto/src/asn1/x509/X509Extensions.cs | 2 +-
crypto/src/asn1/x509/X509Name.cs | 6 +++---
crypto/src/bcpg/ArmoredOutputStream.cs | 12 ++++++++++++
crypto/src/cms/CMSSignedDataGenerator.cs | 2 +-
crypto/src/cms/CMSTypedStream.cs | 2 +-
.../src/cms/DefaultSignedAttributeTableGenerator.cs | 2 +-
crypto/src/crypto/modes/CcmBlockCipher.cs | 20 ++++++++++++++++++--
.../parameters/NaccacheSternPrivateKeyParameters.cs | 4 ++--
crypto/src/crypto/prng/CryptoApiRandomGenerator.cs | 2 +-
crypto/src/crypto/prng/ThreadedSeedGenerator.cs | 8 ++++++--
crypto/src/pkcs/AsymmetricKeyEntry.cs | 2 +-
crypto/src/pkcs/X509CertificateEntry.cs | 2 +-
crypto/src/pkix/PkixCertPath.cs | 4 ++--
crypto/src/pkix/PkixNameConstraintValidator.cs | 7 ++++---
crypto/src/security/DotNetUtilities.cs | 2 +-
crypto/src/security/SecureRandom.cs | 2 +-
crypto/src/util/Enums.cs | 4 ++--
crypto/src/util/Platform.cs | 16 +++++++++++++---
crypto/src/util/Strings.cs | 6 +++---
crypto/src/x509/store/IX509Selector.cs | 4 ++--
30 files changed, 91 insertions(+), 46 deletions(-)
(limited to 'crypto/src')
diff --git a/crypto/src/AssemblyInfo.cs b/crypto/src/AssemblyInfo.cs
index 4a813bc5a..36beb99c4 100644
--- a/crypto/src/AssemblyInfo.cs
+++ b/crypto/src/AssemblyInfo.cs
@@ -65,7 +65,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyKeyName("")]
[assembly: CLSCompliant(true)]
+#if !PORTABLE
[assembly: ComVisible(false)]
+#endif
// Start with no permissions
//[assembly: PermissionSet(SecurityAction.RequestOptional, Unrestricted=false)]
diff --git a/crypto/src/asn1/DerGeneralizedTime.cs b/crypto/src/asn1/DerGeneralizedTime.cs
index 548a268e1..6700b9016 100644
--- a/crypto/src/asn1/DerGeneralizedTime.cs
+++ b/crypto/src/asn1/DerGeneralizedTime.cs
@@ -159,7 +159,7 @@ namespace Org.BouncyCastle.Asn1
char sign = '+';
DateTime time = ToDateTime();
-#if SILVERLIGHT
+#if SILVERLIGHT || PORTABLE
long offset = time.Ticks - time.ToUniversalTime().Ticks;
if (offset < 0)
{
diff --git a/crypto/src/asn1/cms/AttributeTable.cs b/crypto/src/asn1/cms/AttributeTable.cs
index 8a3ee5d0e..8d357f1a6 100644
--- a/crypto/src/asn1/cms/AttributeTable.cs
+++ b/crypto/src/asn1/cms/AttributeTable.cs
@@ -10,7 +10,7 @@ namespace Org.BouncyCastle.Asn1.Cms
{
private readonly IDictionary attributes;
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete]
public AttributeTable(
Hashtable attrs)
@@ -168,7 +168,7 @@ namespace Org.BouncyCastle.Asn1.Cms
return Platform.CreateHashtable(attributes);
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete("Use 'ToDictionary' instead")]
public Hashtable ToHashtable()
{
diff --git a/crypto/src/asn1/smime/SMIMECapabilities.cs b/crypto/src/asn1/smime/SMIMECapabilities.cs
index 5fb67dde1..6435caf68 100644
--- a/crypto/src/asn1/smime/SMIMECapabilities.cs
+++ b/crypto/src/asn1/smime/SMIMECapabilities.cs
@@ -71,7 +71,7 @@ namespace Org.BouncyCastle.Asn1.Smime
capabilities = seq;
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete("Use 'GetCapabilitiesForOid' instead")]
public ArrayList GetCapabilities(
DerObjectIdentifier capability)
diff --git a/crypto/src/asn1/util/Dump.cs b/crypto/src/asn1/util/Dump.cs
index 27c87f127..99ced5836 100644
--- a/crypto/src/asn1/util/Dump.cs
+++ b/crypto/src/asn1/util/Dump.cs
@@ -1,5 +1,4 @@
-using Org.BouncyCastle.Asn1;
-
+#if !PORTABLE
using System;
using System.IO;
@@ -26,3 +25,4 @@ namespace Org.BouncyCastle.Asn1.Utilities
}
}
}
+#endif
diff --git a/crypto/src/asn1/x509/AttributeTable.cs b/crypto/src/asn1/x509/AttributeTable.cs
index ffe0ea935..33faad64a 100644
--- a/crypto/src/asn1/x509/AttributeTable.cs
+++ b/crypto/src/asn1/x509/AttributeTable.cs
@@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Asn1.X509
this.attributes = Platform.CreateHashtable(attrs);
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete]
public AttributeTable(
Hashtable attrs)
@@ -57,7 +57,7 @@ namespace Org.BouncyCastle.Asn1.X509
return (AttributeX509) attributes[oid];
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete("Use 'ToDictionary' instead")]
public Hashtable ToHashtable()
{
diff --git a/crypto/src/asn1/x509/ExtendedKeyUsage.cs b/crypto/src/asn1/x509/ExtendedKeyUsage.cs
index a5b11f210..9b1400db9 100644
--- a/crypto/src/asn1/x509/ExtendedKeyUsage.cs
+++ b/crypto/src/asn1/x509/ExtendedKeyUsage.cs
@@ -70,7 +70,7 @@ namespace Org.BouncyCastle.Asn1.X509
}
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete]
public ExtendedKeyUsage(
ArrayList usages)
@@ -101,7 +101,7 @@ namespace Org.BouncyCastle.Asn1.X509
return usageTable.Contains(keyPurposeId);
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete("Use 'GetAllUsages'")]
public ArrayList GetUsages()
{
diff --git a/crypto/src/asn1/x509/NameConstraints.cs b/crypto/src/asn1/x509/NameConstraints.cs
index 8374ff60a..c178f5b45 100644
--- a/crypto/src/asn1/x509/NameConstraints.cs
+++ b/crypto/src/asn1/x509/NameConstraints.cs
@@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Asn1.X509
}
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
public NameConstraints(
ArrayList permitted,
ArrayList excluded)
diff --git a/crypto/src/asn1/x509/PolicyMappings.cs b/crypto/src/asn1/x509/PolicyMappings.cs
index 3ad351107..928ad134d 100644
--- a/crypto/src/asn1/x509/PolicyMappings.cs
+++ b/crypto/src/asn1/x509/PolicyMappings.cs
@@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Asn1.X509
this.seq = seq;
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
public PolicyMappings(
Hashtable mappings)
: this((IDictionary)mappings)
diff --git a/crypto/src/asn1/x509/SubjectDirectoryAttributes.cs b/crypto/src/asn1/x509/SubjectDirectoryAttributes.cs
index fcb30290d..c76d94d78 100644
--- a/crypto/src/asn1/x509/SubjectDirectoryAttributes.cs
+++ b/crypto/src/asn1/x509/SubjectDirectoryAttributes.cs
@@ -78,7 +78,7 @@ namespace Org.BouncyCastle.Asn1.X509
}
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
[Obsolete]
public SubjectDirectoryAttributes(
ArrayList attributes)
diff --git a/crypto/src/asn1/x509/X509Extensions.cs b/crypto/src/asn1/x509/X509Extensions.cs
index 5dce5622d..1896450f5 100644
--- a/crypto/src/asn1/x509/X509Extensions.cs
+++ b/crypto/src/asn1/x509/X509Extensions.cs
@@ -278,7 +278,7 @@ namespace Org.BouncyCastle.Asn1.X509
}
}
-#if !SILVERLIGHT
+#if !(SILVERLIGHT || PORTABLE)
/**
* constructor from a table of extensions.
*
diff --git a/crypto/src/asn1/x509/X509Name.cs b/crypto/src/asn1/x509/X509Name.cs
index c183e5798..fb404a3ec 100644
--- a/crypto/src/asn1/x509/X509Name.cs
+++ b/crypto/src/asn1/x509/X509Name.cs
@@ -3,7 +3,7 @@ using System.Collections;
using System.IO;
using System.Text;
-#if SILVERLIGHT
+#if SILVERLIGHT || PORTABLE
using System.Collections.Generic;
#endif
@@ -203,7 +203,7 @@ namespace Org.BouncyCastle.Asn1.X509
private static readonly bool[] defaultReverse = { false };
-#if SILVERLIGHT
+#if SILVERLIGHT || PORTABLE
/**
* default look up table translating OID values into their common symbols following
* the convention in RFC 2253 with a few extras
@@ -1027,7 +1027,7 @@ namespace Org.BouncyCastle.Asn1.X509
bool reverse,
IDictionary oidSymbols)
{
-#if SILVERLIGHT
+#if SILVERLIGHT || PORTABLE
List