summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/crypto/engines/SerpentEngine.cs10
-rw-r--r--crypto/src/crypto/engines/SerpentEngineBase.cs12
-rw-r--r--crypto/src/crypto/engines/SkipjackEngine.cs40
-rw-r--r--crypto/src/crypto/engines/TnepresEngine.cs10
-rw-r--r--crypto/src/crypto/modes/CfbBlockCipher.cs8
5 files changed, 39 insertions, 41 deletions
diff --git a/crypto/src/crypto/engines/SerpentEngine.cs b/crypto/src/crypto/engines/SerpentEngine.cs
index bec459215..47f714a64 100644
--- a/crypto/src/crypto/engines/SerpentEngine.cs
+++ b/crypto/src/crypto/engines/SerpentEngine.cs
@@ -26,7 +26,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         * @param key  The user-key bytes (multiples of 4) to use.
         * @exception ArgumentException
         */
-        protected override int[] MakeWorkingKey(byte[] key)
+        internal override int[] MakeWorkingKey(byte[] key)
         {
             //
             // pad key to 256 bits
@@ -151,7 +151,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         }
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-        protected override void EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        internal override void EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             X0 = (int)Pack.LE_To_UInt32(input);
             X1 = (int)Pack.LE_To_UInt32(input[4..]);
@@ -197,7 +197,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             Pack.UInt32_To_LE((uint)(wKey[131] ^ X3), output[12..]);
         }
 
-        protected override void DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        internal override void DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             X0 = wKey[128] ^ (int)Pack.LE_To_UInt32(input);
             X1 = wKey[129] ^ (int)Pack.LE_To_UInt32(input[4..]);
@@ -274,7 +274,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             Pack.UInt32_To_LE((uint)(X3 ^ wKey[3]), output[12..]);
         }
 #else
-        protected override void EncryptBlock(byte[] input, int inOff, byte[] output, int outOff)
+        internal override void EncryptBlock(byte[] input, int inOff, byte[] output, int outOff)
         {
             X0 = (int)Pack.LE_To_UInt32(input, inOff);
             X1 = (int)Pack.LE_To_UInt32(input, inOff + 4);
@@ -320,7 +320,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             Pack.UInt32_To_LE((uint)(wKey[131] ^ X3), output, outOff + 12);
         }
 
-        protected override void DecryptBlock(byte[] input, int inOff, byte[] output, int outOff)
+        internal override void DecryptBlock(byte[] input, int inOff, byte[] output, int outOff)
         {
             X0 = wKey[128] ^ (int)Pack.LE_To_UInt32(input, inOff);
             X1 = wKey[129] ^ (int)Pack.LE_To_UInt32(input, inOff + 4);
diff --git a/crypto/src/crypto/engines/SerpentEngineBase.cs b/crypto/src/crypto/engines/SerpentEngineBase.cs
index 0ce3a0e4f..44020f06f 100644
--- a/crypto/src/crypto/engines/SerpentEngineBase.cs
+++ b/crypto/src/crypto/engines/SerpentEngineBase.cs
@@ -18,7 +18,7 @@ namespace Org.BouncyCastle.Crypto.Engines
 
         protected int X0, X1, X2, X3;    // registers
 
-        protected SerpentEngineBase()
+        internal SerpentEngineBase()
         {
         }
 
@@ -474,14 +474,14 @@ namespace Org.BouncyCastle.Crypto.Engines
             X0 = Integers.RotateRight(x0, 13);
         }
 
-        protected abstract int[] MakeWorkingKey(byte[] key);
+        internal abstract int[] MakeWorkingKey(byte[] key);
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-        protected abstract void EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output);
-        protected abstract void DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output);
+        internal abstract void EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output);
+        internal abstract void DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output);
 #else
-        protected abstract void EncryptBlock(byte[] input, int inOff, byte[] output, int outOff);
-        protected abstract void DecryptBlock(byte[] input, int inOff, byte[] output, int outOff);
+        internal abstract void EncryptBlock(byte[] input, int inOff, byte[] output, int outOff);
+        internal abstract void DecryptBlock(byte[] input, int inOff, byte[] output, int outOff);
 #endif
     }
 }
