summary refs log tree commit diff
path: root/crypto/src/math/BigInteger.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/math/BigInteger.cs')
-rw-r--r--crypto/src/math/BigInteger.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs
index 98d1fcb1d..50229e2db 100644
--- a/crypto/src/math/BigInteger.cs
+++ b/crypto/src/math/BigInteger.cs
@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
+using System.Runtime.Serialization;
 using System.Text;
 
 using Org.BouncyCastle.Security;
@@ -9,9 +10,7 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Math
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class BigInteger
     {
         // The first few odd primes
@@ -239,10 +238,22 @@ namespace Org.BouncyCastle.Math
 
         private int[] magnitude; // array of ints with [0] being the most significant
         private int sign; // -1 means -ve; +1 means +ve; 0 means 0;
+
+        [NonSerialized]
         private int nBits = -1; // cache BitCount() value
+        [NonSerialized]
         private int nBitLength = -1; // cache BitLength() value
+        [NonSerialized]
         private int mQuote = 0; // -m^(-1) mod b, b = 2^32 (see Montgomery mult.), 0 when uninitialised
 
+        [OnDeserialized]
+        private void OnDeserialized(StreamingContext context)
+        {
+            this.nBits = -1;
+            this.nBitLength = -1;
+            this.mQuote = 0;
+        }
+
         private static int GetByteLength(
             int nBits)
         {