コード例 #1
0
        new public CBORObject EncodeToCBORObject()
        {
            CBORObject cborBodyAttributes = null;

            byte[] rgbBody = null;

            if (m_msgToSign != null)
            {
                if (m_msgToSign.GetType() == typeof(EnvelopedMessage))
                {
                    EnvelopedMessage msg = (EnvelopedMessage)m_msgToSign;
                    msg.Encrypt();
                    CBORObject obj = msg.EncodeToCBORObject();
                    if (obj[1].Type != CBORType.ByteString)
                    {
                        throw new Exception("Internal error");
                    }
                    if (obj[3].Type != CBORType.ByteString)
                    {
                        throw new Exception("Internal error");
                    }
                    rgbBody            = obj[3].GetByteString();
                    cborBodyAttributes = obj[1];
                }
            }
            else if (m_signerToSign != null)
            {
                CBORObject obj = m_signerToSign.EncodeToCBORObject();
            }


            return(base.EncodeToCBORObject(cborBodyAttributes.GetByteString(), rgbBody));
        }
コード例 #2
0
        public void encryptNoEmitContent()
        {
            EnvelopedMessage msg = new EnvelopedMessage(true, false);

            msg.AddAttribute(HeaderKeys.Algorithm, AlgorithmValues.AES_GCM_128, true);
            msg.AddAttribute(HeaderKeys.IV, CBORObject.FromObject(rgbIV96), false);
            msg.SetContent(strContent);
            Recipient r = new Recipient(key128, AlgorithmValues.Direct);

            msg.AddRecipient(r);
            msg.Encrypt();
            CBORObject cn = msg.EncodeToCBORObject();


            Assert.IsTrue(cn[2].IsNull);
        }