diff --git a/crypto/src/crypto/engines/SkipjackEngine.cs b/crypto/src/crypto/engines/SkipjackEngine.cs
index 4a5355963..c6a3e458e 100644
--- a/crypto/src/crypto/engines/SkipjackEngine.cs
+++ b/crypto/src/crypto/engines/SkipjackEngine.cs
@@ -8,12 +8,12 @@ namespace Org.BouncyCastle.Crypto.Engines
     /**
     * a class that provides a basic SKIPJACK engine.
     */
-    public class SkipjackEngine
+    public sealed class SkipjackEngine
 		: IBlockCipher
     {
-        const int BLOCK_SIZE = 8;
+        private const int BLOCK_SIZE = 8;
 
-        static readonly short [] ftable =
+        private static readonly short[] ftable =
         {
             0xa3, 0xd7, 0x09, 0x83, 0xf8, 0x48, 0xf6, 0xf4, 0xb3, 0x21, 0x15, 0x78, 0x99, 0xb1, 0xaf, 0xf9,
             0xe7, 0x2d, 0x4d, 0x8a, 0xce, 0x4c, 0xca, 0x2e, 0x52, 0x95, 0xd9, 0x1e, 0x4e, 0x38, 0x44, 0x28,
@@ -44,14 +44,12 @@ namespace Org.BouncyCastle.Crypto.Engines
         * @exception ArgumentException if the parameters argument is
         * inappropriate.
         */
-        public virtual void Init(
-            bool				forEncryption,
-            ICipherParameters	parameters)
+        public void Init(bool forEncryption, ICipherParameters parameters)
         {
-            if (!(parameters is KeyParameter))
+            if (!(parameters is KeyParameter keyParameter))
 	            throw new ArgumentException("invalid parameter passed to SKIPJACK init - " + Platform.GetTypeName(parameters));
 
-			byte[] keyBytes = ((KeyParameter)parameters).GetKey();
+			byte[] keyBytes = keyParameter.GetKey();
 
             this.encrypting = forEncryption;
             this.key0 = new int[32];
@@ -63,26 +61,26 @@ namespace Org.BouncyCastle.Crypto.Engines
             // expand the key to 128 bytes in 4 parts (saving us a modulo, multiply
             // and an addition).
             //
-            for (int i = 0; i < 32; i ++)
+            for (int i = 0; i < 32; i++)
             {
-                key0[i] = keyBytes[(i * 4) % 10] & 0xff;
-                key1[i] = keyBytes[(i * 4 + 1) % 10] & 0xff;
-                key2[i] = keyBytes[(i * 4 + 2) % 10] & 0xff;
-                key3[i] = keyBytes[(i * 4 + 3) % 10] & 0xff;
+                key0[i] = keyBytes[(i * 4 + 0) % 10];
+                key1[i] = keyBytes[(i * 4 + 1) % 10];
+                key2[i] = keyBytes[(i * 4 + 2) % 10];
+                key3[i] = keyBytes[(i * 4 + 3) % 10];
             }
         }
 
-        public virtual string AlgorithmName
+        public string AlgorithmName
         {
             get { return "SKIPJACK"; }
         }
 
-        public virtual int GetBlockSize()
+        public int GetBlockSize()
         {
             return BLOCK_SIZE;
         }
 
-        public virtual int ProcessBlock(byte[] input, int inOff, byte[]	output, int outOff)
+        public int ProcessBlock(byte[] input, int inOff, byte[]	output, int outOff)
         {
             if (key1 == null)
                 throw new InvalidOperationException("SKIPJACK engine not initialised");
@@ -114,7 +112,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         }
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-        public virtual int ProcessBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        public int ProcessBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             if (key1 == null)
                 throw new InvalidOperationException("SKIPJACK engine not initialised");
@@ -156,7 +154,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         }
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-        public virtual int EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        private int EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             int w1 = (input[0] << 8) + (input[1] & 0xff);
             int w2 = (input[2] << 8) + (input[3] & 0xff);
@@ -200,7 +198,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             return BLOCK_SIZE;
         }
 
-        public virtual int DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        private int DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             int w2 = (input[0] << 8) + (input[1] & 0xff);
             int w1 = (input[2] << 8) + (input[3] & 0xff);
@@ -245,7 +243,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         }
 
 #else
-        public virtual int EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
+        private int EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
         {
             int w1 = (input[inOff + 0] << 8) + (input[inOff + 1] & 0xff);
             int w2 = (input[inOff + 2] << 8) + (input[inOff + 3] & 0xff);
@@ -289,7 +287,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             return BLOCK_SIZE;
         }
 
