summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Hook <david.hook@keyfactor.com>2022-11-07 17:38:55 +1100
committerDavid Hook <david.hook@keyfactor.com>2022-11-07 17:38:55 +1100
commit69df93393c6d28a6ea17f0015834a2eda3e52dda (patch)
tree2de9f73d1b59b3b1ff79b1e13f1cbf3cfcc35c2b
parentMerge branch 'master' of gitlab.cryptoworkshop.com:root/bc-csharp (diff)
downloadBouncyCastle.NET-ed25519-69df93393c6d28a6ea17f0015834a2eda3e52dda.tar.xz
fixed use of property
-rw-r--r--crypto/src/pqc/crypto/cmce/CmceKemExtractor.cs6
-rw-r--r--crypto/src/pqc/crypto/cmce/CmceKemGenerator.cs2
-rw-r--r--crypto/src/pqc/crypto/cmce/CmcePrivateKeyParameters.cs17
-rw-r--r--crypto/src/pqc/crypto/cmce/CmcePublicKeyParameters.cs9
-rw-r--r--crypto/test/src/pqc/crypto/test/CmceVectorTest.cs4
5 files changed, 22 insertions, 16 deletions
diff --git a/crypto/src/pqc/crypto/cmce/CmceKemExtractor.cs b/crypto/src/pqc/crypto/cmce/CmceKemExtractor.cs
index 805dce7b6..d65f20d2b 100644
--- a/crypto/src/pqc/crypto/cmce/CmceKemExtractor.cs
+++ b/crypto/src/pqc/crypto/cmce/CmceKemExtractor.cs
@@ -21,9 +21,9 @@ namespace Org.BouncyCastle.Pqc.Crypto.Cmce
         {
             engine = param.Engine;
             CmcePrivateKeyParameters privateParams = (CmcePrivateKeyParameters)key;
-            if (privateParams.PrivateKey.Length < engine.PrivateKeySize)
+            if (privateParams.privateKey.Length < engine.PrivateKeySize)
             {
-                key = new CmcePrivateKeyParameters(privateParams.Parameters, engine.decompress_private_key(privateParams.PrivateKey));
+                key = new CmcePrivateKeyParameters(privateParams.Parameters, engine.decompress_private_key(privateParams.privateKey));
             }
         }
 
@@ -35,7 +35,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Cmce
         private byte[] ExtractSecret(byte[] encapsulation, int sessionKeySizeInBits)
         {
             byte[] session_key = new byte[sessionKeySizeInBits / 8];
-            engine.kem_dec(session_key, encapsulation, ((CmcePrivateKeyParameters)key).PrivateKey);
+            engine.kem_dec(session_key, encapsulation, ((CmcePrivateKeyParameters)key).privateKey);
             return session_key;
         }
 
diff --git a/crypto/src/pqc/crypto/cmce/CmceKemGenerator.cs b/crypto/src/pqc/crypto/cmce/CmceKemGenerator.cs
index ac97fb594..7bd38a43a 100644
--- a/crypto/src/pqc/crypto/cmce/CmceKemGenerator.cs
+++ b/crypto/src/pqc/crypto/cmce/CmceKemGenerator.cs
@@ -32,7 +32,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Cmce
             CmceEngine engine = key.Parameters.Engine;
             byte[] cipher_text = new byte[engine.CipherTextSize];
             byte[] sessionKey = new byte[sessionKeySizeInBits / 8];     // document as 32 - l/8  - Section 2.5.2
-            engine.kem_enc(cipher_text, sessionKey, key.PublicKey, sr);
+            engine.kem_enc(cipher_text, sessionKey, key.publicKey, sr);
             return new SecretWithEncapsulationImpl(sessionKey, cipher_text);
         }
     }
