diff options
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); |