-        public virtual int DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
+        private int DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
         {
             int w2 = (input[inOff + 0] << 8) + (input[inOff + 1] & 0xff);
             int w1 = (input[inOff + 2] << 8) + (input[inOff + 3] & 0xff);
diff --git a/crypto/src/crypto/engines/TnepresEngine.cs b/crypto/src/crypto/engines/TnepresEngine.cs
index 50f5a58c4..7751e20bc 100644
--- a/crypto/src/crypto/engines/TnepresEngine.cs
+++ b/crypto/src/crypto/engines/TnepresEngine.cs
@@ -33,7 +33,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         * @param key  The user-key bytes (multiples of 4) to use.
         * @exception ArgumentException
         */
-        protected override int[] MakeWorkingKey(byte[] key)
+        internal override int[] MakeWorkingKey(byte[] key)
         {
             //
             // pad key to 256 bits
@@ -158,7 +158,7 @@ namespace Org.BouncyCastle.Crypto.Engines
         }
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-        protected override void EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        internal override void EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             X3 = (int)Pack.BE_To_UInt32(input);
             X2 = (int)Pack.BE_To_UInt32(input[4..]);
@@ -204,7 +204,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             Pack.UInt32_To_BE((uint)(wKey[128] ^ X0), output[12..]);
         }
 
-        protected override void DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        internal override void DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             X3 = wKey[131] ^ (int)Pack.BE_To_UInt32(input);
             X2 = wKey[130] ^ (int)Pack.BE_To_UInt32(input[4..]);
@@ -281,7 +281,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             Pack.UInt32_To_BE((uint)(X0 ^ wKey[0]), output[12..]);
         }
 #else
-        protected override void EncryptBlock(byte[] input, int inOff, byte[] output, int outOff)
+        internal override void EncryptBlock(byte[] input, int inOff, byte[] output, int outOff)
         {
             X3 = (int)Pack.BE_To_UInt32(input, inOff);
             X2 = (int)Pack.BE_To_UInt32(input, inOff + 4);
@@ -327,7 +327,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             Pack.UInt32_To_BE((uint)(wKey[128] ^ X0), output, outOff + 12);
         }
 
-        protected override void DecryptBlock(byte[] input, int inOff, byte[] output, int outOff)
+        internal override void DecryptBlock(byte[] input, int inOff, byte[] output, int outOff)
         {
             X3 = wKey[131] ^ (int)Pack.BE_To_UInt32(input, inOff);
             X2 = wKey[130] ^ (int)Pack.BE_To_UInt32(input, inOff + 4);
diff --git a/crypto/src/crypto/modes/CfbBlockCipher.cs b/crypto/src/crypto/modes/CfbBlockCipher.cs
index abcdca959..7bce9843f 100644
--- a/crypto/src/crypto/modes/CfbBlockCipher.cs
+++ b/crypto/src/crypto/modes/CfbBlockCipher.cs
@@ -129,7 +129,7 @@ namespace Org.BouncyCastle.Crypto.Modes
 #endif
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-        public int EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        private int EncryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             Check.DataLength(input, blockSize, "input buffer too short");
             Check.OutputLength(output, blockSize, "output buffer too short");
@@ -150,7 +150,7 @@ namespace Org.BouncyCastle.Crypto.Modes
             return blockSize;
         }
 
-        public int DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
+        private int DecryptBlock(ReadOnlySpan<byte> input, Span<byte> output)
         {
             Check.DataLength(input, blockSize, "input buffer too short");
             Check.OutputLength(output, blockSize, "output buffer too short");
@@ -171,7 +171,7 @@ namespace Org.BouncyCastle.Crypto.Modes
             return blockSize;
         }
 #else
-        public int EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
+        private int EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
         {
             Check.DataLength(input, inOff, blockSize, "input buffer too short");
             Check.OutputLength(outBytes, outOff, blockSize, "output buffer too short");
@@ -192,7 +192,7 @@ namespace Org.BouncyCastle.Crypto.Modes
             return blockSize;
         }
 
-        public int DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
+        private int DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
         {
             Check.DataLength(input, inOff, blockSize, "input buffer too short");
             Check.OutputLength(outBytes, outOff, blockSize, "output buffer too short");