diff options
-rw-r--r-- | crypto/src/crypto/modes/gcm/GcmUtilities.cs | 24 | ||||
-rw-r--r-- | crypto/src/math/ec/rfc8032/Ed25519.cs | 10 | ||||
-rw-r--r-- | crypto/src/math/ec/rfc8032/Ed448.cs | 2 | ||||
-rw-r--r-- | crypto/src/util/Integers.cs | 22 | ||||
-rw-r--r-- | crypto/src/util/Longs.cs | 10 | ||||
-rw-r--r-- | crypto/src/x509/X509Certificate.cs | 8 | ||||
-rw-r--r-- | crypto/src/x509/X509Crl.cs | 15 |
7 files changed, 55 insertions, 36 deletions
diff --git a/crypto/src/crypto/modes/gcm/GcmUtilities.cs b/crypto/src/crypto/modes/gcm/GcmUtilities.cs index 8cc3fd887..1dd4cd612 100644 --- a/crypto/src/crypto/modes/gcm/GcmUtilities.cs +++ b/crypto/src/crypto/modes/gcm/GcmUtilities.cs @@ -123,10 +123,10 @@ namespace Org.BouncyCastle.Crypto.Modes.Gcm internal static void Multiply(byte[] x, byte[] y) { - ulong[] t1 = GcmUtilities.AsUlongs(x); - ulong[] t2 = GcmUtilities.AsUlongs(y); - GcmUtilities.Multiply(t1, t2); - GcmUtilities.AsBytes(t1, x); + ulong[] t1 = AsUlongs(x); + ulong[] t2 = AsUlongs(y); + Multiply(t1, t2); + AsBytes(t1, x); } internal static void Multiply(uint[] x, uint[] y) @@ -140,10 +140,10 @@ namespace Org.BouncyCastle.Crypto.Modes.Gcm for (int j = 0; j < 32; ++j) { uint m1 = (uint)(bits >> 31); bits <<= 1; - z0 ^= (y0 & m1); - z1 ^= (y1 & m1); - z2 ^= (y2 & m1); - z3 ^= (y3 & m1); + z0 ^= y0 & m1; + z1 ^= y1 & m1; + z2 ^= y2 & m1; + z3 ^= y3 & m1; uint m2 = (uint)((int)(y3 << 31) >> 8); y3 = (y3 >> 1) | (y2 << 31); @@ -168,12 +168,12 @@ namespace Org.BouncyCastle.Crypto.Modes.Gcm //for (int j = 0; j < 64; ++j) //{ // ulong m0 = (ulong)((long)x0 >> 63); x0 <<= 1; - // z0 ^= (y0 & m0); - // z1 ^= (y1 & m0); + // z0 ^= y0 & m0; + // z1 ^= y1 & m0; // ulong m1 = (ulong)((long)x1 >> 63); x1 <<= 1; - // z1 ^= (y0 & m1); - // z2 ^= (y1 & m1); + // z1 ^= y0 & m1; + // z2 ^= y1 & m1; // ulong c = (ulong)((long)(y1 << 63) >> 8); // y1 = (y1 >> 1) | (y0 << 63); diff --git a/crypto/src/math/ec/rfc8032/Ed25519.cs b/crypto/src/math/ec/rfc8032/Ed25519.cs index b50df8525..8f87e3a5a 100644 --- a/crypto/src/math/ec/rfc8032/Ed25519.cs +++ b/crypto/src/math/ec/rfc8032/Ed25519.cs @@ -803,16 +803,16 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 PointExt d = PointCopy(q); PointAdd(q, d); - int[] table = X25519Field.CreateTable(count * 4); + int[] table = F.CreateTable(count * 4); int off = 0; int i = 0; for (;;) { - X25519Field.Copy(q.x, 0, table, off); off += X25519Field.Size; - X25519Field.Copy(q.y, 0, table, off); off += X25519Field.Size; - X25519Field.Copy(q.z, 0, table, off); off += X25519Field.Size; - X25519Field.Copy(q.t, 0, table, off); off += X25519Field.Size; + F.Copy(q.x, 0, table, off); off += F.Size; + F.Copy(q.y, 0, table, off); off += F.Size; + F.Copy(q.z, 0, table, off); off += F.Size; + F.Copy(q.t, 0, table, off); off += F.Size; if (++i == count) break; diff --git a/crypto/src/math/ec/rfc8032/Ed448.cs b/crypto/src/math/ec/rfc8032/Ed448.cs index 710fb545e..e0478af9f 100644 --- a/crypto/src/math/ec/rfc8032/Ed448.cs +++ b/crypto/src/math/ec/rfc8032/Ed448.cs @@ -713,7 +713,7 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 PointExt d = PointCopy(q); PointDouble(d); - uint[] table = X448Field.CreateTable(count * 3); + uint[] table = F.CreateTable(count * 3); int off = 0; int i = 0; diff --git a/crypto/src/util/Integers.cs b/crypto/src/util/Integers.cs index cc46862bd..efa437e17 100644 --- a/crypto/src/util/Integers.cs +++ b/crypto/src/util/Integers.cs @@ -37,16 +37,28 @@ namespace Org.BouncyCastle.Utilities public static int Reverse(int i) { - i = (int)Bits.BitPermuteStepSimple((uint)i, 0x55555555U, 1); - i = (int)Bits.BitPermuteStepSimple((uint)i, 0x33333333U, 2); - i = (int)Bits.BitPermuteStepSimple((uint)i, 0x0F0F0F0FU, 4); + return (int)Reverse((uint)i); + } + + [CLSCompliantAttribute(false)] + public static uint Reverse(uint i) + { + i = Bits.BitPermuteStepSimple(i, 0x55555555U, 1); + i = Bits.BitPermuteStepSimple(i, 0x33333333U, 2); + i = Bits.BitPermuteStepSimple(i, 0x0F0F0F0FU, 4); return ReverseBytes(i); } public static int ReverseBytes(int i) { - return RotateLeft((int)((uint)i & 0xFF00FF00U), 8) | - RotateLeft((int)((uint)i & 0x00FF00FFU), 24); + return (int)ReverseBytes((uint)i); + } + + [CLSCompliantAttribute(false)] + public static uint ReverseBytes(uint i) + { + return RotateLeft(i & 0xFF00FF00U, 8) | + RotateLeft(i & 0x00FF00FFU, 24); } public static int RotateLeft(int i, int distance) diff --git a/crypto/src/util/Longs.cs b/crypto/src/util/Longs.cs index 66b14b95c..4d675bdba 100644 --- a/crypto/src/util/Longs.cs +++ b/crypto/src/util/Longs.cs @@ -35,10 +35,7 @@ namespace Org.BouncyCastle.Utilities public static long Reverse(long i) { - i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x5555555555555555UL, 1); - i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x3333333333333333UL, 2); - i = (long)Bits.BitPermuteStepSimple((ulong)i, 0x0F0F0F0F0F0F0F0FUL, 4); - return ReverseBytes(i); + return (long)Reverse((ulong)i); } [CLSCompliantAttribute(false)] @@ -52,10 +49,7 @@ namespace Org.BouncyCastle.Utilities public static long ReverseBytes(long i) { - return RotateLeft((long)((ulong)i & 0xFF000000FF000000UL), 8) | - RotateLeft((long)((ulong)i & 0x00FF000000FF0000UL), 24) | - RotateLeft((long)((ulong)i & 0x0000FF000000FF00UL), 40) | - RotateLeft((long)((ulong)i & 0x000000FF000000FFUL), 56); + return (long)ReverseBytes((ulong)i); } [CLSCompliantAttribute(false)] diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs index 4f4f1e991..985ec0aeb 100644 --- a/crypto/src/x509/X509Certificate.cs +++ b/crypto/src/x509/X509Certificate.cs @@ -73,8 +73,12 @@ namespace Org.BouncyCastle.X509 { } - public X509Certificate( - X509CertificateStructure c) + public X509Certificate(byte[] certData) + : this(X509CertificateStructure.GetInstance(certData)) + { + } + + public X509Certificate(X509CertificateStructure c) { this.c = c; diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs index a5aabf974..9acebf2dd 100644 --- a/crypto/src/x509/X509Crl.cs +++ b/crypto/src/x509/X509Crl.cs @@ -71,8 +71,12 @@ namespace Org.BouncyCastle.X509 private volatile bool hashValueSet; private volatile int hashValue; - public X509Crl( - CertificateList c) + public X509Crl(byte[] encoding) + : this(CertificateList.GetInstance(encoding)) + { + } + + public X509Crl(CertificateList c) { this.c = c; @@ -91,7 +95,12 @@ namespace Org.BouncyCastle.X509 } } - protected override X509Extensions GetX509Extensions() + public virtual CertificateList CertificateList + { + get { return c; } + } + + protected override X509Extensions GetX509Extensions() { return c.Version >= 2 ? c.TbsCertList.Extensions |