diff options
-rw-r--r-- | crypto/src/pqc/crypto/utils/SubjectPublicKeyInfoFactory.cs | 6 | ||||
-rw-r--r-- | crypto/test/src/pqc/crypto/test/CrystalsDilithiumTest.cs | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/crypto/src/pqc/crypto/utils/SubjectPublicKeyInfoFactory.cs b/crypto/src/pqc/crypto/utils/SubjectPublicKeyInfoFactory.cs index 75a89c3f0..a919a71e5 100644 --- a/crypto/src/pqc/crypto/utils/SubjectPublicKeyInfoFactory.cs +++ b/crypto/src/pqc/crypto/utils/SubjectPublicKeyInfoFactory.cs @@ -116,10 +116,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities DilithiumPublicKeyParameters parameters = (DilithiumPublicKeyParameters)publicKey; AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PqcUtilities.DilithiumOidLookup(parameters.Parameters)); - Asn1EncodableVector v = new Asn1EncodableVector(); - v.Add(new DerOctetString(parameters.Rho)); - v.Add(new DerOctetString(parameters.T1)); - return new SubjectPublicKeyInfo(algorithmIdentifier, new DerSequence(v)); + + return new SubjectPublicKeyInfo(algorithmIdentifier, new DerOctetString(Arrays.Concatenate(parameters.Rho, parameters.T1))); } if (publicKey is BikePublicKeyParameters) { diff --git a/crypto/test/src/pqc/crypto/test/CrystalsDilithiumTest.cs b/crypto/test/src/pqc/crypto/test/CrystalsDilithiumTest.cs index 9d4d7fc9f..2d682179c 100644 --- a/crypto/test/src/pqc/crypto/test/CrystalsDilithiumTest.cs +++ b/crypto/test/src/pqc/crypto/test/CrystalsDilithiumTest.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium; +using Org.BouncyCastle.Pqc.Crypto.Utilities; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Encoders; using Org.BouncyCastle.Utilities.Test; @@ -71,6 +72,9 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests //Console.WriteLine(string.Format("{0} Expected pk = {1}", pk.Length, Convert.ToHexString(pk))); //Console.WriteLine(String.Format("{0} Actual Public key = {1}", pubParams.GetEncoded().Length, Convert.ToHexString(pubParams.GetEncoded()))); + pubParams = (DilithiumPublicKeyParameters)PublicKeyFactory.CreateKey(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(ackp.Public)); + privParams = (DilithiumPrivateKeyParameters)PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(ackp.Private)); + Assert.True(Arrays.AreEqual(pk, pubParams.GetEncoded()), name + " " + count + ": public key"); Assert.True(Arrays.AreEqual(sk, privParams.GetEncoded()), name + " " + count + ": secret key"); |