summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-13 01:01:06 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-13 01:01:06 +0700
commit1f978a59ada56703a6dfcb81a5cbdcae226d0ac8 (patch)
treeb52a45226ffb2aebc0c86f1c598446c2e39b301d
parentRefactoring in Pqc.Crypto.Cmce (diff)
downloadBouncyCastle.NET-ed25519-1f978a59ada56703a6dfcb81a5cbdcae226d0ac8.tar.xz
Refactoring in Pqc.Crypto
-rw-r--r--crypto/src/pqc/crypto/bike/BikeKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/bike/BikeParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/bike/BikePrivateKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/bike/BikePublicKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/crystals/dilithium/DilithiumKeyParameters.cs13
-rw-r--r--crypto/src/pqc/crypto/crystals/dilithium/DilithiumParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/crystals/dilithium/DilithiumPrivateKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/crystals/dilithium/DilithiumPublicKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/crystals/kyber/KyberKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/crystals/kyber/KyberParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/crystals/kyber/KyberPrivateKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/falcon/FalconKeyParameters.cs12
-rw-r--r--crypto/src/pqc/crypto/falcon/FalconParameters.cs3
-rw-r--r--crypto/src/pqc/crypto/frodo/FrodoKeyParameters.cs16
-rw-r--r--crypto/src/pqc/crypto/frodo/FrodoParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/frodo/FrodoPrivateKeyParameters.cs14
-rw-r--r--crypto/src/pqc/crypto/frodo/FrodoPublicKeyParameters.cs17
-rw-r--r--crypto/src/pqc/crypto/hqc/HqcKeyParameters.cs15
-rw-r--r--crypto/src/pqc/crypto/hqc/HqcParameters.cs4
-rw-r--r--crypto/src/pqc/crypto/hqc/HqcPrivateKeyParameters.cs3
-rw-r--r--crypto/src/pqc/crypto/hqc/HqcPublicKeyParameters.cs3
-rw-r--r--crypto/src/pqc/crypto/ntru/NtruKemGenerator.cs8
-rw-r--r--crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs19
-rw-r--r--crypto/src/pqc/crypto/ntru/NtruParameters.cs3
-rw-r--r--crypto/src/pqc/crypto/ntru/NtruPrivateKeyParamaters.cs4
-rw-r--r--crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs3
-rw-r--r--crypto/src/pqc/crypto/ntruprime/NtruLPRimeKeyParameters.cs15
-rw-r--r--crypto/src/pqc/crypto/ntruprime/NtruLPRimePrivateKeyParameters.cs13
-rw-r--r--crypto/src/pqc/crypto/ntruprime/NtruLPRimePublicKeyParameters.cs14
-rw-r--r--crypto/src/pqc/crypto/ntruprime/SNtruPrimeKeyParameters.cs15
-rw-r--r--crypto/src/pqc/crypto/ntruprime/SNtruPrimeParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/ntruprime/SNtruPrimePrivateKeyParameters.cs13
-rw-r--r--crypto/src/pqc/crypto/ntruprime/SNtruPrimePublicKeyParameters.cs13
-rw-r--r--crypto/src/pqc/crypto/picnic/PicnicKeyParameters.cs2
-rw-r--r--crypto/src/pqc/crypto/saber/SABERKeyParameters.cs8
-rw-r--r--crypto/src/pqc/crypto/sike/SIKEKeyParameters.cs4
-rw-r--r--crypto/src/pqc/crypto/sike/SIKEParameters.cs1
-rw-r--r--crypto/src/pqc/crypto/sphincsplus/SPHINCSPlusKeyParameters.cs4
38 files changed, 128 insertions, 135 deletions
diff --git a/crypto/src/pqc/crypto/bike/BikeKeyParameters.cs b/crypto/src/pqc/crypto/bike/BikeKeyParameters.cs
index fd15138e4..17913ad99 100644
--- a/crypto/src/pqc/crypto/bike/BikeKeyParameters.cs
+++ b/crypto/src/pqc/crypto/bike/BikeKeyParameters.cs
@@ -7,7 +7,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
     {
         private readonly BikeParameters m_parameters;
 
-        public BikeKeyParameters(bool isPrivate, BikeParameters parameters)
+        internal BikeKeyParameters(bool isPrivate, BikeParameters parameters)
             : base(isPrivate)
         {
             this.m_parameters = parameters;
diff --git a/crypto/src/pqc/crypto/bike/BikeParameters.cs b/crypto/src/pqc/crypto/bike/BikeParameters.cs
index 9fd658e0c..6d0daca14 100644
--- a/crypto/src/pqc/crypto/bike/BikeParameters.cs
+++ b/crypto/src/pqc/crypto/bike/BikeParameters.cs
@@ -24,7 +24,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Bike
         private readonly int defaultKeySize;
         private readonly BikeEngine bikeEngine;
 
-        internal BikeParameters(string name, int r, int w, int t, int l, int nbIter, int tau, int defaultKeySize)
+        private BikeParameters(string name, int r, int w, int t, int l, int nbIter, int tau, int defaultKeySize)
         {
             this.name = name;
             this.r = r;
diff --git a/crypto/src/pqc/crypto/bike/BikePrivateKeyParameters.cs b/crypto/src/pqc/crypto/bike/BikePrivateKeyParameters.cs
index dce003a7b..b44d33ce1 100644
--- a/crypto/src/pqc/crypto/bike/BikePrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/bike/BikePrivateKeyParameters.cs
@@ -2,7 +2,7 @@
 
 namespace Org.BouncyCastle.Pqc.Crypto.Bike
 {
-    public class BikePrivateKeyParameters
+    public sealed class BikePrivateKeyParameters
         : BikeKeyParameters
     {
         // h0
diff --git a/crypto/src/pqc/crypto/bike/BikePublicKeyParameters.cs b/crypto/src/pqc/crypto/bike/BikePublicKeyParameters.cs
index dbbe2480c..fe79fed26 100644
--- a/crypto/src/pqc/crypto/bike/BikePublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/bike/BikePublicKeyParameters.cs
@@ -2,7 +2,7 @@
 
 namespace Org.BouncyCastle.Pqc.Crypto.Bike
 {
-    public class BikePublicKeyParameters
+    public sealed class BikePublicKeyParameters
         : BikeKeyParameters
     {
         private readonly byte[] publicKey;
diff --git a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumKeyParameters.cs b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumKeyParameters.cs
index 789f3f5ef..664cd0c97 100644
--- a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumKeyParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumKeyParameters.cs
@@ -2,16 +2,17 @@ using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium
 {
-    public class DilithiumKeyParameters
+    public abstract class DilithiumKeyParameters
         : AsymmetricKeyParameter
     {
-        DilithiumParameters parameters;
+        private readonly DilithiumParameters m_parameters;
 
-        public DilithiumKeyParameters(bool isPrivate, DilithiumParameters parameters) : base(isPrivate)
+        internal DilithiumKeyParameters(bool isPrivate, DilithiumParameters parameters)
+            : base(isPrivate)
         {
-            this.parameters = parameters;
+            m_parameters = parameters;
         }
 
-        public DilithiumParameters Parameters => parameters;
+        public DilithiumParameters Parameters => m_parameters;
     }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumParameters.cs b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumParameters.cs
index fb726473a..e6aa6ab21 100644
--- a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumParameters.cs
@@ -3,7 +3,7 @@ using Org.BouncyCastle.Security;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium
 {
-    public class DilithiumParameters
+    public sealed class DilithiumParameters
         : ICipherParameters
     {
         public static DilithiumParameters Dilithium2 = new DilithiumParameters(2, false);
diff --git a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPrivateKeyParameters.cs b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPrivateKeyParameters.cs
index bb1b95ff6..b5f3c2a32 100644
--- a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPrivateKeyParameters.cs
@@ -2,7 +2,7 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium
 {
-    public class DilithiumPrivateKeyParameters
+    public sealed class DilithiumPrivateKeyParameters
         : DilithiumKeyParameters
     {
         internal byte[] rho;
diff --git a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPublicKeyParameters.cs b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPublicKeyParameters.cs
index 04ac7e423..681435439 100644
--- a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumPublicKeyParameters.cs
@@ -2,7 +2,7 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium
 {
-    public class DilithiumPublicKeyParameters
+    public sealed class DilithiumPublicKeyParameters
         : DilithiumKeyParameters
     {
         internal byte[] rho;
diff --git a/crypto/src/pqc/crypto/crystals/kyber/KyberKeyParameters.cs b/crypto/src/pqc/crypto/crystals/kyber/KyberKeyParameters.cs
index 9fb26c2ad..597e6732a 100644
--- a/crypto/src/pqc/crypto/crystals/kyber/KyberKeyParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/kyber/KyberKeyParameters.cs
@@ -7,7 +7,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Kyber
     {
         private readonly KyberParameters m_parameters;
 
-        public KyberKeyParameters(bool isPrivate, KyberParameters parameters)
+        internal KyberKeyParameters(bool isPrivate, KyberParameters parameters)
             : base(isPrivate)
         {
             m_parameters = parameters;
diff --git a/crypto/src/pqc/crypto/crystals/kyber/KyberParameters.cs b/crypto/src/pqc/crypto/crystals/kyber/KyberParameters.cs
index 00bc3950b..5b3f71000 100644
--- a/crypto/src/pqc/crypto/crystals/kyber/KyberParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/kyber/KyberParameters.cs
@@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Kyber
         private int m_sessionKeySize;
         private KyberEngine m_engine;
 
-        public KyberParameters(string name, int k, int sessionKeySize, bool usingAes)
+        private KyberParameters(string name, int k, int sessionKeySize, bool usingAes)
         {
             m_name = name;
             this.m_sessionKeySize = sessionKeySize;
diff --git a/crypto/src/pqc/crypto/crystals/kyber/KyberPrivateKeyParameters.cs b/crypto/src/pqc/crypto/crystals/kyber/KyberPrivateKeyParameters.cs
index c9cf3a360..0fac30e47 100644
--- a/crypto/src/pqc/crypto/crystals/kyber/KyberPrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/crystals/kyber/KyberPrivateKeyParameters.cs
@@ -2,7 +2,7 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Kyber
 {
-    public class KyberPrivateKeyParameters
+    public sealed class KyberPrivateKeyParameters
         : KyberKeyParameters
     {
         private readonly byte[] m_s;
diff --git a/crypto/src/pqc/crypto/falcon/FalconKeyParameters.cs b/crypto/src/pqc/crypto/falcon/FalconKeyParameters.cs
index bb1252706..443c38116 100644
--- a/crypto/src/pqc/crypto/falcon/FalconKeyParameters.cs
+++ b/crypto/src/pqc/crypto/falcon/FalconKeyParameters.cs
@@ -1,22 +1,18 @@
 using Org.BouncyCastle.Crypto;
 
-
 namespace Org.BouncyCastle.Pqc.Crypto.Falcon
 {
     public abstract class FalconKeyParameters 
         : AsymmetricKeyParameter
     {
-        private FalconParameters parameters;
+        private readonly FalconParameters m_parameters;
 
-        public FalconKeyParameters(bool isprivate, FalconParameters parameters)
+        internal FalconKeyParameters(bool isprivate, FalconParameters parameters)
             : base(isprivate)
         {
-            this.parameters = parameters;
+            m_parameters = parameters;
         }
 
-        public FalconParameters Parameters
-        {
-            get { return parameters; }
-        }
+        public FalconParameters Parameters => m_parameters;
     }
 }
diff --git a/crypto/src/pqc/crypto/falcon/FalconParameters.cs b/crypto/src/pqc/crypto/falcon/FalconParameters.cs
index 10d22a241..2e17104b4 100644
--- a/crypto/src/pqc/crypto/falcon/FalconParameters.cs
+++ b/crypto/src/pqc/crypto/falcon/FalconParameters.cs
@@ -1,6 +1,7 @@
-using Org.BouncyCastle.Crypto;
 using System;
 
+using Org.BouncyCastle.Crypto;
+
 namespace Org.BouncyCastle.Pqc.Crypto.Falcon
 {
     public sealed class FalconParameters 
diff --git a/crypto/src/pqc/crypto/frodo/FrodoKeyParameters.cs b/crypto/src/pqc/crypto/frodo/FrodoKeyParameters.cs
index 9ac284c68..d195eba2b 100644
--- a/crypto/src/pqc/crypto/frodo/FrodoKeyParameters.cs
+++ b/crypto/src/pqc/crypto/frodo/FrodoKeyParameters.cs
@@ -1,22 +1,18 @@
-
 using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Frodo
 {
-    public class FrodoKeyParameters
+    public abstract class FrodoKeyParameters
         : AsymmetricKeyParameter
     {
-        private FrodoParameters parameters;
+        private readonly FrodoParameters m_parameters;
 
-        public FrodoKeyParameters(
-            bool isPrivate,
-            FrodoParameters parameters)
+        internal FrodoKeyParameters(bool isPrivate, FrodoParameters parameters)
             : base(isPrivate)
         {
-            this.parameters = parameters;
+            this.m_parameters = parameters;
         }
 
-        public FrodoParameters Parameters => parameters;
-
+        public FrodoParameters Parameters => m_parameters;
     }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/pqc/crypto/frodo/FrodoParameters.cs b/crypto/src/pqc/crypto/frodo/FrodoParameters.cs
index 69d3e5de6..3f8fe254d 100644
--- a/crypto/src/pqc/crypto/frodo/FrodoParameters.cs
+++ b/crypto/src/pqc/crypto/frodo/FrodoParameters.cs
@@ -29,7 +29,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Frodo
         private int defaultKeySize;
         private FrodoEngine engine;
 
-        public FrodoParameters(string name, int n, int d, int b, short[] cdf_table, IDigest digest,
+        private FrodoParameters(string name, int n, int d, int b, short[] cdf_table, IDigest digest,
             FrodoMatrixGenerator mGen)
         {
             this.name = name;
diff --git a/crypto/src/pqc/crypto/frodo/FrodoPrivateKeyParameters.cs b/crypto/src/pqc/crypto/frodo/FrodoPrivateKeyParameters.cs
index 7cf215504..cfbf1c3ea 100644
--- a/crypto/src/pqc/crypto/frodo/FrodoPrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/frodo/FrodoPrivateKeyParameters.cs
@@ -1,25 +1,23 @@
-
-
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Frodo
 {
-    public class FrodoPrivateKeyParameters
+    public sealed class FrodoPrivateKeyParameters
         : FrodoKeyParameters
     {
         internal byte[] privateKey;
 
-        public byte[] GetPrivateKey()
-        {
-            return Arrays.Clone(privateKey);
-        }
-
         public FrodoPrivateKeyParameters(FrodoParameters parameters, byte[] privateKey)
             : base(true, parameters)
         {
             this.privateKey = Arrays.Clone(privateKey);
         }
 
+        public byte[] GetPrivateKey()
+        {
+            return Arrays.Clone(privateKey);
+        }
+
         public byte[] GetEncoded()
         {
             return Arrays.Clone(privateKey);
diff --git a/crypto/src/pqc/crypto/frodo/FrodoPublicKeyParameters.cs b/crypto/src/pqc/crypto/frodo/FrodoPublicKeyParameters.cs
index 70fad4024..fe2fdb502 100644
--- a/crypto/src/pqc/crypto/frodo/FrodoPublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/frodo/FrodoPublicKeyParameters.cs
@@ -1,29 +1,26 @@
-using System;
-
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Frodo
 {
-    public class FrodoPublicKeyParameters
+    public sealed class FrodoPublicKeyParameters
         : FrodoKeyParameters
     {
         internal readonly byte[] m_publicKey;
 
+        public FrodoPublicKeyParameters(FrodoParameters parameters, byte[] publicKey)
+            : base(false, parameters)
+        {
+            m_publicKey = Arrays.Clone(publicKey);
+        }
+
         public byte[] GetPublicKey()
         {
             return Arrays.Clone(m_publicKey);
         }
 
-
         public byte[] GetEncoded()
         {
             return GetPublicKey();
         }
-
-        public FrodoPublicKeyParameters(FrodoParameters parameters, byte[] publicKey)
-            : base(false, parameters)
-        {
-            m_publicKey = Arrays.Clone(publicKey);
-        }
     }
 }
diff --git a/crypto/src/pqc/crypto/hqc/HqcKeyParameters.cs b/crypto/src/pqc/crypto/hqc/HqcKeyParameters.cs
index 8fc900a64..29cc99cc0 100644
--- a/crypto/src/pqc/crypto/hqc/HqcKeyParameters.cs
+++ b/crypto/src/pqc/crypto/hqc/HqcKeyParameters.cs
@@ -2,18 +2,17 @@
 
 namespace Org.BouncyCastle.Pqc.Crypto.Hqc
 {
-    public class HqcKeyParameters : AsymmetricKeyParameter
+    public abstract class HqcKeyParameters
+        : AsymmetricKeyParameter
     {
-        private HqcParameters param;
+        private readonly HqcParameters m_parameters;
 
-        public HqcKeyParameters(
-            bool isPrivate,
-            HqcParameters param) : base(isPrivate)
+        internal HqcKeyParameters(bool isPrivate, HqcParameters parameters)
+            : base(isPrivate)
         {
-            this.param = param;
+            m_parameters = parameters;
         }
 
-        public HqcParameters Parameters => param;
-       
+        public HqcParameters Parameters => m_parameters;
     }
 }
diff --git a/crypto/src/pqc/crypto/hqc/HqcParameters.cs b/crypto/src/pqc/crypto/hqc/HqcParameters.cs
index da5948296..c397f65b1 100644
--- a/crypto/src/pqc/crypto/hqc/HqcParameters.cs
+++ b/crypto/src/pqc/crypto/hqc/HqcParameters.cs
@@ -1,9 +1,9 @@
 using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Hqc
-
 {
-    public class HqcParameters : ICipherParameters
+    public sealed class HqcParameters
+        : ICipherParameters
     {
         // 128 bits security
         public static HqcParameters hqc128 = new HqcParameters("hqc128", 17669, 46, 384, 16, 31, 15, 66, 75, 75, 16767881, 4, new int[] { 89, 69, 153, 116, 176, 117, 111, 75, 73, 233, 242, 233, 65, 210, 21, 139, 103, 173, 67, 118, 105, 210, 174, 110, 74, 69, 228, 82, 255, 181, 1 }, 128);
diff --git a/crypto/src/pqc/crypto/hqc/HqcPrivateKeyParameters.cs b/crypto/src/pqc/crypto/hqc/HqcPrivateKeyParameters.cs
index 96963e53c..34107ca55 100644
--- a/crypto/src/pqc/crypto/hqc/HqcPrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/hqc/HqcPrivateKeyParameters.cs
@@ -2,7 +2,8 @@
 
 namespace Org.BouncyCastle.Pqc.Crypto.Hqc
 {
-    public class HqcPrivateKeyParameters : HqcKeyParameters
+    public sealed class HqcPrivateKeyParameters
+        : HqcKeyParameters
     {
         private byte[] sk;
 
diff --git a/crypto/src/pqc/crypto/hqc/HqcPublicKeyParameters.cs b/crypto/src/pqc/crypto/hqc/HqcPublicKeyParameters.cs
index a87d24704..5f5649851 100644
--- a/crypto/src/pqc/crypto/hqc/HqcPublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/hqc/HqcPublicKeyParameters.cs
@@ -2,7 +2,8 @@
 
 namespace Org.BouncyCastle.Pqc.Crypto.Hqc
 {
-    public class HqcPublicKeyParameters : HqcKeyParameters
+    public sealed class HqcPublicKeyParameters
+        : HqcKeyParameters
     {
         private byte[] pk;
 
diff --git a/crypto/src/pqc/crypto/ntru/NtruKemGenerator.cs b/crypto/src/pqc/crypto/ntru/NtruKemGenerator.cs
index 283bddbda..184bb515a 100644
--- a/crypto/src/pqc/crypto/ntru/NtruKemGenerator.cs
+++ b/crypto/src/pqc/crypto/ntru/NtruKemGenerator.cs
@@ -25,19 +25,17 @@ namespace Org.BouncyCastle.Pqc.Crypto.Ntru
 
         public ISecretWithEncapsulation GenerateEncapsulated(AsymmetricKeyParameter recipientKey)
         {
-            var parameterSet = ((NtruPublicKeyParameters)recipientKey).GetParameters().ParameterSet;
+            var parameterSet = ((NtruPublicKeyParameters)recipientKey).Parameters.ParameterSet;
             var sampling = new NtruSampling(parameterSet);
             var owcpa = new NtruOwcpa(parameterSet);
-            Polynomial r;
-            Polynomial m;
             var rm = new byte[parameterSet.OwcpaMsgBytes()];
             var rmSeed = new byte[parameterSet.SampleRmBytes()];
 
             _random.NextBytes(rmSeed);
 
             var pair = sampling.SampleRm(rmSeed);
-            r = pair.R();
-            m = pair.M();
+            Polynomial r = pair.R();
+            Polynomial m = pair.M();
 
             var rm1 = r.S3ToBytes(parameterSet.OwcpaMsgBytes());
             Array.Copy(rm1, 0, rm, 0, rm1.Length);
diff --git a/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs b/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs
index 906f7d5d4..4b570fdd9 100644
--- a/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs
@@ -2,20 +2,19 @@
 
 namespace Org.BouncyCastle.Pqc.Crypto.Ntru
 {
-    public abstract class NtruKeyParameters : AsymmetricKeyParameter
+    public abstract class NtruKeyParameters
+        : AsymmetricKeyParameter
     {
-        public NtruParameters Parameters { get; }
+        private readonly NtruParameters m_parameters;
 
-        public NtruKeyParameters(bool privateKey, NtruParameters parameters) : base(privateKey)
+        internal NtruKeyParameters(bool privateKey, NtruParameters parameters)
+            : base(privateKey)
         {
-            Parameters = parameters;
+            m_parameters = parameters;
         }
 
-        public abstract byte[] GetEncoded();
+        public NtruParameters Parameters => m_parameters;
 
-        public NtruParameters GetParameters()
-        {
-            return Parameters;
-        }
+        public abstract byte[] GetEncoded();
     }
-}
\ No newline at end of file
+}
diff --git a/crypto/src/pqc/crypto/ntru/NtruParameters.cs b/crypto/src/pqc/crypto/ntru/NtruParameters.cs
index 3bf2233ff..934cc21cb 100644
--- a/crypto/src/pqc/crypto/ntru/NtruParameters.cs
+++ b/crypto/src/pqc/crypto/ntru/NtruParameters.cs
@@ -3,7 +3,8 @@ using Org.BouncyCastle.Pqc.Crypto.Ntru.ParameterSets;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Ntru
 {
-    public class NtruParameters : ICipherParameters
+    public sealed class NtruParameters
+        : ICipherParameters
     {
         public static readonly NtruParameters NtruHps2048509 =
             new NtruParameters("ntruhps2048509", new NtruHps2048509());
diff --git a/crypto/src/pqc/crypto/ntru/NtruPrivateKeyParamaters.cs b/crypto/src/pqc/crypto/ntru/NtruPrivateKeyParamaters.cs
index 0c90a8afa..3acd5f40e 100644
--- a/crypto/src/pqc/crypto/ntru/NtruPrivateKeyParamaters.cs
+++ b/crypto/src/pqc/crypto/ntru/NtruPrivateKeyParamaters.cs
@@ -1,6 +1,7 @@
 namespace Org.BouncyCastle.Pqc.Crypto.Ntru
 {
-    public class NtruPrivateKeyParameters : NtruKeyParameters
+    public sealed class NtruPrivateKeyParameters
+        : NtruKeyParameters
     {
         private byte[] _privateKey;
 
@@ -15,7 +16,6 @@
             PrivateKey = key;
         }
 
-
         public override byte[] GetEncoded()
         {
             return PrivateKey;
diff --git a/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs b/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs
index 6a7cc0752..38b0d8e74 100644
--- a/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs
@@ -1,6 +1,7 @@
 namespace Org.BouncyCastle.Pqc.Crypto.Ntru
 {
-    public class NtruPublicKeyParameters : NtruKeyParameters
+    public sealed class NtruPublicKeyParameters
+        : NtruKeyParameters
     {
         private byte[] _publicKey;
 
diff --git a/crypto/src/pqc/crypto/ntruprime/NtruLPRimeKeyParameters.cs b/crypto/src/pqc/crypto/ntruprime/NtruLPRimeKeyParameters.cs
index da38bf4d8..425b1403f 100644
--- a/crypto/src/pqc/crypto/ntruprime/NtruLPRimeKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/NtruLPRimeKeyParameters.cs
@@ -2,16 +2,17 @@ using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
 {
-    public class NtruLPRimeKeyParameters : AsymmetricKeyParameter
+    public abstract class NtruLPRimeKeyParameters
+        : AsymmetricKeyParameter
     {
-        private NtruLPRimeParameters _primeParameters;
-        
-        public NtruLPRimeKeyParameters(bool isPrivate, NtruLPRimeParameters primeParameters) : base(isPrivate)
+        private readonly NtruLPRimeParameters m_primeParameters;
+
+        internal NtruLPRimeKeyParameters(bool isPrivate, NtruLPRimeParameters primeParameters)
+            : base(isPrivate)
         {
-            this._primeParameters = primeParameters;
+            m_primeParameters = primeParameters;
         }
 
-        public NtruLPRimeParameters Parameters => _primeParameters;
-
+        public NtruLPRimeParameters Parameters => m_primeParameters;
     }
 }
diff --git a/crypto/src/pqc/crypto/ntruprime/NtruLPRimePrivateKeyParameters.cs b/crypto/src/pqc/crypto/ntruprime/NtruLPRimePrivateKeyParameters.cs
index 1164ab197..adc499982 100644
--- a/crypto/src/pqc/crypto/ntruprime/NtruLPRimePrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/NtruLPRimePrivateKeyParameters.cs
@@ -1,20 +1,21 @@
-using System;
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
 {
-    public class NtruLPRimePrivateKeyParameters : NtruLPRimeKeyParameters
+    public sealed class NtruLPRimePrivateKeyParameters
+        : NtruLPRimeKeyParameters
     {
         internal byte[] privKey;
 
-        public byte[] GetPrivateKey()
+        public NtruLPRimePrivateKeyParameters(NtruLPRimeParameters primeParameters, byte[] privKey)
+            : base(true, primeParameters)
         {
-            return Arrays.Clone(privKey);
+            this.privKey = Arrays.Clone(privKey);
         }
 
-        public NtruLPRimePrivateKeyParameters(NtruLPRimeParameters primeParameters, byte[] privKey) : base(true, primeParameters)
+        public byte[] GetPrivateKey()
         {
-            this.privKey = Arrays.Clone(privKey);
+            return Arrays.Clone(privKey);
         }
         
         public byte[] GetEncoded()
diff --git a/crypto/src/pqc/crypto/ntruprime/NtruLPRimePublicKeyParameters.cs b/crypto/src/pqc/crypto/ntruprime/NtruLPRimePublicKeyParameters.cs
index 9566165d1..3af69093b 100644
--- a/crypto/src/pqc/crypto/ntruprime/NtruLPRimePublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/NtruLPRimePublicKeyParameters.cs
@@ -2,10 +2,17 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
 {
-    public class NtruLPRimePublicKeyParameters : NtruLPRimeKeyParameters
+    public sealed class NtruLPRimePublicKeyParameters
+        : NtruLPRimeKeyParameters
     {
         internal byte[] pubKey;
 
+        public NtruLPRimePublicKeyParameters(NtruLPRimeParameters primeParameters, byte[] pubKey)
+            : base(false, primeParameters)
+        {
+            this.pubKey = Arrays.Clone(pubKey);
+        }
+
         public byte[] GetPublicKey()
         {
             return Arrays.Clone(pubKey);
@@ -15,10 +22,5 @@ namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
         {
             return GetPublicKey();
         }
-
-        public NtruLPRimePublicKeyParameters(NtruLPRimeParameters primeParameters, byte[] pubKey) : base(false,primeParameters)
-        {
-            this.pubKey = Arrays.Clone(pubKey);
-        }
     }
 }
diff --git a/crypto/src/pqc/crypto/ntruprime/SNtruPrimeKeyParameters.cs b/crypto/src/pqc/crypto/ntruprime/SNtruPrimeKeyParameters.cs
index e4e03a2bb..3d907b474 100644
--- a/crypto/src/pqc/crypto/ntruprime/SNtruPrimeKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/SNtruPrimeKeyParameters.cs
@@ -2,16 +2,17 @@ using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
 {
-    public class SNtruPrimeKeyParameters : AsymmetricKeyParameter
+    public abstract class SNtruPrimeKeyParameters
+        : AsymmetricKeyParameter
     {
-        private SNtruPrimeParameters _primeParameters;
-        
-        public SNtruPrimeKeyParameters(bool isPrivate, SNtruPrimeParameters primeParameters) : base(isPrivate)
+        private readonly SNtruPrimeParameters m_primeParameters;
+
+        internal SNtruPrimeKeyParameters(bool isPrivate, SNtruPrimeParameters primeParameters)
+            : base(isPrivate)
         {
-            this._primeParameters = primeParameters;
+            m_primeParameters = primeParameters;
         }
 
-        public SNtruPrimeParameters Parameters => _primeParameters;
-
+        public SNtruPrimeParameters Parameters => m_primeParameters;
     }
 }
diff --git a/crypto/src/pqc/crypto/ntruprime/SNtruPrimeParameters.cs b/crypto/src/pqc/crypto/ntruprime/SNtruPrimeParameters.cs
index 4ec03a497..b6872da79 100644
--- a/crypto/src/pqc/crypto/ntruprime/SNtruPrimeParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/SNtruPrimeParameters.cs
@@ -1,5 +1,3 @@
-using System;
-
 using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
diff --git a/crypto/src/pqc/crypto/ntruprime/SNtruPrimePrivateKeyParameters.cs b/crypto/src/pqc/crypto/ntruprime/SNtruPrimePrivateKeyParameters.cs
index 62f336459..7e16bf1ca 100644
--- a/crypto/src/pqc/crypto/ntruprime/SNtruPrimePrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/SNtruPrimePrivateKeyParameters.cs
@@ -1,20 +1,21 @@
-using System;
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
 {
-    public class SNtruPrimePrivateKeyParameters : SNtruPrimeKeyParameters
+    public sealed class SNtruPrimePrivateKeyParameters
+        : SNtruPrimeKeyParameters
     {
         internal byte[] privKey;
 
-        public byte[] GetPrivateKey()
+        public SNtruPrimePrivateKeyParameters(SNtruPrimeParameters primeParameters, byte[] privKey)
+            : base(true, primeParameters)
         {
-            return Arrays.Clone(privKey);
+            this.privKey = Arrays.Clone(privKey);
         }
 
-        public SNtruPrimePrivateKeyParameters(SNtruPrimeParameters primeParameters, byte[] privKey) : base(true, primeParameters)
+        public byte[] GetPrivateKey()
         {
-            this.privKey = Arrays.Clone(privKey);
+            return Arrays.Clone(privKey);
         }
         
         public byte[] GetEncoded()
diff --git a/crypto/src/pqc/crypto/ntruprime/SNtruPrimePublicKeyParameters.cs b/crypto/src/pqc/crypto/ntruprime/SNtruPrimePublicKeyParameters.cs
index 80bd6ddd0..88be3bcdd 100644
--- a/crypto/src/pqc/crypto/ntruprime/SNtruPrimePublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/ntruprime/SNtruPrimePublicKeyParameters.cs
@@ -2,10 +2,16 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
 {
-    public class SNtruPrimePublicKeyParameters : SNtruPrimeKeyParameters
+    public sealed class SNtruPrimePublicKeyParameters
+        : SNtruPrimeKeyParameters
     {
         internal byte[] pubKey;
 
+        public SNtruPrimePublicKeyParameters(SNtruPrimeParameters primeParameters, byte[] pubKey) : base(false, primeParameters)
+        {
+            this.pubKey = Arrays.Clone(pubKey);
+        }
+
         public byte[] GetPublicKey()
         {
             return Arrays.Clone(pubKey);
@@ -15,10 +21,5 @@ namespace Org.BouncyCastle.Pqc.Crypto.NtruPrime
         {
             return GetPublicKey();
         }
-
-        public SNtruPrimePublicKeyParameters(SNtruPrimeParameters primeParameters, byte[] pubKey) : base(false,primeParameters)
-        {
-            this.pubKey = Arrays.Clone(pubKey);
-        }
     }
 }
diff --git a/crypto/src/pqc/crypto/picnic/PicnicKeyParameters.cs b/crypto/src/pqc/crypto/picnic/PicnicKeyParameters.cs
index 3d1fc6cc4..3c30a4624 100644
--- a/crypto/src/pqc/crypto/picnic/PicnicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/picnic/PicnicKeyParameters.cs
@@ -7,7 +7,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Picnic
     {
         private readonly PicnicParameters m_parameters;
 
-        public PicnicKeyParameters(bool isPrivate, PicnicParameters parameters)
+        internal PicnicKeyParameters(bool isPrivate, PicnicParameters parameters)
             : base(isPrivate)
         {
             m_parameters = parameters;
diff --git a/crypto/src/pqc/crypto/saber/SABERKeyParameters.cs b/crypto/src/pqc/crypto/saber/SABERKeyParameters.cs
index d83d2e3ea..26ba7d4f3 100644
--- a/crypto/src/pqc/crypto/saber/SABERKeyParameters.cs
+++ b/crypto/src/pqc/crypto/saber/SABERKeyParameters.cs
@@ -5,14 +5,14 @@ namespace Org.BouncyCastle.Pqc.Crypto.Saber
     public abstract class SaberKeyParameters
         : AsymmetricKeyParameter
     {
-        private readonly SaberParameters parameters;
+        private readonly SaberParameters m_parameters;
 
-        public SaberKeyParameters(bool isPrivate, SaberParameters parameters)
+        internal SaberKeyParameters(bool isPrivate, SaberParameters parameters)
             : base(isPrivate)
         {
-            this.parameters = parameters;
+            m_parameters = parameters;
         }
 
-        public SaberParameters Parameters => parameters;
+        public SaberParameters Parameters => m_parameters;
     }
 }
diff --git a/crypto/src/pqc/crypto/sike/SIKEKeyParameters.cs b/crypto/src/pqc/crypto/sike/SIKEKeyParameters.cs
index 759c8dd5d..72f2ffb42 100644
--- a/crypto/src/pqc/crypto/sike/SIKEKeyParameters.cs
+++ b/crypto/src/pqc/crypto/sike/SIKEKeyParameters.cs
@@ -10,10 +10,10 @@ namespace Org.BouncyCastle.Pqc.Crypto.Sike
     {
         private readonly SikeParameters m_parameters;
 
-        public SikeKeyParameters(bool isPrivate, SikeParameters param)
+        internal SikeKeyParameters(bool isPrivate, SikeParameters parameters)
             : base(isPrivate)
         {
-            this.m_parameters = param;
+            m_parameters = parameters;
         }
 
         public SikeParameters Parameters => m_parameters;
diff --git a/crypto/src/pqc/crypto/sike/SIKEParameters.cs b/crypto/src/pqc/crypto/sike/SIKEParameters.cs
index 07d2d77ef..23bb193ac 100644
--- a/crypto/src/pqc/crypto/sike/SIKEParameters.cs
+++ b/crypto/src/pqc/crypto/sike/SIKEParameters.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Runtime.ConstrainedExecution;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Sike
 {
diff --git a/crypto/src/pqc/crypto/sphincsplus/SPHINCSPlusKeyParameters.cs b/crypto/src/pqc/crypto/sphincsplus/SPHINCSPlusKeyParameters.cs
index 82220f9db..42ecdc7d7 100644
--- a/crypto/src/pqc/crypto/sphincsplus/SPHINCSPlusKeyParameters.cs
+++ b/crypto/src/pqc/crypto/sphincsplus/SPHINCSPlusKeyParameters.cs
@@ -5,9 +5,9 @@ namespace Org.BouncyCastle.Pqc.Crypto.SphincsPlus
     public abstract class SphincsPlusKeyParameters
         : AsymmetricKeyParameter
     {
-        protected readonly SphincsPlusParameters m_parameters;
+        private readonly SphincsPlusParameters m_parameters;
 
-        protected SphincsPlusKeyParameters(bool isPrivate, SphincsPlusParameters parameters)
+        internal SphincsPlusKeyParameters(bool isPrivate, SphincsPlusParameters parameters)
             : base(isPrivate)
         {
             m_parameters = parameters;