summary refs log tree commit diff
path: root/crypto/src/pqc/asn1/CmcePrivateKey.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-05-01 17:50:05 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-05-01 17:50:05 +0700
commitd5116b38e5b8a0425d31e5fe711866515bc91af6 (patch)
tree19d43d38824512db369b739dcab78f71304c221a /crypto/src/pqc/asn1/CmcePrivateKey.cs
parentPQC test cleanup (diff)
downloadBouncyCastle.NET-ed25519-d5116b38e5b8a0425d31e5fe711866515bc91af6.tar.xz
Update Pqc.Crypto.Crystals from bc-java
- add PqcOtherInfoGenerator and supporting code
Diffstat (limited to 'crypto/src/pqc/asn1/CmcePrivateKey.cs')
-rw-r--r--crypto/src/pqc/asn1/CmcePrivateKey.cs15
1 files changed, 6 insertions, 9 deletions
diff --git a/crypto/src/pqc/asn1/CmcePrivateKey.cs b/crypto/src/pqc/asn1/CmcePrivateKey.cs
index 042325d1d..44b52ca56 100644
--- a/crypto/src/pqc/asn1/CmcePrivateKey.cs
+++ b/crypto/src/pqc/asn1/CmcePrivateKey.cs
@@ -42,11 +42,10 @@ namespace Org.BouncyCastle.Pqc.Asn1
         
         public CmcePrivateKey(int version, byte[] delta, byte[] c, byte[] g, byte[] alpha, byte[] s, CmcePublicKey pubKey = null)
         {
-            this.version = version;
             if (version != 0)
-            {
-                 throw new Exception("unrecognized version");
-            }
+                throw new Exception("unrecognized version");
+
+            this.version = version;
             this.delta = Arrays.Clone(delta);
             this.c = Arrays.Clone(c);
             this.g = Arrays.Clone(g);
@@ -57,11 +56,10 @@ namespace Org.BouncyCastle.Pqc.Asn1
 
         private CmcePrivateKey(Asn1Sequence seq)
         {
-            version = DerInteger.GetInstance(seq[0]).Value.IntValue;
+            version = DerInteger.GetInstance(seq[0]).IntValueExact;
             if (version != 0)
-            {
                  throw new Exception("unrecognized version");
-            }
+
             delta = Arrays.Clone(Asn1OctetString.GetInstance(seq[1]).GetOctets());
 
             c = Arrays.Clone(Asn1OctetString.GetInstance(seq[2]).GetOctets());
@@ -72,8 +70,7 @@ namespace Org.BouncyCastle.Pqc.Asn1
 
             s = Arrays.Clone(Asn1OctetString.GetInstance(seq[5]).GetOctets());
 
-            // todo optional publickey
-            if(seq.Count == 7)
+            if (seq.Count == 7)
             {
                 publicKey = CmcePublicKey.GetInstance(seq[6]);
             }