diff --git a/crypto/src/pqc/crypto/cmce/CmcePrivateKeyParameters.cs b/crypto/src/pqc/crypto/cmce/CmcePrivateKeyParameters.cs
index a336295d5..1331aea14 100644
--- a/crypto/src/pqc/crypto/cmce/CmcePrivateKeyParameters.cs
+++ b/crypto/src/pqc/crypto/cmce/CmcePrivateKeyParameters.cs
@@ -7,9 +7,12 @@ namespace Org.BouncyCastle.Pqc.Crypto.Cmce
     public class CmcePrivateKeyParameters
         : CmceKeyParameters
     {
-        private byte[] privateKey;
+        internal byte[] privateKey;
 
-        public byte[] PrivateKey => Arrays.Clone(privateKey);
+        public byte[] GetPrivateKey()
+        {
+            return Arrays.Clone(privateKey);
+        }
 
         public CmcePrivateKeyParameters(CmceParameters parameters, byte[] privateKey)
             : base(true, parameters)
@@ -49,14 +52,14 @@ namespace Org.BouncyCastle.Pqc.Crypto.Cmce
             return Arrays.Clone(privateKey);
         }
 
-        public byte[] Delta => Arrays.CopyOfRange(privateKey, 0, 32);
+        internal byte[] Delta => Arrays.CopyOfRange(privateKey, 0, 32);
 
-        public byte[] C => Arrays.CopyOfRange(privateKey, 32, 32 + 8);
+        internal byte[] C => Arrays.CopyOfRange(privateKey, 32, 32 + 8);
 
-        public byte[] G => Arrays.CopyOfRange(privateKey, 40, 40 + Parameters.T * 2);
+        internal byte[] G => Arrays.CopyOfRange(privateKey, 40, 40 + Parameters.T * 2);
 
-        public byte[] Alpha => Arrays.CopyOfRange(privateKey, 40 + Parameters.T * 2, privateKey.Length - 32);
+        internal byte[] Alpha => Arrays.CopyOfRange(privateKey, 40 + Parameters.T * 2, privateKey.Length - 32);
 
-        public byte[] S => Arrays.CopyOfRange(privateKey, privateKey.Length - 32, privateKey.Length);
+        internal byte[] S => Arrays.CopyOfRange(privateKey, privateKey.Length - 32, privateKey.Length);
     }
 }
diff --git a/crypto/src/pqc/crypto/cmce/CmcePublicKeyParameters.cs b/crypto/src/pqc/crypto/cmce/CmcePublicKeyParameters.cs
index 333203226..e394f643d 100644
--- a/crypto/src/pqc/crypto/cmce/CmcePublicKeyParameters.cs
+++ b/crypto/src/pqc/crypto/cmce/CmcePublicKeyParameters.cs
@@ -7,13 +7,16 @@ namespace Org.BouncyCastle.Pqc.Crypto.Cmce
     public class CmcePublicKeyParameters
         : CmceKeyParameters
     {
-        private byte[] publicKey;
+        internal byte[] publicKey;
 
-        public byte[] PublicKey => Arrays.Clone(publicKey);
+        public byte[] GetPublicKey()
+        { 
+            return Arrays.Clone(publicKey);
+        }
 
         public byte[] GetEncoded()
         {
-            return PublicKey;
+            return GetPublicKey();
         }
 
         public CmcePublicKeyParameters(CmceParameters parameters, byte[] publicKey)
diff --git a/crypto/test/src/pqc/crypto/test/CmceVectorTest.cs b/crypto/test/src/pqc/crypto/test/CmceVectorTest.cs
index eefdd96df..e6b4d120c 100644
--- a/crypto/test/src/pqc/crypto/test/CmceVectorTest.cs
+++ b/crypto/test/src/pqc/crypto/test/CmceVectorTest.cs
@@ -103,8 +103,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests
             CmcePublicKeyParameters pubParams = (CmcePublicKeyParameters)PublicKeyFactory.CreateKey(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo((CmcePublicKeyParameters)kp.Public));
             CmcePrivateKeyParameters privParams = (CmcePrivateKeyParameters)PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo((CmcePrivateKeyParameters)kp.Private));
 
-            Assert.True(Arrays.AreEqual(pk, pubParams.PublicKey), name + " " + count + ": public key");
-            Assert.True(Arrays.AreEqual(sk, privParams.PrivateKey), name + " " + count + ": secret key");
+            Assert.True(Arrays.AreEqual(pk, pubParams.GetPublicKey()), name + " " + count + ": public key");
+            Assert.True(Arrays.AreEqual(sk, privParams.GetPrivateKey()), name + " " + count + ": secret key");
 
             // KEM Enc
             CmceKemGenerator CmceEncCipher = new CmceKemGenerator(random);