Пример #1
0
        public void testSign()
        {
            SignMessage instance = new SignMessage();

            instance.Encode();
            // TODO review the generated test code and remove the default call to fail.
            /// fail("The test case is a prototype.");
        }
Пример #2
0
        static Message ProcessSign(CBORObject control, ref bool fDirty)
        {
            CBORObject input = control["input"];
            CBORObject sign  = input["sign"];
            CBORObject signers;

            SignMessage msg = new SignMessage();

            if (!input.ContainsKey("plaintext"))
            {
                throw new Exception("missing plaintext field");
            }
            msg.SetContent(input["plaintext"].AsString());

            if (sign.ContainsKey("protected"))
            {
                AddAttributes(msg, sign["protected"], 0);
            }
            if (sign.ContainsKey("unprotected"))
            {
                AddAttributes(msg, sign["unprotected"], 1);
            }
            if (sign.ContainsKey("unsent"))
            {
                AddAttributes(msg, sign["unsent"], 2);
            }

            if ((!sign.ContainsKey("signers")) || (sign["signers"].Type != CBORType.Array))
            {
                throw new Exception("Missing or malformed recipients");
            }
            foreach (CBORObject recip in sign["signers"].Values)
            {
                msg.AddSigner(GetSigner(recip));
            }

            {
                msg.Encode();

                signers = Program.GetSection(Program.GetSection(control, "intermediates"), "signers", CBORType.Array);


                for (int iSigner = 0; iSigner < msg.SignerList.Count; iSigner++)
                {
                    while (signers.Count < msg.SignerList.Count)
                    {
                        signers.Add(CBORObject.NewMap());
                    }

                    Program.SetField(signers[iSigner], "ToBeSign", msg.SignerList[iSigner].ToBeSigned, ref fDirty);
                }
            }

            return(msg);
        }