Exemple #1
0
 public void AddSigner(Signer sig)
 {
     signerList.Add(sig);
 }
Exemple #2
0
        protected override void InternalDecodeFromCBORObject(CBORObject obj)
        {
            if (obj.Count != 4)
            {
                throw new CoseException("Invalid SignMessage structure");
            }

            //  Protected values.
            if (obj[0].Type == CBORType.ByteString)
            {
                ProtectedBytes = obj[0].GetByteString();
                if (ProtectedBytes.Length == 0)
                {
                    ProtectedMap = CBORObject.NewMap();
                }
                else
                {
                    ProtectedMap = CBORObject.DecodeFromBytes(ProtectedBytes);
                    if (ProtectedMap.Type != CBORType.Map)
                    {
                        throw new CoseException("Invalid SignMessage structure");
                    }
                    if (ProtectedMap.Count == 0)
                    {
                        ProtectedBytes = new byte[0];
                    }
                }
            }
            else
            {
                throw new CoseException("Invalid SignMessage structure");
            }

            //  Unprotected attributes
            if (obj[1].Type == CBORType.Map)
            {
                UnprotectedMap = obj[1];
            }
            else
            {
                throw new CoseException("Invalid SignMessage structure");
            }

            // Plain Text
            if (obj[2].Type == CBORType.ByteString)
            {
                rgbContent = obj[2].GetByteString();
            }
            else if (!obj[2].IsNull)                 // Detached content - will need to get externally
            {
                throw new CoseException("Invalid SignMessage structure");
            }

            // Signers
            if (obj[3].Type != CBORType.Array)
            {
                throw new CoseException("Invalid SignMessage structure");
            }
            // An array of signers to be processed
            for (int i = 0; i < obj[3].Count; i++)
            {
                Signer recip = new Signer();
                recip.DecodeFromCBORObject(obj[3][i]);
                signerList.Add(recip);
            }
        }
Exemple #3
0
 public void SetObject(Signer signer)
 {
     m_signerToSign = signer;
 }