summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/pqc/crypto/utils/PrivateKeyFactory.cs8
-rw-r--r--crypto/test/src/pqc/crypto/test/SikeVectorTest.cs9
2 files changed, 13 insertions, 4 deletions
diff --git a/crypto/src/pqc/crypto/utils/PrivateKeyFactory.cs b/crypto/src/pqc/crypto/utils/PrivateKeyFactory.cs
index 009cadedf..0fadab855 100644
--- a/crypto/src/pqc/crypto/utils/PrivateKeyFactory.cs
+++ b/crypto/src/pqc/crypto/utils/PrivateKeyFactory.cs
@@ -13,6 +13,7 @@ using Org.BouncyCastle.Pqc.Crypto.Cmce;
 using Org.BouncyCastle.Pqc.Crypto.Lms;
 using Org.BouncyCastle.Pqc.Crypto.Picnic;
 using Org.BouncyCastle.Pqc.Crypto.Saber;
+using Org.BouncyCastle.Pqc.Crypto.Sike;
 using Org.BouncyCastle.Pqc.Crypto.SphincsPlus;
 using Org.BouncyCastle.Utilities;
 
@@ -97,6 +98,13 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities
 
                 return new PicnicPrivateKeyParameters(picnicParams, keyEnc);
             }
+            if (algOID.On(BCObjectIdentifiers.pqc_kem_sike))
+            {
+                byte[] keyEnc = Asn1OctetString.GetInstance(keyInfo.ParsePrivateKey()).GetOctets();
+                SIKEParameters sikeParams = PqcUtilities.SikeParamsLookup(keyInfo.PrivateKeyAlgorithm.Algorithm);
+
+                return new SIKEPrivateKeyParameters(sikeParams, keyEnc);
+            }
             
             
             throw new Exception("algorithm identifier in private key not recognised");
diff --git a/crypto/test/src/pqc/crypto/test/SikeVectorTest.cs b/crypto/test/src/pqc/crypto/test/SikeVectorTest.cs
index af8187a2d..3daac41e5 100644
--- a/crypto/test/src/pqc/crypto/test/SikeVectorTest.cs
+++ b/crypto/test/src/pqc/crypto/test/SikeVectorTest.cs
@@ -6,6 +6,7 @@ using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Pqc.Crypto.Sike;
+using Org.BouncyCastle.Pqc.Crypto.Utilities;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
@@ -80,11 +81,11 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests
             AsymmetricCipherKeyPair kp = kpGen.GenerateKeyPair();
 
             // todo
-            // SIKEPublicKeyParameters pubParams = (SIKEPublicKeyParameters)PublicKeyFactory.CreateKey(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(kp.Public));
-            // SIKEPrivateKeyParameters privParams = (SIKEPrivateKeyParameters)PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(kp.Private));
+            SIKEPublicKeyParameters pubParams = (SIKEPublicKeyParameters)PublicKeyFactory.CreateKey(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(kp.Public));
+            SIKEPrivateKeyParameters privParams = (SIKEPrivateKeyParameters)PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(kp.Private));
 
-            SIKEPublicKeyParameters pubParams = (SIKEPublicKeyParameters)kp.Public;
-            SIKEPrivateKeyParameters privParams = (SIKEPrivateKeyParameters)kp.Private;
+            // SIKEPublicKeyParameters pubParams = (SIKEPublicKeyParameters)kp.Public;
+            // SIKEPrivateKeyParameters privParams = (SIKEPrivateKeyParameters)kp.Private;
 
             // Console.WriteLine(Hex.ToHexString(pk));
             // Console.WriteLine(Hex.ToHexString(pubParams.GetEncoded()));