summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/pqc/crypto/picnic/PicnicSigner.cs2
-rw-r--r--crypto/test/src/pqc/crypto/test/PicnicVectorTest.cs18
2 files changed, 16 insertions, 4 deletions
diff --git a/crypto/src/pqc/crypto/picnic/PicnicSigner.cs b/crypto/src/pqc/crypto/picnic/PicnicSigner.cs
index 302d144b3..7b631b3cb 100644
--- a/crypto/src/pqc/crypto/picnic/PicnicSigner.cs
+++ b/crypto/src/pqc/crypto/picnic/PicnicSigner.cs
@@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Picnic
             byte[] sig = new byte[engine.GetSignatureSize(message.Length)];
             engine.crypto_sign(sig, message, privKey.GetEncoded());
 
-            return Arrays.CopyOfRange(sig, 0, message.Length + engine.GetTrueSignatureSize());
+            return Arrays.CopyOfRange(sig, message.Length + 4,  engine.GetTrueSignatureSize() + message.Length);
         }
 
         public bool VerifySignature(byte[] message, byte[] signature)
diff --git a/crypto/test/src/pqc/crypto/test/PicnicVectorTest.cs b/crypto/test/src/pqc/crypto/test/PicnicVectorTest.cs
index 550a94c68..e8ca6b4fb 100644
--- a/crypto/test/src/pqc/crypto/test/PicnicVectorTest.cs
+++ b/crypto/test/src/pqc/crypto/test/PicnicVectorTest.cs
@@ -103,11 +103,23 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests
 
             signer.Init(true, privParams);
             byte[] sigGenerated = signer.GenerateSignature(msg);
-            Assert.True(smlen == sigGenerated.Length, name + " " + count + ": signature length");
+            byte[] attachedSig = Arrays.ConcatenateAll(UInt32_To_LE((uint)sigGenerated.Length), msg, sigGenerated);
+            
+            Assert.True(smlen == attachedSig.Length, name + " " + count + ": signature length");
 
             signer.Init(false, pubParams);
-            Assert.True(signer.VerifySignature(msg, sigGenerated), (name + " " + count + ": signature verify"));
-            Assert.True(Arrays.AreEqual(sigExpected, sigGenerated), name + " " + count + ": signature gen match");
+            Assert.True(signer.VerifySignature(msg, attachedSig), (name + " " + count + ": signature verify"));
+            Assert.True(Arrays.AreEqual(sigExpected, attachedSig), name + " " + count + ": signature gen match");
+        }
+
+        private static byte[] UInt32_To_LE(uint n)
+        {
+            byte[] bs = new byte[4];
+            bs[0] = (byte)(n);
+            bs[1] = (byte)(n >> 8);
+            bs[2] = (byte)(n >> 16);
+            bs[3] = (byte)(n >> 24);
+            return bs;
         }
 
         private static void RunTestVectorFile(string name)